Correctly select customers under reseller-> customers section

Only show the most applicable billing_profile using the complex
query from the Contract controller
Mantis: 3855
agranig/peering-route
Gerhard Jungwirth 12 years ago
parent 594f341ee8
commit c6abfbc7cb

@ -377,6 +377,31 @@ sub customer_ajax :Chained('customer_list') :PathPart('ajax') :Args(0) {
$c->detach( $c->view("JSON") );
}
sub customer_ajax_reseller_filter :Chained('customer_list') :PathPart('ajax/reseller') :Args(1) {
my ($self, $c, $reseller_id) = @_;
unless($reseller_id && $reseller_id->is_int) {
$c->flash(messages => [{type => 'error', text => 'Invalid reseller id detected'}]);
$c->response->redirect($c->uri_for());
return;
}
my $rs = $c->stash->{customer_rs}->search_rs({
'contact.reseller_id' => $reseller_id,
},{
join => 'contact',
});
my $reseller_customer_columns = NGCP::Panel::Utils::Datatables::set_columns($c, [
{ name => "id", search => 1, title => "#" },
{ name => "external_id", search => 1, title => "External #" },
{ name => "billing_mappings.product.name", search => 1, title => "Product" },
{ name => "contact.email", search => 1, title => "Contact Email" },
{ name => "status", search => 1, title => "Status" },
]);
NGCP::Panel::Utils::Datatables::process($c, $rs, $reseller_customer_columns);
$c->detach( $c->view("JSON") );
}
sub customer_create :Chained('customer_list') :PathPart('create') :Args(0) {
my ($self, $c) = @_;

@ -185,24 +185,6 @@ sub reseller_admin :Chained('base') :PathPart('admins/ajax') :Args(0) {
return;
}
sub reseller_customers :Chained('base') :PathPart('customers/ajax') :Args(0) {
my ($self, $c) = @_;
my $rs = $c->model('DB')->resultset('contracts')->search({
'contact.reseller_id' => $c->stash->{reseller}->first->id,
'me.status' => { '!=' => 'terminated' },
'-or' => [
'product.class' => 'sipaccount',
'product.class' => 'pbxaccount',
],
}, {
join => [ {'billing_mappings' => 'product' }, 'contact'],
});
NGCP::Panel::Utils::Datatables::process($c, $rs, $c->stash->{customer_dt_columns});
$c->detach($c->view('JSON'));
return;
}
sub edit :Chained('base') :PathPart('edit') :Args(0) {
my ($self, $c) = @_;

@ -195,7 +195,7 @@
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.ajax_uri = c.uri_for_action('/contract/customer_ajax_reseller_filter', c.req.captures );
UNLESS c.user.read_only;
helper.dt_buttons = [

Loading…
Cancel
Save