componentize conflicting %once subroutines (rt#3250)
[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 % if ( $curuser->access_right('Cancel customer')
20 %        && $cust_main->ncancelled_pkgs
21 %      ) {
22
23   <% include( '/elements/popup_link-cust_main.html',
24               { 'action'      => $p. 'misc/cancel_cust.html',
25                 'label'       => 'Cancel&nbsp;this&nbsp;customer',
26                 'actionlabel' => 'Confirm Cancellation',
27                 'color'       => '#ff0000',
28                 'cust_main'   => $cust_main,
29               }
30             )
31   %> | 
32
33 % } 
34
35 % if ( $conf->exists('deletecustomers')
36 %        && $curuser->access_right('Delete customer')
37 %      ) {
38   <A HREF="<% $p %>misc/delete-customer.cgi?<% $custnum%>">Delete this customer</A> | 
39 % } 
40
41 % unless ( $conf->exists('disable_customer_referrals') ) { 
42   <A HREF="<% $p %>edit/cust_main.cgi?referral_custnum=<% $custnum %>">Refer a new customer</A> | 
43   <A HREF="<% $p %>search/cust_main.cgi?referral_custnum=<% $custnum %>">View this customer's referrals</A>
44 % } 
45
46 <BR><BR>
47
48 % if (    $curuser->access_right('Billing event reports') 
49 %      || $curuser->access_right('View customer billing events')
50 %    ) {
51
52   <A HREF="<% $p %>search/cust_event.html?custnum=<% $custnum %>">View billing events for this customer</A>
53   <BR><BR>
54
55 % }
56
57 %my $signupurl = $conf->config('signupurl');
58 %if ( $signupurl ) {
59   This customer's signup URL: <A HREF="<% $signupurl %>?ref=<% $custnum %>"><% $signupurl %>?ref=<% $custnum %></A><BR><BR>
60 % } 
61
62
63 <A NAME="cust_main"></A>
64 <TABLE BORDER=0>
65 <TR>
66   <TD VALIGN="top">
67     <% include('cust_main/contacts.html', $cust_main ) %>
68   </TD>
69   <TD VALIGN="top" STYLE="padding-left: 54px">
70     <% include('cust_main/misc.html', $cust_main ) %>
71 % if ( $conf->config('payby-default') ne 'HIDE' ) { 
72
73       <BR>
74       <% include('cust_main/billing.html', $cust_main ) %>
75 % } 
76
77   </TD>
78 </TR>
79 </TABLE>
80 %
81 %if ( $cust_main->comments =~ /[^\s\n\r]/ ) {
82 %
83
84 <BR>
85 Comments
86 <% ntable("#cccccc") %><TR><TD><% ntable("#cccccc",2) %>
87 <TR>
88   <TD BGCOLOR="#ffffff">
89     <PRE><% encode_entities($cust_main->comments) %></PRE>
90   </TD>
91 </TR>
92 </TABLE></TABLE>
93 % } 
94 <BR><BR>
95 % my $notecount = scalar($cust_main->notes());
96 % if ( ! $conf->exists('cust_main-disable_notes') || $notecount) {
97
98 <A NAME="cust_main_note"><FONT SIZE="+2">Notes</FONT></A><BR>
99 %   if ( $curuser->access_right('Add customer note') &&
100 %        ! $conf->exists('cust_main-disable_notes')
101 %      ) {
102
103   <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>
104
105 %   }
106
107 <BR>
108
109 %   if ($notecount) {
110
111 <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">
112   <div><br>[iframe not supported]<br><br></div>
113 </iframe>
114
115 %   }else{ # make firefox happy wrt POSTDATA
116
117 <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">
118   <div><br>[iframe not supported]<br><br></div>
119 </iframe>
120
121 %   }
122
123 % }
124
125
126 % if ( $conf->config('ticket_system') ) { 
127
128   <BR><BR>
129   <% include('cust_main/tickets.html', $cust_main ) %>
130 % } 
131
132
133 <BR><BR>
134
135 % #XXX enable me# if ( $curuser->access_right('View customer packages') { 
136 <% include('cust_main/packages.html', $cust_main ) %>
137 % #}
138
139 % if ( $conf->config('payby-default') ne 'HIDE' ) { 
140   <% include('cust_main/payment_history.html', $cust_main ) %>
141 % } 
142
143
144 <% include('/elements/footer.html') %>
145 <%init>
146
147 my $curuser = $FS::CurrentUser::CurrentUser;
148
149 die "access denied"
150   unless $curuser->access_right('View customer');
151
152 my $conf = new FS::Conf;
153
154 die "No customer specified (bad URL)!" unless $cgi->keywords;
155 my($query) = $cgi->keywords; # needs parens with my, ->keywords returns array
156 $query =~ /^(\d+)$/;
157 my $custnum = $1;
158 my $cust_main = qsearchs( {
159   'table'     => 'cust_main',
160   'hashref'   => { 'custnum' => $custnum },
161   'extra_sql' => ' AND '. $curuser->agentnums_sql,
162 });
163 die "Customer not found!" unless $cust_main;
164
165 </%init>