1 <& elements/svc_Common.html,
2 'title' => 'External service search results',
3 'name' => 'external services',
5 'count_query' => $count_query,
6 'redirect' => $redirect,
9 ( FS::Msgcat::_gettext('svc_external-id') || 'External ID' ),
10 ( FS::Msgcat::_gettext('svc_external-title') || 'Title' ),
12 FS::UI::Web::cust_header(),
14 'fields' => [ 'svcnum',
19 $cust_pkg_cache{$_[0]->svcnum} ||= $_[0]->cust_svc->cust_pkg;
20 $cust_pkg_cache{$_[0]->svcnum}->ucfirst_status
22 \&FS::UI::Web::cust_fields,
29 ( map { $_ ne 'Cust. Status' ? $link_cust : '' }
30 FS::UI::Web::cust_header()
34 FS::UI::Web::cust_aligns(),
41 my $c = FS::cust_pkg::statuscolors;
42 $c->{$cust_pkg_cache{$_[0]->svcnum}->status };
44 FS::UI::Web::cust_colors(),
52 FS::UI::Web::cust_styles(),
59 unless $FS::CurrentUser::CurrentUser->access_right('List services');
63 my $conf = new FS::Conf;
67 my $orderby = 'ORDER BY svcnum';
69 my $link = [ "${p}view/svc_external.cgi?", 'svcnum' ];
72 if ( $cgi->param('magic') =~ /^(all|unlinked)$/ ) {
74 push @extra_sql, 'pkgnum IS NULL'
75 if $cgi->param('magic') eq 'unlinked';
77 if ( $cgi->param('sortby') =~ /^(\w+)$/ ) {
79 $orderby = "ORDER BY $sortby";
82 } elsif ( $cgi->param('svcpart') =~ /^(\d+)$/ ) {
84 push @extra_sql, "svcpart = $1";
85 if (defined($cgi->param('cancelled'))) {
86 if ($cgi->param('cancelled')) {
87 push @extra_sql, "cust_pkg.cancel IS NOT NULL";
89 push @extra_sql, "cust_pkg.cancel IS NULL";
93 } elsif ( $cgi->param('title') =~ /^(.*)$/ ) {
95 $svc_external{'title'} = $1;
96 $orderby = 'ORDER BY id';
98 # is this linked from anywhere???
99 # if( $cgi->param('history') == 1 ) {
100 # @h_svc_external=qsearch('h_svc_external',{ title => $1 });
103 } elsif ( $cgi->param('id') =~ /^([\w\-\.]+)$/ ) {
105 $svc_external{'id'} = $1;
109 my $addl_from = ' LEFT JOIN cust_svc USING ( svcnum ) '.
110 ' LEFT JOIN part_svc USING ( svcpart ) '.
111 ' LEFT JOIN cust_pkg USING ( pkgnum ) '.
112 FS::UI::Web::join_cust_main('cust_pkg', 'cust_pkg');
114 #here is the agent virtualization
115 push @extra_sql, $FS::CurrentUser::CurrentUser->agentnums_sql(
116 'null_right' => 'View/link unlinked services'
121 $extra_sql = ( keys(%svc_external) ? ' AND ' : ' WHERE ' ).
122 join(' AND ', @extra_sql );
125 my $count_query = "SELECT COUNT(*) FROM svc_external $addl_from ";
126 if ( keys %svc_external ) {
127 $count_query .= ' WHERE '.
128 join(' AND ', map "$_ = ". dbh->quote($svc_external{$_}),
132 $count_query .= $extra_sql;
135 'table' => 'svc_external',
136 'hashref' => \%svc_external,
137 'select' => join(', ',
141 FS::UI::Web::cust_sql_fields(),
143 'extra_sql' => $extra_sql,
144 'order_by' => $orderby,
145 'addl_from' => $addl_from,
148 #smaller false laziness w/svc_*.cgi here
149 my $link_cust = sub {
151 $svc_x->custnum ? [ "${p}view/cust_main.cgi?", 'custnum' ] : '';