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