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 return '' unless $cust_pkg_cache{$_[0]->svcnum};
21 $cust_pkg_cache{$_[0]->svcnum}->ucfirst_status
23 \&FS::UI::Web::cust_fields,
30 ( map { $_ ne 'Cust. Status' ? $link_cust : '' }
31 FS::UI::Web::cust_header()
35 FS::UI::Web::cust_aligns(),
42 $cust_pkg_cache{$_[0]->svcnum} ||= $_[0]->cust_svc->cust_pkg;
43 return '' unless $cust_pkg_cache{$_[0]->svcnum};
44 my $c = FS::cust_pkg::statuscolors;
45 $c->{$cust_pkg_cache{$_[0]->svcnum}->status };
47 FS::UI::Web::cust_colors(),
55 FS::UI::Web::cust_styles(),
62 unless $FS::CurrentUser::CurrentUser->access_right('List services');
66 my $conf = new FS::Conf;
70 my $orderby = 'ORDER BY svcnum';
72 my $link = [ "${p}view/svc_external.cgi?", 'svcnum' ];
75 if ( $cgi->param('magic') =~ /^(all|unlinked)$/ ) {
77 push @extra_sql, 'pkgnum IS NULL'
78 if $cgi->param('magic') eq 'unlinked';
80 if ( $cgi->param('sortby') =~ /^(\w+)$/ ) {
82 $orderby = "ORDER BY $sortby";
85 } elsif ( $cgi->param('svcpart') =~ /^(\d+)$/ ) {
87 push @extra_sql, "svcpart = $1";
88 if (defined($cgi->param('cancelled'))) {
89 if ($cgi->param('cancelled')) {
90 push @extra_sql, "cust_pkg.cancel IS NOT NULL";
92 push @extra_sql, "cust_pkg.cancel IS NULL";
96 } elsif ( $cgi->param('title') =~ /^(.*)$/ ) {
98 $svc_external{'title'} = $1;
99 $orderby = 'ORDER BY id';
101 # is this linked from anywhere???
102 # if( $cgi->param('history') == 1 ) {
103 # @h_svc_external=qsearch('h_svc_external',{ title => $1 });
106 } elsif ( $cgi->param('id') =~ /^([\w\-\.]+)$/ ) {
108 $svc_external{'id'} = $1;
112 my $addl_from = ' LEFT JOIN cust_svc USING ( svcnum ) '.
113 ' LEFT JOIN part_svc USING ( svcpart ) '.
114 ' LEFT JOIN cust_pkg USING ( pkgnum ) '.
115 FS::UI::Web::join_cust_main('cust_pkg', 'cust_pkg');
117 #here is the agent virtualization
118 push @extra_sql, $FS::CurrentUser::CurrentUser->agentnums_sql(
119 'null_right' => 'View/link unlinked services'
124 $extra_sql = ( keys(%svc_external) ? ' AND ' : ' WHERE ' ).
125 join(' AND ', @extra_sql );
128 my $count_query = "SELECT COUNT(*) FROM svc_external $addl_from ";
129 if ( keys %svc_external ) {
130 $count_query .= ' WHERE '.
131 join(' AND ', map "$_ = ". dbh->quote($svc_external{$_}),
135 $count_query .= $extra_sql;
138 'table' => 'svc_external',
139 'hashref' => \%svc_external,
140 'select' => join(', ',
144 FS::UI::Web::cust_sql_fields(),
146 'extra_sql' => $extra_sql,
147 'order_by' => $orderby,
148 'addl_from' => $addl_from,
151 #smaller false laziness w/svc_*.cgi here
152 my $link_cust = sub {
154 $svc_x->custnum ? [ "${p}view/cust_main.cgi?", 'custnum' ] : '';