1 <& elements/svc_Common.html,
2 'title' => 'Hardware service search results',
3 'name' => 'installations',
5 'count_query' => $count_query,
6 'redirect' => $link_svc,
16 FS::UI::Web::cust_header(),
18 'fields' => [ 'svcnum',
27 $cust_pkg_cache{$_[0]->svcnum} ||= $_[0]->cust_svc->cust_pkg;
28 return '' unless $cust_pkg_cache{$_[0]->svcnum};
29 $cust_pkg_cache{$_[0]->svcnum}->ucfirst_status
31 \&FS::UI::Web::cust_fields,
33 'links' => [ ($link_svc) x 8,
35 ( map { $_ ne 'Cust. Status' ?
37 FS::UI::Web::cust_header() )
39 'align' => 'rlllllllr' . FS::UI::Web::cust_aligns(),
40 'color' => [ ('') x 8,
42 $cust_pkg_cache{$_[0]->svcnum} ||= $_[0]->cust_svc->cust_pkg;
43 return '' unless $cust_pkg_cache{$_[0]->svcnum};
44 my $c = FS::cust_pkg::statuscolors;
45 $c->{$cust_pkg_cache{$_[0]->svcnum}->status };
47 FS::UI::Web::cust_colors() ],
48 'style' => [ $svc_cancel_style, ('') x 7,
50 FS::UI::Web::cust_styles() ],
55 unless $FS::CurrentUser::CurrentUser->access_right('List services');
60 LEFT JOIN cust_svc USING ( svcnum )
61 LEFT JOIN part_svc USING ( svcpart )
62 LEFT JOIN cust_pkg USING ( pkgnum )'.
63 FS::UI::Web::join_cust_main('cust_pkg', 'cust_pkg').'
64 LEFT JOIN hardware_type USING ( typenum )';
67 push @extra_sql, $FS::CurrentUser::CurrentUser->agentnums_sql(
68 'null_right' => 'View/link unlinked services'
71 if ( $cgi->param('magic') =~ /^(unlinked)$/ ) {
72 push @extra_sql, 'pkgnum IS NULL';
75 if ( lc($cgi->param('serial')) =~ /^(\w+)$/ ) {
76 push @extra_sql, "LOWER(serial) LIKE '%$1%'";
79 if ( $cgi->param('hw_addr') =~ /^(\S+)$/ ) {
82 push @extra_sql, "hw_addr LIKE '%$hw_addr%'";
85 if ( $cgi->param('ip_addr') ) {
86 my $ip = NetAddr::IP->new($cgi->param('ip_addr'));
87 push @extra_sql, "ip_addr = '".lc($ip->addr)."'" if $ip;
90 if ( lc($cgi->param('smartcard')) =~ /^(\w+)$/ ) {
91 push @extra_sql, "LOWER(smartcard) LIKE '%$1%'";
94 if ( $cgi->param('statusnum') =~ /^(\d+)$/ ) {
95 push @extra_sql, "statusnum = $1";
98 if ( $cgi->param('classnum') =~ /^(\d+)$/ ) {
99 push @extra_sql, "hardware_type.classnum = $1";
102 if ( $cgi->param('model') =~ /^([\w\s]+)$/ ) {
103 push @extra_sql, "hardware_type.model = '$1'";
106 if ( $cgi->param('typenum') =~ /^(\d+)$/ ) {
107 push @extra_sql, "svc_hardware.typenum = $1";
110 if ( $cgi->param('svcpart') =~ /^(\d+)$/ ) {
111 push @extra_sql, "cust_svc.svcpart = $1";
112 if (defined($cgi->param('cancelled'))) {
113 if ($cgi->param('cancelled')) {
114 push @extra_sql, "cust_pkg.cancel IS NOT NULL";
116 push @extra_sql, "cust_pkg.cancel IS NULL";
121 my ($orderby) = $cgi->param('orderby') =~ /^(\w+( ASC| DESC)?)$/i;
122 $orderby ||= 'svcnum';
125 $extra_sql = ' WHERE '.join(' AND ', @extra_sql) if @extra_sql;
128 'table' => 'svc_hardware',
129 'select' => join(', ',
133 'hardware_type.model',
134 'hardware_type.revision',
136 FS::UI::Web::cust_sql_fields(),
139 'extra_sql' => $extra_sql,
140 'order_by' => "ORDER BY $orderby",
141 'addl_from' => $addl_from,
143 my $count_query = "SELECT COUNT(*) FROM svc_hardware $addl_from $extra_sql";
144 my $link_svc = [ $p.'view/svc_hardware.cgi?', 'svcnum' ];
145 my $link_cust = [ $p.'view/cust_main.cgi?', 'custnum' ];
147 my $svc_cancel_style = sub {
149 ( $svc->getfield('cancel') == 0 ) ? '' : 's';