C is for Cookie^WControl
[freeside.git] / httemplate / view / cust_main.cgi
1 <% include("/elements/header.html","Customer View: ". $cust_main->name ) %>
2
3 % if ( $curuser->access_right('Edit customer') ) { 
4   <A HREF="<% $p %>edit/cust_main.cgi?<% $custnum %>">Edit this customer</A> | 
5 % } 
6
7 <SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/overlibmws.js"></SCRIPT>
8 <SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/overlibmws_iframe.js"></SCRIPT>
9 <SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/overlibmws_draggable.js"></SCRIPT>
10 <SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/iframecontentmws.js"></SCRIPT>
11
12 <SCRIPT TYPE="text/javascript">
13 function areyousure(href, message) {
14   if (confirm(message) == true)
15     window.location.href = href;
16 }
17 </SCRIPT>
18
19 <SCRIPT TYPE="text/javascript">
20 %
21 %my $ban = '';
22 %if ( $cust_main->payby =~ /^(CARD|DCRD|CHEK|DCHK)$/ ) {
23 %  $ban = '<BR><P ALIGN="center">'.
24 %         '<INPUT TYPE="checkbox" NAME="ban" VALUE="1"> Ban this customer\\\'s ';
25 %  if ( $cust_main->payby =~ /^(CARD|DCRD)$/ ) {
26 %    $ban .= 'credit card';
27 %  } elsif (  $cust_main->payby =~ /^(CHEK|DCHK)$/ ) {
28 %    $ban .= 'ACH account';
29 %  }
30 %}
31 %
32
33
34 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> ';
35
36 </SCRIPT>
37 % if ( $curuser->access_right('Cancel customer')
38 %        && $cust_main->ncancelled_pkgs
39 %      ) {
40 %
41
42   <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> | 
43 % } 
44 % if ( $conf->exists('deletecustomers')
45 %        && $curuser->access_right('Delete customer')
46 %      ) {
47 %
48
49   <A HREF="<% $p %>misc/delete-customer.cgi?<% $custnum%>">Delete this customer</A> | 
50 % } 
51 % unless ( $conf->exists('disable_customer_referrals') ) { 
52
53   <A HREF="<% popurl(2) %>edit/cust_main.cgi?referral_custnum=<% $custnum %>">Refer a new customer</A> | 
54   <A HREF="<% popurl(2) %>search/cust_main.cgi?referral_custnum=<% $custnum %>">View this customer's referrals</A>
55 % } 
56
57
58
59 <BR><BR>
60 %
61 %my $signupurl = $conf->config('signupurl');
62 %if ( $signupurl ) {
63 %
64
65   This customer's signup URL: <A HREF="<% $signupurl %>?ref=<% $custnum %>"><% $signupurl %>?ref=<% $custnum %></A><BR><BR>
66 % } 
67
68
69 <A NAME="cust_main"></A>
70 <TABLE BORDER=0>
71 <TR>
72   <TD VALIGN="top">
73     <% include('cust_main/contacts.html', $cust_main ) %>
74   </TD>
75   <TD VALIGN="top" STYLE="padding-left: 54px">
76     <% include('cust_main/misc.html', $cust_main ) %>
77 % if ( $conf->config('payby-default') ne 'HIDE' ) { 
78
79       <BR>
80       <% include('cust_main/billing.html', $cust_main ) %>
81 % } 
82
83   </TD>
84 </TR>
85 </TABLE>
86 %
87 %if ( $cust_main->comments =~ /[^\s\n\r]/ ) {
88 %
89
90 <BR>
91 Comments
92 <% ntable("#cccccc") %><TR><TD><% ntable("#cccccc",2) %>
93 <TR>
94   <TD BGCOLOR="#ffffff">
95     <PRE><% encode_entities($cust_main->comments) %></PRE>
96   </TD>
97 </TR>
98 </TABLE></TABLE>
99 % } 
100 <BR><BR>
101 % my $notecount = scalar($cust_main->notes());
102 % if ( ! $conf->exists('cust_main-disable_notes') || $notecount) {
103
104 <A NAME="cust_main_note"><FONT SIZE="+2">Notes</FONT></A><BR>
105 %   if ( $curuser->access_right('Add customer note') &&
106 %        ! $conf->exists('cust_main-disable_notes')
107 %      ) {
108
109   <A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('<% $p %>edit/cust_main_note.cgi?custnum=<% $cust_main->custnum %>', 616, 386, 'cust_main_note_popup' ), CAPTION, 'Enter customer note', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK); return false;">Add customer note</A>
110
111 %   }
112
113 <BR>
114
115 %   if ($notecount) {
116
117 <iframe src="<% $p %>view/cust_main/notes.html?custnum=<% $cust_main->custnum %>" height="186" width="616" name="cust_main_notes" frameborder="0" marginborder="0" marginheight="0" scrolling="auto">
118   <div><br>[iframe not supported]<br><br></div>
119 </iframe>
120
121 %   }else{ # make firefox happy wrt POSTDATA
122
123 <iframe src="<% $p %>view/cust_main/notes.html?custnum=<% $cust_main->custnum %>" height="24" width="616" name="cust_main_notes" frameborder="0" marginborder="0" marginheight="0" scrolling="auto">
124   <div><br>[iframe not supported]<br><br></div>
125 </iframe>
126
127 %   }
128
129 % }
130
131
132 % if ( $conf->config('ticket_system') ) { 
133
134   <BR><BR>
135   <% include('cust_main/tickets.html', $cust_main ) %>
136 % } 
137
138
139 <BR><BR>
140
141 % #XXX enable me# if ( $curuser->access_right('View customer packages') { 
142 <% include('cust_main/packages.html', $cust_main ) %>
143 % #}
144
145 % if ( $conf->config('payby-default') ne 'HIDE' ) { 
146   <% include('cust_main/payment_history.html', $cust_main ) %>
147 % } 
148
149
150 <% include('/elements/footer.html') %>
151 <%init>
152
153 my $curuser = $FS::CurrentUser::CurrentUser;
154
155 die "access denied"
156   unless $curuser->access_right('View customer');
157
158 my $conf = new FS::Conf;
159
160 die "No customer specified (bad URL)!" unless $cgi->keywords;
161 my($query) = $cgi->keywords; # needs parens with my, ->keywords returns array
162 $query =~ /^(\d+)$/;
163 my $custnum = $1;
164 my $cust_main = qsearchs({
165   'table'     => 'cust_main',
166   'hashref'   => {'custnum'=>$custnum},
167   'extra_sql' => ' AND '. $curuser->agentnums_sql,
168 });
169 die "Customer not found!" unless $cust_main;
170
171 </%init>