1 <% include( 'elements/search.html',
2 'title' => "Mail forward Search Results",
3 'name' => 'mail forwards',
5 'count_query' => $count_query,
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()
27 'align' => 'rlll'. FS::UI::Web::cust_aligns(),
33 FS::UI::Web::cust_colors(),
40 FS::UI::Web::cust_styles(),
47 unless $FS::CurrentUser::CurrentUser->access_right('List services');
49 my $conf = new FS::Conf;
51 my $orderby = 'ORDER BY svcnum';
53 if ( $cgi->param('magic') =~ /^(all|unlinked)$/ ) {
55 push @extra_sql, 'pkgnum IS NULL'
56 if $cgi->param('magic') eq 'unlinked';
58 if ( $cgi->param('sortby') =~ /^(\w+)$/ ) {
60 $orderby = "ORDER BY $sortby";
63 } elsif ( $cgi->param('svcpart') =~ /^(\d+)$/ ) {
64 push @extra_sql, "svcpart = $1";
67 my $addl_from = ' LEFT JOIN cust_svc USING ( svcnum ) '.
68 ' LEFT JOIN part_svc USING ( svcpart ) '.
69 ' LEFT JOIN cust_pkg USING ( pkgnum ) '.
70 ' LEFT JOIN cust_main USING ( custnum ) ';
72 #here is the agent virtualization
73 push @extra_sql, $FS::CurrentUser::CurrentUser->agentnums_sql(
74 'null_right' => 'View/link unlinked services'
79 ? ' WHERE '. join(' AND ', @extra_sql )
82 my $count_query = "SELECT COUNT(*) FROM svc_forward $addl_from $extra_sql";
84 'table' => 'svc_forward',
86 'select' => join(', ',
90 FS::UI::Web::cust_sql_fields(),
92 'extra_sql' => "$extra_sql $orderby",
93 'addl_from' => $addl_from,
96 # <TH>Service #<BR><FONT SIZE=-1>(click to view forward)</FONT></TH>
97 # <TH>Mail to<BR><FONT SIZE=-1>(click to view account)</FONT></TH>
98 # <TH>Forwards to<BR><FONT SIZE=-1>(click to view account)</FONT></TH>
100 my $link = [ "${p}view/svc_forward.cgi?", 'svcnum' ];
102 my $format_src = sub {
103 my $svc_forward = shift;
104 if ( $svc_forward->srcsvc_acct ) {
105 $svc_forward->srcsvc_acct->email;
107 my $src = $svc_forward->src;
108 $src = "<I>(anything)</I>$src" if $src =~ /^@/;
114 my $svc_forward = shift;
115 if ( $svc_forward->srcsvc_acct ) {
116 [ "${p}view/svc_acct.cgi?", 'srcsvc' ];
122 my $format_dst = sub {
123 my $svc_forward = shift;
124 if ( $svc_forward->dstsvc_acct ) {
125 $svc_forward->dstsvc_acct->email;
132 my $svc_forward = shift;
133 if ( $svc_forward->dstsvc_acct ) {
134 [ "${p}view/svc_acct.cgi?", 'dstsvc' ];
140 #smaller false laziness w/svc_*.cgi here
141 my $link_cust = sub {
143 $svc_x->custnum ? [ "${p}view/cust_main.cgi?", 'custnum' ] : '';