1 <& elements/search.html,
2 'title' => "Mail forward Search Results",
3 'name' => 'mail forwards',
5 'count_query' => $count_query,
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()
34 'align' => 'rlllr'. FS::UI::Web::cust_aligns(),
41 $cust_pkg_cache{$_[0]->svcnum} ||= $_[0]->cust_svc->cust_pkg;
42 return '' unless $cust_pkg_cache{$_[0]->svcnum};
43 my $c = FS::cust_pkg::statuscolors;
44 $c->{$cust_pkg_cache{$_[0]->svcnum}->status };
46 FS::UI::Web::cust_colors(),
54 FS::UI::Web::cust_styles(),
61 unless $FS::CurrentUser::CurrentUser->access_right('List services');
65 my $conf = new FS::Conf;
67 my $orderby = 'ORDER BY svcnum';
69 if ( $cgi->param('magic') =~ /^(all|unlinked)$/ ) {
71 push @extra_sql, 'pkgnum IS NULL'
72 if $cgi->param('magic') eq 'unlinked';
74 if ( $cgi->param('sortby') =~ /^(\w+)$/ ) {
76 $orderby = "ORDER BY $sortby";
79 } elsif ( $cgi->param('svcpart') =~ /^(\d+)$/ ) {
80 push @extra_sql, "svcpart = $1";
81 if (defined($cgi->param('cancelled'))) {
82 if ($cgi->param('cancelled')) {
83 push @extra_sql, "cust_pkg.cancel IS NOT NULL";
85 push @extra_sql, "cust_pkg.cancel IS NULL";
90 my $addl_from = ' LEFT JOIN cust_svc USING ( svcnum ) '.
91 ' LEFT JOIN part_svc USING ( svcpart ) '.
92 ' LEFT JOIN cust_pkg USING ( pkgnum ) '.
93 FS::UI::Web::join_cust_main('cust_pkg', 'cust_pkg');
95 #here is the agent virtualization
96 push @extra_sql, $FS::CurrentUser::CurrentUser->agentnums_sql(
97 'null_right' => 'View/link unlinked services'
102 ? ' WHERE '. join(' AND ', @extra_sql )
105 my $count_query = "SELECT COUNT(*) FROM svc_forward $addl_from $extra_sql";
107 'table' => 'svc_forward',
109 'select' => join(', ',
113 FS::UI::Web::cust_sql_fields(),
115 'extra_sql' => $extra_sql,
116 'order_by' => $orderby,
117 'addl_from' => $addl_from,
120 # <TH>Service #<BR><FONT SIZE=-1>(click to view forward)</FONT></TH>
121 # <TH>Mail to<BR><FONT SIZE=-1>(click to view account)</FONT></TH>
122 # <TH>Forwards to<BR><FONT SIZE=-1>(click to view account)</FONT></TH>
124 my $link = [ "${p}view/svc_forward.cgi?", 'svcnum' ];
126 my $format_src = sub {
127 my $svc_forward = shift;
128 if ( $svc_forward->srcsvc_acct ) {
129 $svc_forward->srcsvc_acct->email;
131 my $src = $svc_forward->src;
132 $src = "<I>(anything)</I>$src" if $src =~ /^@/;
138 my $svc_forward = shift;
139 if ( $svc_forward->srcsvc_acct ) {
140 [ "${p}view/svc_acct.cgi?", 'srcsvc' ];
146 my $format_dst = sub {
147 my $svc_forward = shift;
148 if ( $svc_forward->dstsvc_acct ) {
149 $svc_forward->dstsvc_acct->email;
156 my $svc_forward = shift;
157 if ( $svc_forward->dstsvc_acct ) {
158 [ "${p}view/svc_acct.cgi?", 'dstsvc' ];
164 #smaller false laziness w/svc_*.cgi here
165 my $link_cust = sub {
167 $svc_x->custnum ? [ "${p}view/cust_main.cgi?", 'custnum' ] : '';