1 <% include('elements/search.html',
2 'title' => 'Hardware service search results',
3 'name' => 'installations',
5 'count_query' => $count_query,
6 'redirect' => $link_svc,
15 FS::UI::Web::cust_header(),
17 'fields' => [ 'svcnum',
25 \&FS::UI::Web::cust_fields,
27 'links' => [ ($link_svc) x 8,
28 ( map { $_ ne 'Cust. Status' ?
30 FS::UI::Web::cust_header() )
32 'align' => 'rlllllll' . FS::UI::Web::cust_aligns(),
33 'color' => [ ('') x 8,
34 FS::UI::Web::cust_colors() ],
35 'style' => [ $svc_cancel_style, ('') x 7,
36 FS::UI::Web::cust_styles() ],
42 unless $FS::CurrentUser::CurrentUser->access_right('List services');
45 LEFT JOIN cust_svc USING ( svcnum )
46 LEFT JOIN part_svc USING ( svcpart )
47 LEFT JOIN cust_pkg USING ( pkgnum )
48 LEFT JOIN cust_main USING ( custnum )
49 LEFT JOIN hardware_type USING ( typenum )';
52 push @extra_sql, $FS::CurrentUser::CurrentUser->agentnums_sql(
53 'null_right' => 'View/link unlinked services'
56 if ( $cgi->param('magic') =~ /^(unlinked)$/ ) {
57 push @extra_sql, 'pkgnum IS NULL';
60 if ( lc($cgi->param('serial')) =~ /^(\w+)$/ ) {
61 push @extra_sql, "LOWER(serial) LIKE '%$1%'";
64 if ( $cgi->param('hw_addr') =~ /^(\S+)$/ ) {
67 push @extra_sql, "hw_addr LIKE '%$hw_addr%'";
70 if ( $cgi->param('ip_addr') ) {
71 my $ip = NetAddr::IP->new($cgi->param('ip_addr'));
72 push @extra_sql, "ip_addr = '".lc($ip->addr)."'" if $ip;
75 if ( lc($cgi->param('smartcard')) =~ /^(\w+)$/ ) {
76 push @extra_sql, "LOWER(smartcard) LIKE '%$1%'";
79 if ( $cgi->param('statusnum') =~ /^(\d+)$/ ) {
80 push @extra_sql, "statusnum = $1";
83 if ( $cgi->param('classnum') =~ /^(\d+)$/ ) {
84 push @extra_sql, "hardware_type.classnum = $1";
87 if ( $cgi->param('model') =~ /^([\w\s]+)$/ ) {
88 push @extra_sql, "hardware_type.model = '$1'";
91 if ( $cgi->param('typenum') =~ /^(\d+)$/ ) {
92 push @extra_sql, "svc_hardware.typenum = $1";
95 if ( $cgi->param('svcpart') =~ /^(\d+)$/ ) {
96 push @extra_sql, "cust_svc.svcpart = $1";
99 my ($orderby) = $cgi->param('orderby') =~ /^(\w+( ASC| DESC)?)$/i;
100 $orderby ||= 'svcnum';
103 $extra_sql = ' WHERE '.join(' AND ', @extra_sql) if @extra_sql;
106 'table' => 'svc_hardware',
107 'select' => join(', ',
111 'hardware_type.model',
112 'hardware_type.revision',
114 FS::UI::Web::cust_sql_fields(),
117 'extra_sql' => $extra_sql,
118 'order_by' => "ORDER BY $orderby",
119 'addl_from' => $addl_from,
121 my $count_query = "SELECT COUNT(*) FROM svc_hardware $addl_from $extra_sql";
122 my $link_svc = [ $p.'view/svc_hardware.cgi?', 'svcnum' ];
123 my $link_cust = [ $p.'view/cust_main.cgi?', 'custnum' ];
125 my $svc_cancel_style = sub {
127 ( $svc->getfield('cancel') == 0 ) ? '' : 's';