Merge branch 'master' of git.freeside.biz:/home/git/freeside
[freeside.git] / httemplate / view / cust_main / menu.html
1 <style type="text/css">
2
3 #customer_menu {
4   margin-top: .6em;
5   margin-bottom: 16px;
6 }
7
8 /* #customer_menu .ui-menu-item  */
9 #customer_menu > li {
10   background-color: #f8f8f8;
11 }
12
13 /* #customer_menu .ui-menu-item  */
14 #customer_menu > li.ui-state-focus {
15   background-color: #f8f8f8;
16 }
17
18 #customer_menu > li.ui-state-active {
19   background-color: #f8f8f8;
20 }
21
22 #customer_menu > li > a {
23   border-top: 1px solid transparent;
24   border-left: 1px solid transparent;
25   border-right: 1px solid transparent;
26   border-bottom: none;
27   padding: .5em .75em;
28 }
29
30 #customer_menu > li.ui-state-active > a {
31
32 /* if i could find something light enough that didn't look pink?
33      or is this too visually distracting and not the useful hint i think it is?
34   background: #ED55E7;
35 */
36 }
37
38 #customer_menu a.current_show {
39   font-weight: bold;
40   background: #FFFFFF;
41   border-top: 1px solid #7e0079;
42   border-left: 1px solid #7e0079;
43   border-right: 1px solid #7e0079;
44   border-bottom: 2px solid #ffffff;
45   margin-bottom: -2px;
46   border-bottom-left-radius: 2px;
47   border-bottom-right-radius: 2px;
48 }
49
50 #customer_menu a {
51   margin-left: 0;
52   margin-right: 1em;
53   margin-top: 0;
54   border-top-left-radius: .5em;
55   border-top-right-radius: .5em;
56
57   font-weight: normal;
58   background: #e0e0e0;
59   color: #525151;
60   text-decoration: none;
61 }
62
63 #customer_menu ul a {
64   background: transparent;
65 }
66
67 </style>
68
69 <& /elements/dropdown-menu.html,
70      'id'        => 'customer_menu',
71      #'class'     => 'customer_submenu',
72                     #XXX support installs outside /freeside in 4.x
73      'self_url'  => "/freeside/view/cust_main.cgi?custnum=$custnum;show=",
74      'menu'      => \@menu,
75      'cust_main' => $cust_main,
76      'show'      => $opt{'show'},
77 &>
78
79 <%init>
80 my %opt = @_;
81 my $cust_main = $opt{'cust_main'};
82 my $custnum = $cust_main->custnum;
83 my $curuser = $FS::CurrentUser::CurrentUser;
84 my $conf = FS::Conf->new;
85
86 my @payby = grep /\w/, $conf->config('payby');
87 @payby = (qw( CARD DCRD CHEK DCHK ))
88   unless @payby;
89 my %payby = map { $_ => 1 } @payby;
90
91 # cached for conditions, to avoid looking it up twice
92 my $invoicing_list_emailonly = $cust_main->invoicing_list_emailonly;
93
94 # nice declarative menu; a parameter to some kind of menu generator
95 my @menu = ( 
96   [
97     { show        => 'basics',
98       label       => 'Basics',
99     },
100     {
101       label       => 'Edit customer',
102       url         => "edit/cust_main.cgi?$custnum",
103       acl         => 'Edit customer'
104     },
105     {
106       label       => 'Edit contacts',
107       url         => "edit/cust_main-contacts.html?$custnum",
108     },
109
110     { label   => '-',
111       content => '-',
112     },
113
114     {
115       label       => 'Bill now',
116       acl         => 'Bill customer now',
117       content     => sub { include( '/elements/bill.html',
118                               label   => emt('Bill now'),
119                               url     => $cgi->self_url,
120                               custnum => shift->custnum,
121                            ),
122                      },
123     },
124     {
125       label       => 'Suspend',
126       popup       => "misc/suspend_cust.html?custnum=$custnum",
127       acl         => 'Suspend customer',
128       condition   => sub { shift->unsuspended_pkgs > 0 },
129       actionlabel => 'Confirm Suspension',
130       color       => '#ff9900',
131     },
132     {
133       label       => 'Unsuspend',
134       popup       => "misc/unsuspend_cust.html?custnum=$custnum",
135       acl         => 'Unsuspend customer',
136       condition   => sub { shift->suspended_pkgs > 0 },
137       actionlabel => 'Confirm Unsuspension',
138     },
139     {
140       label       => 'Cancel',
141       popup       => "misc/cancel_cust.html?custnum=$custnum",
142       acl         => 'Cancel customer',
143       condition   => sub { shift->ncancelled_pkgs > 0 },
144       actionlabel => 'Confirm Cancellation',
145       color       => '#ff0000',
146     },
147     {
148       label       => 'Merge',
149       popup       => "misc/merge_cust.html?custnum=$custnum",
150       acl         => 'Merge customer',
151       actionlabel => 'Merge customer',
152       width       => 569,
153       height      => 210,
154     },
155     {
156       label       => 'Refer a new customer',
157       url         => "edit/cust_main.cgi?referral_custnum=$custnum",
158       confexists  => '!disable_customer_referrals',
159     },
160
161     { label   => '-',
162       content => '-',
163     },
164
165     {
166       label       => 'View this customer\'s referrals',
167       url         => "search/cust_main.cgi?referral_custnum=$custnum",
168       confexists  => '!disable_customer_referrals',
169       condition   => sub {
170         FS::cust_main->count('referral_custnum = ?', shift->custnum) > 0
171       },
172     },
173     {
174       label       => 'View billing events',
175       url         => "search/cust_event.html?custnum=$custnum",
176       acl         => [ 'Billing event reports',
177                        'View customer billing events' ],
178     },
179     {
180       label       => 'Test billing events',
181       url         => "misc/test-part_event.html?custnum=$custnum",
182       acl         => 'Configuration',
183     },
184     {
185       label       => 'Email a notice to this customer',
186       url         => sub {
187                       my $cust_main = shift;
188                       my $agentnum = $cust_main->agentnum;
189                       'misc/email-customers.html?table=cust_main;'.
190                       'agent_virt_agentnum='.$agentnum.";custnum=$custnum;url=".
191                       uri_escape($cgi->self_url);
192                      },
193       condition   => sub { $invoicing_list_emailonly },
194       acl         => 'Bulk send customer notices',
195     },
196   ],
197   [
198     {
199       label => 'Notes',
200       show  => 'notes',
201     },
202     {
203       label       => 'Add note',
204       popup       => "edit/cust_main_note.cgi?custnum=$custnum",
205       actionlabel => 'Add note',
206       confexists  => '!cust_main-disable_notes',
207       acl         => 'Add customer note',
208       width       => 875,
209       height      => 548,
210     },
211     {
212       label       => 'Attach file',
213       popup       => "edit/cust_main_attach.cgi?custnum=$custnum",
214       actionlabel => 'Upload file',
215       confexists  => '!disable_cust_attachment',
216       acl         => 'Add attachment',
217       width       => 480,
218       height      => 296,
219     },
220   ],
221   [
222     {
223       label => 'Tickets',
224       show  => 'tickets',
225       confexists => 'ticket_system'
226     },
227   ],
228   [
229     {
230       label => 'Appointments',
231       show  => 'appointments',
232       confexists => 'ticket_system',
233       acl   => 'View appointments',
234     },
235     {
236       label       => 'Schedule new appointment',
237       confexists  => 'ticket_system',
238       acl        => 'Make appointment',
239       popup       => "misc/make_appointment.html?custnum=$custnum",
240       actionlabel => 'Schedule appointment',
241     },
242   ],
243   [
244     {
245       label => 'Quotations',
246       show  => 'quotations',
247     },
248     {
249       label => 'Create new quotation',
250       url   => "edit/quotation.html?custnum=$custnum",
251       acl   => 'Generate quotation',
252     },
253   ],
254   [
255     {
256       label => 'Packages',
257       show  => 'packages',
258     },
259     {
260       label       => 'New qualification',
261       popup       => "misc/qual.html?custnum=$custnum",
262       actionlabel => 'New qualification',
263       color       => '#333399',
264       width       => 763,
265       height      => 436,
266       acl         => 'Qualify service',
267     },
268     {
269       label       => 'Order new package',
270       popup       => "misc/order_pkg.html?custnum=$custnum",
271       actionlabel => 'Order new package',
272       color       => '#333399',
273       width       => 960,
274       height      => 740,
275       acl         => 'Order customer package',
276     },
277     {
278       # it's just a popup, but there's some freaky CCH tax stuff in it
279       label       => 'One-time charge',
280       url         => "edit/quick-charge.html?custnum=$custnum",
281       acl         => 'One-time charge',
282     },
283     {
284       label       => 'Move services between packages',
285       popup       => "edit/bulk-cust_svc-pkgnum.html?custnum=$custnum",
286       actionlabel => 'Move services',
287       width       => 968,
288       height      => 575,
289       acl         => 'Bulk move customer services',
290     },
291     {
292       label       => 'Bulk order and cancel packages',
293       url         => "edit/cust_pkg.cgi?$custnum",
294       acl         => 'Bulk change customer packages',
295     },
296
297     { label   => '-',
298       content => '-',
299     },
300
301     {
302       label => 'Package reports',
303       url   => "search/report_cust_pkg.html?custnum=$custnum",
304     },
305     {
306       label => 'View qualifications',
307       url   => "search/qual.cgi?custnum=$custnum",
308       acl   => 'Qualify service',
309     },
310     {
311       label => 'View accounts',
312       url   => "search/report_svc_acct.html?custnum=$custnum",
313     },
314     {
315       label => 'View data usage',
316       popup => "search/report_sqlradius_usage-custnum.html?$custnum",
317       acl   => 'Usage: RADIUS sessions',
318       actionlabel => 'Data usage report',
319       width   => 480,
320       height  => 345,
321       condition => sub { shift->num_usage_pkgs > 0 },
322     },
323     {
324       label => 'View CDRs',
325       url   => "search/report_cdr.html?custnum=$custnum",
326       # XXX should have a condition that the customer has any CDR packages
327     },
328   ],
329   [
330     {
331       label => 'Payment History',
332       show  => 'payment_history',
333     },
334
335     # manual payment entry via edit/cust_pay
336     { label   => 'Enter payment',
337       submenu => [
338         {
339           label       => 'Enter check payment',
340           popup       => "edit/cust_pay.cgi?popup=1;payby=BILL;custnum=$custnum",
341           actionlabel => 'Enter check payment',
342           width       => 763,
343           height      => 392,
344           acl         => [ 'Post payment', 'Post check payment' ],
345         },
346         {
347           label       => 'Enter cash payment',
348           popup       => "edit/cust_pay.cgi?popup=1;payby=CASH;custnum=$custnum",
349           actionlabel => 'Enter cash payment',
350           width       => 763,
351           height      => 392,
352           acl         => [ 'Post payment', 'Post cash payment' ],
353         },
354         #{
355         #  label       => 'Enter Western Union payment',
356         #  popup       => "edit/cust_pay.cgi?popup=1;payby=WEST;custnum=$custnum",
357         #  actionlabel => 'Enter Western Union payment',
358         #  width       => 763,
359         #  height      => 392,
360         #  acl         => [ 'Post payment', ],
361         ##  condition   => sub { $payby{WEST} },
362         #},
363         #{
364         #  label       => 'Record manual (offline/POS) credit card payment',
365         #  popup       => "edit/cust_pay.cgi?popup=1;payby=MCRD;custnum=$custnum",
366         #  actionlabel => 'Enter credit card payment',
367         #  width       => 763,
368         #  height      => 392,
369         #  acl         => [ 'Post payment', ],
370         ##  condition   => sub { $payby{MCRD} },
371         #},
372         #{
373         #  label       => 'Record manual (offline/POS) electronic check',
374         #  popup       => "edit/cust_pay.cgi?popup=1;payby=MCHK;custnum=$custnum",
375         #  actionlabel => 'Enter credit card payment',
376         #  width       => 763,
377         #  height      => 392,
378         #  acl         => [ 'Post payment', ],
379         ##  condition   => sub { $payby{MCHK} },
380         #},
381       ],
382     },
383
384     # realtime payments via payment.cgi
385     { label   => 'Process payment',
386       submenu => [
387         {
388           label       => 'Process credit card payment',
389           url         => "misc/payment.cgi?payby=CARD;custnum=$custnum",
390           acl         => [ 'Process payment', 'Process credit card payment', ],
391           condition   => sub { $payby{CARD} or $payby{DCRD} },
392         },
393         {
394           label       => 'Process electronic check payment',
395           url         => "misc/payment.cgi?payby=CHEK;custnum=$custnum",
396           acl         => [ 'Process payment', 'Process Echeck payment', ],
397           condition   => sub { $payby{CHEK} or $payby{DCHK} },
398         },
399       ],
400     },
401
402     { label   => '-',
403       content => '-',
404     },
405
406     {
407       label       => 'Enter credit',
408       popup       => "edit/cust_credit.cgi?custnum=$custnum",
409       actionlabel => 'Enter credit',
410       width       => 763,
411       acl         => 'Post credit',
412     },
413     {
414       label       => 'Credit line items',
415       popup       => "edit/credit-cust_bill_pkg.html?custnum=$custnum",
416       actionlabel => 'Credit line items',
417       width       => 968,
418       height      => 575,
419       acl         => 'Credit line items',
420       condition   => sub {
421         FS::cust_bill->count('custnum = ?', shift->custnum) > 0
422       },
423     },
424
425     { label   => '-',
426       content => '-',
427     },
428
429     { label   => 'Enter refund',
430       submenu => [
431
432         {
433           label       => 'Enter check refund',
434           popup       => "edit/cust_refund.cgi?popup=1;payby=BILL;custnum=$custnum",
435           actionlabel => 'Enter check refund',
436           width       => 440,
437           acl         => ['Post refund', 'Post check refund'],
438         },
439         {
440           label       => 'Enter cash refund',
441           popup       => "edit/cust_refund.cgi?popup=1;payby=CASH;custnum=$custnum",
442           actionlabel => 'Enter cash refund',
443           width       => 392,
444           acl         => ['Post refund', 'Post cash refund'],
445         },
446         #{
447         #  label       => 'Record manual (offline/POS) credit card refund',
448         #  popup       => "edit/cust_refund.cgi?popup=1;payby=MCRD;custnum=$custnum",
449         #  actionlabel => 'Enter credit card refund',
450         #  width       => 440,
451         #  acl         => ['Post refund' ],
452         ##  condition   => sub { $payby{MCRD} },
453         #},
454         #{
455         #  label       => 'Record manual (offline/POS) electronic check refund',
456         #  popup       => "edit/cust_refund.cgi?popup=1;payby=MCHK;custnum=$custnum",
457         #  actionlabel => 'Enter electronic check refund',
458         #  width       => 440,
459         #  acl         => ['Post refund' ],
460         ##  condition   => sub { $payby{MCHK} },
461         #},
462         {
463            label       => 'Enter electronic check refund',
464            popup       => "edit/cust_refund.cgi?popup=1;payby=CHEK;custnum=$custnum",
465            actionlabel => 'Enter electronic check refund',
466            width       => 440,
467            acl         => ['Post refund' ],
468         },
469
470       ],
471
472     },
473
474     { label   => '-',
475       content => '-',
476     },
477
478     {
479       label       => 'Add tax adjustment',
480       popup       => "edit/cust_tax_adjustment.html?custnum=$custnum",
481       actionlabel => 'Add tax adjustment',
482       height      => 200,
483       confexists  => 'enable_tax_adjustments',
484       acl         => 'Add customer tax adjustment',
485     },
486
487     { label       => '-',
488       content     => '-',
489       confexists  => 'enable_tax_adjustments',
490       acl         => 'Add customer tax adjustment',
491     },
492
493     {
494       label       => 'Email statement to this customer',
495       url         => sub {
496                       my $cust_main = shift;
497                       my $agentnum = $cust_main->agentnum;
498                       'misc/email-customer-statement.html?table=cust_main;'.
499                       'agent_virt_agentnum='.$agentnum.";custnum=$custnum;url=".
500                       uri_escape($cgi->self_url);
501                      },
502       condition   => sub { $invoicing_list_emailonly },
503       acl         => 'Resend invoices',
504     },
505     {
506       label       => 'Download PDF statement',
507       url         => "view/cust_main_statement-pdf.cgi?$custnum",
508       acl         => 'View legacy typeset statements',
509       condition   => sub {
510         FS::cust_bill->count('custnum = ?', shift->custnum) > 0
511       },
512     },
513     {
514       label       => 'Search invoices',
515       url         => "search/report_cust_bill.html?custnum=$custnum",
516       acl         => 'List invoices',
517     },
518     {
519       label       => 'View tax exemptions',
520       url         => "search/cust_tax_exempt_pkg.cgi?custnum=$custnum",
521       acl         => 'View customer tax exemptions',
522     },
523     {
524       label       => 'View tax adjustments',
525       url         => "search/cust_tax_adjustment.html?custnum=$custnum",
526       confexists  => 'enable_tax_adjustments',
527       acl         => 'Add customer tax adjustment',
528     },
529     {
530       label       => 'View pending payments',
531       url         => "search/cust_pay_pending.html?magic=_date;statusNOT=done;custnum=$custnum",
532       acl         => 'View pending payments',
533       condition   => sub { 
534         FS::cust_pay_pending->count('custnum = ?', shift->custnum) > 0
535       },
536     },
537
538   ],
539   [
540     {
541       label => 'Change History',
542       show  => 'change_history',
543       acl   => 'View customer history',
544     },
545   ],
546 );
547
548 </%init>