oops, still need areyousure javascript for some sub-bits of the page (package unprovi...
[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
42 <SCRIPT TYPE="text/javascript">
43 function areyousure(href, message) {
44   if (confirm(message) == true)
45     window.location.href = href;
46 }
47 </SCRIPT>
48
49 <SCRIPT TYPE="text/javascript">
50
51 <%
52 my $ban = '';
53 if ( $cust_main->payby =~ /^(CARD|DCRD|CHEK|DCHK)$/ ) {
54   $ban = '<BR><P ALIGN="center">'.
55          '<INPUT TYPE="checkbox" NAME="ban" VALUE="1"> Ban this customer\\\'s ';
56   if ( $cust_main->payby =~ /^(CARD|DCRD)$/ ) {
57     $ban .= 'credit card';
58   } elsif (  $cust_main->payby =~ /^(CHEK|DCHK)$/ ) {
59     $ban .= 'ACH account';
60   }
61 }
62 %>
63
64 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> ';
65
66 </SCRIPT>
67
68 <% if ( $cust_main->ncancelled_pkgs ) { %>
69
70   | <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>
71
72 <% } %>
73
74 <%
75
76 print qq! | <A HREF="${p}misc/delete-customer.cgi?$custnum">!.
77       'Delete this customer</A>'
78   if $conf->exists('deletecustomers');
79
80 unless ( $conf->exists('disable_customer_referrals') ) {
81   print qq! | <A HREF="!, popurl(2),
82         qq!edit/cust_main.cgi?referral_custnum=$custnum">!,
83         qq!Refer a new customer</A>!;
84
85   print qq! | <A HREF="!, popurl(2),
86         qq!search/cust_main.cgi?referral_custnum=$custnum">!,
87         qq!View this customer's referrals</A>!;
88 }
89
90 print '<BR><BR>';
91
92 my $signupurl = $conf->config('signupurl');
93 if ( $signupurl ) {
94 print "This customer's signup URL: ".
95       "<a href=\"$signupurl?ref=$custnum\">$signupurl?ref=$custnum</a><BR><BR>";
96 }
97
98 %>
99
100 <A NAME="cust_main"></A>
101 <%= &itable() %>
102 <TR>
103   <TD VALIGN="top">
104     <%= include('cust_main/contacts.html', $cust_main ) %>
105   </TD>
106   <TD VALIGN="top">
107     <%= include('cust_main/misc.html', $cust_main ) %>
108     <% if ( $conf->config('payby-default') ne 'HIDE' ) { %>
109       <BR>
110       <%= include('cust_main/billing.html', $cust_main ) %>
111     <% } %>
112   </TD>
113 </TR>
114 </TABLE>
115
116 <%
117 if ( defined $cust_main->dbdef_table->column('comments')
118      && $cust_main->comments =~ /[^\s\n\r]/              ) {
119 %>
120 <BR>
121 Comments
122 <%= ntable("#cccccc") %><TR><TD><%= ntable("#cccccc",2) %>
123 <TR>
124   <TD BGCOLOR="#ffffff">
125     <PRE><%= encode_entities($cust_main->comments) %></PRE>
126   </TD>
127 </TR>
128 </TABLE></TABLE>
129 <% } %>
130
131 <% if ( $conf->config('ticket_system') ) { %>
132   <BR>
133   <%= include('cust_main/tickets.html', $cust_main ) %>
134 <% } %>
135
136 <BR><BR>
137 <%= include('cust_main/packages.html', $cust_main ) %>
138
139 <% if ( $conf->config('payby-default') ne 'HIDE' ) { %>
140   <%= include('cust_main/payment_history.html', $cust_main ) %>
141 <% } %>
142
143 </BODY></HTML>
144