historical package definition feature, part 1, #16824
[freeside.git] / httemplate / browse / part_pkg.cgi
index dd20f8d..4ca78d7 100755 (executable)
@@ -45,6 +45,7 @@ my $select = '*';
 my $orderby = 'pkgpart';
 my %hash = ();
 my $extra_count = '';
+my $family_pkgpart;
 
 if ( $cgi->param('active') ) {
   $orderby = 'num_active DESC';
@@ -77,6 +78,16 @@ if ( $cgi->param('missing_recur_fee') ) {
                     )";
 }
 
+if ( $cgi->param('family') =~ /^(\d+)$/ ) {
+  $family_pkgpart = $1;
+  push @where, "family_pkgpart = $1";
+  # Hiding disabled or one-time charges and limiting by classnum aren't 
+  # very useful in this mode, so all links should still refer back to the 
+  # non-family-limited display.
+  $cgi->param('showdisabled', 1);
+  $cgi->delete('family');
+}
+
 push @where, FS::part_pkg->curuser_pkgs_sql
   unless $acl_edit_global;
 
@@ -209,6 +220,16 @@ push @fields, sub {
                   $part_pkg->part_pkg_discount;
 
   [
+    ( !$family_pkgpart &&
+      $part_pkg->pkgpart == $part_pkg->family_pkgpart ? () : [
+      {
+        'align'=> 'center',
+        'colspan' => 2,
+        'size' => '-1',
+        'data' => '<b>Show all versions</b>',
+        'link' => $p.'browse/part_pkg.cgi?family='.$part_pkg->family_pkgpart,
+      }
+    ] ),
     [
       { data =>$plan,
         align=>'center',
@@ -220,20 +241,34 @@ push @fields, sub {
                sprintf('%.2f', $part_pkg->option('setup_fee') ),
         align=>'right'
       },
-      { data => ( $is_recur ? ' setup' : ' one-time' ),
+      { data => ( ( $is_recur ? ' setup' : ' one-time' ).
+                  ( $part_pkg->option('recur_fee') == 0
+                      && $part_pkg->setup_show_zero
+                    ? ' (printed on invoices)'
+                    : ''
+                  )
+                ),
         align=>'left',
       },
     ],
     [
-      { data=>( $is_recur
-                  ? $money_char.sprintf('%.2f ', $part_pkg->option('recur_fee') )
-                  : $part_pkg->freq_pretty
-              ),
+      { data=>(
+          $is_recur
+            ? $money_char. sprintf('%.2f ', $part_pkg->option('recur_fee'))
+            : $part_pkg->freq_pretty
+        ),
         align=> ( $is_recur ? 'right' : 'center' ),
         colspan=> ( $is_recur ? 1 : 2 ),
       },
       ( $is_recur
-        ?  { data => ( $is_recur ? $part_pkg->freq_pretty : '' ),
+        ?  { data => ( $is_recur
+               ? $part_pkg->freq_pretty.
+                 ( $part_pkg->option('recur_fee') == 0
+                     && $part_pkg->recur_show_zero
+                   ? ' (printed on invoices)'
+                   : ''
+                 )
+               : '' ),
              align=>'left',
            }
         : ()