1 <& elements/search.html,
2 'title' => "Domain Search Results",
5 'count_query' => $count_query,
11 FS::UI::Web::cust_header(),
13 'fields' => [ 'svcnum',
17 $cust_pkg_cache{$_[0]->svcnum} ||= $_[0]->cust_svc->cust_pkg;
18 return '' unless $cust_pkg_cache{$_[0]->svcnum};
19 $cust_pkg_cache{$_[0]->svcnum}->ucfirst_status
21 \&FS::UI::Web::cust_fields,
27 ( map { $_ ne 'Cust. Status' ? $link_cust : '' }
28 FS::UI::Web::cust_header()
31 'align' => 'rllr'. FS::UI::Web::cust_aligns(),
37 $cust_pkg_cache{$_[0]->svcnum} ||= $_[0]->cust_svc->cust_pkg;
38 return '' unless $cust_pkg_cache{$_[0]->svcnum};
39 my $c = FS::cust_pkg::statuscolors;
40 $c->{$cust_pkg_cache{$_[0]->svcnum}->status };
42 FS::UI::Web::cust_colors(),
49 FS::UI::Web::cust_styles(),
56 unless $FS::CurrentUser::CurrentUser->access_right('List services');
60 my $conf = new FS::Conf;
62 my $orderby = 'ORDER BY svcnum';
65 if ( $cgi->param('magic') =~ /^(all|unlinked)$/ ) {
67 push @extra_sql, 'pkgnum IS NULL'
68 if $cgi->param('magic') eq 'unlinked';
70 if ( $cgi->param('sortby') =~ /^(\w+)$/ ) {
72 $orderby = "ORDER BY $sortby";
75 } elsif ( $cgi->param('svcpart') =~ /^(\d+)$/ ) {
76 push @extra_sql, "svcpart = $1";
77 if (defined($cgi->param('cancelled'))) {
78 if ($cgi->param('cancelled')) {
79 push @extra_sql, "cust_pkg.cancel IS NOT NULL";
81 push @extra_sql, "cust_pkg.cancel IS NULL";
85 $cgi->param('domain') =~ /^([\w\-\.]+)$/;
86 $svc_domain{'domain'} = $1;
89 my $addl_from = ' LEFT JOIN cust_svc USING ( svcnum ) '.
90 ' LEFT JOIN part_svc USING ( svcpart ) '.
91 ' LEFT JOIN cust_pkg USING ( pkgnum ) '.
92 FS::UI::Web::join_cust_main('cust_pkg', 'cust_pkg');
94 #here is the agent virtualization
95 push @extra_sql, $FS::CurrentUser::CurrentUser->agentnums_sql(
96 'null_right' => 'View/link unlinked services'
101 $extra_sql = ( keys(%svc_domain) ? ' AND ' : ' WHERE ' ).
102 join(' AND ', @extra_sql );
105 my $count_query = "SELECT COUNT(*) FROM svc_domain $addl_from ";
106 if ( keys %svc_domain ) {
107 $count_query .= ' WHERE '.
108 join(' AND ', map "$_ = ". dbh->quote($svc_domain{$_}),
112 $count_query .= $extra_sql;
115 'table' => 'svc_domain',
116 'hashref' => \%svc_domain,
117 'select' => join(', ',
121 FS::UI::Web::cust_sql_fields(),
123 'extra_sql' => $extra_sql,
124 'order_by' => $orderby,
125 'addl_from' => $addl_from,
128 my $link = [ "${p}view/svc_domain.cgi?", 'svcnum' ];
130 #smaller false laziness w/svc_*.cgi here
131 my $link_cust = sub {
133 $svc_x->custnum ? [ "${p}view/cust_main.cgi?", 'custnum' ] : '';