6f2bb80bc9e8b69a6b005f563ed6f5d059adaef6
[freeside.git] / httemplate / view / cust_main.cgi
1 <& /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 <& /elements/menubar.html,
26              { 'newstyle' => 1,
27                'selected' => $viewname{$view},
28                'url_base' => $cgi->url. "?custnum=$custnum;show=",
29              },
30              %views,
31 &>
32 <DIV CLASS="fstabcontainer">
33
34 <& /elements/init_overlib.html &>
35
36 <SCRIPT TYPE="text/javascript">
37 function areyousure(href, message) {
38   if (confirm(message) == true)
39     window.location.href = href;
40 }
41 </SCRIPT>
42
43 % if ( $view eq 'basics' || $view eq 'jumbo' ) {
44
45 % if ( $curuser->access_right('Edit customer') ) { 
46   <A HREF="<% $p %>edit/cust_main.cgi?<% $custnum %>"><% mt('Edit this customer') |h %></A> | 
47 % } 
48
49 % if ( $curuser->access_right('Suspend customer')
50 %        && scalar($cust_main->unsuspended_pkgs)
51 %      ) {
52   <& /elements/popup_link-cust_main.html,
53               { 'action'      => $p. 'misc/suspend_cust.html',
54                 'label'       => emt('Suspend this customer'),
55                 'actionlabel' => emt('Confirm Suspension'),
56                 'color'       => '#ff9900',
57                 'cust_main'   => $cust_main,
58                 'width'       => 616, #make room for reasons
59                 'height'      => 366,
60               }
61   &> | 
62 % }
63
64 % if ( $curuser->access_right('Unsuspend customer')
65 %        && scalar($cust_main->suspended_pkgs)
66 %      ) {
67   <& /elements/popup_link-cust_main.html,
68               { 'action'      => $p. 'misc/unsuspend_cust.html',
69                 'label'       => emt('Unsuspend this customer'),
70                 'actionlabel' => emt('Confirm Unsuspension'),
71                 #'color'       => '#ff9900',
72                 'cust_main'   => $cust_main,
73                 #'width'       => 616, #make room for reasons
74                 #'height'      => 366,
75               }
76   &> | 
77 % }
78
79 % if ( $curuser->access_right('Cancel customer')
80 %        && scalar($cust_main->ncancelled_pkgs)
81 %      ) {
82   <& /elements/popup_link-cust_main.html,
83               { 'action'      => $p. 'misc/cancel_cust.html',
84                 'label'       => emt('Cancel this customer'),
85                 'actionlabel' => emt('Confirm Cancellation'),
86                 'color'       => '#ff0000',
87                 'cust_main'   => $cust_main,
88                 'width'       => 616, #make room for reasons
89                 'height'      => 366,
90               }
91   &> | 
92 % }
93
94 % if (     $curuser->access_right('Merge customer')
95 %      and (    scalar($cust_main->ncancelled_pkgs)
96 %            # || we start supporting payment info merge again in some way
97 %          )
98 %    )
99 % {
100   <& /elements/popup_link-cust_main.html,
101               { 'action'      => $p. 'misc/merge_cust.html',
102                 'label'       => emt('Merge this customer'),
103                 'actionlabel' => emt('Merge customer'),
104                 'cust_main'   => $cust_main,
105                 'width'       => 569,
106                 'height'      => 210,
107               }
108   &> | 
109 % } 
110
111 % unless ( $conf->exists('disable_customer_referrals') ) { 
112   <A HREF="<% $p %>edit/cust_main.cgi?referral_custnum=<% $custnum %>"><% mt('Refer a new customer') |h %></A> | 
113   <A HREF="<% $p %>search/cust_main.cgi?referral_custnum=<% $custnum %>"><% mt('View this customer\'s referrals') |h %></A>
114 % } 
115
116 <BR><BR>
117
118 % my $br = 0;
119 % if (    $curuser->access_right('Billing event reports') 
120 %      || $curuser->access_right('View customer billing events')
121 %    ) {
122 % $br=1;
123   <A HREF="<% $p %>search/cust_event.html?custnum=<% $custnum %>"><% mt('View billing events for this customer') |h %></A>
124 % }
125
126 % my $email_link = ($cust_main->invoicing_list_emailonly) && 
127 %   include('/elements/email-link.html',
128 %            'table'               => 'cust_main', 
129 %            'search_hash'         => { 'custnum' => $custnum },
130 %            'agent_virt_agentnum' => $cust_main->agentnum,
131 %            'label'               => 'Email a notice to this customer',
132 % );
133 % if ( $email_link and $br ) {
134  | 
135 % }
136 <% $email_link || '' %>
137
138 % if ( $curuser->access_right('Order customer package') && $conf->exists('cust_main-enable_order_package') ) {
139   | <& /elements/order_pkg_link.html, 'cust_main'=>$cust_main &>
140 % }
141
142 % if ( $conf->config('cust_main-external_links') ) {
143     <% $br++ ? ' | ' : '' %>
144 %   my @links = split(/\n/, $conf->config('cust_main-external_links'));
145 %   foreach my $link (@links) {
146 %     $link =~ /^\s*(\S+)\s+(.*?)(\s*\(([^\)]*)\))?$/ or next;
147 %     my($url, $label, $alt) = ($1, $2, $4);
148       <A HREF="<% $url.$custnum %>" ALT="<% $alt |h %>"><% $label |h %></A>
149 %   }
150 % }
151
152 % if ( $br ) {
153   <BR><BR>
154 % }
155
156 %my $signupurl = $conf->config('signupurl');
157 %if ( $signupurl ) {
158   <% mt('This customer\'s signup URL:') |h %>
159   <A HREF="<% $signupurl %>?ref=<% $custnum %>"><% $signupurl %>?ref=<% $custnum %></A>
160   <BR><BR>
161 % } 
162
163 <A NAME="cust_main"></A>
164 <TABLE BORDER=0>
165 <TR>
166   <TD VALIGN="top">
167     <& cust_main/contacts.html, $cust_main &>
168   </TD>
169   <TD VALIGN="top" STYLE="padding-left: 54px">
170     <& cust_main/misc.html, $cust_main &>
171 % if ( $conf->config('payby-default') ne 'HIDE' ) { 
172       <BR><& cust_main/billing.html, $cust_main &>
173 % } 
174
175   </TD>
176 </TR>
177 <TR>
178   <TD COLSPAN = 2>
179     <& cust_main/contacts_new.html, $cust_main &>
180   </TD>
181 </TR>
182 </TABLE>
183
184 % }
185
186 % if ( $view eq 'notes' || $view eq 'jumbo' ) {
187
188 %if ( $cust_main->comments =~ /[^\s\n\r]/ ) {
189 <BR><% mt('Comments') |h %> 
190 <% ntable("#cccccc") %><TR><TD><% ntable("#cccccc",2) %>
191 <TR>
192   <TD BGCOLOR="#ffffff">
193     <PRE><% encode_entities($cust_main->comments) %></PRE>
194   </TD>
195 </TR>
196 </TABLE></TABLE>
197 <BR><BR>
198 % }
199 <A NAME="notes">
200 % my $notecount = scalar($cust_main->notes(0));
201 % if ( ! $conf->exists('cust_main-disable_notes') || $notecount) {
202
203 %   unless ( $view eq 'notes' && $cust_main->comments !~ /[^\s\n\r]/ ) {
204       <BR>
205       <A NAME="cust_main_note"><FONT SIZE="+2"><% mt('Notes') |h %></FONT></A><BR>
206 %   }
207
208 %   if ( $curuser->access_right('Add customer note') &&
209 %        ! $conf->exists('cust_main-disable_notes')
210 %      ) {
211
212   <& /elements/popup_link-cust_main.html,
213                 'label'       => emt('Add customer note'),
214                 'action'      => $p. 'edit/cust_main_note.cgi',
215                 'actionlabel' => emt('Enter customer note'),
216                 'cust_main'   => $cust_main,
217                 'width'       => 616,
218                 'height'      => 538, #575
219   &>
220
221 %   }
222
223 <BR>
224
225 <& cust_main/notes.html, 'custnum' => $cust_main->custnum &>
226
227 % }
228 <BR>
229
230 % if(! $conf->config('disable_cust_attachment') 
231 %  and $curuser->access_right('Add attachment')) {
232 <& /elements/popup_link-cust_main.html,
233               'label'       => emt('Attach file'),
234               'action'      => $p.'edit/cust_main_attach.cgi',
235               'actionlabel' => emt('Upload file'),
236               'cust_main'   => $cust_main,
237               'width'       => 480,
238               'height'      => 296,
239 &>
240 % }
241 % if( $curuser->access_right('View attachments') ) {
242 <& cust_main/attachments.html, 'custnum' => $cust_main->custnum &>
243 %   if ($cgi->param('show_deleted')) {
244 <A HREF="<% $p.'view/cust_main.cgi?custnum=' . $cust_main->custnum .
245            ($view ? ";show=$view" : '') . '#notes' 
246            %>"><I>(<% mt('Show active attachments') |h %>)</I></A>
247 %   }
248 % elsif($curuser->access_right('View deleted attachments')) {
249 <A HREF="<% $p.'view/cust_main.cgi?custnum=' . $cust_main->custnum .
250            ($view ? ";show=$view" : '') . ';show_deleted=1#notes'
251            %>"><I>(<% mt('Show deleted attachments') |h %>)</I></A>
252 %   }
253 % }
254 <BR>
255
256 % }
257
258 % if ( $view eq 'jumbo' ) {
259     <BR>
260 % }
261 <BR>
262
263 % if ( $view eq 'tickets' || $view eq 'jumbo' ) {
264
265 % if ( $conf->config('ticket_system') ) { 
266   <& cust_main/tickets.html, $cust_main &>
267 % } 
268   <BR><BR>
269
270 % }
271
272 % if ( $view eq 'appointments' || $view eq 'jumbo' ) {
273
274 % if ( $conf->config('ticket_system')
275 %        && $curuser->access_right('View appointments') ) { 
276   <& cust_main/appointments.html, $cust_main &>
277 % } 
278   <BR><BR>
279
280 % }
281
282 % if ( $view eq 'jumbo' ) { #XXX enable me && $curuser->access_right('View customer packages') { 
283
284   <A NAME="cust_pkg"><FONT SIZE="+2"><% mt('Packages') |h %></FONT></A><BR>
285 % }
286
287 % if ( $view eq 'packages' || $view eq 'jumbo' ) {
288
289 % #XXX enable me# if ( $curuser->access_right('View customer packages') { 
290 <& cust_main/packages.html, $cust_main &>
291 % #}
292
293 % }
294
295 % if ( $view eq 'jumbo' ) {
296     <BR><BR>
297     <A NAME="history"><FONT SIZE="+2"><% mt('Payment History') |h %></FONT></A>
298     <BR>
299 % }
300
301 % if ( $view eq 'payment_history' || $view eq 'jumbo' ) {
302
303 % if ( $conf->config('payby-default') ne 'HIDE' ) { 
304   <& cust_main/payment_history.html, $cust_main &>
305 % } 
306
307 % }
308
309 % if ( $view eq 'change_history' ) { #  || $view eq 'jumbo'      
310 <& cust_main/change_history.html, $cust_main &>          
311 % }
312
313 % if ( $view eq 'custom' ) { 
314 %   if ( $conf->config('cust_main-custom_link') ) {
315 <& cust_main/custom.html, $cust_main &>
316 %   } elsif ( $conf->config('cust_main-custom_content') ) {
317       <& cust_main/custom_content.html, $cust_main &>
318 %   #} else {
319 %   #  warn "custom view without cust_main-custom_link or -custom_content?";
320 %   }
321 % }
322
323 </DIV>
324 <& /elements/footer.html &>
325 <%init>
326
327 my $curuser = $FS::CurrentUser::CurrentUser;
328
329 die "access denied"
330   unless $curuser->access_right('View customer');
331
332 my $conf = new FS::Conf;
333
334 my $custnum;
335 if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
336   $custnum = $1;
337 } else {
338   die "No customer specified (bad URL)!" unless $cgi->keywords;
339   my($query) = $cgi->keywords; # needs parens with my, ->keywords returns array
340   $query =~ /^(\d+)$/;
341   $custnum = $1;
342 }
343
344 my $cust_main = qsearchs( {
345   'table'     => 'cust_main',
346   'hashref'   => { 'custnum' => $custnum },
347   'extra_sql' => ' AND '. $curuser->agentnums_sql,
348 });
349 die "Customer not found!" unless $cust_main;
350
351 my $title = $cust_main->name;
352 $title = '('. $cust_main->display_custnum. ") $title"
353   if $conf->exists('cust_main-title-display_custnum');
354 $title = mt("Customer:")." ".$title;
355
356 #false laziness w/pref/pref.html and Conf.pm (cust_main-default_view)
357 tie my %views, 'Tie::IxHash',
358        emt('Basics')           => 'basics',
359        emt('Notes')            => 'notes', #notes and files?
360 ;
361 if ( $conf->config('ticket_system') ) {
362   $views{emt('Tickets')}       =  'tickets';
363   $views{emt('Appointments')}  =  'appointments'
364     if $curuser->access_right('View appointments');
365 }
366 $views{emt('Packages')}        =  'packages';
367 $views{emt('Payment History')} =  'payment_history'
368                                unless $conf->config('payby-default' eq 'HIDE');
369 $views{emt('Change History')}  =  'change_history'
370   if $curuser->access_right('View customer history');
371 $views{$conf->config('cust_main-custom_title') || emt('Custom')} =  'custom'
372   if $conf->config('cust_main-custom_link')
373   || $conf->config('cust_main-custom_content');
374 $views{emt('Jumbo')}           =  'jumbo';
375
376 my %viewname = reverse %views;
377
378 my $view =  $cgi->param('show') || $curuser->default_customer_view;
379
380 my $ie_compat = $conf->config('ie-compatibility_mode');
381 my $head = '';
382 if ( $ie_compat ) {
383   $head = qq(<meta http-equiv="X-UA-Compatible" content="IE=$ie_compat" />);
384 }
385
386 </%init>