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