-<%
-#
-# $Id: svc_acct_pop.cgi,v 1.1 2001-07-30 07:36:03 ivan Exp $
-#
-# ivan@sisd.com 98-mar-8
-#
-# Changes to allow page to work at a relative position in server
-# bmccane@maxbaud.net 98-apr-3
-#
-# lose background, FS::CGI ivan@sisd.com 98-sep-2
-#
-# $Log: svc_acct_pop.cgi,v $
-# Revision 1.1 2001-07-30 07:36:03 ivan
-# templates!!!
-#
-# Revision 1.8 2000/01/28 22:56:13 ivan
-# track full phone number
-#
-# Revision 1.7 1999/04/09 04:22:34 ivan
-# also table()
-#
-# Revision 1.6 1999/04/09 03:52:55 ivan
-# explicit & for table/itable/ntable
-#
-# Revision 1.5 1999/01/19 05:13:30 ivan
-# for mod_perl: no more top-level my() variables; use vars instead
-# also the last s/create/new/;
-#
-# Revision 1.4 1999/01/18 09:41:20 ivan
-# all $cgi->header calls now include ( '-expires' => 'now' ) for mod_perl
-# (good idea anyway)
-#
-# Revision 1.3 1998/12/17 05:25:22 ivan
-# fix visual and other bugs
-#
-# Revision 1.2 1998/12/17 04:36:59 ivan
-# use CGI;, use CGI::Carp, visual changes, relative URLs
-#
+<% 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>
-use strict;
-use vars qw( $cgi $p $svc_acct_pop );
-use CGI;
-use CGI::Carp qw(fatalsToBrowser);
-use FS::UID qw(cgisuidsetup swapuid);
-use FS::Record qw(qsearch qsearchs);
-use FS::CGI qw(header menubar table popurl);
-use FS::svc_acct_pop;
+my $curuser = $FS::CurrentUser::CurrentUser;
-$cgi = new CGI;
+die "access denied"
+ unless $curuser->access_right('Dialup configuration')
+ || $curuser->access_right('Dialup global configuration');
-&cgisuidsetup($cgi);
+my $html_init = qq!
+ <A HREF="${p}edit/svc_acct_pop.cgi"><I>Add new Access Number</I></A>
+ <BR><BR>
+!;
-$p = popurl(2);
+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',
+ };
-print $cgi->header( '-expires' => 'now' ), header('POP Listing', menubar(
- 'Main Menu' => $p,
-)), "Points of Presence<BR><BR>", &table(), <<END;
- <TR>
- <TH></TH>
- <TH>City</TH>
- <TH>State</TH>
- <TH>Area code</TH>
- <TH>Exchange</TH>
- <TH>Local</TH>
- </TR>
-END
+my $count_query = "SELECT COUNT(*) FROM svc_acct_pop"; # WHERE DISABLED IS NULL OR DISABLED = ''";
-foreach $svc_acct_pop ( sort {
- $a->getfield('popnum') <=> $b->getfield('popnum')
-} qsearch('svc_acct_pop',{}) ) {
- my($hashref)=$svc_acct_pop->hashref;
- print <<END;
- <TR>
- <TD><A HREF="${p}edit/svc_acct_pop.cgi?$hashref->{popnum}">
- $hashref->{popnum}</A></TD>
- <TD><A HREF="${p}edit/svc_acct_pop.cgi?$hashref->{popnum}">
- $hashref->{city}</A></TD>
- <TD><A HREF="${p}edit/svc_acct_pop.cgi?$hashref->{popnum}">
- $hashref->{state}</A></TD>
- <TD><A HREF="${p}edit/svc_acct_pop.cgi?$hashref->{popnum}">
- $hashref->{ac}</A></TD>
- <TD><A HREF="${p}edit/svc_acct_pop.cgi?$hashref->{popnum}">
- $hashref->{exch}</A></TD>
- <TD><A HREF="${p}edit/svc_acct_pop.cgi?$hashref->{popnum}">
- $hashref->{loc}</A></TD>
- </TR>
-END
+my $svc_acct_pop_link = [ $p.'edit/svc_acct_pop.cgi?', 'popnum' ];
-}
+my $svc_acct_link = $p. 'search/svc_acct.cgi?popnum=';
-print <<END;
- <TR>
- <TD COLSPAN=5><A HREF="${p}edit/svc_acct_pop.cgi"><I>Add new POP</I></A></TD>
- </TR>
- </TABLE>
- </CENTER>
- </BODY>
-</HTML>
-END
+my $num_accounts_sub = sub {
+ my $svc_acct_pop = shift;
+ [
+ [
+ { 'data' => '<B><FONT COLOR="#00CC00">'.
+ $svc_acct_pop->get('num_accounts').
+ '</FONT></B>',
+ 'align' => 'right',
+ },
+ { 'data' => 'active',
+ 'align' => 'left',
+ 'link' => ( $svc_acct_pop->get('num_accounts')
+ ? $svc_acct_link. $svc_acct_pop->popnum
+ : ''
+ ),
+ },
+ ],
+ ];
+};
-%>
+</%init>