summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorivan <ivan>2008-03-15 19:53:00 +0000
committerivan <ivan>2008-03-15 19:53:00 +0000
commit8bd2ad71aef6e393425ddf8f959f02e69aec4a61 (patch)
treed432b6908bf8232d42d627ddc426e74a6a65cde0 /FS
parent05bb22caa2c2c32bc7f40bcdc3f0c1f88e3d7b1e (diff)
check on invoice re-printing newest percust... can't reproduce any problem, prints newest per cust fine, closes: #3161
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/cust_bill.pm46
1 files changed, 35 insertions, 11 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 );