fix null option with placeholders
[freeside.git] / httemplate / browse / part_pkg.cgi
index 886c6c8..d9b90cf 100755 (executable)
@@ -4,11 +4,11 @@
                  'html_posttotal'        => $html_posttotal,
                  'name'                  => 'package definitions',
                  'disableable'           => 1,
-                 'disabled_statuspos'    => 3,
+                 'disabled_statuspos'    => 4,
                  'agent_virt'            => 1,
                  'agent_null_right'      => [ $edit, $edit_global ],
                  'agent_null_right_link' => $edit_global,
-                 'agent_pos'             => 5,
+                 'agent_pos'             => 6,
                  'query'                 => { 'select'    => $select,
                                               'table'     => 'part_pkg',
                                               'hashref'   => \%hash,
@@ -57,7 +57,7 @@ my @where = ();
 
 if ( $cgi->param('recurring') ) {
   $hash{'freq'} = { op=>'!=', value=>'0' };
-  $extra_count = ' freq != 0 ';
+  $extra_count = " freq != '0' ";
 }
 
 my $classnum = '';
@@ -96,8 +96,15 @@ $select = "
   *,
 
   ( $count_cust_pkg
+      AND ( setup  IS NULL OR cancel = 0 )
       AND ( cancel IS NULL OR cancel = 0 )
-      AND ( susp IS NULL OR susp = 0 )
+      AND ( susp   IS NULL OR susp   = 0 )
+  ) AS num_not_yet_billed,
+
+  ( $count_cust_pkg
+      AND setup IS NOT NULL AND setup != 0
+      AND ( cancel IS NULL OR cancel = 0 )
+      AND ( susp   IS NULL OR susp   = 0 )
   ) AS num_active,
 
   ( $count_cust_pkg
@@ -152,14 +159,24 @@ my $html_posttotal =
          ).
   ' )';
 
+my $recur_toggle = $cgi->param('recurring') ? 'show' : 'hide';
+$cgi->param('recurring', $cgi->param('recurring') ^ 1 );
+
+$html_posttotal .=
+  '( <A HREF="'. $cgi->self_url.'">'. "$recur_toggle one-time charges</A> )";
+
+$cgi->param('recurring', $cgi->param('recurring') ^ 1 ); #put it back
+
 # ------
 
 my $link = [ $p.'edit/part_pkg.cgi?', 'pkgpart' ];
 
-my @header = ( '#', 'Package', 'Comment' );
-my @fields = ( 'pkgpart', 'pkg', 'comment' );
-my $align = 'rll';
-my @links = ( $link, $link, '' );
+my @header = ( '#', 'Package', 'Comment', 'Custom' );
+my @fields = ( 'pkgpart', 'pkg', 'comment',
+               sub{ '<B><FONT COLOR="#0000CC">'.$_[0]->custom.'</FONT></B>' }
+             );
+my $align = 'rllc';
+my @links = ( $link, $link, '', '' );
 
 unless ( 0 ) { #already showing only one class or something?
   push @header, 'Class';
@@ -273,6 +290,8 @@ if ( $acl_edit_global ) {
     'cancelled'       => 'FF0000',
     #'one-time charge' => '000000',
     'charge'          => '000000',
+    #'not yet billed'  => '000000',
+    'not&nbsp;yet&nbsp;billed'  => '000000',
   );
   my $cust_pkg_link = $p. 'search/cust_pkg.cgi?pkgpart=';
   push @fields, sub { my $part_pkg = shift;
@@ -284,6 +303,8 @@ if ( $acl_edit_global ) {
                                 $magic = 'inactive';
                                 #$label = 'one-time charge',
                                 $label = 'charge',
+                              } else {
+                                $label =~ s/_/&nbsp;/g;
                               }
                           
                               [
@@ -309,7 +330,7 @@ if ( $acl_edit_global ) {
                                             ),
                                 },
                               ],
-                            } (qw( active suspended cancelled ))
+                            } qw(not_yet_billed active suspended cancelled)
                       ]; };
   $align .= 'r';
 #}