add banned credit card / ACH table, re-do cancel popup to have a checkbox to ban...
[freeside.git] / httemplate / view / cust_main.cgi
1 <!-- mason kludge -->
2 <%
3
4 my $conf = new FS::Conf;
5
6 my %uiview = ();
7 my %uiadd = ();
8 foreach my $part_svc ( qsearch('part_svc',{}) ) {
9   $uiview{$part_svc->svcpart} = $p. "view/". $part_svc->svcdb . ".cgi";
10   $uiadd{$part_svc->svcpart}= $p. "edit/". $part_svc->svcdb . ".cgi";
11 }
12
13 %>
14
15 <%= header("Customer View", menubar(
16   'Main Menu' => $p,
17 )) %>
18
19 <STYLE TYPE="text/css">
20 .package TH { font-size: medium }
21 .package TR { font-size: smaller }
22 .package .provision { font-weight: bold }
23 </STYLE>
24
25 <%
26
27 die "No customer specified (bad URL)!" unless $cgi->keywords;
28 my($query) = $cgi->keywords; # needs parens with my, ->keywords returns array
29 $query =~ /^(\d+)$/;
30 my $custnum = $1;
31 my $cust_main = qsearchs('cust_main',{'custnum'=>$custnum});
32 die "Customer not found!" unless $cust_main;
33
34 print qq!<A HREF="${p}edit/cust_main.cgi?$custnum">Edit this customer</A>!;
35
36 %>
37
38 <SCRIPT TYPE="text/javascript" SRC="../elements/overlibmws.js"></SCRIPT>
39 <SCRIPT TYPE="text/javascript" SRC="../elements/overlibmws_iframe.js"></SCRIPT>
40 <SCRIPT TYPE="text/javascript" SRC="../elements/overlibmws_draggable.js"></SCRIPT>
41 <SCRIPT TYPE="text/javascript">
42
43 <%
44 my $ban = '';
45 if ( $cust_main->payby =~ /^(CARD|DCRD|CHEK|DCHK)$/ ) {
46   $ban = '<BR><P ALIGN="center">'.
47          '<INPUT TYPE="checkbox" NAME="ban" VALUE="1"> Ban this customer\\\'s ';
48   if ( $cust_main->payby =~ /^(CARD|DCRD)$/ ) {
49     $ban .= 'credit card';
50   } elsif (  $cust_main->payby =~ /^(CHEK|DCHK)$/ ) {
51     $ban .= 'ACH account';
52   }
53 }
54 %>
55
56 var confirm_cancel = '<FORM METHOD="POST" ACTION="<%= $p %>misc/cust_main-cancel.cgi"> <INPUT TYPE="hidden" NAME="custnum" VALUE="<%= $custnum %>"> <BR><P ALIGN="center"><B>Perminantly delete all services and cancel this customer?</B> <%= $ban%><BR><P ALIGN="CENTER"> <INPUT TYPE="submit" VALUE="Cancel customer">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<INPUT TYPE="BUTTON" VALUE="Don\'t cancel" onClick="cClick()"> </FORM> ';
57
58 </SCRIPT>
59
60 <% if ( $cust_main->ncancelled_pkgs ) { %>
61
62   | <A HREF="javascript:void(0);" onClick="overlib(confirm_cancel, CAPTION, 'Confirm cancellation', STICKY, AUTOSTATUSCAP, CLOSETEXT, '', MIDX, 0, MIDY, 0, DRAGGABLE, WIDTH, 576, HEIGHT, 128, TEXTSIZE, 3, BGCOLOR, '#ff0000', CGCOLOR, '#ff0000' ); return false; ">Cancel this customer</A>
63
64 <% } %>
65
66 <%
67
68 print qq! | <A HREF="${p}misc/delete-customer.cgi?$custnum">!.
69       'Delete this customer</A>'
70   if $conf->exists('deletecustomers');
71
72 unless ( $conf->exists('disable_customer_referrals') ) {
73   print qq! | <A HREF="!, popurl(2),
74         qq!edit/cust_main.cgi?referral_custnum=$custnum">!,
75         qq!Refer a new customer</A>!;
76
77   print qq! | <A HREF="!, popurl(2),
78         qq!search/cust_main.cgi?referral_custnum=$custnum">!,
79         qq!View this customer's referrals</A>!;
80 }
81
82 print '<BR><BR>';
83
84 my $signupurl = $conf->config('signupurl');
85 if ( $signupurl ) {
86 print "This customer's signup URL: ".
87       "<a href=\"$signupurl?ref=$custnum\">$signupurl?ref=$custnum</a><BR><BR>";
88 }
89
90 %>
91
92 <A NAME="cust_main"></A>
93 <%= &itable() %>
94 <TR>
95   <TD VALIGN="top">
96     <%= include('cust_main/contacts.html', $cust_main ) %>
97   </TD>
98   <TD VALIGN="top">
99     <%= include('cust_main/misc.html', $cust_main ) %>
100     <% if ( $conf->config('payby-default') ne 'HIDE' ) { %>
101       <BR>
102       <%= include('cust_main/billing.html', $cust_main ) %>
103     <% } %>
104   </TD>
105 </TR>
106 </TABLE>
107
108 <%
109 if ( defined $cust_main->dbdef_table->column('comments')
110      && $cust_main->comments =~ /[^\s\n\r]/              ) {
111 %>
112 <BR>
113 Comments
114 <%= ntable("#cccccc") %><TR><TD><%= ntable("#cccccc",2) %>
115 <TR>
116   <TD BGCOLOR="#ffffff">
117     <PRE><%= encode_entities($cust_main->comments) %></PRE>
118   </TD>
119 </TR>
120 </TABLE></TABLE>
121 <% } %>
122
123 <% if ( $conf->config('ticket_system') ) { %>
124   <BR>
125   <%= include('cust_main/tickets.html', $cust_main ) %>
126 <% } %>
127
128 <BR><BR>
129 <%= include('cust_main/packages.html', $cust_main ) %>
130
131 <% if ( $conf->config('payby-default') ne 'HIDE' ) { %>
132   <%= include('cust_main/payment_history.html', $cust_main ) %>
133 <% } %>
134
135 </BODY></HTML>
136