Add customer list to reseller details.

agranig/1_0_subfix
Andreas Granig 12 years ago
parent 248ea962d6
commit 74ae3d91d3

@ -200,7 +200,7 @@ sub ajax :Chained('contract_list') :PathPart('ajax') :Args(0) {
my $rs = $c->stash->{contract_select_rs};
$c->forward( "/ajax_process_resultset", [$rs,
["id","contact_id","billing_profile_name","status"],
["id", "contact_id", "billing_profile_name", "billing_profile_id", "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_id", "billing_profile_name","status"],
["id","contact_id", "billing_profile_id", "billing_profile_name","status"],
["billing_profile.name", "status"]]);
$c->detach( $c->view("JSON") );

@ -8,8 +8,6 @@ use NGCP::Panel::Form::CustomerDailyFraud;
use NGCP::Panel::Form::CustomerBalance;
use NGCP::Panel::Utils;
use Data::Printer;
=head1 NAME
NGCP::Panel::Controller::Customer - Catalyst Controller
@ -51,11 +49,11 @@ sub base :Chained('list_customer') :PathPart('') :CaptureArgs(1) {
}
my $contract = $c->model('billing')->resultset('contracts')
->find($contract_id);
->search_rs(id => $contract_id);
my $stime = DateTime->now->truncate(to => 'month');
my $etime = $stime->clone->add(months => 1);
my $balance = $contract->contract_balances
my $balance = $contract->first->contract_balances
->find({
start => { '>=' => $stime },
end => { '<' => $etime },
@ -64,7 +62,7 @@ sub base :Chained('list_customer') :PathPart('') :CaptureArgs(1) {
try {
NGCP::Panel::Utils::Contract::create_contract_balance(
c => $c,
profile => $contract->billing_mappings->search({
profile => $contract->first->billing_mappings->search({
-and => [
-or => [
start_date => undef,
@ -79,7 +77,7 @@ sub base :Chained('list_customer') :PathPart('') :CaptureArgs(1) {
{
order_by => { -desc => 'start_time', -desc => 'id' }
})->first->billing_profile,
contract => $contract,
contract => $contract->first,
);
} catch($e) {
$c->log->error("Failed to create contract balance: $e");
@ -87,7 +85,7 @@ sub base :Chained('list_customer') :PathPart('') :CaptureArgs(1) {
$c->response->redirect($c->uri_for());
return;
}
$balance = $contract->contract_balances
$balance = $contract->first->contract_balances
->find({
start => { '>=' => $stime },
end => { '<' => $etime },
@ -95,13 +93,18 @@ sub base :Chained('list_customer') :PathPart('') :CaptureArgs(1) {
}
$c->stash(balance => $balance);
$c->stash(fraud => $contract->contract_fraud_preference);
$c->stash(fraud => $contract->first->contract_fraud_preference);
$c->stash(template => 'customer/details.tt');
$c->stash(contract => $contract);
$c->stash(contract => $contract->first);
$c->stash(contract_rs => $contract);
}
sub details :Chained('base') :PathPart('details') :Args(0) {
my ($self, $c) = @_;
$c->stash(
subscribers => $c->stash->{contract}->voip_subscribers,
);
}
sub edit_fraud :Chained('base') :PathPart('fraud/edit') :Args(1) {

@ -150,6 +150,22 @@ sub reseller_admin :Chained('base') :PathPart('admins') :Args(0) {
return;
}
sub reseller_customers :Chained('base') :PathPart('customers') :Args(0)
{
my ($self, $c) = @_;
$c->forward(
'/ajax_process_resultset', [
$c->stash->{reseller}->first->search_related_rs('contracts'),
# TODO: also external_id (same in Customer list)
[qw(id contact_id status)],
[ "contact_id", "status" ]
]
);
$c->detach($c->view('JSON'));
return;
}
sub edit :Chained('base') :PathPart('edit') :Args(0) {
my ($self, $c) = @_;

@ -4,8 +4,8 @@
helper.show_create_button = 1;
helper.data = contracts;
helper.messages = messages;
helper.column_titles = [ '#', 'Contact #', 'Billing Profile #', 'Status' ];
helper.column_fields = [ 'id', 'contact_id', 'billing_profile_id', 'status' ];
helper.column_titles = [ '#', 'Contact #', 'Billing Profile', 'Status' ];
helper.column_fields = [ 'id', 'contact_id', 'billing_profile_name', 'status' ];
helper.close_target = close_target;
helper.create_flag = create_flag;

@ -40,24 +40,14 @@
</tr>
</thead>
<tbody>
[% FOR subscriber IN subscribers -%]
<tr>
<td>testuser1@example.org</td>
<td>4312345</td>
<td>Fooagent 1/0 something very long in version 20130702 foooooooooo</td>
<td class="ngcp-actions-column"> </td>
</tr>
<tr>
<td>testuser2@example.org</td>
<td>4312346</td>
<td>Fooagent 1/0 something very long in version 20130702 foooooooooo</td>
<td class="ngcp-actions-column"></td>
</tr>
<tr>
<td>testuser1@example.org</td>
<td>4312345</td>
<td>Baragent</td>
<td>[% subscriber.username %]@[% subscriber.domain.domain %]</td>
<td>[% subscriber.primary_number.cc %] [% subscriber.primary_number.ac %] [% subscriber.primary_number.sn %]</td>
<td>TODO[% # subscriber.provisioning_voip_subscriber.password %]</td>
<td class="ngcp-actions-column"></td>
</tr>
[% END -%]
</tbody>
</table>

@ -110,6 +110,36 @@
helper.ajax_uri = c.uri_for_action('/reseller/reseller_admin', c.req.captures );
helper.base_uri = c.uri_for_action('/administrator/root');
PROCESS 'helpers/datatables.tt';
-%]
</div>
</div>
</div>
<div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#reseller_details" href="#collapse_customer">Customers</a>
</div>
<div class="accordion-body collapse" id="collapse_customer">
<div class="accordion-inner">
[%
helper.name = 'Customer';
helper.messages = messages;
helper.column_titles = [ '#', 'Contact #', 'Status' ];
helper.column_fields = [ 'id', 'contact_id', 'status' ];
helper.paginate = 'true';
helper.filter = 'true';
helper.close_target = close_target;
helper.create_flag = create_flag;
helper.edit_flag = edit_flag;
helper.form_object = form;
helper.ajax_uri = c.uri_for_action('/reseller/reseller_customers', c.req.captures );
helper.dt_buttons = [
{ name = 'Edit', uri = "/contract/'+full[\"id\"]+'/edit", class = 'btn-small btn-primary', icon = 'icon-edit' },
{ name = 'Delete', uri = "/contract/'+full[\"id\"]+'/delete", class = 'btn-small btn-secondary', icon = 'icon-trash' },
{ name = 'Details', uri = "/customer/'+full[\"id\"]+'/details", class = 'btn-small btn-tertiary', icon = 'icon-list' },
];
PROCESS 'helpers/datatables.tt';
-%]
</div>

Loading…
Cancel
Save