1 <& elements/search.html,
2 'title' => "Domain Search Results",
5 'count_query' => $count_query,
10 FS::UI::Web::cust_header(),
12 'fields' => [ 'svcnum',
15 \&FS::UI::Web::cust_fields,
20 ( map { $_ ne 'Cust. Status' ? $link_cust : '' }
21 FS::UI::Web::cust_header()
24 'align' => 'rll'. FS::UI::Web::cust_aligns(),
29 FS::UI::Web::cust_colors(),
35 FS::UI::Web::cust_styles(),
42 unless $FS::CurrentUser::CurrentUser->access_right('List services');
44 my $conf = new FS::Conf;
46 my $orderby = 'ORDER BY svcnum';
49 if ( $cgi->param('magic') =~ /^(all|unlinked)$/ ) {
51 push @extra_sql, 'pkgnum IS NULL'
52 if $cgi->param('magic') eq 'unlinked';
54 if ( $cgi->param('sortby') =~ /^(\w+)$/ ) {
56 $orderby = "ORDER BY $sortby";
59 } elsif ( $cgi->param('svcpart') =~ /^(\d+)$/ ) {
60 push @extra_sql, "svcpart = $1";
62 $cgi->param('domain') =~ /^([\w\-\.]+)$/;
63 $svc_domain{'domain'} = $1;
66 my $addl_from = ' LEFT JOIN cust_svc USING ( svcnum ) '.
67 ' LEFT JOIN part_svc USING ( svcpart ) '.
68 ' LEFT JOIN cust_pkg USING ( pkgnum ) '.
69 FS::UI::Web::join_cust_main('cust_pkg', 'cust_pkg');
71 #here is the agent virtualization
72 push @extra_sql, $FS::CurrentUser::CurrentUser->agentnums_sql(
73 'null_right' => 'View/link unlinked services'
78 $extra_sql = ( keys(%svc_domain) ? ' AND ' : ' WHERE ' ).
79 join(' AND ', @extra_sql );
82 my $count_query = "SELECT COUNT(*) FROM svc_domain $addl_from ";
83 if ( keys %svc_domain ) {
84 $count_query .= ' WHERE '.
85 join(' AND ', map "$_ = ". dbh->quote($svc_domain{$_}),
89 $count_query .= $extra_sql;
92 'table' => 'svc_domain',
93 'hashref' => \%svc_domain,
94 'select' => join(', ',
98 FS::UI::Web::cust_sql_fields(),
100 'extra_sql' => $extra_sql,
101 'order_by' => $orderby,
102 'addl_from' => $addl_from,
105 my $link = [ "${p}view/svc_domain.cgi?", 'svcnum' ];
107 #smaller false laziness w/svc_*.cgi here
108 my $link_cust = sub {
110 $svc_x->custnum ? [ "${p}view/cust_main.cgi?", 'custnum' ] : '';