add agent type list to package def browse, RT#4880
[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           )
27 %>
28 <%init>
29
30 my $curuser = $FS::CurrentUser::CurrentUser;
31
32 die "access denied"
33   unless $curuser->access_right('Dialup configuration')
34       || $curuser->access_right('Dialup global configuration');
35
36 my $html_init = qq!
37   <A HREF="${p}edit/svc_acct_pop.cgi"><I>Add new Access Number</I></A>
38   <BR><BR>
39 !;
40
41 my $query = { 'select'    => '*,
42                               ( SELECT COUNT(*) FROM svc_acct
43                                   WHERE svc_acct.popnum = svc_acct_pop.popnum
44                               ) AS num_accounts
45                              ',
46               'table'     => 'svc_acct_pop',
47               #'hashref'   => { 'disabled' => '' },
48               'extra_sql' => 'ORDER BY state, city, ac, exch, loc',
49             };
50
51 my $count_query = "SELECT COUNT(*) FROM svc_acct_pop"; # WHERE DISABLED IS NULL OR DISABLED = ''";
52
53 my $svc_acct_pop_link = [ $p.'edit/svc_acct_pop.cgi?', 'popnum' ];
54
55 my $svc_acct_link = $p. 'search/svc_acct.cgi?popnum=';
56
57 my $num_accounts_sub = sub {
58   my $svc_acct_pop = shift;
59   [
60     [
61       { 'data'  => '<B><FONT COLOR="#00CC00">'.
62                    $svc_acct_pop->get('num_accounts').
63                    '</FONT></B>',
64         'align' => 'right',
65       },
66       { 'data'  => 'active',
67         'align' => 'left',
68         'link'  => ( $svc_acct_pop->get('num_accounts')
69                        ? $svc_acct_link. $svc_acct_pop->popnum
70                        : ''
71                    ),
72       },
73     ],
74   ];
75 };
76
77 </%init>