time/data/etc. unit pricing add-ons, RT#24392
[freeside.git] / httemplate / browse / part_pkg.cgi
index 5dee5b8..574cf7a 100755 (executable)
@@ -1,5 +1,6 @@
 <% include( 'elements/browse.html',
                  'title'                 => 'Package Definitions',
+                 'menubar'               => \@menubar,
                  'html_init'             => $html_init,
                  'html_form'             => $html_form,
                  'html_posttotal'        => $html_posttotal,
@@ -240,10 +241,10 @@ push @fields, sub {
     ],
     [
       { data =>$money_char.
-               sprintf('%.2f', $part_pkg->option('setup_fee') ),
+               sprintf('%.2f ', $part_pkg->option('setup_fee') ),
         align=>'right'
       },
-      { data => ( ( $is_recur ? ' setup' : ' one-time' ).
+      { data => ( ( $is_recur ? ' &nbsp; setup' : ' &nbsp; one-time' ).
                   ( $part_pkg->option('recur_fee') == 0
                       && $part_pkg->setup_show_zero
                     ? ' (printed on invoices)'
@@ -256,7 +257,7 @@ push @fields, sub {
     [
       { data=>(
           $is_recur
-            ? $money_char. sprintf('%.2f ', $part_pkg->option('recur_fee'))
+            ? $money_char. sprintf('%.2f', $part_pkg->option('recur_fee'))
             : $part_pkg->freq_pretty
         ),
         align=> ( $is_recur ? 'right' : 'center' ),
@@ -264,7 +265,7 @@ push @fields, sub {
       },
       ( $is_recur
         ?  { data => ( $is_recur
-               ? $part_pkg->freq_pretty.
+               ? ' &nbsp; '. $part_pkg->freq_pretty.
                  ( $part_pkg->option('recur_fee') == 0
                      && $part_pkg->recur_show_zero
                    ? ' (printed on invoices)'
@@ -276,6 +277,20 @@ push @fields, sub {
         : ()
       ),
     ],
+    (
+      map { my $amount = $_->amount / ($_->target_info->{multiplier} || 1);
+            my $label = $_->target_info->{label};
+            [
+              { data    => "Plus&nbsp;$money_char". $_->price. '&nbsp;'.
+                           ( $_->action eq 'increment' ? 'per' : 'for' ).
+                           "&nbsp;$amount&nbsp;$label",
+                align   => 'center', #left?
+                colspan => 2,
+              },
+            ];
+          }
+        $part_pkg->part_pkg_usageprice
+    ),
     ( map { my $dst_pkg = $_->dst_pkg;
             [
               { data => 'Supplemental: &nbsp;'.
@@ -517,6 +532,8 @@ push @fields,
 
               sub {
                     my $part_pkg = shift;
+                    my @part_pkg_usage = sort { $a->priority <=> $b->priority }
+                                         $part_pkg->part_pkg_usage;
 
                     [ 
                       (map {
@@ -559,7 +576,27 @@ push @fields,
                               ]
                             }
                         $part_pkg->svc_part_pkg_link
-                      )
+                      ),
+                      ( scalar(@part_pkg_usage) ? 
+                          [ { data  => 'Usage minutes',
+                              align => 'center',
+                              colspan    => 2,
+                              data_style => 'b',
+                              link  => $p.'browse/part_pkg_usage.html#pkgpart'.
+                                       $part_pkg->pkgpart 
+                            } ]
+                          : ()
+                      ),
+                      ( map {
+                              [ { data  => $_->minutes,
+                                  align => 'right'
+                                },
+                                { data  => $_->description,
+                                  align => 'left'
+                                },
+                              ]
+                            } @part_pkg_usage
+                      ),
                     ];
 
                   };
@@ -590,4 +627,9 @@ if ( $acl_edit_bulk ) {
   ) . '</FORM>';
 }
 
+my @menubar;
+# show this if there are any voip_cdr packages defined
+if ( FS::part_pkg->count("plan = 'voip_cdr'") ) {
+  push @menubar, 'Per-package usage minutes' => $p.'browse/part_pkg_usage.html';
+}
 </%init>