This commit was generated by cvs2svn to compensate for changes in r11022,
[freeside.git] / httemplate / view / cust_main.cgi
1 <% include('/elements/header.html', {
2              'title' => $title,
3              'head'  => $head,
4              'nobr'  => 1,
5           })
6 %>
7 <BR>
8 % my @part_tag = $cust_main->part_tag;
9 % if ( $conf->config('cust_tag-location') eq 'top' && @part_tag ) {
10 <TABLE STYLE="margin-bottom:8px" CELLSPACING=2>
11 %   foreach my $part_tag ( @part_tag ) {
12 <TR>
13   <TD>
14       <FONT SIZE="+1"
15             <% length($part_tag->tagcolor)
16                  ? 'STYLE="background-color:#'.$part_tag->tagcolor.'"'
17                  : ''
18       %>><% $part_tag->tagname.': '. $part_tag->tagdesc |h %></FONT>
19   </TD>
20 </TR>
21 %   }
22 </TABLE>
23 % }
24
25 <% include('/elements/menubar.html',
26              { 'newstyle' => 1,
27                'selected' => $viewname{$view},
28                'url_base' => $cgi->url. "?custnum=$custnum;show=",
29              },
30              %views,
31           )
32 %>
33 <DIV CLASS="fstabcontainer">
34
35 <% include('/elements/init_overlib.html') %>
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 % if ( $view eq 'basics' || $view eq 'jumbo' ) {
45
46 % if ( $curuser->access_right('Edit customer') ) { 
47   <A HREF="<% $p %>edit/cust_main.cgi?<% $custnum %>">Edit this customer</A> | 
48 % } 
49
50 % if ( $curuser->access_right('Cancel customer')
51 %        && $cust_main->ncancelled_pkgs
52 %      ) {
53
54   <% include( '/elements/popup_link-cust_main.html',
55               { 'action'      => $p. 'misc/cancel_cust.html',
56                 'label'       => 'Cancel&nbsp;this&nbsp;customer',
57                 'actionlabel' => 'Confirm Cancellation',
58                 'color'       => '#ff0000',
59                 'cust_main'   => $cust_main,
60                 'width'       => 616, #make room for reasons
61                 'height'      => 366,
62               }
63             )
64   %> | 
65
66 % }
67
68 % if ( $curuser->access_right('Merge customer') ) {
69
70   <% include( '/elements/popup_link-cust_main.html',
71               { 'action'      => $p. 'misc/merge_cust.html',
72                 'label'       => 'Merge&nbsp;this&nbsp;customer',
73                 'actionlabel' => 'Merge customer',
74                 #'color'       => '#ff0000',
75                 'cust_main'   => $cust_main,
76                 'width'       => 480,
77                 'height'      => 192,
78               }
79             )
80   %> | 
81
82 % } 
83
84 % if ( $conf->exists('deletecustomers')
85 %        && $curuser->access_right('Delete customer')
86 %      ) {
87   <A HREF="<% $p %>misc/delete-customer.cgi?<% $custnum%>">Delete this customer</A> | 
88 % } 
89
90 % unless ( $conf->exists('disable_customer_referrals') ) { 
91   <A HREF="<% $p %>edit/cust_main.cgi?referral_custnum=<% $custnum %>">Refer a new customer</A> | 
92   <A HREF="<% $p %>search/cust_main.cgi?referral_custnum=<% $custnum %>">View this customer's referrals</A>
93 % } 
94
95 <BR><BR>
96
97 % my $br = 0;
98 % if (    $curuser->access_right('Billing event reports') 
99 %      || $curuser->access_right('View customer billing events')
100 %    ) {
101 % $br=1;
102   <A HREF="<% $p %>search/cust_event.html?custnum=<% $custnum %>">View billing events for this customer</A>
103 % }
104
105 % if ( $conf->config('cust_main-external_links') ) {
106     <% $br++ ? ' | ' : '' %>
107 %   my @links = split(/\n/, $conf->config('menu-prepend_links'));
108 %   foreach my $link (@links) {
109 %     $link =~ /^\s*(\S+)\s+(.*?)(\s*\(([^\)]*)\))?$/ or next;
110 %     my($url, $label, $alt) = ($1, $2, $4);
111       <A HREF="<% $url.$custnum %>" ALT="<% $alt |h %>"><% $label |h %></A>
112 %   }
113 % }
114
115 % if ( $br ) {
116   <BR><BR>
117 % }
118 </%doc>
119
120 %my $signupurl = $conf->config('signupurl');
121 %if ( $signupurl ) {
122   This customer's signup URL: <A HREF="<% $signupurl %>?ref=<% $custnum %>"><% $signupurl %>?ref=<% $custnum %></A><BR><BR>
123 % } 
124
125 %if ( $conf->exists('maestro-status_test') ) {
126   <A HREF="<% $p %>misc/maestro-customer_status-test.html?<% $custnum %>">Test maestro status</A><BR><BR>
127 % } 
128
129 <A NAME="cust_main"></A>
130 <TABLE BORDER=0>
131 <TR>
132   <TD VALIGN="top">
133     <% include('cust_main/contacts.html', $cust_main ) %>
134   </TD>
135   <TD VALIGN="top" STYLE="padding-left: 54px">
136     <% include('cust_main/misc.html', $cust_main ) %>
137 % if ( $conf->config('payby-default') ne 'HIDE' ) { 
138
139       <BR>
140       <% include('cust_main/billing.html', $cust_main ) %>
141 % } 
142
143   </TD>
144 </TR>
145 </TABLE>
146
147 % }
148
149 % if ( $view eq 'notes' || $view eq 'jumbo' ) {
150
151 %if ( $cust_main->comments =~ /[^\s\n\r]/ ) {
152 <BR>
153 Comments
154 <% ntable("#cccccc") %><TR><TD><% ntable("#cccccc",2) %>
155 <TR>
156   <TD BGCOLOR="#ffffff">
157     <PRE><% encode_entities($cust_main->comments) %></PRE>
158   </TD>
159 </TR>
160 </TABLE></TABLE>
161 <BR><BR>
162 % }
163 <A NAME="notes">
164 % my $notecount = scalar($cust_main->notes(0));
165 % if ( ! $conf->exists('cust_main-disable_notes') || $notecount) {
166
167 %   unless ( $view eq 'notes' && $cust_main->comments !~ /[^\s\n\r]/ ) {
168       <BR>
169       <A NAME="cust_main_note"><FONT SIZE="+2">Notes</FONT></A><BR>
170 %   }
171
172 %   if ( $curuser->access_right('Add customer note') &&
173 %        ! $conf->exists('cust_main-disable_notes')
174 %      ) {
175
176   <% include( '/elements/popup_link-cust_main.html',
177                 'label'       => 'Add customer note',
178                 'action'      => $p. 'edit/cust_main_note.cgi',
179                 'actionlabel' => 'Enter customer note',
180                 'cust_main'   => $cust_main,
181                 'width'       => 616,
182                 'height'      => 538, #575
183             )
184   %>
185
186 %   }
187
188 <BR>
189
190 <% include('cust_main/notes.html', 'custnum' => $cust_main->custnum ) %>
191
192 % }
193 <BR>
194
195 % if(! $conf->config('disable_cust_attachment') 
196 %  and $curuser->access_right('Add attachment')) {
197 <% include( '/elements/popup_link-cust_main.html',
198               'label'       => 'Attach file',
199               'action'      => $p.'edit/cust_main_attach.cgi',
200               'actionlabel' => 'Upload file',
201               'cust_main'   => $cust_main,
202               'width'       => 480,
203               'height'      => 296,
204           )
205 %>
206 % }
207 % if( $curuser->access_right('View attachments') ) {
208 <% include('cust_main/attachments.html', 'custnum' => $cust_main->custnum ) %>
209 %   if ($cgi->param('show_deleted')) {
210 <A HREF="<% $p.'view/cust_main.cgi?custnum=' . $cust_main->custnum .
211            ($view ? ";show=$view" : '') . '#notes' 
212            %>"><I>(Show active attachments)</I></A>
213 %   }
214 % elsif($curuser->access_right('View deleted attachments')) {
215 <A HREF="<% $p.'view/cust_main.cgi?custnum=' . $cust_main->custnum .
216            ($view ? ";show=$view" : '') . ';show_deleted=1#notes'
217            %>"><I>(Show deleted attachments)</I></A>
218 %   }
219 % }
220 <BR>
221
222 % }
223
224 % if ( $view eq 'jumbo' ) {
225     <BR><BR>
226     <A NAME="tickets"><FONT SIZE="+2">Tickets</FONT></A><BR>
227 % }
228
229 % if ( $view eq 'tickets' || $view eq 'jumbo' ) {
230
231 % if ( $conf->config('ticket_system') ) { 
232   <% include('cust_main/tickets.html', $cust_main ) %>
233 % } 
234   <BR><BR>
235
236 % }
237
238 % if ( $view eq 'jumbo' ) { #XXX enable me && $curuser->access_right('View customer packages') { 
239
240   <A NAME="cust_pkg"><FONT SIZE="+2">Packages</FONT></A><BR>
241 % }
242
243 % if ( $view eq 'packages' || $view eq 'jumbo' ) {
244
245 % #XXX enable me# if ( $curuser->access_right('View customer packages') { 
246 <% include('cust_main/packages.html', $cust_main ) %>
247 % #}
248
249 % }
250
251 % if ( $view eq 'jumbo' ) {
252     <BR><BR>
253     <A NAME="history"><FONT SIZE="+2">Payment History</FONT></A><BR>
254 % }
255
256 % if ( $view eq 'payment_history' || $view eq 'jumbo' ) {
257
258 % if ( $conf->config('payby-default') ne 'HIDE' ) { 
259   <% include('cust_main/payment_history.html', $cust_main ) %>
260 % } 
261
262 % }
263
264 % if ( $view eq 'change_history' ) { #  || $view eq 'jumbo'      
265 <% include('cust_main/change_history.html', $cust_main ) %>      
266 % }
267
268 % if ( $view eq 'custom' ) { 
269 <% include('cust_main/custom.html', $cust_main ) %>
270 % }
271
272 </DIV>
273 <% include('/elements/footer.html') %>
274 <%init>
275
276 my $curuser = $FS::CurrentUser::CurrentUser;
277
278 die "access denied"
279   unless $curuser->access_right('View customer');
280
281 my $conf = new FS::Conf;
282
283 my $custnum;
284 if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
285   $custnum = $1;
286 } else {
287   die "No customer specified (bad URL)!" unless $cgi->keywords;
288   my($query) = $cgi->keywords; # needs parens with my, ->keywords returns array
289   $query =~ /^(\d+)$/;
290   $custnum = $1;
291 }
292
293 my $cust_main = qsearchs( {
294   'table'     => 'cust_main',
295   'hashref'   => { 'custnum' => $custnum },
296   'extra_sql' => ' AND '. $curuser->agentnums_sql,
297 });
298 die "Customer not found!" unless $cust_main;
299
300 my $title = $cust_main->name;
301 $title = '('. $cust_main->display_custnum. ") $title"
302   if $conf->exists('cust_main-title-display_custnum');
303 $title = "Customer: $title";
304
305 #false laziness w/pref/pref.html and Conf.pm (cust_main-default_view)
306 tie my %views, 'Tie::IxHash',
307        'Basics'           => 'basics',
308        'Notes'            => 'notes', #notes and files?
309 ;
310 $views{'Tickets'}         =  'tickets'
311                                if $conf->config('ticket_system');
312 $views{'Packages'}        =  'packages';
313 $views{'Payment History'} =  'payment_history'
314                                unless $conf->config('payby-default' eq 'HIDE');
315 $views{'Change History'}  =  'change_history'
316   if $curuser->access_right('View customer history');
317 $views{$conf->config('cust_main-custom_title') || 'Custom'} =  'custom'
318   if $conf->config('cust_main-custom_link');
319 $views{'Jumbo'}           =  'jumbo';
320
321 my %viewname = reverse %views;
322
323 my $view =  $cgi->param('show') || $curuser->default_customer_view;
324
325 my $ie_compat = $conf->config('ie-compatibility_mode');
326 my $head = '';
327 if ( $ie_compat ) {
328   $head = qq(<meta http-equiv="X-UA-Compatible" content="IE=$ie_compat" />);
329 }
330
331 </%init>