diff --git a/lib/NGCP/Panel/Widget/Plugin/AdminResellerOverview.pm b/lib/NGCP/Panel/Widget/Plugin/AdminResellerOverview.pm index 6507a7bf91..fea9ff342e 100644 --- a/lib/NGCP/Panel/Widget/Plugin/AdminResellerOverview.pm +++ b/lib/NGCP/Panel/Widget/Plugin/AdminResellerOverview.pm @@ -26,6 +26,7 @@ around handle => sub { resellers => $c->model('DB')->resultset('resellers')->search_rs({}), domains => $c->model('DB')->resultset('domain_resellers')->search_rs({}), customers => $c->model('DB')->resultset('contracts')->search_rs({ + status => { '!=' => 'terminated' }, product_id => undef, }, { join => 'billing_mappings', diff --git a/lib/NGCP/Panel/Widget/Plugin/ResellerBillingOverview.pm b/lib/NGCP/Panel/Widget/Plugin/ResellerBillingOverview.pm new file mode 100644 index 0000000000..e2bb5a849e --- /dev/null +++ b/lib/NGCP/Panel/Widget/Plugin/ResellerBillingOverview.pm @@ -0,0 +1,65 @@ +package NGCP::Panel::Widget::Plugin::ResellerBillingOverview; +use Moose::Role; + +has 'template' => ( + is => 'ro', + isa => 'Str', + default => 'widgets/reseller_billing_overview.tt', +); + +has 'type' => ( + is => 'ro', + isa => 'Str', + default => 'dashboard_widgets', +); + +has 'priority' => ( + is => 'ro', + isa => 'Int', + default => 11, +); + +around handle => sub { + my ($foo, $self, $c) = @_; + my $stime = DateTime->now->truncate(to => 'month'); + my $etime = $stime->clone->add(months => 1); + + my $reseller = $c->model('DB')->resultset('resellers')->find($c->user->reseller_id); + my $reseller_balance = $reseller->contract->contract_balances->search({ + 'start' => { '>=' => $stime }, + 'end' => { '<' => $etime}, + })->first; + my $reseller_sum = 0; + if($reseller_balance) { + $reseller_sum = $reseller_balance->cash_balance_interval; + } + + $c->stash( + profiles => $reseller->billing_profiles, + reseller_sum => $reseller_sum, + customer_sum => $c->model('DB')->resultset('contract_balances')->search_rs({ + 'start' => { '>=' => $stime }, + 'end' => { '<' => $etime}, + 'contact.reseller_id' => $c->user->reseller_id, + }, { + join => { + 'contract' => 'contact', + }, + })->get_column('cash_balance_interval')->sum, + ); + return; +}; + +sub filter { + my ($self, $c, $type) = @_; + + return $self if( + $type eq $self->type && + $c->user_in_realm('reseller') && + ref $c->controller eq 'NGCP::Panel::Controller::Dashboard' + ); + return; +} + +1; +# vim: set tabstop=4 expandtab: diff --git a/lib/NGCP/Panel/Widget/Plugin/ResellerCustomerOverview.pm b/lib/NGCP/Panel/Widget/Plugin/ResellerCustomerOverview.pm new file mode 100644 index 0000000000..650d984ff2 --- /dev/null +++ b/lib/NGCP/Panel/Widget/Plugin/ResellerCustomerOverview.pm @@ -0,0 +1,59 @@ +package NGCP::Panel::Widget::Plugin::ResellerCustomerOverview; +use Moose::Role; + +has 'template' => ( + is => 'ro', + isa => 'Str', + default => 'widgets/reseller_customer_overview.tt' +); + +has 'type' => ( + is => 'ro', + isa => 'Str', + default => 'dashboard_widgets', +); + +has 'priority' => ( + is => 'ro', + isa => 'Int', + default => 10, +); + +around handle => sub { + my ($foo, $self, $c) = @_; + + my $reseller = $c->model('DB')->resultset('resellers')->find($c->user->reseller_id); + + $c->stash( + customers => $c->model('DB')->resultset('contracts')->search({ + 'me.status' => { '!=' => 'terminated' }, + 'contact.reseller_id' => $c->user->reseller_id, + },{ + join => 'contact', + }), + subscribers => $c->model('DB')->resultset('voip_subscribers')->search({ + 'contact.reseller_id' => $c->user->reseller_id, + 'me.status' => { '!=' => 'terminated' }, + },{ + join => { 'contract' => 'contact'}, + }), + contacts => $c->model('DB')->resultset('contacts')->search({ + reseller_id => $c->user->reseller_id, + }), + ); + return; +}; + +sub filter { + my ($self, $c, $type) = @_; + + return $self if( + $type eq $self->type && + $c->user_in_realm('reseller') && + ref $c->controller eq 'NGCP::Panel::Controller::Dashboard' + ); + return; +} + +1; +# vim: set tabstop=4 expandtab: diff --git a/lib/NGCP/Panel/Widget/Plugin/ResellerDomainOverview.pm b/lib/NGCP/Panel/Widget/Plugin/ResellerDomainOverview.pm index 1674bfc962..d52999a4a3 100644 --- a/lib/NGCP/Panel/Widget/Plugin/ResellerDomainOverview.pm +++ b/lib/NGCP/Panel/Widget/Plugin/ResellerDomainOverview.pm @@ -16,13 +16,19 @@ has 'type' => ( has 'priority' => ( is => 'ro', isa => 'Int', - default => 100, + default => 10, ); around handle => sub { my ($foo, $self, $c) = @_; - $c->log->debug("ResellerDomainOverview::handle"); + my $reseller = $c->model('DB')->resultset('resellers')->find($c->user->reseller_id); + + $c->stash( + domains => $reseller->domain_resellers, + rwr_sets => $reseller->voip_rewrite_rule_sets, + sound_sets => $reseller->voip_sound_sets, + ); return; }; diff --git a/share/templates/widgets/admin_billing_overview.tt b/share/templates/widgets/admin_billing_overview.tt index 622aa22551..1284dbdf65 100644 --- a/share/templates/widgets/admin_billing_overview.tt +++ b/share/templates/widgets/admin_billing_overview.tt @@ -4,7 +4,7 @@