customer link to package reports for that customer, RT#6180
[freeside.git] / httemplate / search / cust_bill.html
index d22c744..751bef6 100755 (executable)
@@ -15,7 +15,7 @@
                                     FS::UI::Web::cust_header(),
                                   ],
                  'fields'      => [
-                   'invnum',
+                   'display_invnum',
                    sub { sprintf($money_char.'%.2f', shift->get('owed') ) },
                    sub { sprintf($money_char.'%.2f', shift->get('net') ) },
                    sub { sprintf($money_char.'%.2f', shift->charged     ) },
@@ -69,15 +69,17 @@ my %search;
 
 if ( $cgi->param('invnum') =~ /^\s*(FS-)?(\d+)\s*$/ ) {
 
-  $count_query =
-    "SELECT COUNT(*) FROM cust_bill $join_cust_main".
-    "  WHERE invnum = $2 AND $agentnums_sql"; #agent virtualization
+  my $invnum_or_invid = "( invnum = $2 OR agent_invid = $2 )";
+  my $where = "WHERE $invnum_or_invid AND $agentnums_sql";
+  
+  $count_query = "SELECT COUNT(*) FROM cust_bill $join_cust_main $where";
+
   $sql_query = {
+    #'select'    => '*',
     'table'     => 'cust_bill',
     'addl_from' => $join_cust_main,
-    'hashref'   => { 'invnum' => $2 },
-    #'select'    => '*',
-    'extra_sql' => " AND $agentnums_sql", #agent virtualization
+    'hashref'   => {},
+    'extra_sql' => $where,
   };
 
 } else {
@@ -188,7 +190,7 @@ my $html_init = join("\n", map {
  qq!<FORM NAME="${_}form">!,
  ( map qq!<INPUT TYPE="hidden" NAME="$_" VALUE="$search{$_}">!, keys %search ),
  qq!</FORM>!
-} qw( print_ email_ fax_ ftp_ ) ). 
+} qw( print_ email_ fax_ ftp_ spool_ ) ). 
 
 '<SCRIPT TYPE="text/javascript">
 
@@ -216,6 +218,12 @@ function confirm_ftp_process() {
   }
   ftp_process();
 }
+function confirm_spool_process() {
+  if ( ! confirm("Are you sure you want to re-spool these invoices?") ) {
+    return;
+  }
+  spool_process();
+}
 
 </SCRIPT>';
 
@@ -235,6 +243,11 @@ if ( $FS::CurrentUser::CurrentUser->access_right('Resend invoices') ) {
   push @$menubar, 'FTP these invoices' =>
                     "javascript:confirm_ftp_process()"
     if $conf->exists('cust_bill-ftpformat');
+
+  push @$menubar, 'Spool these invoices' =>
+                    "javascript:confirm_spool_process()"
+    if $conf->exists('cust_bill-spoolformat');
+
 }
 
 </%init>