X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fview%2Fcust_main%2Fmenu.html;h=6f177c3c4aefe1d753f5d8a5ebf19819404a844d;hp=b8740635de49803614cd2d06fb910d83bc304087;hb=def729d3a87b31aa3748527e9bf4e4a3558a8f30;hpb=434137989f7343ada30ceff4056c5f75ef8d9d27 diff --git a/httemplate/view/cust_main/menu.html b/httemplate/view/cust_main/menu.html index b8740635d..6f177c3c4 100644 --- a/httemplate/view/cust_main/menu.html +++ b/httemplate/view/cust_main/menu.html @@ -1,32 +1,22 @@ -<& /elements/one_time_charge_link.html, form_only=>1 &> - - - - - +<& /elements/dropdown-menu.html, + 'id' => 'customer_menu', + #'class' => 'customer_submenu', + #XXX support installs outside /freeside in 4.x + 'self_url' => "/freeside/view/cust_main.cgi?custnum=$custnum;show=", + 'menu' => \@menu, + 'cust_main' => $cust_main, + 'show' => $opt{'show'}, +&> <%init> my %opt = @_; @@ -177,7 +88,7 @@ my %payby = map { $_ => 1 } $conf->config('payby'); # cached for conditions, to avoid looking it up twice my $invoicing_list_emailonly = $cust_main->invoicing_list_emailonly; -# nice declarative menu; should be a parameter to some kind of menu generator +# nice declarative menu; a parameter to some kind of menu generator my @menu = ( [ { show => 'basics', @@ -317,7 +228,7 @@ my @menu = ( label => 'Schedule new appointment', confexists => 'ticket_system', acl => 'Make appointment', - popup => "elements/make_appointment.html?custnum=$custnum", + popup => "misc/make_appointment.html?custnum=$custnum", actionlabel => 'Schedule appointment', }, ], @@ -358,12 +269,7 @@ my @menu = ( { # it's just a popup, but there's some freaky CCH tax stuff in it label => 'One-time charge', - content => sub { - include( '/elements/one_time_charge_link.html', - custnum => shift->custnum, - no_form => 1, - ); - }, + url => "edit/quick-charge.html?custnum=$custnum", acl => 'One-time charge', }, { @@ -398,8 +304,18 @@ my @menu = ( url => "search/report_svc_acct.html?custnum=$custnum", }, { + label => 'View data usage', + popup => "search/report_sqlradius_usage-custnum.html?$custnum", + acl => 'Usage: RADIUS sessions', + actionlabel => 'Data usage report', + width => 480, + height => 345, + condition => sub { shift->num_usage_pkgs > 0 }, + }, + { label => 'View CDRs', url => "search/report_cdr.html?custnum=$custnum", + # XXX should have a condition that the customer has any CDR packages }, ], [ @@ -614,108 +530,4 @@ my @menu = ( ], ); - -my @processed_menu; -foreach my $submenu (@menu) { - - my @links; - my $first = 1; - foreach my $entry ( @$submenu ) { - # if the menu head was skipped, skip the whole menu - last if (!$first and !@links); - $first = 0; - - my $a = entry2link($entry, $cust_main, $opt{show}); - push @links, $a if length($a); - - } # foreach $entry - - if (@links) { - push @processed_menu, \@links; - } - -} - -sub entry2link { - my( $entry, $cust_main, $show ) = @_; - - # check conditions - if ( $entry->{acl} ) { - return '' - unless $FS::CurrentUser::CurrentUser->access_right( $entry->{acl} ); - } - if ( $entry->{confexists} ) { - if ( $entry->{confexists} =~ /^!(.*)/ ) { - # confexists => !foo, a negative condition - return '' if FS::Conf->new->exists( $1 ); - } else { - return '' unless FS::Conf->new->exists( $entry->{confexists} ); - } - } - if ( $entry->{condition} ) { - return '' unless &{ $entry->{condition} }($cust_main); - } - - my $label = emt($entry->{label}); - - if ( $entry->{submenu} ) { - - my $a = ''. $label. - ''. - ''; - - } - - my $target = $entry->{content} - || $entry->{popup} - || $entry->{url}; - - if ( ref($target) eq 'CODE' ) { - $target = &$target($cust_main); - } - - return $target if $entry->{content}; #the coderef specified the whole thing - - if ( $entry->{show} ) { - - # the menu head: always a link back to this page - $cgi->param('show', $entry->{show}); - $target = $cgi->self_url; - $cgi->param('show', $show); - - my $a = qq[ {show}; - return $a. qq[>$label ]; - - } elsif ( $entry->{popup} ) { - - $target =~ s/\$custnum/$custnum/g; - $target = $p.$target; - - return include('/elements/popup_link.html', - action => $target, - width => 616, - height => 410, - %$entry, - label => $label, - ); - - } elsif ( $entry->{url} ) { - - $target =~ s/\$custnum/$custnum/g; - $target = $p.$target; - - return qq[ $label ]; - - } else { - die "bad entry ". join(',',%$entry). " in menu: no url, popup or content"; - } - -} -