customer quotations are work orders? RT#25561
[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
44 % ###
45 % # Basics
46 % ###
47
48 % if ( $view eq 'basics' || $view eq 'jumbo' ) {
49
50 % if ( $curuser->access_right('Edit customer') ) { 
51   <A HREF="<% $p %>edit/cust_main.cgi?<% $custnum %>"><% mt('Edit this customer') |h %></A> | 
52 % } 
53
54 % if ( $curuser->access_right('Suspend customer')
55 %        && scalar($cust_main->unsuspended_pkgs)
56 %      ) {
57   <& /elements/popup_link-cust_main.html,
58               { 'action'      => $p. 'misc/suspend_cust.html',
59                 'label'       => emt('Suspend this customer'),
60                 'actionlabel' => emt('Confirm Suspension'),
61                 'color'       => '#ff9900',
62                 'cust_main'   => $cust_main,
63                 'width'       => 616, #make room for reasons
64                 'height'      => 366,
65               }
66   &> | 
67 % }
68
69 % if ( $curuser->access_right('Unsuspend customer')
70 %        && scalar($cust_main->suspended_pkgs)
71 %      ) {
72   <& /elements/popup_link-cust_main.html,
73               { 'action'      => $p. 'misc/unsuspend_cust.html',
74                 'label'       => emt('Unsuspend this customer'),
75                 'actionlabel' => emt('Confirm Unsuspension'),
76                 #'color'       => '#ff9900',
77                 'cust_main'   => $cust_main,
78                 #'width'       => 616, #make room for reasons
79                 #'height'      => 366,
80               }
81   &> | 
82 % }
83
84 % if ( $curuser->access_right('Cancel customer')
85 %        && scalar($cust_main->ncancelled_pkgs)
86 %      ) {
87   <& /elements/popup_link-cust_main.html,
88               { 'action'      => $p. 'misc/cancel_cust.html',
89                 'label'       => emt('Cancel this customer'),
90                 'actionlabel' => emt('Confirm Cancellation'),
91                 'color'       => '#ff0000',
92                 'cust_main'   => $cust_main,
93                 'width'       => 616, #make room for reasons
94                 'height'      => 366,
95               }
96   &> | 
97 % }
98
99 % if (     $curuser->access_right('Merge customer')
100 %      and (    scalar($cust_main->ncancelled_pkgs)
101 %            || $conf->exists('deletecustomers')
102 %          )
103 %    )
104 % {
105   <& /elements/popup_link-cust_main.html,
106               { 'action'      => $p. 'misc/merge_cust.html',
107                 'label'       => emt('Merge this customer'),
108                 'actionlabel' => emt('Merge customer'),
109                 'cust_main'   => $cust_main,
110                 'width'       => 569,
111                 'height'      => 210,
112               }
113   &> | 
114 % } 
115
116 % if ( $conf->exists('deletecustomers')
117 %        && $curuser->access_right('Delete customer')
118 %      ) {
119   <A HREF="<% $p %>misc/delete-customer.cgi?<% $custnum%>"><% mt('Delete this customer') |h %></A> | 
120 % } 
121
122 % unless ( $conf->exists('disable_customer_referrals') ) { 
123   <A HREF="<% $p %>edit/cust_main.cgi?referral_custnum=<% $custnum %>"><% mt('Refer a new customer') |h %></A> | 
124   <A HREF="<% $p %>search/cust_main.cgi?referral_custnum=<% $custnum %>"><% mt('View this customer\'s referrals') |h %></A>
125 % } 
126
127 <BR><BR>
128
129 % my $br = 0;
130 % if (    $curuser->access_right('Billing event reports') 
131 %      || $curuser->access_right('View customer billing events')
132 %    ) {
133 % $br=1;
134   <A HREF="<% $p %>search/cust_event.html?custnum=<% $custnum %>"><% mt('View billing events for this customer') |h %></A>
135 % }
136
137 % my $email_link = ($cust_main->invoicing_list_emailonly) && 
138 %   include('/elements/email-link.html',
139 %            'table'               => 'cust_main', 
140 %            'search_hash'         => { 'custnum' => $custnum },
141 %            'agent_virt_agentnum' => $cust_main->agentnum,
142 %            'label'               => 'Email a notice to this customer',
143 % );
144 % if ( $email_link and $br ) {
145  | 
146 % }
147 <% $email_link || '' %>
148
149 % if ( $curuser->access_right('Order customer package') && $conf->exists('cust_main-enable_order_package') ) {
150   | <& /elements/order_pkg_link.html, 'cust_main'=>$cust_main &>
151 % }
152
153 % if ( $conf->config('cust_main-external_links') ) {
154     <% $br++ ? ' | ' : '' %>
155 %   my @links = split(/\n/, $conf->config('cust_main-external_links'));
156 %   foreach my $link (@links) {
157 %     $link =~ /^\s*(\S+)\s+(.*?)(\s*\(([^\)]*)\))?$/ or next;
158 %     my($url, $label, $alt) = ($1, $2, $4);
159       <A HREF="<% $url.$custnum %>" ALT="<% $alt |h %>"><% $label |h %></A>
160 %   }
161 % }
162
163 % if ( $br ) {
164   <BR><BR>
165 % }
166
167 %my $signupurl = $conf->config('signupurl');
168 %if ( $signupurl ) {
169   <% mt('This customer\'s signup URL:') |h %>
170   <A HREF="<% $signupurl %>?ref=<% $custnum %>"><% $signupurl %>?ref=<% $custnum %></A>
171   <BR><BR>
172 % } 
173
174 <A NAME="cust_main"></A>
175 <TABLE BORDER=0>
176 <TR>
177   <TD VALIGN="top">
178     <& cust_main/contacts.html, $cust_main &>
179   </TD>
180   <TD VALIGN="top" STYLE="padding-left: 54px">
181     <& cust_main/misc.html, $cust_main &>
182 % if ( $conf->config('payby-default') ne 'HIDE' ) { 
183       <BR><& cust_main/billing.html, $cust_main &>
184 % } 
185
186   </TD>
187 </TR>
188 <TR>
189   <TD COLSPAN = 2>
190     <& cust_main/contacts_new.html, $cust_main &>
191   </TD>
192 </TR>
193 </TABLE>
194
195 % }
196
197
198 % ###
199 % # Notes
200 % ###
201
202 % if ( $view eq 'notes' || $view eq 'jumbo' ) {
203
204 <& cust_main/notes.html, 'cust_main' => $cust_main &>
205
206 % }
207
208 % if ( $view eq 'jumbo' ) {
209     <BR>
210 % }
211
212 <BR>
213
214
215 % ###
216 % # Tickets
217 % ###
218
219 % if ( $view eq 'tickets' || $view eq 'jumbo' ) {
220
221 % if ( $conf->config('ticket_system') ) { 
222   <& cust_main/tickets.html, $cust_main &>
223 % } 
224   <BR><BR>
225
226 % }
227
228 % ###
229 % # Appointments
230 % ###
231
232 % if ( $view eq 'appointments' || $view eq 'jumbo' ) {
233
234 % if ( $conf->config('ticket_system')
235 %        && $curuser->access_right('View appointments') ) { 
236   <& cust_main/appointments.html, $cust_main &>
237 % } 
238   <BR><BR>
239
240 % }
241
242
243 % ###
244 % # Quotations
245 % ###
246
247 % if ( $view eq 'jumbo' && $curuser->access_right('Generate quotation') ) { 
248   <A NAME="quotation"><FONT SIZE="+2"><% mt('Quotations') |h %></FONT></A><BR>
249 % }
250
251 % if ( $view eq 'quotations' || $view eq 'jumbo' ) {
252
253 %   if ( $curuser->access_right('Generate quotation') ) { 
254       <& cust_main/quotations.html, $cust_main &>
255 %   }
256
257 % }
258
259
260 % ###
261 % # Packages
262 % ###
263
264 % if ( $view eq 'jumbo' ) { #XXX enable me && $curuser->access_right('View customer packages') { 
265
266   <A NAME="cust_pkg"><FONT SIZE="+2"><% mt('Packages') |h %></FONT></A><BR>
267 % }
268
269 % if ( $view eq 'packages' || $view eq 'jumbo' ) {
270
271 % #XXX enable me# if ( $curuser->access_right('View customer packages') { 
272 <& cust_main/packages.html, $cust_main &>
273 % #}
274
275 % }
276
277
278 % ###
279 % # Payment History
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
297 % ###
298 % # Change History
299 % ###
300
301 % if ( $view eq 'change_history' ) { #  || $view eq 'jumbo'      
302 <& cust_main/change_history.html, $cust_main &>          
303 % }
304
305 % if ( $view eq 'custom' ) { 
306 %   if ( $conf->config('cust_main-custom_link') ) {
307 <& cust_main/custom.html, $cust_main &>
308 %   } elsif ( $conf->config('cust_main-custom_content') ) {
309       <& cust_main/custom_content.html, $cust_main &>
310 %   #} else {
311 %   #  warn "custom view without cust_main-custom_link or -custom_content?";
312 %   }
313 % }
314
315 </DIV>
316 <& /elements/footer.html &>
317 <%init>
318
319 my $curuser = $FS::CurrentUser::CurrentUser;
320
321 die "access denied"
322   unless $curuser->access_right('View customer');
323
324 my $conf = new FS::Conf;
325
326 my $custnum;
327 if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
328   $custnum = $1;
329 } else {
330   die "No customer specified (bad URL)!" unless $cgi->keywords;
331   my($query) = $cgi->keywords; # needs parens with my, ->keywords returns array
332   $query =~ /^(\d+)$/;
333   $custnum = $1;
334   $cgi->param('custnum', $1);
335 }
336
337 my $cust_main = qsearchs( {
338   'table'     => 'cust_main',
339   'hashref'   => { 'custnum' => $custnum },
340   'extra_sql' => ' AND '. $curuser->agentnums_sql,
341 });
342 die "Customer not found!" unless $cust_main;
343
344 my $title = $cust_main->name;
345 $title = '('. $cust_main->display_custnum. ") $title"
346   if $conf->exists('cust_main-title-display_custnum');
347 $title = mt("Customer:")." ".$title;
348
349 #false laziness w/pref/pref.html and Conf.pm (cust_main-default_view)
350 tie my %views, 'Tie::IxHash',
351        emt('Basics')           => 'basics',
352        emt('Notes')            => 'notes', #notes and files?
353 ;
354 if ( $conf->config('ticket_system') ) {
355   $views{emt('Tickets')}       =  'tickets';
356   $views{emt('Appointments')}  =  'appointments'
357     if $curuser->access_right('View appointments');
358 }
359 $views{emt('Quotations')}      =  'quotations';
360 $views{emt('Packages')}        =  'packages';
361 $views{emt('Payment History')} =  'payment_history'
362                                unless $conf->config('payby-default' eq 'HIDE');
363 $views{emt('Change History')}  =  'change_history'
364   if $curuser->access_right('View customer history');
365 $views{$conf->config('cust_main-custom_title') || emt('Custom')} =  'custom'
366   if $conf->config('cust_main-custom_link')
367   || $conf->config('cust_main-custom_content');
368 $views{emt('Jumbo')}           =  'jumbo';
369
370 my %viewname = reverse %views;
371
372 my $view =  $cgi->param('show') || $curuser->default_customer_view;
373
374 my $ie_compat = $conf->config('ie-compatibility_mode');
375 my $head = '';
376 if ( $ie_compat ) {
377   $head = qq(<meta http-equiv="X-UA-Compatible" content="IE=$ie_compat" />);
378 }
379
380 </%init>