MT#8645 - billing profiles, disable seaerch by "Used", "used" internal renamed into "v_count_used" to be taken as a virtual column by the Datatables module

changes/52/552/1
Kirill Solomko 11 years ago
parent 55a5b1d433
commit f5830cd43a

@ -36,7 +36,7 @@ sub profile_list :Chained('/') :PathPart('billing') :CaptureArgs(0) {
{ name => "id", "search" => 1, "title" => $c->loc("#") },
{ name => "name", "search" => 1, "title" => $c->loc("Name") },
{ name => "reseller.name", "search" => 1, "title" => $c->loc("Reseller") },
{ name => "used", "search" => 1, "title" => $c->loc("Used") },
{ name => "v_count_used", "search" => 0, "title" => $c->loc("Used") },
]);
$c->stash(template => 'billing/list.tt');
@ -48,7 +48,7 @@ sub _profile_resultset_admin {
'me.status' => { '!=' => 'terminated' },
}, {
join => { 'billing_mappings' => 'contract_active' },
'+select' => { count => 'contract_active.status', -as => 'used' },
'+select' => { count => 'contract_active.status', -as => 'v_count_used' },
'group_by' => [ qw(me.id) ]
});
return $rs;
@ -62,7 +62,7 @@ sub _profile_resultset_reseller {
'me.status' => { '!=' => 'terminated' },
}, {
join => { 'billing_mappings' => 'contract_active' },
'+select' => { count => 'contract_active.status', -as => 'used' },
'+select' => { count => 'contract_active.status', -as => 'v_count_used' },
'group_by' => [ qw(me.id) ]
});
return $rs;

@ -22,7 +22,7 @@ sub item_rs {
my $item_rs = $c->model('DB')->resultset('billing_profiles');
my $search_xtra = {
join => { 'billing_mappings' => 'contract_active' },
'+select' => { count => 'contract_active.status', -as => 'used' },
'+select' => { count => 'contract_active.status', -as => 'v_count_used' },
'group_by' => [ qw(me.id) ] };
if($c->user->roles eq "admin") {
$item_rs = $item_rs->search({ 'me.status' => { '!=' => 'terminated' } },
@ -112,7 +112,7 @@ sub update_profile {
}
if(exists $resource->{status} && $resource->{status} eq 'terminated') {
my $profile_used = {$profile->get_inflated_columns}->{used};
my $profile_used = {$profile->get_inflated_columns}->{v_count_used};
if ($profile_used) {
$self->error($c, HTTP_UNPROCESSABLE_ENTITY,
"Cannnot terminate billing_profile that is used (count: $profile_used)");

Loading…
Cancel
Save