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