parent
7db9c09b13
commit
0b596b7c85
@ -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:
|
@ -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:
|
@ -0,0 +1,21 @@
|
||||
<div class="plan-container">
|
||||
<div class="plan">
|
||||
<div class="plan-header">
|
||||
<div class="plan-title">Billing</div>
|
||||
<div class="plan-price">
|
||||
<span>[% profiles.count %]</span>
|
||||
<span class="term">Billing Profile[% profiles.count == 1 ? "" : "s" %]</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="plan-features">
|
||||
<ul>
|
||||
<li><strong>[% FILTER format("%.02f") %][% reseller_sum / 100.0 %][% END %]</strong> Reseller Cost</li>
|
||||
<li><strong>[% FILTER format("%.02f") %][% customer_sum / 100.0 %][% END %]</strong> Customer Revenue</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="plan-actions">
|
||||
<a href="[% c.uri_for('/billing') %]" class="btn">Configure</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
[% # vim: set tabstop=4 syntax=html expandtab: -%]
|
@ -0,0 +1,21 @@
|
||||
<div class="plan-container">
|
||||
<div class="plan">
|
||||
<div class="plan-header">
|
||||
<div class="plan-title">Customers</div>
|
||||
<div class="plan-price">
|
||||
<span>[% customers.count %]</span>
|
||||
<span class="term">Customer[% customers.count == 1 ? "" : "s" %]</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="plan-features">
|
||||
<ul>
|
||||
<li><strong>[% contacts.count %]</strong> Contact[% contacts.count == 1 ? "" : "s" %]</li>
|
||||
<li><strong>[% subscribers.count %]</strong> Subscriber[% subscribers.count == 1 ? "" : "s" %]</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="plan-actions">
|
||||
<a href="[% c.uri_for('/customer') %]" class="btn">Configure</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
[% # vim: set tabstop=4 syntax=html expandtab: -%]
|
Loading…
Reference in new issue