summaryrefslogtreecommitdiff
path: root/httemplate/browse/svc_acct_pop.cgi
blob: e71a8a7328c4b832557e35930eea78dc2a8f3302 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<% 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!
  <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' => '' },
              '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'  => '<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>