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