customer link to package reports for that customer, RT#6180
[freeside.git] / httemplate / search / cust_bill.html
index 9166f6d..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 {
@@ -159,7 +161,8 @@ if ( $cgi->param('invnum') =~ /^\s*(FS-)?(\d+)\s*$/ ) {
                      FS::cust_bill->owed_sql. ' AS owed',
                      FS::cust_bill->net_sql.  ' AS net',
                    ),
-    'extra_sql' => "$extra_sql $orderby"
+    'extra_sql' => $extra_sql,
+    'order_by'  => $orderby,
   };
 
 }
@@ -187,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_ ) ). 
+} qw( print_ email_ fax_ ftp_ spool_ ) ). 
 
 '<SCRIPT TYPE="text/javascript">
 
@@ -209,18 +212,42 @@ function confirm_fax_process() {
   }
   fax_process();
 }
+function confirm_ftp_process() {
+  if ( ! confirm("Are you sure you want to re-FTP these invoices?") ) {
+    return;
+  }
+  ftp_process();
+}
+function confirm_spool_process() {
+  if ( ! confirm("Are you sure you want to re-spool these invoices?") ) {
+    return;
+  }
+  spool_process();
+}
 
 </SCRIPT>';
 
-my $menubar =  [
-                'Print these invoices' =>
-                  "javascript:confirm_print_process()",
-                'Email these invoices' =>
-                  "javascript:confirm_email_process()",
-              ];
+my $menubar = [];
+
+if ( $FS::CurrentUser::CurrentUser->access_right('Resend invoices') ) {
+
+  push @$menubar, 'Print these invoices' =>
+                    "javascript:confirm_print_process()",
+                  'Email these invoices' =>
+                    "javascript:confirm_email_process()";
 
-push @$menubar, 'Fax these invoices' =>
-                 "javascript:confirm_fax_process()"
- if $conf->exists('hylafax');
+  push @$menubar, 'Fax these invoices' =>
+                    "javascript:confirm_fax_process()"
+    if $conf->exists('hylafax');
+
+  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>