enable CardFortress in test database, #71513
[freeside.git] / httemplate / browse / svc_acct_pop.cgi
1 <% include( 'elements/browse.html',
2                 'title'         => 'Access Numbers',
3                 'html_init'     => $html_init,
4                 'name_singular' => 'access number',
5                 'query'         => $query,
6                 'count_query'   => $count_query,
7                 'header'        => [
8                                      '#',
9                                      'City',
10                                      'State',
11                                      'Area code',
12                                      'Exchange',
13                                      'Local',
14                                      'Accounts',
15                                    ],
16                   'fields'      => [
17                                      'popnum',
18                                      'city',
19                                      'state',
20                                      'ac',
21                                      'exch',
22                                      'loc',
23                                      $num_accounts_sub,
24                                    ],
25                   'align'       => 'rllrrrr',
26                   'links'       => [ map { $svc_acct_pop_link } (1..6) ],
27           )
28 %>
29 <%init>
30
31 my $curuser = $FS::CurrentUser::CurrentUser;
32
33 die "access denied"
34   unless $curuser->access_right('Dialup configuration')
35       || $curuser->access_right('Dialup global configuration');
36
37 my $html_init = qq!
38   <A HREF="${p}edit/svc_acct_pop.cgi"><I>Add new Access Number</I></A>
39   <BR><BR>
40 !;
41
42 my $query = { 'select'    => '*,
43                               ( SELECT COUNT(*) FROM svc_acct
44                                   WHERE svc_acct.popnum = svc_acct_pop.popnum
45                               ) AS num_accounts
46                              ',
47               'table'     => 'svc_acct_pop',
48               #'hashref'   => { 'disabled' => '' },
49               'order_by' => 'ORDER BY state, city, ac, exch, loc',
50             };
51
52 my $count_query = "SELECT COUNT(*) FROM svc_acct_pop"; # WHERE DISABLED IS NULL OR DISABLED = ''";
53
54 my $svc_acct_pop_link = [ $p.'edit/svc_acct_pop.cgi?', 'popnum' ];
55
56 my $svc_acct_link = $p. 'search/svc_acct.cgi?popnum=';
57
58 my $num_accounts_sub = sub {
59   my $svc_acct_pop = shift;
60   [
61     [
62       { 'data'  => '<B><FONT COLOR="#00CC00">'.
63                    $svc_acct_pop->get('num_accounts').
64                    '</FONT></B>',
65         'align' => 'right',
66       },
67       { 'data'  => 'active',
68         'align' => 'left',
69         'link'  => ( $svc_acct_pop->get('num_accounts')
70                        ? $svc_acct_link. $svc_acct_pop->popnum
71                        : ''
72                    ),
73       },
74     ],
75   ];
76 };
77
78 </%init>