better height for pkg order popup
[freeside.git] / httemplate / view / cust_main / menu.html
index 6e66ea7..b1464b5 100644 (file)
 <style type="text/css">
-#menu_ul {
-  padding: 0;
-  margin: .5em 0 0 0;
-  font-size: smaller;
+
+#customer_menu {
+  margin-top: .6em;
+  margin-bottom: 16px;
 }
 
-#menu_ul li {
-  margin: 0;
-  float: left;
-  list-style: none;
-  position: relative;
+/* #customer_menu .ui-menu-item  */
+#customer_menu > li {
+  background-color: #f8f8f8;
 }
 
-#menu_ul a {
-  display: block;
-  margin-left: 0;
-  margin-right: 1em;
-  margin-bottom: -1px;
-  margin-top: 0;
+/* #customer_menu .ui-menu-item  */
+#customer_menu > li.ui-state-focus {
+  background-color: #f8f8f8;
+}
+
+#customer_menu > li.ui-state-active {
+  background-color: #f8f8f8;
+}
+
+#customer_menu > li > a {
+  border-top: 1px solid transparent;
+  border-left: 1px solid transparent;
+  border-right: 1px solid transparent;
+  border-bottom: none;
   padding: .5em .75em;
-  background: #e0e0e0;
-  color: #525151;
-  white-space: nowrap;
-  text-decoration: none;
-  border-top-left-radius: .5em;
-  border-top-right-radius: .5em;
 }
 
-#menu_ul a.current_show {
+#customer_menu > li.ui-state-active > a {
+
+/* if i could find something light enough that didn't look pink?
+     or is this too visually distracting and not the useful hint i think it is?
+  background: #ED55E7;
+*/
+}
+
+#customer_menu a.current_show {
   font-weight: bold;
   background: #FFFFFF;
-  border-top: thin solid #7e0079;
-  border-left: thin solid #7e0079;
-  border-right: thin solid #7e0079;
-  border-bottom: thin solid #ffffff;
+  border-top: 1px solid #7e0079;
+  border-left: 1px solid #7e0079;
+  border-right: 1px solid #7e0079;
+  border-bottom: 2px solid #ffffff;
+  margin-bottom: -2px;
+  border-bottom-left-radius: 2px;
+  border-bottom-right-radius: 2px;
 }
 
-#menu_ul ul {
-  margin:0;
-  padding:0;
-  display:none;
-  position: absolute;
-  top: 100%;
-  left: 0;
-  background: #ffffff;
-  border: thin solid #7e0079;
-  z-index:8888;
-  border-radius: 2px;
-  box-shadow: #333333 1px 1px 2px;
-}
+#customer_menu a {
+  margin-left: 0;
+  margin-right: 1em;
+  margin-top: 0;
+  border-top-left-radius: .5em;
+  border-top-right-radius: .5em;
 
-#menu_ul ul li {
-  margin: 0;
-  padding: 0;
-  float: none;
+  font-weight: normal;
+  background: #e0e0e0;
+  color: #525151;
+  text-decoration: none;
 }
 
-#menu_ul ul a {
-  color: #333333;
+#customer_menu ul a,
+#customer_menu ul form {
   background: transparent;
-  border-bottom: none;
-  border-radius: 0;
-}
-
-#menu_ul a:hover {
-  text-decoration: underline;
-  color: #7e0079;
+  border: none;
 }
 
 </style>
-<script src="<% $p %>elements/jquery.js"></script>
-<script type="text/javascript">
-
-$(document).ready(function() {
-       var openmenu;
-       function closemenu () {
-               if (openmenu !== undefined) {
-                       openmenu.hide();
-                       openmenu = undefined;
-               }
-       }               
-       $('#menu_ul > li').hover(function(){
-               closemenu();
-               openmenu = $('ul:first', this);
-               openmenu.show();
-       }, function(){
-               closemenu();
-       });
-});
-</script>
-
-<ul id="menu_ul">
-% foreach my $submenu (@processed_menu) {
-  <li>
-    <% shift @$submenu %>
-    <ul>
-%   foreach my $link ( @$submenu ) {
-      <li><% $link %></li>
-%   }
-    </ul>
-  </li>
-% }
-</ul>
+
+<& /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 = @_;
@@ -110,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',
@@ -130,7 +108,11 @@ my @menu = (
       label       => 'Edit contacts',
       url         => "edit/cust_main-contacts.html?$custnum",
     },
-# separator
+
+    { label   => '-',
+      content => '-',
+    },
+
     {
       label       => 'Bill now',
       acl         => 'Bill customer now',
@@ -158,7 +140,7 @@ my @menu = (
     },
     {
       label       => 'Cancel',
-      popup       => "misc/suspend_cust.html?custnum=$custnum",
+      popup       => "misc/cancel_cust.html?custnum=$custnum",
       acl         => 'Cancel customer',
       condition   => sub { shift->ncancelled_pkgs > 0 },
       actionlabel => 'Confirm Cancellation',
@@ -177,7 +159,11 @@ my @menu = (
       url         => "edit/cust_main.cgi?referral_custnum=$custnum",
       confexists  => '!disable_customer_referrals',
     },
-# should have a separator here
+
+    { label   => '-',
+      content => '-',
+    },
+
     {
       label       => 'View this customer\'s referrals',
       url         => "search/cust_main.cgi?referral_custnum=$custnum",
@@ -193,12 +179,18 @@ 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;
                       my $agentnum = $cust_main->agentnum;
-                      'misc/email-customers.html?table=cust_main;search_hash='.
-                      'agent_virt_agentnum='.$agentnum.";custnum=$custnum";
+                      'misc/email-customers.html?table=cust_main;'.
+                      'agent_virt_agentnum='.$agentnum.";custnum=$custnum;url=".
+                      uri_escape($cgi->self_url);
                      },
       condition   => sub { $invoicing_list_emailonly },
       acl         => 'Bulk send customer notices',
@@ -215,8 +207,8 @@ my @menu = (
       actionlabel => 'Add note',
       confexists  => '!cust_main-disable_notes',
       acl         => 'Add customer note',
-      width       => 616,
-      height      => 538,
+      width       => 875,
+      height      => 548,
     },
     {
       label       => 'Attach file',
@@ -246,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',
     },
   ],
@@ -281,17 +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,
-                      );
-                     },
+      url         => "edit/quick-charge.html?custnum=$custnum",
       acl         => 'One-time charge',
     },
     {
@@ -307,10 +295,14 @@ my @menu = (
       url         => "edit/cust_pkg.cgi?$custnum",
       acl         => 'Bulk change customer packages',
     },
-# separator
+
+    { label   => '-',
+      content => '-',
+    },
+
     {
       label => 'Package reports',
-      url   => "search/report_cust_pkg?custnum=$custnum",
+      url   => "search/report_cust_pkg.html?custnum=$custnum",
     },
     {
       label => 'View qualifications',
@@ -322,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
     },
   ],
   [
@@ -331,66 +333,87 @@ my @menu = (
       label => 'Payment History',
       show  => 'payment_history',
     },
+
     # manual payment entry via edit/cust_pay
-    {
-      label       => 'Enter check payment',
-      popup       => "edit/cust_pay.cgi?popup=1;payby=BILL;custnum=$custnum",
-      actionlabel => 'Enter check payment',
-      width       => 763,
-      height      => 392,
-      acl         => [ 'Post payment', 'Post check payment' ],
-      condition   => sub { $payby{BILL} },
-    },
-    {
-      label       => 'Enter cash payment',
-      popup       => "edit/cust_pay.cgi?popup=1;payby=CASH;custnum=$custnum",
-      actionlabel => 'Enter cash payment',
-      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       => 'Post 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       => 'Post 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 payment',
+      submenu => [
+        {
+          label       => 'Enter check payment',
+          popup       => "edit/cust_pay.cgi?popup=1;payby=BILL;custnum=$custnum",
+          actionlabel => 'Enter check payment',
+          width       => 763,
+          height      => 392,
+          acl         => [ 'Post payment', 'Post check payment' ],
+        },
+        {
+          label       => 'Enter cash payment',
+          popup       => "edit/cust_pay.cgi?popup=1;payby=CASH;custnum=$custnum",
+          actionlabel => 'Enter cash payment',
+          width       => 763,
+          height      => 392,
+          acl         => [ 'Post payment', 'Post cash payment' ],
+        },
+        #{
+        #  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       => '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', 'Post Paypal payment', ],
+          condition   => sub { $payby{PPAL} },
+        },
+      ],
     },
+
     # realtime payments via payment.cgi
-    {
-      label       => 'Process credit card payment',
-      url         => "misc/payment.cgi?payby=CARD;custnum=$custnum",
-      acl         => [ 'Process payment', 'Process credit card payment', ],
-      condition   => sub { $payby{CARD} or $payby{DCRD} },
+    { label   => 'Process payment',
+      submenu => [
+        {
+          label       => 'Process credit card payment',
+          url         => "misc/payment.cgi?payby=CARD;custnum=$custnum",
+          acl         => [ 'Process payment', 'Process credit card payment', ],
+          condition   => sub { $payby{CARD} or $payby{DCRD} },
+        },
+        {
+          label       => 'Process electronic check payment',
+          url         => "misc/payment.cgi?payby=CHEK;custnum=$custnum",
+          acl         => [ 'Process payment', 'Process Echeck payment', ],
+          condition   => sub { $payby{CHEK} or $payby{DCHK} },
+        },
+      ],
     },
-    {
-      label       => 'Process electronic check payment',
-      url         => "misc/payment.cgi?payby=CHEK;custnum=$custnum",
-      acl         => [ 'Process payment', 'Process Echeck payment', ],
-      condition   => sub { $payby{CHEK} or $payby{DCHK} },
+
+    { label   => '-',
+      content => '-',
     },
-#separator?
+
     {
       label       => 'Enter credit',
       popup       => "edit/cust_credit.cgi?custnum=$custnum",
@@ -409,38 +432,63 @@ my @menu = (
         FS::cust_bill->count('custnum = ?', shift->custnum) > 0
       },
     },
-    {
-      label       => 'Enter check refund',
-      popup       => "edit/cust_refund.cgi?popup=1;payby=BILL;custnum=$custnum",
-      actionlabel => 'Enter check refund',
-      width       => 440,
-      acl         => ['Post refund', 'Post check refund'],
-      condition   => sub { $payby{BILL} },
-    },
-    {
-      label       => 'Enter cash refund',
-      popup       => "edit/cust_refund.cgi?popup=1;payby=CASH;custnum=$custnum",
-      actionlabel => 'Enter cash refund',
-      width       => 392,
-      acl         => ['Post refund', 'Post cash refund'],
-      condition   => sub { $payby{CASH} },
+
+    { label   => '-',
+      content => '-',
     },
-    {
-      label       => 'Enter 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   => 'Enter refund',
+      submenu => [
+
+        {
+          label       => 'Enter check refund',
+          popup       => "edit/cust_refund.cgi?popup=1;payby=BILL;custnum=$custnum",
+          actionlabel => 'Enter check refund',
+          width       => 440,
+          acl         => ['Post refund', 'Post check refund'],
+        },
+        {
+          label       => 'Enter cash refund',
+          popup       => "edit/cust_refund.cgi?popup=1;payby=CASH;custnum=$custnum",
+          actionlabel => 'Enter cash refund',
+          width       => 392,
+          acl         => ['Post refund', 'Post cash refund'],
+        },
+        #{
+        #  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       => '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
+           },
+        },
+
+      ],
+
     },
-    {
-      label       => 'Enter 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   => '-',
+      content => '-',
     },
+
     {
       label       => 'Add tax adjustment',
       popup       => "edit/cust_tax_adjustment.html?custnum=$custnum",
@@ -449,11 +497,29 @@ my @menu = (
       confexists  => 'enable_tax_adjustments',
       acl         => 'Add customer tax adjustment',
     },
-# separator, definitely
+
+    { label       => '-',
+      content     => '-',
+      confexists  => 'enable_tax_adjustments',
+      acl         => 'Add customer tax adjustment',
+    },
+
+    {
+      label       => 'Email statement to this customer',
+      url         => sub {
+                      my $cust_main = shift;
+                      my $agentnum = $cust_main->agentnum;
+                      'misc/email-customer-statement.html?table=cust_main;'.
+                      'agent_virt_agentnum='.$agentnum.";custnum=$custnum;url=".
+                      uri_escape($cgi->self_url);
+                     },
+      condition   => sub { $invoicing_list_emailonly },
+      acl         => 'Resend invoices',
+    },
     {
-      label       => 'Download statement',
+      label       => 'Download PDF statement',
       url         => "view/cust_main_statement-pdf.cgi?$custnum",
-      acl         => 'List invoices',
+      acl         => 'View legacy typeset statements',
       condition   => sub {
         FS::cust_bill->count('custnum = ?', shift->custnum) > 0
       },
@@ -482,18 +548,7 @@ my @menu = (
         FS::cust_pay_pending->count('custnum = ?', shift->custnum) > 0
       },
     },
-    {
-      label       => 'Email statement to this customer',
-      url         => sub {
-                      my $cust_main = shift;
-                      my $agentnum = $cust_main->agentnum;
-                      'misc/email-customer-statement.html?table=cust_main;search_hash='.
-                      'agent_virt_agentnum='.$agentnum.";custnum=$custnum;url=".
-                      uri_escape($cgi->self_url);
-                     },
-      condition   => sub { $invoicing_list_emailonly },
-      acl         => [ 'View invoices', 'Bulk send customer notices' ],
-    },
+
   ],
   [
     {
@@ -504,83 +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;
-
-    # check conditions
-    if ( $entry->{acl} ) {
-      next unless $curuser->access_right( $entry->{acl} );
-    }
-    if ( $entry->{confexists} ) {
-      if ( $entry->{confexists} =~ /^!(.*)/ ) {
-        # confexists => !foo, a negative condition
-        next if $conf->exists( $1 );
-      } else {
-        next unless $conf->exists( $entry->{confexists} );
-      }
-    }
-    if ( $entry->{condition} ) {
-      next unless &{ $entry->{condition} }($cust_main);
-    }
-
-    my $label = emt($entry->{label});
-    my $target = $entry->{content}
-              || $entry->{popup}
-              || $entry->{url};
-
-    if ( ref($target) eq 'CODE' ) {
-      $target = &$target($cust_main);
-    }
-    my $a = '';
-
-    if ( $entry->{content} ) { # then the coderef specified the whole thing
-      $a = $target;
-
-    } elsif ( $entry->{show} ) {
-
-      # the menu head: always a link back to this page
-      $cgi->param('show', $entry->{show});
-            $target = $cgi->self_url;
-
-      $a = qq[ <A HREF="$target"];
-      if ( $opt{'show'} eq $entry->{show} ) {
-        $a .= ' class="current_show"';
-      }
-      $a .= qq[>$label</A> ];
-
-
-    } elsif ( $entry->{popup} ) {
-
-      $target =~ s/\$custnum/$custnum/g;
-      $target = $p.$target;
-      $a = include('/elements/popup_link.html',
-        action  => $target,
-        width   => 616,
-        height  => 410,
-        %$entry,
-        label   => emt($label),
-      );
-
-    } elsif ( $entry->{url} ) {
-
-      $target =~ s/\$custnum/$custnum/g;
-      $target = $p.$target;
-      $a = qq[ <A HREF="$target">$label</A> ];
-    }
-
-    push @links, $a;
-
-  } # foreach $entry
-  if (@links) {
-    push @processed_menu, \@links;
-  }
-}
 </%init>