1 <& 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() ],
41 unless $FS::CurrentUser::CurrentUser->access_right('List services');
44 LEFT JOIN cust_svc USING ( svcnum )
45 LEFT JOIN part_svc USING ( svcpart )
46 LEFT JOIN cust_pkg USING ( pkgnum )'.
47 FS::UI::Web::join_cust_main('cust_pkg', 'cust_pkg').'
48 LEFT JOIN hardware_type USING ( typenum )';
51 push @extra_sql, $FS::CurrentUser::CurrentUser->agentnums_sql(
52 'null_right' => 'View/link unlinked services'
55 if ( $cgi->param('magic') =~ /^(unlinked)$/ ) {
56 push @extra_sql, 'pkgnum IS NULL';
59 if ( lc($cgi->param('serial')) =~ /^(\w+)$/ ) {
60 push @extra_sql, "LOWER(serial) LIKE '%$1%'";
63 if ( $cgi->param('hw_addr') =~ /^(\S+)$/ ) {
66 push @extra_sql, "hw_addr LIKE '%$hw_addr%'";
69 if ( $cgi->param('ip_addr') ) {
70 my $ip = NetAddr::IP->new($cgi->param('ip_addr'));
71 push @extra_sql, "ip_addr = '".lc($ip->addr)."'" if $ip;
74 if ( lc($cgi->param('smartcard')) =~ /^(\w+)$/ ) {
75 push @extra_sql, "LOWER(smartcard) LIKE '%$1%'";
78 if ( $cgi->param('statusnum') =~ /^(\d+)$/ ) {
79 push @extra_sql, "statusnum = $1";
82 if ( $cgi->param('classnum') =~ /^(\d+)$/ ) {
83 push @extra_sql, "hardware_type.classnum = $1";
86 if ( $cgi->param('model') =~ /^([\w\s]+)$/ ) {
87 push @extra_sql, "hardware_type.model = '$1'";
90 if ( $cgi->param('typenum') =~ /^(\d+)$/ ) {
91 push @extra_sql, "svc_hardware.typenum = $1";
94 if ( $cgi->param('svcpart') =~ /^(\d+)$/ ) {
95 push @extra_sql, "cust_svc.svcpart = $1";
98 my ($orderby) = $cgi->param('orderby') =~ /^(\w+( ASC| DESC)?)$/i;
99 $orderby ||= 'svcnum';
102 $extra_sql = ' WHERE '.join(' AND ', @extra_sql) if @extra_sql;
105 'table' => 'svc_hardware',
106 'select' => join(', ',
110 'hardware_type.model',
111 'hardware_type.revision',
113 FS::UI::Web::cust_sql_fields(),
116 'extra_sql' => $extra_sql,
117 'order_by' => "ORDER BY $orderby",
118 'addl_from' => $addl_from,
120 my $count_query = "SELECT COUNT(*) FROM svc_hardware $addl_from $extra_sql";
121 my $link_svc = [ $p.'view/svc_hardware.cgi?', 'svcnum' ];
122 my $link_cust = [ $p.'view/cust_main.cgi?', 'custnum' ];
124 my $svc_cancel_style = sub {
126 ( $svc->getfield('cancel') == 0 ) ? '' : 's';