better height for pkg order popup
[freeside.git] / httemplate / view / cust_main / menu.html
index f8ccc69..b1464b5 100644 (file)
@@ -1,32 +1,22 @@
 <style type="text/css">
 
 #customer_menu {
-  font-size: smaller;
-  border: none;
   margin-top: .6em;
   margin-bottom: 16px;
 }
 
-#customer_menu li {
-  float: left;
-  padding: .25em;
-}
-
 /* #customer_menu .ui-menu-item  */
 #customer_menu > li {
   background-color: #f8f8f8;
-  padding-left: 0px;
 }
 
 /* #customer_menu .ui-menu-item  */
 #customer_menu > li.ui-state-focus {
   background-color: #f8f8f8;
-  border: 1px solid transparent;
 }
 
 #customer_menu > li.ui-state-active {
   background-color: #f8f8f8;
-  border: 1px solid transparent;
 }
 
 #customer_menu > li > a {
   font-weight: normal;
   background: #e0e0e0;
   color: #525151;
-  white-space: nowrap;
   text-decoration: none;
 }
 
-#customer_menu ul {
-  background: #ffffff;
-  border: 1px solid #7e0079;
-  border-radius: 2px;
-  box-shadow: #333333 1px 1px 2px;
-}
-
-#customer_menu ul li {
-  float: none;
-  margin-right: 2px;
-  margin-left: 2px;
-}
-
-#customer_menu ul a {
-  color: #333333;
+#customer_menu ul a,
+#customer_menu ul form {
   background: transparent;
-}
-
-#customer_menu li.ui-menu-divider {
-  border-color: #7e0079;
-/*  margin-right: 2px;
-  margin-left: 2px; */
-}
-
-#customer_menu a:hover {
-  text-decoration: underline;
-  color: #7e0079;
-}
-
-#customer_menu ul li.ui-state-focus {
-  background: transparent;
-  border: 1px solid transparent;
-  margin-right: 1px;
-  margin-left: 1px;
-}
-
-#customer_menu ul li.ui-state-active {
-  background: #f8f0fc;
-  border: 1px solid #7e0079;
-  border-radius: 2px;
-  margin-right: 1px;
-  margin-left: 1px;
-}
-
-#customer_menu a .arrow {
-  float: right;
-  background-image: url("<% $p %>images/arrow.right.black.png");
-  width: 3px;
-  height: 6px;
-  margin-top:4px;
-}
-
-@-moz-document url-prefix() {
-  #customer_menu a .arrow {
-    margin-top:-.8em;
-  }
+  border: none;
 }
 
 </style>
 
-<& /elements/one_time_charge_link.html, form_only=>1 &>
-
-<ul id="customer_menu">
-% foreach my $submenu (@processed_menu) {
-  <li>
-    <% shift @$submenu %>
-%   if ( @$submenu ) {
-      <ul class="customer_submenu">
-%     foreach my $link ( @$submenu ) {
-        <li><% $link %></li>
-%     }
-      </ul>
-%   }
-  </li>
-% }
-</ul>
-
-<script type="text/javascript">
-
-  $("#customer_menu").menu({
-    position: { my: "left top", at: "left+1 bottom+3" },
-    blur: function() {
-      $(this).menu("option", "position", { my:"left top", at:"left+1 bottom+3" } );
-    },
-    focus: function(e,ui) {
-      if ($("#customer_menu").get(0) !== $(ui).get(0).item.parent().get(0)) {
-        $(this).menu("option", "position", { my:"left top", at:"right+2 top"} );
-      }
-    },
-  });
-
-</script>
-
+<& /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 = @_;
@@ -172,12 +85,15 @@ my $custnum = $cust_main->custnum;
 my $curuser = $FS::CurrentUser::CurrentUser;
 my $conf = FS::Conf->new;
 
-my %payby = map { $_ => 1 } $conf->config('payby');
+my @payby = grep /\w/, $conf->config('payby');
+@payby = (qw( CARD DCRD CHEK DCHK ))
+  unless @payby;
+my %payby = map { $_ => 1 } @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',
@@ -263,6 +179,11 @@ my @menu = (
                        'View customer billing events' ],
     },
     {
+      label       => 'Test billing events',
+      url         => "misc/test-part_event.html?custnum=$custnum",
+      acl         => 'Configuration',
+    },
+    {
       label       => 'Email a notice to this customer',
       url         => sub {
                       my $cust_main = shift;
@@ -287,7 +208,7 @@ my @menu = (
       confexists  => '!cust_main-disable_notes',
       acl         => 'Add customer note',
       width       => 875,
-      height      => 538,
+      height      => 548,
     },
     {
       label       => 'Attach file',
@@ -317,7 +238,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',
     },
   ],
@@ -352,18 +273,13 @@ my @menu = (
       actionlabel => 'Order new package',
       color       => '#333399',
       width       => 960,
-      height      => 740,
+      height      => 850,
       acl         => 'Order customer package',
     },
     {
       # 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',
     },
     {
@@ -386,7 +302,7 @@ my @menu = (
 
     {
       label => 'Package reports',
-      url   => "search/report_cust_pkg?custnum=$custnum",
+      url   => "search/report_cust_pkg.html?custnum=$custnum",
     },
     {
       label => 'View qualifications',
@@ -398,8 +314,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
     },
   ],
   [
@@ -418,7 +344,6 @@ my @menu = (
           width       => 763,
           height      => 392,
           acl         => [ 'Post payment', 'Post check payment' ],
-          condition   => sub { $payby{BILL} },
         },
         {
           label       => 'Enter cash payment',
@@ -427,34 +352,42 @@ my @menu = (
           width       => 763,
           height      => 392,
           acl         => [ 'Post payment', 'Post cash payment' ],
-          condition   => sub { $payby{CASH} },
         },
+        #{
+        #  label       => 'Enter Western Union payment',
+        #  popup       => "edit/cust_pay.cgi?popup=1;payby=WEST;custnum=$custnum",
+        #  actionlabel => 'Enter Western Union payment',
+        #  width       => 763,
+        #  height      => 392,
+        #  acl         => [ 'Post payment', ],
+        ##  condition   => sub { $payby{WEST} },
+        #},
+        #{
+        #  label       => 'Record manual (offline/POS) credit card payment',
+        #  popup       => "edit/cust_pay.cgi?popup=1;payby=MCRD;custnum=$custnum",
+        #  actionlabel => 'Enter credit card payment',
+        #  width       => 763,
+        #  height      => 392,
+        #  acl         => [ 'Post payment', ],
+        ##  condition   => sub { $payby{MCRD} },
+        #},
+        #{
+        #  label       => 'Record manual (offline/POS) electronic check',
+        #  popup       => "edit/cust_pay.cgi?popup=1;payby=MCHK;custnum=$custnum",
+        #  actionlabel => 'Enter credit card payment',
+        #  width       => 763,
+        #  height      => 392,
+        #  acl         => [ 'Post payment', ],
+        ##  condition   => sub { $payby{MCHK} },
+        #},
         {
-          label       => 'Enter Western Union payment',
-          popup       => "edit/cust_pay.cgi?popup=1;payby=WEST;custnum=$custnum",
-          actionlabel => 'Enter Western Union payment',
+          label       => 'Record manual (non-Freeside) Paypal payment',
+          popup       => "edit/cust_pay.cgi?popup=1;payby=PPAL;custnum=$custnum",
+          actionlabel => 'Enter Paypal payment',
           width       => 763,
           height      => 392,
-          acl         => [ 'Post payment', ],
-          condition   => sub { $payby{WEST} },
-        },
-        {
-          label       => 'Record manual (offline/POS) credit card payment',
-          popup       => "edit/cust_pay.cgi?popup=1;payby=MCRD;custnum=$custnum",
-          actionlabel => 'Enter credit card payment',
-          width       => 763,
-          height      => 392,
-          acl         => [ 'Post payment', ],
-          condition   => sub { $payby{MCRD} },
-        },
-        {
-          label       => 'Record manual (offline/POS) electronic check',
-          popup       => "edit/cust_pay.cgi?popup=1;payby=MCHK;custnum=$custnum",
-          actionlabel => 'Enter credit card payment',
-          width       => 763,
-          height      => 392,
-          acl         => [ 'Post payment', ],
-          condition   => sub { $payby{MCHK} },
+          acl         => [ 'Post Payment', 'Post Paypal payment', ],
+          condition   => sub { $payby{PPAL} },
         },
       ],
     },
@@ -513,7 +446,6 @@ my @menu = (
           actionlabel => 'Enter check refund',
           width       => 440,
           acl         => ['Post refund', 'Post check refund'],
-          condition   => sub { $payby{BILL} },
         },
         {
           label       => 'Enter cash refund',
@@ -521,23 +453,32 @@ my @menu = (
           actionlabel => 'Enter cash refund',
           width       => 392,
           acl         => ['Post refund', 'Post cash refund'],
-          condition   => sub { $payby{CASH} },
-        },
-        {
-          label       => 'Record manual (offline/POS) credit card refund',
-          popup       => "edit/cust_refund.cgi?popup=1;payby=MCRD;custnum=$custnum",
-          actionlabel => 'Enter credit card refund',
-          width       => 440,
-          acl         => ['Post refund' ],
-          condition   => sub { $payby{MCRD} },
         },
+        #{
+        #  label       => 'Record manual (offline/POS) credit card refund',
+        #  popup       => "edit/cust_refund.cgi?popup=1;payby=MCRD;custnum=$custnum",
+        #  actionlabel => 'Enter credit card refund',
+        #  width       => 440,
+        #  acl         => ['Post refund' ],
+        ##  condition   => sub { $payby{MCRD} },
+        #},
+        #{
+        #  label       => 'Record manual (offline/POS) electronic check refund',
+        #  popup       => "edit/cust_refund.cgi?popup=1;payby=MCHK;custnum=$custnum",
+        #  actionlabel => 'Enter electronic check refund',
+        #  width       => 440,
+        #  acl         => ['Post refund' ],
+        ##  condition   => sub { $payby{MCHK} },
+        #},
         {
-          label       => 'Record manual (offline/POS) electronic check refund',
-          popup       => "edit/cust_refund.cgi?popup=1;payby=MCHK;custnum=$custnum",
-          actionlabel => 'Enter electronic check refund',
-          width       => 440,
-          acl         => ['Post refund' ],
-          condition   => sub { $payby{MCHK} },
+           label       => 'Enter electronic check refund',
+           popup       => "edit/cust_refund.cgi?popup=1;payby=CHEK;custnum=$custnum",
+           actionlabel => 'Enter electronic check refund',
+           width       => 440,
+           acl         => ['Post refund' ],
+           condition   => sub {
+             FS::pay_batch->can_handle_electronic_refunds
+           },
         },
 
       ],
@@ -618,108 +559,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 = '<a href="javascript:void(0);">'. $label.
-              '<span class="arrow"></span>'.
-              '</a><ul class="customer_subsubmenu">';
-      foreach my $submenu (@{ $entry->{submenu} }) {
-        $a .= '<li>'. entry2link($submenu, $cust_main, $show), '</li>';
-      }
-
-      return $a. '</ul>';
-
-    }
-
-    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[ <A HREF="$target"];
-      $a .= ' class="current_show"' if $show eq $entry->{show};
-      return $a. qq[>$label</A> ];
-
-    } 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[ <A HREF="$target">$label</A> ];
-
-    } else {
-      die "bad entry ". join(',',%$entry). " in menu: no url, popup or content";
-    }
-
-}
-
 </%init>