1 <style type="text/css">
25 text-decoration: none;
26 border-top-left-radius: .5em;
27 border-top-right-radius: .5em;
30 #menu_ul a.current_show {
33 border-top: thin solid #7e0079;
34 border-left: thin solid #7e0079;
35 border-right: thin solid #7e0079;
36 border-bottom: thin solid #ffffff;
47 border: thin solid #7e0079;
50 box-shadow: #333333 1px 1px 2px;
61 background: transparent;
67 text-decoration: underline;
72 <script src="<% $p %>elements/jquery.js"></script>
73 <script type="text/javascript">
75 $(document).ready(function() {
77 function closemenu () {
78 if (openmenu !== undefined) {
83 $('#menu_ul > li').hover(function(){
85 openmenu = $('ul:first', this);
94 % foreach my $submenu (@processed_menu) {
98 % foreach my $link ( @$submenu ) {
108 my $cust_main = $opt{'cust_main'};
109 my $custnum = $cust_main->custnum;
110 my $curuser = $FS::CurrentUser::CurrentUser;
111 my $conf = FS::Conf->new;
113 my %payby = map { $_ => 1 } $conf->config('payby');
115 # nice declarative menu; should be a parameter to some kind of menu generator
122 label => 'Edit customer',
123 url => "edit/cust_main.cgi?$custnum",
124 acl => 'Edit customer'
127 label => 'Edit contacts',
128 url => "edit/cust_main-contacts.html?$custnum",
133 acl => 'Bill customer now',
134 content => sub { include( '/elements/bill.html',
135 label => emt('Bill now'),
136 url => $cgi->self_url,
137 custnum => shift->custnum,
143 popup => "misc/suspend_cust.html?custnum=$custnum",
144 acl => 'Suspend customer',
145 condition => sub { shift->unsuspended_pkgs > 0 },
146 actionlabel => 'Confirm Suspension',
150 label => 'Unsuspend',
151 popup => "misc/unsuspend_cust.html?custnum=$custnum",
152 acl => 'Unsuspend customer',
153 condition => sub { shift->suspended_pkgs > 0 },
154 actionlabel => 'Confirm Unsuspension',
158 popup => "misc/suspend_cust.html?custnum=$custnum",
159 acl => 'Cancel customer',
160 condition => sub { shift->ncancelled_pkgs > 0 },
161 actionlabel => 'Confirm Cancellation',
166 popup => "misc/merge_cust.html?custnum=$custnum",
167 acl => 'Merge customer',
168 actionlabel => 'Merge customer',
173 label => 'Refer a new customer',
174 url => "edit/cust_main.cgi?referral_custnum=$custnum",
175 confexists => '!disable_customer_referrals',
177 # should have a separator here
179 label => 'View this customer\'s referrals',
180 url => "search/cust_main.cgi?referral_custnum=$custnum",
181 confexists => '!disable_customer_referrals',
183 FS::cust_main->count('referral_custnum = ?', shift->custnum) > 0
187 label => 'View billing events',
188 url => "search/cust_event.html?custnum=$custnum",
189 acl => [ 'Billing event reports',
190 'View customer billing events' ],
193 label => 'Email a notice to this customer',
195 my $cust_main = shift;
196 my $agentnum = $cust_main->agentnum;
197 'misc/email-customers.html?table=cust_main;search_hash='.
198 'agent_virt_agentnum='.$agentnum.";custnum=$custnum";
200 condition => sub { shift->invoicing_list_emailonly },
210 popup => "edit/cust_main_note.cgi?custnum=$custnum",
211 actionlabel => 'Add note',
212 confexists => '!cust_main-disable_notes',
213 acl => 'Add customer note',
218 label => 'Attach file',
219 popup => "edit/cust_main_attach.cgi?custnum=$custnum",
220 actionlabel => 'Upload file',
221 confexists => '!disable_cust_attachment',
222 acl => 'Add attachment',
231 confexists => 'ticket_system'
236 label => 'Appointments',
237 show => 'appointments',
238 confexists => 'ticket_system',
239 acl => 'View appointments',
242 label => 'Schedule new appointment',
243 confexists => 'ticket_system',
244 acl => 'Make appointment',
245 popup => "elements/make_appointment.html?custnum=$custnum",
246 actionlabel => 'Schedule appointment',
251 label => 'Quotations',
252 show => 'quotations',
255 label => 'Create new quotation',
256 url => "edit/quotation.html?custnum=$custnum",
257 acl => 'Generate quotation',
266 label => 'New qualification',
267 popup => "misc/qual.html?custnum=$custnum",
268 actionlabel => 'New qualification',
272 acl => 'Qualify service',
275 label => 'Order new package',
276 popup => "misc/order_pkg.html?custnum=$custnum",
277 actionlabel => 'Order new package',
281 acl => 'Order customer package',
284 # it's just a popup, but there's some freaky CCH tax stuff in it
285 label => 'One-time charge',
287 include( '/elements/one_time_charge_link.html',
288 custnum => shift->custnum,
291 acl => 'One-time charge',
294 label => 'Move services between packages',
295 popup => "edit/bulk-cust_svc-pkgnum.html?custnum=$custnum",
296 actionlabel => 'Move services',
299 acl => 'Bulk move customer services',
302 label => 'Bulk order and cancel packages',
303 url => "edit/cust_pkg.cgi?$custnum",
304 acl => 'Bulk change customer packages',
308 label => 'Package reports',
309 url => "search/report_cust_pkg?custnum=$custnum",
312 label => 'View qualifications',
313 url => "search/qual.cgi?custnum=$custnum",
314 acl => 'Qualify service',
317 label => 'View accounts',
318 url => "search/report_svc_acct.html?custnum=$custnum",
321 label => 'View CDRs',
322 url => "search/report_cdr.html?custnum=$custnum",
327 label => 'Payment History',
328 show => 'payment_history',
330 # manual payment entry via edit/cust_pay
332 label => 'Enter check payment',
333 popup => "edit/cust_pay.cgi?popup=1;payby=BILL;custnum=$custnum",
334 actionlabel => 'Enter check payment',
337 acl => [ 'Post payment', 'Post check payment' ],
338 condition => sub { $payby{BILL} },
341 label => 'Enter cash payment',
342 popup => "edit/cust_pay.cgi?popup=1;payby=CASH;custnum=$custnum",
343 actionlabel => 'Enter cash payment',
346 acl => [ 'Post payment', 'Post cash payment' ],
347 condition => sub { $payby{CASH} },
350 label => 'Enter Western Union payment',
351 popup => "edit/cust_pay.cgi?popup=1;payby=WEST;custnum=$custnum",
352 actionlabel => 'Enter Western Union payment',
355 acl => [ 'Post payment', ],
356 condition => sub { $payby{WEST} },
359 label => 'Post manual (offline/POS) credit card payment',
360 popup => "edit/cust_pay.cgi?popup=1;payby=MCRD;custnum=$custnum",
361 actionlabel => 'Enter credit card payment',
364 acl => [ 'Post payment', ],
365 condition => sub { $payby{MCRD} },
368 label => 'Post manual (offline/POS) electronic check',
369 popup => "edit/cust_pay.cgi?popup=1;payby=MCHK;custnum=$custnum",
370 actionlabel => 'Enter credit card payment',
373 acl => [ 'Post payment', ],
374 condition => sub { $payby{MCHK} },
376 # realtime payments via payment.cgi
378 label => 'Process credit card payment',
379 url => "misc/payment.cgi?payby=CARD;custnum=$custnum",
380 acl => [ 'Process payment', 'Process credit card payment', ],
381 condition => sub { $payby{CARD} or $payby{DCRD} },
384 label => 'Process electronic check payment',
385 url => "misc/payment.cgi?payby=CHEK;custnum=$custnum",
386 acl => [ 'Process payment', 'Process Echeck payment', ],
387 condition => sub { $payby{CHEK} or $payby{DCHK} },
391 label => 'Enter credit',
392 popup => "edit/cust_credit.cgi?custnum=$custnum",
393 actionlabel => 'Enter credit',
395 acl => 'Post credit',
398 label => 'Credit line items',
399 popup => "edit/credit-cust_bill_pkg.html?custnum=$custnum",
400 actionlabel => 'Credit line items',
403 acl => 'Credit line items',
405 FS::cust_bill->count('custnum = ?', shift->custnum) > 0
409 label => 'Enter check refund',
410 popup => "edit/cust_refund.cgi?popup=1;payby=BILL;custnum=$custnum",
411 actionlabel => 'Enter check refund',
413 acl => ['Post refund', 'Post check refund'],
414 condition => sub { $payby{BILL} },
417 label => 'Enter cash refund',
418 popup => "edit/cust_refund.cgi?popup=1;payby=CASH;custnum=$custnum",
419 actionlabel => 'Enter cash refund',
421 acl => ['Post refund', 'Post cash refund'],
422 condition => sub { $payby{CASH} },
425 label => 'Enter manual (offline/POS) credit card refund',
426 popup => "edit/cust_refund.cgi?popup=1;payby=MCRD;custnum=$custnum",
427 actionlabel => 'Enter credit card refund',
429 acl => ['Post refund' ],
430 condition => sub { $payby{MCRD} },
433 label => 'Enter manual (offline/POS) electronic check refund',
434 popup => "edit/cust_refund.cgi?popup=1;payby=MCHK;custnum=$custnum",
435 actionlabel => 'Enter electronic check refund',
437 acl => ['Post refund' ],
438 condition => sub { $payby{MCHK} },
441 label => 'Add tax adjustment',
442 popup => "edit/cust_tax_adjustment.html?custnum=$custnum",
443 actionlabel => 'Add tax adjustment',
445 confexists => 'enable_tax_adjustments',
446 acl => 'Add customer tax adjustment',
448 # separator, definitely
450 label => 'Download statement',
451 url => "view/cust_main_statement-pdf.cgi?$custnum",
452 acl => 'List invoices',
454 FS::cust_bill->count('custnum = ?', shift->custnum) > 0
458 label => 'Search invoices',
459 url => "search/report_cust_bill.html?custnum=$custnum",
460 acl => 'List invoices',
463 label => 'View tax exemptions',
464 url => "search/cust_tax_exempt_pkg.cgi?custnum=$custnum",
465 acl => 'View customer tax exemptions',
468 label => 'View tax adjustments',
469 url => "search/cust_tax_adjustment.html?custnum=$custnum",
470 confexists => 'enable_tax_adjustments',
471 acl => 'Add customer tax adjustment',
474 label => 'View pending payments',
475 url => "search/cust_pay_pending.html?magic=_date;statusNOT=done;custnum=$custnum",
476 acl => 'View pending payments',
478 FS::cust_pay_pending->count('custnum = ?', shift->custnum) > 0
484 label => 'Change History',
485 show => 'change_history',
486 acl => 'View customer history',
493 foreach my $submenu (@menu) {
497 foreach my $entry ( @$submenu ) {
498 # if the menu head was skipped, skip the whole menu
499 last if (!$first and !@links);
503 if ( $entry->{acl} ) {
504 next unless $curuser->access_right( $entry->{acl} );
506 if ( $entry->{confexists} ) {
507 if ( $entry->{confexists} =~ /^!(.*)/ ) {
508 # confexists => !foo, a negative condition
509 next if $conf->exists( $1 );
511 next unless $conf->exists( $entry->{confexists} );
514 if ( $entry->{condition} ) {
515 next unless &{ $entry->{condition} }($cust_main);
518 my $label = emt($entry->{label});
519 my $target = $entry->{content}
523 if ( ref($target) eq 'CODE' ) {
524 $target = &$target($cust_main);
528 if ( $entry->{content} ) { # then the coderef specified the whole thing
531 } elsif ( $entry->{show} ) {
533 # the menu head: always a link back to this page
534 $cgi->param('show', $entry->{show});
535 $target = $cgi->self_url;
537 $a = qq[ <A HREF="$target"];
538 if ( $opt{'show'} eq $entry->{show} ) {
539 $a .= ' class="current_show"';
541 $a .= qq[>$label</A> ];
544 } elsif ( $entry->{popup} ) {
546 $target =~ s/\$custnum/$custnum/g;
547 $target = $p.$target;
548 $a = include('/elements/popup_link.html',
553 label => emt($label),
556 } elsif ( $entry->{url} ) {
558 $target =~ s/\$custnum/$custnum/g;
559 $target = $p.$target;
560 $a = qq[ <A HREF="$target">$label</A> ];
567 push @processed_menu, \@links;