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;
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 ) {
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+)$/ ) {
}
- 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 );
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,
};
}
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>