compatible with mason 1.1! closes: bug#492
[freeside.git] / httemplate / view / cust_main.cgi
index 9b7b5d0..2dc53e6 100755 (executable)
@@ -22,10 +22,23 @@ my $custnum = $1;
 my $cust_main = qsearchs('cust_main',{'custnum'=>$custnum});
 die "Customer not found!" unless $cust_main;
 
-print qq!<A HREF="!, popurl(2), 
-      qq!edit/cust_main.cgi?$custnum">Edit this customer</A>!;
-print qq! | <A HREF="!, popurl(2), 
-      qq!misc/delete-customer.cgi?$custnum"> Delete this customer</A>!
+print qq!<A HREF="${p}edit/cust_main.cgi?$custnum">Edit this customer</A>!;
+
+print <<END;
+<SCRIPT>
+function cancel_areyousure(href) {
+    if (confirm("Perminantly delete all services and cancel this customer?") == true)
+        window.location.href = href;
+}
+</SCRIPT>
+END
+
+print qq! | <A HREF="javascript:cancel_areyousure('${p}misc/cust_main-cancel.cgi?$custnum')">!.
+      'Cancel this customer</A>'
+  if $cust_main->ncancelled_pkgs;
+
+print qq! | <A HREF="${p}misc/delete-customer.cgi?$custnum">!.
+      'Delete this customer</A>'
   if $conf->exists('deletecustomers');
 
 unless ( $conf->exists('disable_customer_referrals') ) {
@@ -210,10 +223,12 @@ if ( $conf->config('payby-default') ne 'HIDE' ) {
         '<TR><TD ALIGN="right">Billing type</TD><TD BGCOLOR="#ffffff">',
   ;
 
-  if ( $cust_main->payby eq 'CARD' ) {
+  if ( $cust_main->payby eq 'CARD' && $cust_main->payby eq 'DCRD' ) {
     my $payinfo = $cust_main->payinfo;
     $payinfo = 'x'x(length($payinfo)-4). substr($payinfo,(length($payinfo)-4));
-    print 'Credit card</TD></TR>',
+    print 'Credit card ',
+          ( $cust_main->payby eq 'CARD' ? '(automatic)' : '(on-demand)' ),
+          '</TD></TR>',
           '<TR><TD ALIGN="right">Card number</TD><TD BGCOLOR="#ffffff">',
           $payinfo, '</TD></TR>',
           '<TR><TD ALIGN="right">Expiration</TD><TD BGCOLOR="#ffffff">',
@@ -221,9 +236,11 @@ if ( $conf->config('payby-default') ne 'HIDE' ) {
           '<TR><TD ALIGN="right">Name on card</TD><TD BGCOLOR="#ffffff">',
           $cust_main->payname, '</TD></TR>'
     ;
-  } elsif ( $cust_main->payby eq 'CHEK' ) {
+  } elsif ( $cust_main->payby eq 'CHEK'  && $cust_main->payby eq 'DCHK') {
     my( $account, $aba ) = split('@', $cust_main->payinfo );
-    print 'Electronic check</TD></TR>',
+    print 'Electronic check',
+          ( $cust_main->payby eq 'CHEK' ? '(automatic)' : '(on-demand)' ),
+          '</TD></TR>',
           '<TR><TD ALIGN="right">Account number</TD><TD BGCOLOR="#ffffff">',
           $account, '</TD></TR>',
           '<TR><TD ALIGN="right">ABA/Routing code</TD><TD BGCOLOR="#ffffff">',
@@ -352,8 +369,11 @@ if ( $conf->exists('hidecancelledpackages') ) {
 
 if ( @packages ) {
   #formatting
+
+  my $colspan = $packages[0]->dbdef_table->column('last_bill') ? 6 : 5;
+  
   print &table(), "\n",
-        qq!<TR><TH COLSPAN=2 ROWSPAN=2>Package</TH><TH COLSPAN=5>!,
+        qq!<TR><TH COLSPAN=2 ROWSPAN=2>Package</TH><TH COLSPAN=$colspan>!,
         qq!Dates</TH><TH COLSPAN=2 ROWSPAN=2>Services</TH></TR>\n<TR>!,
         qq!<TH><FONT SIZE=-1>Setup</FONT></TH>!;
 
@@ -362,7 +382,7 @@ if ( @packages ) {
 
   print qq!<TH><FONT SIZE=-1>Next bill</FONT></TH>!,
         qq!<TH><FONT SIZE=-1>Susp.</FONT></TH>!,
-        qq!<TH><FONT SIZE=-1>Expire!</FONT></TH>!,
+        qq!<TH><FONT SIZE=-1>Expire</FONT></TH>!,
         qq!<TH><FONT SIZE=-1>Cancel</FONT></TH>!,
         qq!</TR>\n!;
 }