diff --git a/lib/NGCP/Panel/Controller/Customer.pm b/lib/NGCP/Panel/Controller/Customer.pm index 05403673c1..f0557567c8 100644 --- a/lib/NGCP/Panel/Controller/Customer.pm +++ b/lib/NGCP/Panel/Controller/Customer.pm @@ -311,6 +311,10 @@ sub base :Chained('list_customer') :PathPart('') :CaptureArgs(1) { return; } + $c->stash->{balanceinterval_dt_columns} = NGCP::Panel::Utils::Datatables::set_columns($c, [ + NGCP::Panel::Utils::ProfilePackages::get_balanceinterval_datatable_cols($c), + ]); + my $product_id = $contract_rs->first->get_column('product_id'); NGCP::Panel::Utils::Message->error( c => $c, @@ -1101,6 +1105,13 @@ sub topup_voucher :Chained('base_restricted') :PathPart('balance/topupvoucher') $c->stash(edit_flag => 1); } +sub balanceinterval_ajax :Chained('base') :PathPart('balanceinterval/ajax') :Args(0) { + my ($self, $c) = @_; + my $res = $c->stash->{contract}->contract_balances; + NGCP::Panel::Utils::Datatables::process($c, $res, $c->stash->{balanceinterval_dt_columns}); + $c->detach( $c->view("JSON") ); +} + sub subscriber_ajax :Chained('base') :PathPart('subscriber/ajax') :Args(0) { my ($self, $c) = @_; my $res = $c->stash->{contract}->voip_subscribers->search({ diff --git a/lib/NGCP/Panel/Utils/ProfilePackages.pm b/lib/NGCP/Panel/Utils/ProfilePackages.pm index ae170d88e5..cb3f22c75c 100644 --- a/lib/NGCP/Panel/Utils/ProfilePackages.pm +++ b/lib/NGCP/Panel/Utils/ProfilePackages.pm @@ -1154,5 +1154,28 @@ sub get_customer_datatable_cols { { name => "status", search => 1, title => $c->loc("Status") }, ); } + +sub get_balanceinterval_datatable_cols { + + my ($c) = @_; + #my $parser_date = DateTime::Format::Strptime->new( + # pattern => '%Y-%m-%d', + #); + #my $parser_datetime = DateTime::Format::Strptime->new( + # pattern => '%Y-%m-%d %H:%M', + #); + return ( #{ name => "id", search => 1, title => $c->loc("#") }, + { name => "start", search => 1, search_lower_column => 'interval', title => $c->loc("From"), }, + #convert_code => sub { my $s = shift; return $s if ($parser_date->parse_datetime($s) or $parser_datetime->parse_datetime($s)); } }, + { name => "end", search => 1, search_upper_column => 'interval', title => $c->loc('To'), }, + #convert_code => sub { my $s = shift; return $s if ($parser_date->parse_datetime($s) or $parser_datetime->parse_datetime($s)); } }, + { name => "balance", search => 0, title => $c->loc('Cash'), literal_sql => "FORMAT(cash_balance / 100,2)" }, + { name => "debit", search => 0, title => $c->loc('Debit'), literal_sql => "FORMAT(cash_balance_interval / 100,2)" }, + { name => "topup_count", search => 0, title => $c->loc('#Top-ups') }, + { name => "timely_topup_count", search => 0, title => $c->loc('#Timely Top-ups') }, + { name => "underrun_profiles", search => 0, title => $c->loc('Underrun (Profiles)') }, + { name => "underrun_lock", search => 0, title => $c->loc('Underrun (Lock)') }, + ); +} 1; \ No newline at end of file diff --git a/share/templates/customer/details.tt b/share/templates/customer/details.tt index 48b9f4f22f..56c804ed33 100644 --- a/share/templates/customer/details.tt +++ b/share/templates/customer/details.tt @@ -423,6 +423,30 @@ + + +
+
+ [% c.loc('Balance Intervals') %] +
+
+ +
+ +[% + helper.name = c.loc('Balance Interval'); + helper.identifier = 'balance_intervals'; + helper.dt_columns = balanceinterval_dt_columns; + helper.ajax_uri = c.uri_for_action('/customer/balanceinterval_ajax', [ c.req.captures.0 ]); + + helper.top_buttons = []; + helper.dt_buttons = []; + + PROCESS 'helpers/datatables.tt'; +%] +
+
+
[% IF c.user.roles == 'admin' || c.user.roles == 'reseller' %]