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 <ul id="customer_menu">
135 % foreach my $submenu (@processed_menu) {
137 <% shift @$submenu %>
139 <ul class="customer_submenu">
140 % foreach my $link ( @$submenu ) {
149 <script type="text/javascript">
151 $("#customer_menu").menu({
152 position: { my: "left top", at: "left+1 bottom+3" },
154 $(this).menu("option", "position", { my:"left top", at:"left+1 bottom+3" } );
156 focus: function(e,ui) {
157 if ($("#customer_menu").get(0) !== $(ui).get(0).item.parent().get(0)) {
158 $(this).menu("option", "position", { my:"left top", at:"right+2 top"} );
168 my $cust_main = $opt{'cust_main'};
169 my $custnum = $cust_main->custnum;
170 my $curuser = $FS::CurrentUser::CurrentUser;
171 my $conf = FS::Conf->new;
173 my %payby = map { $_ => 1 } $conf->config('payby');
175 # cached for conditions, to avoid looking it up twice
176 my $invoicing_list_emailonly = $cust_main->invoicing_list_emailonly;
178 # nice declarative menu; should be a parameter to some kind of menu generator
185 label => 'Edit customer',
186 url => "edit/cust_main.cgi?$custnum",
187 acl => 'Edit customer'
190 label => 'Edit contacts',
191 url => "edit/cust_main-contacts.html?$custnum",
200 acl => 'Bill customer now',
201 content => sub { include( '/elements/bill.html',
202 label => emt('Bill now'),
203 url => $cgi->self_url,
204 custnum => shift->custnum,
210 popup => "misc/suspend_cust.html?custnum=$custnum",
211 acl => 'Suspend customer',
212 condition => sub { shift->unsuspended_pkgs > 0 },
213 actionlabel => 'Confirm Suspension',
217 label => 'Unsuspend',
218 popup => "misc/unsuspend_cust.html?custnum=$custnum",
219 acl => 'Unsuspend customer',
220 condition => sub { shift->suspended_pkgs > 0 },
221 actionlabel => 'Confirm Unsuspension',
225 popup => "misc/cancel_cust.html?custnum=$custnum",
226 acl => 'Cancel customer',
227 condition => sub { shift->ncancelled_pkgs > 0 },
228 actionlabel => 'Confirm Cancellation',
233 popup => "misc/merge_cust.html?custnum=$custnum",
234 acl => 'Merge customer',
235 actionlabel => 'Merge customer',
240 label => 'Refer a new customer',
241 url => "edit/cust_main.cgi?referral_custnum=$custnum",
242 confexists => '!disable_customer_referrals',
250 label => 'View this customer\'s referrals',
251 url => "search/cust_main.cgi?referral_custnum=$custnum",
252 confexists => '!disable_customer_referrals',
254 FS::cust_main->count('referral_custnum = ?', shift->custnum) > 0
258 label => 'View billing events',
259 url => "search/cust_event.html?custnum=$custnum",
260 acl => [ 'Billing event reports',
261 'View customer billing events' ],
264 label => 'Email a notice to this customer',
266 my $cust_main = shift;
267 my $agentnum = $cust_main->agentnum;
268 'misc/email-customers.html?table=cust_main;'.
269 'agent_virt_agentnum='.$agentnum.";custnum=$custnum;url=".
270 uri_escape($cgi->self_url);
272 condition => sub { $invoicing_list_emailonly },
273 acl => 'Bulk send customer notices',
283 popup => "edit/cust_main_note.cgi?custnum=$custnum",
284 actionlabel => 'Add note',
285 confexists => '!cust_main-disable_notes',
286 acl => 'Add customer note',
291 label => 'Attach file',
292 popup => "edit/cust_main_attach.cgi?custnum=$custnum",
293 actionlabel => 'Upload file',
294 confexists => '!disable_cust_attachment',
295 acl => 'Add attachment',
304 confexists => 'ticket_system'
309 label => 'Appointments',
310 show => 'appointments',
311 confexists => 'ticket_system',
312 acl => 'View appointments',
315 label => 'Schedule new appointment',
316 confexists => 'ticket_system',
317 acl => 'Make appointment',
318 popup => "misc/make_appointment.html?custnum=$custnum",
319 actionlabel => 'Schedule appointment',
324 label => 'Quotations',
325 show => 'quotations',
328 label => 'Create new quotation',
329 url => "edit/quotation.html?custnum=$custnum",
330 acl => 'Generate quotation',
339 label => 'New qualification',
340 popup => "misc/qual.html?custnum=$custnum",
341 actionlabel => 'New qualification',
345 acl => 'Qualify service',
348 label => 'Order new package',
349 popup => "misc/order_pkg.html?custnum=$custnum",
350 actionlabel => 'Order new package',
354 acl => 'Order customer package',
357 # it's just a popup, but there's some freaky CCH tax stuff in it
358 label => 'One-time charge',
359 url => "edit/quick-charge.html?custnum=$custnum",
360 acl => 'One-time charge',
363 label => 'Move services between packages',
364 popup => "edit/bulk-cust_svc-pkgnum.html?custnum=$custnum",
365 actionlabel => 'Move services',
368 acl => 'Bulk move customer services',
371 label => 'Bulk order and cancel packages',
372 url => "edit/cust_pkg.cgi?$custnum",
373 acl => 'Bulk change customer packages',
381 label => 'Package reports',
382 url => "search/report_cust_pkg.html?custnum=$custnum",
385 label => 'View qualifications',
386 url => "search/qual.cgi?custnum=$custnum",
387 acl => 'Qualify service',
390 label => 'View accounts',
391 url => "search/report_svc_acct.html?custnum=$custnum",
394 label => 'View data usage',
395 popup => "search/report_sqlradius_usage-custnum.html?$custnum",
396 acl => 'Usage: RADIUS sessions',
397 actionlabel => 'Data usage report',
402 label => 'View CDRs',
403 url => "search/report_cdr.html?custnum=$custnum",
404 # XXX should have a condition that the customer has any CDR packages
409 label => 'Payment History',
410 show => 'payment_history',
413 # manual payment entry via edit/cust_pay
414 { label => 'Enter payment',
417 label => 'Enter check payment',
418 popup => "edit/cust_pay.cgi?popup=1;payby=BILL;custnum=$custnum",
419 actionlabel => 'Enter check payment',
422 acl => [ 'Post payment', 'Post check payment' ],
425 label => 'Enter cash payment',
426 popup => "edit/cust_pay.cgi?popup=1;payby=CASH;custnum=$custnum",
427 actionlabel => 'Enter cash payment',
430 acl => [ 'Post payment', 'Post cash payment' ],
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'],
518 label => 'Enter cash refund',
519 popup => "edit/cust_refund.cgi?popup=1;payby=CASH;custnum=$custnum",
520 actionlabel => 'Enter cash refund',
522 acl => ['Post refund', 'Post cash refund'],
525 # label => 'Record manual (offline/POS) credit card refund',
526 # popup => "edit/cust_refund.cgi?popup=1;payby=MCRD;custnum=$custnum",
527 # actionlabel => 'Enter credit card refund',
529 # acl => ['Post refund' ],
530 ## condition => sub { $payby{MCRD} },
533 # label => 'Record manual (offline/POS) electronic check refund',
534 # popup => "edit/cust_refund.cgi?popup=1;payby=MCHK;custnum=$custnum",
535 # actionlabel => 'Enter electronic check refund',
537 # acl => ['Post refund' ],
538 ## condition => sub { $payby{MCHK} },
550 label => 'Add tax adjustment',
551 popup => "edit/cust_tax_adjustment.html?custnum=$custnum",
552 actionlabel => 'Add tax adjustment',
554 confexists => 'enable_tax_adjustments',
555 acl => 'Add customer tax adjustment',
560 confexists => 'enable_tax_adjustments',
561 acl => 'Add customer tax adjustment',
565 label => 'Email statement to this customer',
567 my $cust_main = shift;
568 my $agentnum = $cust_main->agentnum;
569 'misc/email-customer-statement.html?table=cust_main;'.
570 'agent_virt_agentnum='.$agentnum.";custnum=$custnum;url=".
571 uri_escape($cgi->self_url);
573 condition => sub { $invoicing_list_emailonly },
574 acl => 'Resend invoices',
577 label => 'Download PDF statement',
578 url => "view/cust_main_statement-pdf.cgi?$custnum",
579 acl => 'View legacy typeset statements',
581 FS::cust_bill->count('custnum = ?', shift->custnum) > 0
585 label => 'Search invoices',
586 url => "search/report_cust_bill.html?custnum=$custnum",
587 acl => 'List invoices',
590 label => 'View tax exemptions',
591 url => "search/cust_tax_exempt_pkg.cgi?custnum=$custnum",
592 acl => 'View customer tax exemptions',
595 label => 'View tax adjustments',
596 url => "search/cust_tax_adjustment.html?custnum=$custnum",
597 confexists => 'enable_tax_adjustments',
598 acl => 'Add customer tax adjustment',
601 label => 'View pending payments',
602 url => "search/cust_pay_pending.html?magic=_date;statusNOT=done;custnum=$custnum",
603 acl => 'View pending payments',
605 FS::cust_pay_pending->count('custnum = ?', shift->custnum) > 0
612 label => 'Change History',
613 show => 'change_history',
614 acl => 'View customer history',
621 foreach my $submenu (@menu) {
625 foreach my $entry ( @$submenu ) {
626 # if the menu head was skipped, skip the whole menu
627 last if (!$first and !@links);
630 my $a = entry2link($entry, $cust_main, $opt{show});
631 push @links, $a if length($a);
636 push @processed_menu, \@links;
642 my( $entry, $cust_main, $show ) = @_;
645 if ( $entry->{acl} ) {
647 unless $FS::CurrentUser::CurrentUser->access_right( $entry->{acl} );
649 if ( $entry->{confexists} ) {
650 if ( $entry->{confexists} =~ /^!(.*)/ ) {
651 # confexists => !foo, a negative condition
652 return '' if FS::Conf->new->exists( $1 );
654 return '' unless FS::Conf->new->exists( $entry->{confexists} );
657 if ( $entry->{condition} ) {
658 return '' unless &{ $entry->{condition} }($cust_main);
661 my $label = emt($entry->{label});
663 if ( $entry->{submenu} ) {
665 my $a = '<a href="javascript:void(0);">'. $label.
666 '<span class="arrow"></span>'.
667 '</a><ul class="customer_subsubmenu">';
668 foreach my $submenu (@{ $entry->{submenu} }) {
669 $a .= '<li>'. entry2link($submenu, $cust_main, $show), '</li>';
676 my $target = $entry->{content}
680 if ( ref($target) eq 'CODE' ) {
681 $target = &$target($cust_main);
684 return $target if $entry->{content}; #the coderef specified the whole thing
686 if ( $entry->{show} ) {
688 # the menu head: always a link back to this page
689 $cgi->param('show', $entry->{show});
690 $target = $cgi->self_url;
691 $cgi->param('show', $show);
693 my $a = qq[ <A HREF="$target"];
694 $a .= ' class="current_show"' if $show eq $entry->{show};
695 return $a. qq[>$label</A> ];
697 } elsif ( $entry->{popup} ) {
699 $target =~ s/\$custnum/$custnum/g;
700 $target = $p.$target;
702 return include('/elements/popup_link.html',
710 } elsif ( $entry->{url} ) {
712 $target =~ s/\$custnum/$custnum/g;
713 $target = $p.$target;
715 return qq[ <A HREF="$target">$label</A> ];
718 die "bad entry ". join(',',%$entry). " in menu: no url, popup or content";