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