Implement reseller and billing widget for admins.

agranig/1_0_subfix
Andreas Granig 13 years ago
parent 06eecf8a3d
commit 761aab3220

@ -125,11 +125,11 @@ sub ajax :Chained('list') :PathPart('ajax') :Args(0) {
#TODO: when user is not logged in, this gets forwarded to login page
my $contacts = $c->stash->{contacts};
my $contacts = $c->model('billing')->resultset('contacts')->search_rs({});
$c->forward( "/ajax_process", [$contacts,
["id","firstname","lastname","email"],
[1,2,3]]);
$c->forward( "/ajax_process_resultset", [$contacts,
["id", "firstname", "lastname", "email"],
["firstname", "lastname", "email"]]);
$c->detach( $c->view("JSON") );
}

@ -227,7 +227,7 @@ sub peering_ajax :Chained('peering_list') :PathPart('ajax') :Args(0) {
});
$c->forward( "/ajax_process_resultset", [$rs,
["id","contact_id","billing_profile_name","status"],
["id","contact_id","billing_profile_id", "billing_profile_name","status"],
["billing_profile.name", "status"]]);
$c->detach( $c->view("JSON") );
@ -311,7 +311,7 @@ sub customer_ajax :Chained('customer_list') :PathPart('ajax') :Args(0) {
});
$c->forward( "/ajax_process_resultset", [$rs,
["id","contact_id","billing_profile_name","status"],
["id","contact_id","billing_profile_id", "billing_profile_name","status"],
["billing_profile.name", "status"]]);
$c->detach( $c->view("JSON") );

@ -11,7 +11,7 @@ has_field 'id' => (
template => 'share/templates/helpers/datatables_field.tt',
ajax_src => '/contract/peering/ajax',
table_titles => ['#', 'Contact #', 'Billing Profile #', 'Status'],
table_fields => ['id', 'contact_id', 'billing_profile', 'status'],
table_fields => ['id', 'contact_id', 'billing_profile_id', 'status'],
);
has_field 'create' => (

@ -21,8 +21,39 @@ has 'priority' => (
around handle => sub {
my ($foo, $self, $c) = @_;
my $stime = DateTime->now->truncate(to => 'month');
my $etime = $stime->clone->add(months => 1);
$c->log->debug("AdminBillingOverview::handle");
$c->stash(
profiles => $c->model('billing')->resultset('billing_profiles')->search_rs({}),
peering_sum => $c->model('billing')->resultset('contract_balances')->search_rs({
'start' => { '>=' => $stime },
'end' => { '<' => $etime},
'product.class' => 'sippeering',
}, {
join => {
'contract' => { 'billing_mappings' => 'product' },
},
})->get_column('cash_balance_interval')->sum,
reseller_sum => $c->model('billing')->resultset('contract_balances')->search_rs({
'start' => { '>=' => $stime },
'end' => { '<' => $etime},
'product.class' => 'reseller',
}, {
join => {
'contract' => { 'billing_mappings' => 'product' },
},
})->get_column('cash_balance_interval')->sum,
customer_sum => $c->model('billing')->resultset('contract_balances')->search_rs({
'start' => { '>=' => $stime },
'end' => { '<' => $etime},
'billing_mappings.product_id' => undef,
}, {
join => {
'contract' => 'billing_mappings',
},
})->get_column('cash_balance_interval')->sum,
);
return;
};

@ -22,7 +22,16 @@ has 'priority' => (
around handle => sub {
my ($foo, $self, $c) = @_;
$c->log->debug("AdminResellerOverview::handle");
$c->stash(
resellers => $c->model('billing')->resultset('resellers')->search_rs({}),
domains => $c->model('billing')->resultset('resellers')->search_rs({}),
customers => $c->model('billing')->resultset('contracts')->search_rs({
product_id => undef,
}, {
join => 'billing_mappings',
}),
subscribers => $c->model('provisioning')->resultset('voip_subscribers')->search_rs({}),
);
return;
};

@ -5,7 +5,7 @@
helper.data = contracts;
helper.messages = messages;
helper.column_titles = [ '#', 'Contact #', 'Billing Profile #', 'Status' ];
helper.column_fields = [ 'id', 'contact_id', 'billing_profile', 'status' ];
helper.column_fields = [ 'id', 'contact_id', 'billing_profile_id', 'status' ];
helper.close_target = close_target;
helper.create_flag = create_flag;

@ -1,7 +1,6 @@
[% META title = 'SIP Peering Groups' -%]
[%
helper.name = 'SIP Peering Groups';
helper.show_create_button = 1;
helper.messages = messages;
helper.column_titles = [ '#', 'Name', 'Priority', 'Description', 'Contract #' ];
helper.column_fields = [ 'id', 'name', 'priority', 'description', 'peering_contract_id' ];

@ -11,6 +11,7 @@
[% FOREACH m IN messages -%]
<div class="alert alert-[% m.type %]">[% m.text %]</div>
[% END -%]
[% messages = [] -%]
<div class="accordion" id="reseller_details">

@ -3,14 +3,15 @@
<div class="plan-header">
<div class="plan-title">Billing</div>
<div class="plan-price">
<span>28</span>
<span>[% profiles.count %]</span>
<span class="term">Billing Profiles</span>
</div>
</div>
<div class="plan-features">
<ul>
<li><strong>€2000</strong> Peering Costs</li>
<li><strong>€5000</strong> Reseller Revenue</li>
<li><strong>[% FILTER format("%.02f") %][% peering_sum / 100.0 %][% END %]</strong> Peering Costs</li>
<li><strong>[% FILTER format("%.02f") %][% reseller_sum / 100.0 %][% END %]</strong> Reseller Revenue</li>
<li><strong>[% FILTER format("%.02f") %][% customer_sum / 100.0 %][% END %]</strong> Customer Revenue</li>
</ul>
</div>
<div class="plan-actions">

@ -3,15 +3,15 @@
<div class="plan-header">
<div class="plan-title">Resellers</div>
<div class="plan-price">
<span>4</span>
<span>[% resellers.count %]</span>
<span class="term">Resellers</span>
</div>
</div>
<div class="plan-features">
<ul>
<li><strong>13</strong> Domains</li>
<li><strong>22745</strong> Accounts</li>
<li><strong>49355</strong> Subscribers</li>
<li><strong>[% domains.count %]</strong> Domains</li>
<li><strong>[% customers.count %]</strong> Customers</li>
<li><strong>[% subscribers.count %]</strong> Subscribers</li>
</ul>
</div>
<div class="plan-actions">

Loading…
Cancel
Save