installers (appointments customer view), RT#16584
[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 ( $conf->config('cust_main-external_links') ) {
139     <% $br++ ? ' | ' : '' %>
140 %   my @links = split(/\n/, $conf->config('cust_main-external_links'));
141 %   foreach my $link (@links) {
142 %     $link =~ /^\s*(\S+)\s+(.*?)(\s*\(([^\)]*)\))?$/ or next;
143 %     my($url, $label, $alt) = ($1, $2, $4);
144       <A HREF="<% $url.$custnum %>" ALT="<% $alt |h %>"><% $label |h %></A>
145 %   }
146 % }
147
148 % if ( $br ) {
149   <BR><BR>
150 % }
151
152 %my $signupurl = $conf->config('signupurl');
153 %if ( $signupurl ) {
154   <% mt('This customer\'s signup URL:') |h %>
155   <A HREF="<% $signupurl %>?ref=<% $custnum %>"><% $signupurl %>?ref=<% $custnum %></A>
156   <BR><BR>
157 % } 
158
159 <A NAME="cust_main"></A>
160 <TABLE BORDER=0>
161 <TR>
162   <TD VALIGN="top">
163     <& cust_main/contacts.html, $cust_main &>
164   </TD>
165   <TD VALIGN="top" STYLE="padding-left: 54px">
166     <& cust_main/misc.html, $cust_main &>
167 % if ( $conf->config('payby-default') ne 'HIDE' ) { 
168       <BR><& cust_main/billing.html, $cust_main &>
169 % } 
170
171   </TD>
172 </TR>
173 <TR>
174   <TD COLSPAN = 2>
175     <& cust_main/contacts_new.html, $cust_main &>
176   </TD>
177 </TR>
178 </TABLE>
179
180 % }
181
182 % if ( $view eq 'notes' || $view eq 'jumbo' ) {
183
184 %if ( $cust_main->comments =~ /[^\s\n\r]/ ) {
185 <BR><% mt('Comments') |h %> 
186 <% ntable("#cccccc") %><TR><TD><% ntable("#cccccc",2) %>
187 <TR>
188   <TD BGCOLOR="#ffffff">
189     <PRE><% encode_entities($cust_main->comments) %></PRE>
190   </TD>
191 </TR>
192 </TABLE></TABLE>
193 <BR><BR>
194 % }
195 <A NAME="notes">
196 % my $notecount = scalar($cust_main->notes(0));
197 % if ( ! $conf->exists('cust_main-disable_notes') || $notecount) {
198
199 %   unless ( $view eq 'notes' && $cust_main->comments !~ /[^\s\n\r]/ ) {
200       <BR>
201       <A NAME="cust_main_note"><FONT SIZE="+2"><% mt('Notes') |h %></FONT></A><BR>
202 %   }
203
204 %   if ( $curuser->access_right('Add customer note') &&
205 %        ! $conf->exists('cust_main-disable_notes')
206 %      ) {
207
208   <& /elements/popup_link-cust_main.html,
209                 'label'       => emt('Add customer note'),
210                 'action'      => $p. 'edit/cust_main_note.cgi',
211                 'actionlabel' => emt('Enter customer note'),
212                 'cust_main'   => $cust_main,
213                 'width'       => 616,
214                 'height'      => 538, #575
215   &>
216
217 %   }
218
219 <BR>
220
221 <& cust_main/notes.html, 'custnum' => $cust_main->custnum &>
222
223 % }
224 <BR>
225
226 % if(! $conf->config('disable_cust_attachment') 
227 %  and $curuser->access_right('Add attachment')) {
228 <& /elements/popup_link-cust_main.html,
229               'label'       => emt('Attach file'),
230               'action'      => $p.'edit/cust_main_attach.cgi',
231               'actionlabel' => emt('Upload file'),
232               'cust_main'   => $cust_main,
233               'width'       => 480,
234               'height'      => 296,
235 &>
236 % }
237 % if( $curuser->access_right('View attachments') ) {
238 <& cust_main/attachments.html, 'custnum' => $cust_main->custnum &>
239 %   if ($cgi->param('show_deleted')) {
240 <A HREF="<% $p.'view/cust_main.cgi?custnum=' . $cust_main->custnum .
241            ($view ? ";show=$view" : '') . '#notes' 
242            %>"><I>(<% mt('Show active attachments') |h %>)</I></A>
243 %   }
244 % elsif($curuser->access_right('View deleted attachments')) {
245 <A HREF="<% $p.'view/cust_main.cgi?custnum=' . $cust_main->custnum .
246            ($view ? ";show=$view" : '') . ';show_deleted=1#notes'
247            %>"><I>(<% mt('Show deleted attachments') |h %>)</I></A>
248 %   }
249 % }
250 <BR>
251
252 % }
253
254 % if ( $view eq 'jumbo' ) {
255     <BR>
256 % }
257 <BR>
258
259 % if ( $view eq 'tickets' || $view eq 'jumbo' ) {
260
261 % if ( $conf->config('ticket_system') ) { 
262   <& cust_main/tickets.html, $cust_main &>
263 % } 
264   <BR><BR>
265
266 % }
267
268 % if ( $view eq 'appointments' || $view eq 'jumbo' ) {
269
270 % if ( $conf->config('ticket_system')
271 %        && $curuser->access_right('View appointments') ) { 
272   <& cust_main/appointments.html, $cust_main &>
273 % } 
274   <BR><BR>
275
276 % }
277
278 % if ( $view eq 'jumbo' ) { #XXX enable me && $curuser->access_right('View customer packages') { 
279
280   <A NAME="cust_pkg"><FONT SIZE="+2"><% mt('Packages') |h %></FONT></A><BR>
281 % }
282
283 % if ( $view eq 'packages' || $view eq 'jumbo' ) {
284
285 % #XXX enable me# if ( $curuser->access_right('View customer packages') { 
286 <& cust_main/packages.html, $cust_main &>
287 % #}
288
289 % }
290
291 % if ( $view eq 'jumbo' ) {
292     <BR><BR>
293     <A NAME="history"><FONT SIZE="+2"><% mt('Payment History') |h %></FONT></A>
294     <BR>
295 % }
296
297 % if ( $view eq 'payment_history' || $view eq 'jumbo' ) {
298
299 % if ( $conf->config('payby-default') ne 'HIDE' ) { 
300   <& cust_main/payment_history.html, $cust_main &>
301 % } 
302
303 % }
304
305 % if ( $view eq 'change_history' ) { #  || $view eq 'jumbo'      
306 <& cust_main/change_history.html, $cust_main &>          
307 % }
308
309 % if ( $view eq 'custom' ) { 
310 %   if ( $conf->config('cust_main-custom_link') ) {
311 <& cust_main/custom.html, $cust_main &>
312 %   } elsif ( $conf->config('cust_main-custom_content') ) {
313       <& cust_main/custom_content.html, $cust_main &>
314 %   #} else {
315 %   #  warn "custom view without cust_main-custom_link or -custom_content?";
316 %   }
317 % }
318
319 </DIV>
320 <& /elements/footer.html &>
321 <%init>
322
323 my $curuser = $FS::CurrentUser::CurrentUser;
324
325 die "access denied"
326   unless $curuser->access_right('View customer');
327
328 my $conf = new FS::Conf;
329
330 my $custnum;
331 if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
332   $custnum = $1;
333 } else {
334   die "No customer specified (bad URL)!" unless $cgi->keywords;
335   my($query) = $cgi->keywords; # needs parens with my, ->keywords returns array
336   $query =~ /^(\d+)$/;
337   $custnum = $1;
338 }
339
340 my $cust_main = qsearchs( {
341   'table'     => 'cust_main',
342   'hashref'   => { 'custnum' => $custnum },
343   'extra_sql' => ' AND '. $curuser->agentnums_sql,
344 });
345 die "Customer not found!" unless $cust_main;
346
347 my $title = $cust_main->name;
348 $title = '('. $cust_main->display_custnum. ") $title"
349   if $conf->exists('cust_main-title-display_custnum');
350 $title = mt("Customer:")." ".$title;
351
352 #false laziness w/pref/pref.html and Conf.pm (cust_main-default_view)
353 tie my %views, 'Tie::IxHash',
354        emt('Basics')           => 'basics',
355        emt('Notes')            => 'notes', #notes and files?
356 ;
357 if ( $conf->config('ticket_system') ) {
358   $views{emt('Tickets')}       =  'tickets';
359   $views{emt('Appointments')}  =  'appointments'
360     if $curuser->access_right('View appointments');
361 }
362 $views{emt('Packages')}        =  'packages';
363 $views{emt('Payment History')} =  'payment_history'
364                                unless $conf->config('payby-default' eq 'HIDE');
365 $views{emt('Change History')}  =  'change_history'
366   if $curuser->access_right('View customer history');
367 $views{$conf->config('cust_main-custom_title') || emt('Custom')} =  'custom'
368   if $conf->config('cust_main-custom_link')
369   || $conf->config('cust_main-custom_content');
370 $views{emt('Jumbo')}           =  'jumbo';
371
372 my %viewname = reverse %views;
373
374 my $view =  $cgi->param('show') || $curuser->default_customer_view;
375
376 my $ie_compat = $conf->config('ie-compatibility_mode');
377 my $head = '';
378 if ( $ie_compat ) {
379   $head = qq(<meta http-equiv="X-UA-Compatible" content="IE=$ie_compat" />);
380 }
381
382 </%init>