1 <style type="text/css">
15 /* #customer_menu .ui-menu-item */
17 background-color: #f8f8f8;
21 /* #customer_menu .ui-menu-item */
22 #customer_menu > li.ui-state-focus {
23 background-color: #f8f8f8;
24 border: 1px solid transparent;
27 #customer_menu > li.ui-state-active {
28 background-color: #f8f8f8;
29 border: 1px solid transparent;
32 #customer_menu > li > a {
33 border-top: 1px solid transparent;
34 border-left: 1px solid transparent;
35 border-right: 1px solid transparent;
40 #customer_menu > li.ui-state-active > a {
42 /* if i could find something light enough that didn't look pink?
43 or is this too visually distracting and not the useful hint i think it is?
48 #customer_menu a.current_show {
51 border-top: 1px solid #7e0079;
52 border-left: 1px solid #7e0079;
53 border-right: 1px solid #7e0079;
54 border-bottom: 2px solid #ffffff;
56 border-bottom-left-radius: 2px;
57 border-bottom-right-radius: 2px;
64 border-top-left-radius: .5em;
65 border-top-right-radius: .5em;
71 text-decoration: none;
76 border: 1px solid #7e0079;
78 box-shadow: #333333 1px 1px 2px;
81 #customer_menu ul li {
89 background: transparent;
92 #customer_menu li.ui-menu-divider {
93 border-color: #7e0079;
98 #customer_menu a:hover {
99 text-decoration: underline;
103 #customer_menu ul li.ui-state-focus {
104 background: transparent;
105 border: 1px solid transparent;
110 #customer_menu ul li.ui-state-active {
112 border: 1px solid #7e0079;
118 #customer_menu a .arrow {
120 background-image: url("<% $p %>images/arrow.right.black.png");
126 @-moz-document url-prefix() {
127 #customer_menu a .arrow {
134 <& /elements/one_time_charge_link.html, form_only=>1 &>
136 <ul id="customer_menu">
137 % foreach my $submenu (@processed_menu) {
139 <% shift @$submenu %>
141 <ul class="customer_submenu">
142 % foreach my $link ( @$submenu ) {
151 <script type="text/javascript">
153 $("#customer_menu").menu({
154 position: { my: "left top", at: "left+1 bottom+3" },
156 $(this).menu("option", "position", { my:"left top", at:"left+1 bottom+3" } );
158 focus: function(e,ui) {
159 if ($("#customer_menu").get(0) !== $(ui).get(0).item.parent().get(0)) {
160 $(this).menu("option", "position", { my:"left top", at:"right+2 top"} );
170 my $cust_main = $opt{'cust_main'};
171 my $custnum = $cust_main->custnum;
172 my $curuser = $FS::CurrentUser::CurrentUser;
173 my $conf = FS::Conf->new;
175 my %payby = map { $_ => 1 } $conf->config('payby');
177 # cached for conditions, to avoid looking it up twice
178 my $invoicing_list_emailonly = $cust_main->invoicing_list_emailonly;
180 # nice declarative menu; should be a parameter to some kind of menu generator
187 label => 'Edit customer',
188 url => "edit/cust_main.cgi?$custnum",
189 acl => 'Edit customer'
192 label => 'Edit contacts',
193 url => "edit/cust_main-contacts.html?$custnum",
202 acl => 'Bill customer now',
203 content => sub { include( '/elements/bill.html',
204 label => emt('Bill now'),
205 url => $cgi->self_url,
206 custnum => shift->custnum,
212 popup => "misc/suspend_cust.html?custnum=$custnum",
213 acl => 'Suspend customer',
214 condition => sub { shift->unsuspended_pkgs > 0 },
215 actionlabel => 'Confirm Suspension',
219 label => 'Unsuspend',
220 popup => "misc/unsuspend_cust.html?custnum=$custnum",
221 acl => 'Unsuspend customer',
222 condition => sub { shift->suspended_pkgs > 0 },
223 actionlabel => 'Confirm Unsuspension',
227 popup => "misc/cancel_cust.html?custnum=$custnum",
228 acl => 'Cancel customer',
229 condition => sub { shift->ncancelled_pkgs > 0 },
230 actionlabel => 'Confirm Cancellation',
235 popup => "misc/merge_cust.html?custnum=$custnum",
236 acl => 'Merge customer',
237 actionlabel => 'Merge customer',
242 label => 'Refer a new customer',
243 url => "edit/cust_main.cgi?referral_custnum=$custnum",
244 confexists => '!disable_customer_referrals',
252 label => 'View this customer\'s referrals',
253 url => "search/cust_main.cgi?referral_custnum=$custnum",
254 confexists => '!disable_customer_referrals',
256 FS::cust_main->count('referral_custnum = ?', shift->custnum) > 0
260 label => 'View billing events',
261 url => "search/cust_event.html?custnum=$custnum",
262 acl => [ 'Billing event reports',
263 'View customer billing events' ],
266 label => 'Email a notice to this customer',
268 my $cust_main = shift;
269 my $agentnum = $cust_main->agentnum;
270 'misc/email-customers.html?table=cust_main;'.
271 'agent_virt_agentnum='.$agentnum.";custnum=$custnum;url=".
272 uri_escape($cgi->self_url);
274 condition => sub { $invoicing_list_emailonly },
275 acl => 'Bulk send customer notices',
285 popup => "edit/cust_main_note.cgi?custnum=$custnum",
286 actionlabel => 'Add note',
287 confexists => '!cust_main-disable_notes',
288 acl => 'Add customer note',
293 label => 'Attach file',
294 popup => "edit/cust_main_attach.cgi?custnum=$custnum",
295 actionlabel => 'Upload file',
296 confexists => '!disable_cust_attachment',
297 acl => 'Add attachment',
306 confexists => 'ticket_system'
311 label => 'Appointments',
312 show => 'appointments',
313 confexists => 'ticket_system',
314 acl => 'View appointments',
317 label => 'Schedule new appointment',
318 confexists => 'ticket_system',
319 acl => 'Make appointment',
320 popup => "elements/make_appointment.html?custnum=$custnum",
321 actionlabel => 'Schedule appointment',
326 label => 'Quotations',
327 show => 'quotations',
330 label => 'Create new quotation',
331 url => "edit/quotation.html?custnum=$custnum",
332 acl => 'Generate quotation',
341 label => 'New qualification',
342 popup => "misc/qual.html?custnum=$custnum",
343 actionlabel => 'New qualification',
347 acl => 'Qualify service',
350 label => 'Order new package',
351 popup => "misc/order_pkg.html?custnum=$custnum",
352 actionlabel => 'Order new package',
356 acl => 'Order customer package',
359 # it's just a popup, but there's some freaky CCH tax stuff in it
360 label => 'One-time charge',
362 include( '/elements/one_time_charge_link.html',
363 custnum => shift->custnum,
367 acl => 'One-time charge',
370 label => 'Move services between packages',
371 popup => "edit/bulk-cust_svc-pkgnum.html?custnum=$custnum",
372 actionlabel => 'Move services',
375 acl => 'Bulk move customer services',
378 label => 'Bulk order and cancel packages',
379 url => "edit/cust_pkg.cgi?$custnum",
380 acl => 'Bulk change customer packages',
388 label => 'Package reports',
389 url => "search/report_cust_pkg.html?custnum=$custnum",
392 label => 'View qualifications',
393 url => "search/qual.cgi?custnum=$custnum",
394 acl => 'Qualify service',
397 label => 'View accounts',
398 url => "search/report_svc_acct.html?custnum=$custnum",
401 label => 'View CDRs',
402 url => "search/report_cdr.html?custnum=$custnum",
407 label => 'Payment History',
408 show => 'payment_history',
411 # manual payment entry via edit/cust_pay
412 { label => 'Enter payment',
415 label => 'Enter check payment',
416 popup => "edit/cust_pay.cgi?popup=1;payby=BILL;custnum=$custnum",
417 actionlabel => 'Enter check payment',
420 acl => [ 'Post payment', 'Post check payment' ],
421 condition => sub { $payby{BILL} },
424 label => 'Enter cash payment',
425 popup => "edit/cust_pay.cgi?popup=1;payby=CASH;custnum=$custnum",
426 actionlabel => 'Enter cash payment',
429 acl => [ 'Post payment', 'Post cash payment' ],
430 condition => sub { $payby{CASH} },
433 label => 'Enter Western Union payment',
434 popup => "edit/cust_pay.cgi?popup=1;payby=WEST;custnum=$custnum",
435 actionlabel => 'Enter Western Union payment',
438 acl => [ 'Post payment', ],
439 condition => sub { $payby{WEST} },
442 label => 'Record manual (offline/POS) credit card payment',
443 popup => "edit/cust_pay.cgi?popup=1;payby=MCRD;custnum=$custnum",
444 actionlabel => 'Enter credit card payment',
447 acl => [ 'Post payment', ],
448 condition => sub { $payby{MCRD} },
451 label => 'Record manual (offline/POS) electronic check',
452 popup => "edit/cust_pay.cgi?popup=1;payby=MCHK;custnum=$custnum",
453 actionlabel => 'Enter credit card payment',
456 acl => [ 'Post payment', ],
457 condition => sub { $payby{MCHK} },
462 # realtime payments via payment.cgi
463 { label => 'Process payment',
466 label => 'Process credit card payment',
467 url => "misc/payment.cgi?payby=CARD;custnum=$custnum",
468 acl => [ 'Process payment', 'Process credit card payment', ],
469 condition => sub { $payby{CARD} or $payby{DCRD} },
472 label => 'Process electronic check payment',
473 url => "misc/payment.cgi?payby=CHEK;custnum=$custnum",
474 acl => [ 'Process payment', 'Process Echeck payment', ],
475 condition => sub { $payby{CHEK} or $payby{DCHK} },
485 label => 'Enter credit',
486 popup => "edit/cust_credit.cgi?custnum=$custnum",
487 actionlabel => 'Enter credit',
489 acl => 'Post credit',
492 label => 'Credit line items',
493 popup => "edit/credit-cust_bill_pkg.html?custnum=$custnum",
494 actionlabel => 'Credit line items',
497 acl => 'Credit line items',
499 FS::cust_bill->count('custnum = ?', shift->custnum) > 0
507 { label => 'Enter refund',
511 label => 'Enter check refund',
512 popup => "edit/cust_refund.cgi?popup=1;payby=BILL;custnum=$custnum",
513 actionlabel => 'Enter check refund',
515 acl => ['Post refund', 'Post check refund'],
516 condition => sub { $payby{BILL} },
519 label => 'Enter cash refund',
520 popup => "edit/cust_refund.cgi?popup=1;payby=CASH;custnum=$custnum",
521 actionlabel => 'Enter cash refund',
523 acl => ['Post refund', 'Post cash refund'],
524 condition => sub { $payby{CASH} },
527 label => 'Record manual (offline/POS) credit card refund',
528 popup => "edit/cust_refund.cgi?popup=1;payby=MCRD;custnum=$custnum",
529 actionlabel => 'Enter credit card refund',
531 acl => ['Post refund' ],
532 condition => sub { $payby{MCRD} },
535 label => 'Record manual (offline/POS) electronic check refund',
536 popup => "edit/cust_refund.cgi?popup=1;payby=MCHK;custnum=$custnum",
537 actionlabel => 'Enter electronic check refund',
539 acl => ['Post refund' ],
540 condition => sub { $payby{MCHK} },
552 label => 'Add tax adjustment',
553 popup => "edit/cust_tax_adjustment.html?custnum=$custnum",
554 actionlabel => 'Add tax adjustment',
556 confexists => 'enable_tax_adjustments',
557 acl => 'Add customer tax adjustment',
562 confexists => 'enable_tax_adjustments',
563 acl => 'Add customer tax adjustment',
567 label => 'Email statement to this customer',
569 my $cust_main = shift;
570 my $agentnum = $cust_main->agentnum;
571 'misc/email-customer-statement.html?table=cust_main;'.
572 'agent_virt_agentnum='.$agentnum.";custnum=$custnum;url=".
573 uri_escape($cgi->self_url);
575 condition => sub { $invoicing_list_emailonly },
576 acl => 'Resend invoices',
579 label => 'Download PDF statement',
580 url => "view/cust_main_statement-pdf.cgi?$custnum",
581 acl => 'View legacy typeset statements',
583 FS::cust_bill->count('custnum = ?', shift->custnum) > 0
587 label => 'Search invoices',
588 url => "search/report_cust_bill.html?custnum=$custnum",
589 acl => 'List invoices',
592 label => 'View tax exemptions',
593 url => "search/cust_tax_exempt_pkg.cgi?custnum=$custnum",
594 acl => 'View customer tax exemptions',
597 label => 'View tax adjustments',
598 url => "search/cust_tax_adjustment.html?custnum=$custnum",
599 confexists => 'enable_tax_adjustments',
600 acl => 'Add customer tax adjustment',
603 label => 'View pending payments',
604 url => "search/cust_pay_pending.html?magic=_date;statusNOT=done;custnum=$custnum",
605 acl => 'View pending payments',
607 FS::cust_pay_pending->count('custnum = ?', shift->custnum) > 0
614 label => 'Change History',
615 show => 'change_history',
616 acl => 'View customer history',
623 foreach my $submenu (@menu) {
627 foreach my $entry ( @$submenu ) {
628 # if the menu head was skipped, skip the whole menu
629 last if (!$first and !@links);
632 my $a = entry2link($entry, $cust_main, $opt{show});
633 push @links, $a if length($a);
638 push @processed_menu, \@links;
644 my( $entry, $cust_main, $show ) = @_;
647 if ( $entry->{acl} ) {
649 unless $FS::CurrentUser::CurrentUser->access_right( $entry->{acl} );
651 if ( $entry->{confexists} ) {
652 if ( $entry->{confexists} =~ /^!(.*)/ ) {
653 # confexists => !foo, a negative condition
654 return '' if FS::Conf->new->exists( $1 );
656 return '' unless FS::Conf->new->exists( $entry->{confexists} );
659 if ( $entry->{condition} ) {
660 return '' unless &{ $entry->{condition} }($cust_main);
663 my $label = emt($entry->{label});
665 if ( $entry->{submenu} ) {
667 my $a = '<a href="javascript:void(0);">'. $label.
668 '<span class="arrow"></span>'.
669 '</a><ul class="customer_subsubmenu">';
670 foreach my $submenu (@{ $entry->{submenu} }) {
671 $a .= '<li>'. entry2link($submenu, $cust_main, $show), '</li>';
678 my $target = $entry->{content}
682 if ( ref($target) eq 'CODE' ) {
683 $target = &$target($cust_main);
686 return $target if $entry->{content}; #the coderef specified the whole thing
688 if ( $entry->{show} ) {
690 # the menu head: always a link back to this page
691 $cgi->param('show', $entry->{show});
692 $target = $cgi->self_url;
693 $cgi->param('show', $show);
695 my $a = qq[ <A HREF="$target"];
696 $a .= ' class="current_show"' if $show eq $entry->{show};
697 return $a. qq[>$label</A> ];
699 } elsif ( $entry->{popup} ) {
701 $target =~ s/\$custnum/$custnum/g;
702 $target = $p.$target;
704 return include('/elements/popup_link.html',
712 } elsif ( $entry->{url} ) {
714 $target =~ s/\$custnum/$custnum/g;
715 $target = $p.$target;
717 return qq[ <A HREF="$target">$label</A> ];
720 die "bad entry ". join(',',%$entry). " in menu: no url, popup or content";