From b61732daa5ad31ae36201d6cc471cc9113f6e74a Mon Sep 17 00:00:00 2001 From: Irka Date: Tue, 18 Feb 2014 13:37:44 +0100 Subject: [PATCH] MT#5879: Failed with condition unification for reseller_id of contracts. Return to double search using to construct query. --- lib/NGCP/Panel/Utils/Contract.pm | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/NGCP/Panel/Utils/Contract.pm b/lib/NGCP/Panel/Utils/Contract.pm index beb7bdd7e1..bddf988e28 100644 --- a/lib/NGCP/Panel/Utils/Contract.pm +++ b/lib/NGCP/Panel/Utils/Contract.pm @@ -201,20 +201,23 @@ sub get_contracts_rs_sippbx{ schema => $c->model('DB'), ); #really here we don't need role - we can pass only reseller_id, reseller_id should be tacken according to role in other method - my @reseller_condition = ({ '-not' => undef }); + + #for all + $customers = $customers->search({ + 'contact.reseller_id' => { '-not' => undef }, + },{ + join => 'contact' + }); + + my $reseller_condition; if($c->user->roles eq "reseller") { - push @reseller_condition, $c->user->reseller_id; + $reseller_condition = $c->user->reseller_id; } elsif($c->user->roles eq "subscriberadmin") { - push @reseller_condition, $c->user->contract->contact->reseller_id; + $reseller_condition = $c->user->contract->contact->reseller_id; } elsif($c->user->roles eq "admin") { } - my $reseller_condition = $#reseller_condition > 1 - ? { '-and' => \@reseller_condition } - : $reseller_condition[0]; $customers = $customers->search({ 'contact.reseller_id' => $reseller_condition , - },{ - join => 'contact' }); $customers = $customers->search({