diff options
| -rw-r--r-- | FS/FS/cust_bill.pm | 46 | ||||
| -rwxr-xr-x | httemplate/search/cust_bill.html | 34 | 
2 files changed, 64 insertions, 16 deletions
| diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index 1d76f806a..3c6963284 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -2570,7 +2570,7 @@ use Data::Dumper;  use MIME::Base64;  sub process_re_X {    my( $method, $job ) = ( shift, shift ); -  warn "process_re_X $method for job $job\n" if $DEBUG; +  warn "$me process_re_X $method for job $job\n" if $DEBUG;    my $param = thaw(decode_base64(shift));    warn Dumper($param) if $DEBUG; @@ -2596,16 +2596,20 @@ sub re_X {    my $extra_sql = ' WHERE '. FS::cust_bill->search_sql(\%param); -  my $addl_from = 'left join cust_main using ( custnum )'; +  my $addl_from = 'LEFT JOIN cust_main USING ( custnum )'; -  my @cust_bill = qsearch( 'cust_bill', -                           {}, -                           #"$distinct cust_bill.*", -                           "cust_bill.*", -                           $extra_sql, -                           '', -                           $addl_from -                         ); +  my @cust_bill = qsearch( { +    #'select'    => "cust_bill.*", +    'table'     => 'cust_bill', +    'addl_from' => $addl_from, +    'hashref'   => {}, +    'extra_sql' => $extra_sql, +    'order_by'  => $orderby, +    'debug' => 1, +  } ); + +  warn " $me re_X $method: ". scalar(@cust_bill). " invoices found\n" +    if $DEBUG;    my( $num, $last, $min_sec ) = (0, time, 5); #progresbar foo    foreach my $cust_bill ( @cust_bill ) { @@ -2715,6 +2719,11 @@ Note: validates all passed-in data; i.e. safe to use with unchecked CGI params.  sub search_sql {    my($class, $param) = @_; +  if ( $DEBUG ) { +    warn "$me search_sql called with params: \n". +         join("\n", map { "  $_: ". $param->{$_} } keys %$param ). "\n"; +  } +    my @search = ();    if ( $param->{'begin'} =~ /^(\d+)$/ ) { @@ -2765,7 +2774,22 @@ sub search_sql {    } -  push @search, $FS::CurrentUser::CurrentUser->agentnums_sql; +  my $curuser = $FS::CurrentUser::CurrentUser; +  if ( $curuser->username eq 'fs_queue' +       && $param->{'CurrentUser'} =~ /^(\w+)$/ ) { +    my $username = $1; +    my $newuser = qsearchs('access_user', { +      'username' => $username, +      'disabled' => '', +    } ); +    if ( $newuser ) { +      $curuser = $newuser; +    } else { +      warn "$me WARNING: (fs_queue) can't find CurrentUser $username\n"; +    } +  } + +  push @search, $curuser->agentnums_sql;    join(' AND ', @search ); diff --git a/httemplate/search/cust_bill.html b/httemplate/search/cust_bill.html index 4f0585d0c..25a7ea051 100755 --- a/httemplate/search/cust_bill.html +++ b/httemplate/search/cust_bill.html @@ -159,7 +159,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,17 +188,40 @@ 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_ ) ).  + +'<SCRIPT TYPE="text/javascript"> + +function confirm_print_process() { +  if ( ! confirm("Are you sure you want to reprint these invoices?") ) { +    return; +  } +  print_process(); +} +function confirm_email_process() { +  if ( ! confirm("Are you sure you want to re-email these invoices?") ) { +    return; +  } +  email_process(); +} +function confirm_fax_process() { +  if ( ! confirm("Are you sure you want to re-fax these invoices?") ) { +    return; +  } +  fax_process(); +} + +</SCRIPT>';  my $menubar =  [                  'Print these invoices' => -                  "javascript:print_process()", +                  "javascript:confirm_print_process()",                  'Email these invoices' => -                  "javascript:email_process()", +                  "javascript:confirm_email_process()",                ];  push @$menubar, 'Fax these invoices' => -                 "javascript:fax_process()" +                 "javascript:confirm_fax_process()"   if $conf->exists('hylafax');  </%init> | 
