-%>
- <TR>
- <TD><A HREF="<%= $svc_acct_pop_link %>">
- <%= $svc_acct_pop->popnum %></A></TD>
- <TD><A HREF="<%= $svc_acct_pop_link %>">
- <%= $svc_acct_pop->city %></A></TD>
- <TD><A HREF="<%= $svc_acct_pop_link %>">
- <%= $svc_acct_pop->state %></A></TD>
- <TD><A HREF="<%= $svc_acct_pop_link %>">
- <%= $svc_acct_pop->ac %></A></TD>
- <TD><A HREF="<%= $svc_acct_pop_link %>">
- <%= $svc_acct_pop->exch %></A></TD>
- <TD><A HREF="<%= $svc_acct_pop_link %>">
- <%= $svc_acct_pop->loc %></A></TD>
- <TD>
- <FONT COLOR="#00CC00"><B><%= $num_accounts %></B></FONT>
- <% if ( $num_accounts ) { %><A HREF="<%= $svc_acct_link %>"><% } %>
- active
- <% if ( $num_accounts ) { %></A><% } %>
- </TD>
- </TR>
-<% } %>
-
- <TR>
- </TR>
- </TABLE>
- </BODY>
-</HTML>
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+
+my $html_init = qq!
+ <A HREF="${p}edit/svc_acct_pop.cgi"><I>Add new Access Number</I></A>
+ <BR><BR>
+!;
+
+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' => '' },
+ 'extra_sql' => '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' => '<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
+ : ''
+ ),
+ },
+ ],
+ ];
+};