From: ivan Date: Sat, 15 Mar 2008 19:52:58 +0000 (+0000) Subject: check on invoice re-printing newest percust... can't reproduce any problem, prints... X-Git-Tag: TRIXBOX_2_6~15 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=4879d6626e33e0df7d1655cc4ee4ddaff4279218 check on invoice re-printing newest percust... can't reproduce any problem, prints newest per cust fine, closes: #3161 --- diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index 9a49574f8..0bc084d8b 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -2645,7 +2645,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; @@ -2671,16 +2671,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 ) { @@ -2790,6 +2794,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+)$/ ) { @@ -2840,7 +2849,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 9166f6dcb..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, }; }