a few more fixups for our favorite include(...) from Scott Edwards
[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 <%= include("/elements/header.html","Customer View", 
16         include("/elements/menubar.html",
17   'Main Menu' => $p,
18 )) %>
19
20 <%
21
22 die "No customer specified (bad URL)!" unless $cgi->keywords;
23 my($query) = $cgi->keywords; # needs parens with my, ->keywords returns array
24 $query =~ /^(\d+)$/;
25 my $custnum = $1;
26 my $cust_main = qsearchs('cust_main',{'custnum'=>$custnum});
27 die "Customer not found!" unless $cust_main;
28
29 print qq!<A HREF="${p}edit/cust_main.cgi?$custnum">Edit this customer</A>!;
30
31 %>
32
33 <SCRIPT TYPE="text/javascript" SRC="../elements/overlibmws.js"></SCRIPT>
34 <SCRIPT TYPE="text/javascript" SRC="../elements/overlibmws_iframe.js"></SCRIPT>
35 <SCRIPT TYPE="text/javascript" SRC="../elements/overlibmws_draggable.js"></SCRIPT>
36
37 <SCRIPT TYPE="text/javascript">
38 function areyousure(href, message) {
39   if (confirm(message) == true)
40     window.location.href = href;
41 }
42 </SCRIPT>
43
44 <SCRIPT TYPE="text/javascript">
45
46 <%
47 my $ban = '';
48 if ( $cust_main->payby =~ /^(CARD|DCRD|CHEK|DCHK)$/ ) {
49   $ban = '<BR><P ALIGN="center">'.
50          '<INPUT TYPE="checkbox" NAME="ban" VALUE="1"> Ban this customer\\\'s ';
51   if ( $cust_main->payby =~ /^(CARD|DCRD)$/ ) {
52     $ban .= 'credit card';
53   } elsif (  $cust_main->payby =~ /^(CHEK|DCHK)$/ ) {
54     $ban .= 'ACH account';
55   }
56 }
57 %>
58
59 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>Permanently 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> ';
60
61 </SCRIPT>
62
63 <% if ( $cust_main->ncancelled_pkgs ) { %>
64
65   | <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>
66
67 <% } %>
68
69 <%
70
71 print qq! | <A HREF="${p}misc/delete-customer.cgi?$custnum">!.
72       'Delete this customer</A>'
73   if $conf->exists('deletecustomers');
74
75 unless ( $conf->exists('disable_customer_referrals') ) {
76   print qq! | <A HREF="!, popurl(2),
77         qq!edit/cust_main.cgi?referral_custnum=$custnum">!,
78         qq!Refer a new customer</A>!;
79
80   print qq! | <A HREF="!, popurl(2),
81         qq!search/cust_main.cgi?referral_custnum=$custnum">!,
82         qq!View this customer's referrals</A>!;
83 }
84
85 print '<BR><BR>';
86
87 my $signupurl = $conf->config('signupurl');
88 if ( $signupurl ) {
89 print "This customer's signup URL: ".
90       "<a href=\"$signupurl?ref=$custnum\">$signupurl?ref=$custnum</a><BR><BR>";
91 }
92
93 %>
94
95 <A NAME="cust_main"></A>
96 <TABLE BORDER=0>
97 <TR>
98   <TD VALIGN="top">
99     <%= include('cust_main/contacts.html', $cust_main ) %>
100   </TD>
101   <TD VALIGN="top" STYLE="padding-left: 54px">
102     <%= include('cust_main/misc.html', $cust_main ) %>
103     <% if ( $conf->config('payby-default') ne 'HIDE' ) { %>
104       <BR>
105       <%= include('cust_main/billing.html', $cust_main ) %>
106     <% } %>
107   </TD>
108 </TR>
109 </TABLE>
110
111 <%
112 if ( defined $cust_main->dbdef_table->column('comments')
113      && $cust_main->comments =~ /[^\s\n\r]/              ) {
114 %>
115 <BR>
116 Comments
117 <%= ntable("#cccccc") %><TR><TD><%= ntable("#cccccc",2) %>
118 <TR>
119   <TD BGCOLOR="#ffffff">
120     <PRE><%= encode_entities($cust_main->comments) %></PRE>
121   </TD>
122 </TR>
123 </TABLE></TABLE>
124 <% } %>
125
126 <% if ( $conf->config('ticket_system') ) { %>
127   <BR>
128   <%= include('cust_main/tickets.html', $cust_main ) %>
129 <% } %>
130
131 <BR><BR>
132 <%= include('cust_main/packages.html', $cust_main ) %>
133
134 <% if ( $conf->config('payby-default') ne 'HIDE' ) { %>
135   <%= include('cust_main/payment_history.html', $cust_main ) %>
136 <% } %>
137
138 </BODY></HTML>
139