fix voided invoice report vs. customer classes, similar to #37243
[freeside.git] / httemplate / search / svc_fiber.html
1 <& elements/svc_Common.html,
2   'title'       => 'Fiber Search Results',
3   'name'        => 'fiber services',
4   'query'       => $query,
5   'count_query' => $query->{'count_query'},
6   'redirect'    => $link,
7   'header'      => [ '#',
8                      'OLT',
9                      'Shelf/Card/Port',
10                      'ONT',
11                      'Model',
12                      'Serial',
13                      emt('Pkg. Status'),
14                      FS::UI::Web::cust_header($cgi->param('cust_fields')),
15                    ],
16   'fields'      => [ 'svcnum',
17                      'oltname',
18                      sub { my $svc = shift;
19                            join('-', $svc->shelf, $svc->card, $svc->olt_port)
20                      },
21                      'ont_id',
22                      'ont_description',
23                      'ont_serial',
24                      sub {
25                        $cust_pkg_cache{$_[0]->svcnum} ||= $_[0]->cust_svc->cust_pkg;
26                        $cust_pkg_cache{$_[0]->svcnum}->ucfirst_status
27                      },
28                      \&FS::UI::Web::cust_fields,
29                    ],
30   'links'       => [ $link,
31                      '',
32                      '',
33                      $link,
34                      $link,
35                      $link,
36                      '', # pkg status
37                      FS::UI::Web::cust_links($cgi->param('cust_fields')),
38                    ],
39   'align'       => 'rlllllr'.  FS::UI::Web::cust_aligns(),
40   'color'       => [ 
41                      ('') x 6,
42                      sub {
43                        my $c = FS::cust_pkg::statuscolors;
44                        $c->{$cust_pkg_cache{$_[0]->svcnum}->status };
45                      }, # pkg status
46                      FS::UI::Web::cust_colors(),
47                    ],
48   'style'       => [ 
49                      ('') x 6,
50                      'b',
51                      FS::UI::Web::cust_styles(),
52                    ],
53
54 &>
55 <%init>
56
57 die "access denied" unless
58   $FS::CurrentUser::CurrentUser->access_right([ 'Services: Fiber',
59                                                 'List services'
60                                               ]);
61
62 my %cust_pkg_cache;
63
64 my $conf = new FS::Conf;
65
66 my %search_hash;
67 if ( $cgi->param('magic') eq 'unlinked' ) {
68   %search_hash = ( 'unlinked' => 1 );
69 } else {
70   foreach (qw( custnum agentnum svcpart cust_fields
71                ont_typenum oltnum shelf olt_port card vlan )) {
72     $search_hash{$_} = $cgi->param($_) if defined($cgi->param($_));
73   }
74   if ( defined($cgi->param('cancelled')) ) {
75     $search_hash{'cancelled'} = $cgi->param('cancelled') ? 1 : 0;
76   }
77 }
78
79 my $query = FS::svc_fiber->search(\%search_hash);
80 $query->{addl_from} .= ' LEFT JOIN fiber_olt USING (oltnum) ';
81 $query->{select} .= ', oltname';
82
83 my $link = [ $p.'view/svc_fiber.cgi?', 'svcnum' ];
84
85 </%init>