X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fbrowse%2Fsvc_acct_pop.cgi;h=e71a8a7328c4b832557e35930eea78dc2a8f3302;hp=fb42aa7e6217efa1a699cdd0575dac3a8525f584;hb=ac8410cdb67639afeb84c84e975fffadf3e6cce1;hpb=1eb7fd4c48cadb7a6c8e45c561cd16e01279a56a diff --git a/httemplate/browse/svc_acct_pop.cgi b/httemplate/browse/svc_acct_pop.cgi index fb42aa7e6..e71a8a732 100755 --- a/httemplate/browse/svc_acct_pop.cgi +++ b/httemplate/browse/svc_acct_pop.cgi @@ -1,52 +1,78 @@ - -<% - -print header('Access Number Listing', menubar( - 'Main Menu' => $p, -)), "Points of Presence

", &table(), < - - City - State - Area code - Exchange - Local - -END - -foreach my $svc_acct_pop ( sort { - #$a->getfield('popnum') <=> $b->getfield('popnum') - $a->state cmp $b->state || $a->city cmp $b->city - || $a->ac <=> $b->ac || $a->exch <=> $b->exch || $a->loc <=> $b->loc -} qsearch('svc_acct_pop',{}) ) { - my($hashref)=$svc_acct_pop->hashref; - print < - - $hashref->{popnum} - - $hashref->{city} - - $hashref->{state} - - $hashref->{ac} - - $hashref->{exch} - - $hashref->{loc} - -END - -} - -print < - Add new Access Number - - - - - -END - +<% include( 'elements/browse.html', + 'title' => 'Access Numbers', + 'html_init' => $html_init, + 'name_singular' => 'access number', + 'query' => $query, + 'count_query' => $count_query, + 'header' => [ + '#', + 'City', + 'State', + 'Area code', + 'Exchange', + 'Local', + 'Accounts', + ], + 'fields' => [ + 'popnum', + 'city', + 'state', + 'ac', + 'exch', + 'loc', + $num_accounts_sub, + ], + 'align' => 'rllrrrr', + 'links' => [ map { $svc_acct_pop_link } (1..6) ], + ) %> +<%init> + +my $curuser = $FS::CurrentUser::CurrentUser; + +die "access denied" + unless $curuser->access_right('Dialup configuration') + || $curuser->access_right('Dialup global configuration'); + +my $html_init = qq! + Add new Access Number +

+!; + +my $query = { 'select' => '*, + ( SELECT COUNT(*) FROM svc_acct + WHERE svc_acct.popnum = svc_acct_pop.popnum + ) AS num_accounts + ', + 'table' => 'svc_acct_pop', + #'hashref' => { 'disabled' => '' }, + 'order_by' => 'ORDER BY state, city, ac, exch, loc', + }; + +my $count_query = "SELECT COUNT(*) FROM svc_acct_pop"; # WHERE DISABLED IS NULL OR DISABLED = ''"; + +my $svc_acct_pop_link = [ $p.'edit/svc_acct_pop.cgi?', 'popnum' ]; + +my $svc_acct_link = $p. 'search/svc_acct.cgi?popnum='; + +my $num_accounts_sub = sub { + my $svc_acct_pop = shift; + [ + [ + { 'data' => ''. + $svc_acct_pop->get('num_accounts'). + '', + 'align' => 'right', + }, + { 'data' => 'active', + 'align' => 'left', + 'link' => ( $svc_acct_pop->get('num_accounts') + ? $svc_acct_link. $svc_acct_pop->popnum + : '' + ), + }, + ], + ]; +}; + +