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