improve performance of DID provisioning status report, RT10988
[freeside.git] / httemplate / search / phone_inventory_provisioned.html
1 <% include( 'elements/search.html',
2               'title'         => 'LATA Search Results',
3               'name_singular' => 'LATA',
4               'query'         => {
5                                    'table'   => 'phone_avail',
6                                    'hashref' => {},
7                                    'select'  => 'distinct latanum',
8                                  },
9               'count_query'   => 'SELECT COUNT(distinct latanum) FROM phone_avail',
10               'header'        => [ 
11                     'LATA #',
12                     'LATA Description',
13                                    'Available',
14                                    'Provisioned',
15                                    'Have Usage',
16                                  ],
17               'fields'        => [
18                 'latanum',
19         sub { # LATA Description
20             my $phone_avail = shift;
21             return '' unless $phone_avail->lata;
22             $phone_avail->lata->description;
23         },
24                 sub { # Available
25                     my $latanum = shift->latanum;
26                     my $cnt = qsearchs({ 'table'    => 'phone_avail',
27                                  'hashref'  => 
28                                     { 'svcnum' => '',
29                                       'latanum' => $latanum,
30                                     },
31                                  'select'   => 'count(1) as cnt',
32                           });
33                     ($cnt) ? $cnt->cnt : '';
34                 },
35                 sub { # Provisioned
36                     my $latanum = shift->latanum;
37             my $cnt = qsearchs({   'table'     => 'phone_avail',
38                         'hashref'   => { 'latanum' => $latanum,
39                                          'svcnum' => { op => '>',
40                                                         value => '0'
41                                                      },
42                                         },
43                         'select'    => 'count(1) as cnt'
44                     });
45                     ($cnt) ? $cnt->cnt : '';
46                 },
47                 sub { # Have Usage
48             my $phone_avail = shift;
49             return '' unless $phone_avail->lata;
50             $phone_avail->lata->have_usage;
51                 },
52               ],
53               'align'         => 'lccc',
54               'links'         => [
55                 '',
56                 '',
57                 '',
58                 '',
59               ],
60               'color' => [ 
61                            '',
62                            '',
63                            '',
64                            '',
65                          ],
66               'style' => [ 
67                            '',
68                            '',
69                            '',
70                            '',
71                          ],
72       )
73 %>
74 <%init>
75
76 die "access denied"
77   unless ( $FS::CurrentUser::CurrentUser->access_right('List inventory')
78          && $FS::CurrentUser::CurrentUser->access_right('List services')
79          );
80
81 # XXX: agent virtualize
82
83 </%init>