X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fsearch%2Fphone_inventory_provisioned.html;h=52657e70a30ebee9d63192676cfeee091911dd3f;hp=37fef8a2157c32eaee3895e8580d97e50aaae951;hb=376b1dfc27736a2d7060ad0ca140565c9d3de55d;hpb=fb8915cce4be9520c00cc53c659e34abfb6172e1 diff --git a/httemplate/search/phone_inventory_provisioned.html b/httemplate/search/phone_inventory_provisioned.html index 37fef8a21..52657e70a 100644 --- a/httemplate/search/phone_inventory_provisioned.html +++ b/httemplate/search/phone_inventory_provisioned.html @@ -7,77 +7,72 @@ 'select' => 'distinct latanum', }, 'count_query' => 'SELECT COUNT(distinct latanum) FROM phone_avail', - 'header' => [ 'LATA', + 'header' => [ + 'LATA #', + 'LATA Description', 'Available', 'Provisioned', 'Have Usage', ], 'fields' => [ - sub { # LATA - my $did_order = shift; - my $lata = $did_order->lata; - $lata = $lata ? $lata->description : ''; - $did_order->latanum . " - " . $lata; + 'latanum', + sub { # LATA Description + my $phone_avail = shift; + return '' unless $phone_avail->lata; + $phone_avail->lata->description; }, sub { # Available my $latanum = shift->latanum; - my @dids = qsearch('phone_avail', + my $cnt = qsearchs({ 'table' => 'phone_avail', + 'hashref' => { 'svcnum' => '', 'latanum' => $latanum, - } - ); - return scalar(@dids); + }, + 'select' => 'count(1) as cnt', + }); + ($cnt) ? $cnt->cnt : ''; }, sub { # Provisioned my $latanum = shift->latanum; - my @dids = provisioned_dids($latanum); - return scalar(@dids); + my $cnt = qsearchs({ 'table' => 'phone_avail', + 'hashref' => { 'latanum' => $latanum, + 'svcnum' => { op => '>', + value => '0' + }, + }, + 'select' => 'count(1) as cnt' + }); + ($cnt) ? $cnt->cnt : ''; }, sub { # Have Usage - my $did_order = shift; - my @dids = provisioned_dids($did_order->latanum); - - my $count = 0; - foreach my $did ( @dids ) { - my $cust_svc = $did->cust_svc; - next unless $cust_svc; - - my $svcnum = $cust_svc->svcnum; - my $sql = "select count(1) from cdr where src = - (select phonenum from svc_phone where svcnum = $svcnum) - or charged_party = (select phonenum from svc_phone where - svcnum = $svcnum)"; - my $c = $did_order->scalar_sql($sql); - $count++ if $c > 0; - } - $count; + my $phone_avail = shift; + return '' unless $phone_avail->lata; + $phone_avail->lata->have_usage; }, ], 'align' => 'lccc', 'links' => [ '', - '', - '', - '', + '', + '', + '', ], 'color' => [ '', - '', - '', - '', + '', + '', + '', ], 'style' => [ '', - '', - '', - '', + '', + '', + '', ], ) %> <%init> -warn "started @ ".time; - die "access denied" unless ( $FS::CurrentUser::CurrentUser->access_right('List inventory') && $FS::CurrentUser::CurrentUser->access_right('List services') @@ -85,12 +80,4 @@ die "access denied" # XXX: agent virtualize -sub provisioned_dids { - my $latanum = shift; - qsearch({ 'table' => 'phone_avail', - 'hashref' => { 'latanum' => $latanum, }, - 'extra_sql' => ' and svcnum is not null ', - }); -} -