add progressbar, redirection, and improve links RT#8274
[freeside.git] / httemplate / search / cust_bill_pkg.cgi
index 2e79cd7..6a0b600 100644 (file)
@@ -7,11 +7,11 @@
                                     $unearned ? ( $money_char. '%.2f unearned revenue' ) : (),
                                   ],
                  'header'      => [
-                   '#',
+                   #'#',
                    'Description',
                    ( $unearned
-                     ? 'Unearned'
-                     : 'Setup charge'
+                     ? ( 'Unearned', 'Owed', 'Payment date' )
+                     : ( 'Setup charge' )
                    ),
                    ( $use_usage eq 'usage'
                      ? 'Usage charge'
@@ -26,7 +26,7 @@
                    FS::UI::Web::cust_header(),
                  ],
                  'fields'      => [
-                   'billpkgnum',
+                   #'billpkgnum',
                    sub { $_[0]->pkgnum > 0
                            ? $_[0]->get('pkg')      # possibly use override.pkg
                            : $_[0]->get('itemdesc') # but i think this correct
                            sprintf($money_char.'%.2f', $cust_bill_pkg->setup );
                          }
                        },
+                   ( $unearned
+                     ? ( $owed_sub, $payment_date_sub, )
+                     : ()
+                   ),
                    sub { my $row = shift;
                          my $value = 0;
                          if ( $use_usage eq 'recurring' ) {
@@ -74,6 +78,7 @@
                    #'',
                    '',
                    '',
+                   ( $unearned ? ( '', '' ) : () ),
                    '',
                    ( $unearned ? ( '', '' ) : () ),
                    $ilink,
@@ -83,7 +88,9 @@
                    ),
                  ],
                  #'align' => 'rlrrrc'.FS::UI::Web::cust_aligns(),
-                 'align' => 'lrr'.
+                 'align' => 'lr'.
+                            ( $unearned ? 'rc' : '' ).
+                            'r'.
                             ( $unearned ? 'cc' : '' ).
                             'rc'.
                             FS::UI::Web::cust_aligns(),
@@ -91,6 +98,7 @@
                               #'',
                               '',
                               '',
+                              ( $unearned ? ( '', '' ) : () ),
                               '',
                               ( $unearned ? ( '', '' ) : () ),
                               '',
                               #'',
                               '',
                               '',
+                              ( $unearned ? ( '', '' ) : () ),
                               '',
                               ( $unearned ? ( '', '' ) : () ),
                               '',
@@ -528,7 +537,6 @@ if ($use_usage) {
 } else {
   $count_query .= " FROM cust_bill_pkg $join_cust $join_pkg $where";
 }
-warn "count_query is $count_query\n";
 
 my @select = ( 'cust_bill_pkg.*',
                'cust_bill._date', );
@@ -555,4 +563,17 @@ my $clink = [ "${p}view/cust_main.cgi?", 'custnum' ];
 my $conf = new FS::Conf;
 my $money_char = $conf->config('money_char') || '$';
 
+my $owed_sub = sub {
+  $money_char. shift->owed_recur; #_recur :/
+};
+
+my $payment_date_sub = sub {
+  #my $cust_bill_pkg = shift;
+  my @cust_pay = sort { $a->_date <=> $b->_date }
+                      map $_->cust_bill_pay->cust_pay,
+                          shift->cust_bill_pay_pkg('recur') #recur :/
+    or return '';
+  time2str('%b %d %Y', $cust_pay[-1]->_date );
+};
+
 </%init>