catch misconfigured exports
[freeside.git] / httemplate / view / svc_forward.cgi
1 <!-- mason kludge -->
2 <%
3
4 my $conf = new FS::Conf;
5
6 my($query) = $cgi->keywords;
7 $query =~ /^(\d+)$/;
8 my $svcnum = $1;
9 my $svc_forward = qsearchs('svc_forward',{'svcnum'=>$svcnum});
10 die "Unknown svcnum" unless $svc_forward;
11
12 my $cust_svc = qsearchs('cust_svc',{'svcnum'=>$svcnum});
13 my $pkgnum = $cust_svc->getfield('pkgnum');
14 my($cust_pkg, $custnum);
15 if ($pkgnum) {
16   $cust_pkg=qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
17   $custnum=$cust_pkg->getfield('custnum');
18 } else {
19   $cust_pkg = '';
20   $custnum = '';
21 }
22
23 my $part_svc = qsearchs('part_svc',{'svcpart'=> $cust_svc->svcpart } )
24   or die "Unkonwn svcpart";
25
26 print header('Mail Forward View', menubar(
27   ( ( $pkgnum || $custnum )
28     ? ( "View this customer (#$custnum)" => "${p}view/cust_main.cgi?$custnum",
29       )
30     : ( "Cancel this (unaudited) mail forward" =>
31           "${p}misc/cancel-unaudited.cgi?$svcnum" )
32   ),
33   "Main menu" => $p,
34 ));
35
36 my($srcsvc,$dstsvc,$dst) = (
37   $svc_forward->srcsvc,
38   $svc_forward->dstsvc,
39   $svc_forward->dst,
40 );
41 my $src = $svc_forward->dbdef_table->column('src') ? $svc_forward->src : '';
42
43 my $svc = $part_svc->svc;
44
45 my $source;
46 if ($srcsvc) {
47   my $svc_acct = qsearchs('svc_acct',{'svcnum'=>$srcsvc})
48     or die "Corrupted database: no svc_acct.svcnum matching srcsvc $srcsvc";
49   $source = $svc_acct->email;
50 } else {
51   $source = $src;
52 }
53
54 my $destination;
55 if ($dstsvc) {
56   my $svc_acct = qsearchs('svc_acct',{'svcnum'=>$dstsvc})
57     or die "Corrupted database: no svc_acct.svcnum matching dstsvc $dstsvc";
58   $destination = $svc_acct->email;
59 } else {
60   $destination = $dst;
61 }
62
63 print qq!<A HREF="${p}edit/svc_forward.cgi?$svcnum">Edit this information</A>!.
64       ntable("#cccccc",2).
65       '<TR><TD ALIGN="right">Service number</TD>'.
66         qq!<TD BGCOLOR="#ffffff">$svcnum</TD></TR>!.
67       '<TR><TD ALIGN="right">Service</TD>'.
68         qq!<TD BGCOLOR="#ffffff">$svc</TD></TR>!.
69       qq!<TR><TD ALIGN="right">Email to</TD>!.
70         qq!<TD BGCOLOR="#ffffff">$source</TD></TR>!.
71       qq!<TR><TD ALIGN="right">Forwards to </TD>!.
72         qq!<TD BGCOLOR="#ffffff">$destination</TD></TR>!;
73
74 foreach (sort { $a cmp $b } $svc_forward->virtual_fields) {
75   print $svc_forward->pvf($_)->widget('HTML', 'view', $svc_forward->getfield($_)),
76       "\n";
77 }
78
79 print qq!  </TABLE>!.
80       '<BR>'. joblisting({'svcnum'=>$svcnum}, 1).
81       '</BODY></HTML>'
82 ;
83
84 %>