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' ),
11 FS::UI::Web::cust_header(),
13 'fields' => [ 'svcnum',
17 \&FS::UI::Web::cust_fields,
23 ( map { $_ ne 'Cust. Status' ? $link_cust : '' }
24 FS::UI::Web::cust_header()
28 FS::UI::Web::cust_aligns(),
34 FS::UI::Web::cust_colors(),
41 FS::UI::Web::cust_styles(),
48 unless $FS::CurrentUser::CurrentUser->access_right('List services');
50 my $conf = new FS::Conf;
54 my $orderby = 'ORDER BY svcnum';
56 my $link = [ "${p}view/svc_external.cgi?", 'svcnum' ];
59 if ( $cgi->param('magic') =~ /^(all|unlinked)$/ ) {
61 push @extra_sql, 'pkgnum IS NULL'
62 if $cgi->param('magic') eq 'unlinked';
64 if ( $cgi->param('sortby') =~ /^(\w+)$/ ) {
66 $orderby = "ORDER BY $sortby";
69 } elsif ( $cgi->param('svcpart') =~ /^(\d+)$/ ) {
71 push @extra_sql, "svcpart = $1";
73 } elsif ( $cgi->param('title') =~ /^(.*)$/ ) {
75 $svc_external{'title'} = $1;
76 $orderby = 'ORDER BY id';
78 # is this linked from anywhere???
79 # if( $cgi->param('history') == 1 ) {
80 # @h_svc_external=qsearch('h_svc_external',{ title => $1 });
83 } elsif ( $cgi->param('id') =~ /^([\w\-\.]+)$/ ) {
85 $svc_external{'id'} = $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_external) ? ' AND ' : ' WHERE ' ).
102 join(' AND ', @extra_sql );
105 my $count_query = "SELECT COUNT(*) FROM svc_external $addl_from ";
106 if ( keys %svc_external ) {
107 $count_query .= ' WHERE '.
108 join(' AND ', map "$_ = ". dbh->quote($svc_external{$_}),
112 $count_query .= $extra_sql;
115 'table' => 'svc_external',
116 'hashref' => \%svc_external,
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 #smaller false laziness w/svc_*.cgi here
129 my $link_cust = sub {
131 $svc_x->custnum ? [ "${p}view/cust_main.cgi?", 'custnum' ] : '';