X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fmisc%2Fdownload-batch.cgi;h=c59ba9d370c35bd7c1ef2c3938894f613e3001eb;hb=4021a65b46491615b8577335ab93d4a2eab34c46;hp=23deba712e76c6ad276be4b3b2a73fdc38b67af2;hpb=0fb307c305e4bc2c9c27dc25a3308beae3a4d33c;p=freeside.git diff --git a/httemplate/misc/download-batch.cgi b/httemplate/misc/download-batch.cgi index 23deba712..c59ba9d37 100644 --- a/httemplate/misc/download-batch.cgi +++ b/httemplate/misc/download-batch.cgi @@ -1,21 +1,31 @@ -<% $pay_batch->export_batch($format) %><%init> +<% $pay_batch->export_batch(%opt) %><%init> #http_header('Content-Type' => 'text/comma-separated-values' ); #IE chokes http_header('Content-Type' => 'text/plain' ); # not necessarily correct... my $batchnum; + if ( $cgi->param('batchnum') =~ /^(\d+)$/ ) { $batchnum = $1; } else { die "No batch number (bad URL) \n"; } -my $format; -if ( $cgi->param('format') =~ /^([\w\- ]+)$/ ) { - $format = $1; +my %opt; +if ( $cgi->param('gatewaynum') =~ /^(\d+)$/ ) { + my $gateway = FS::payment_gateway->by_key($1); + die "gatewaynum $1 not found" unless $gateway; + $opt{'gateway'} = $gateway; +} +elsif ( $cgi->param('format') =~ /^([\w\- ]+)$/ ) { + $opt{'format'} = $1; } -my $pay_batch = qsearchs('pay_batch', { batchnum => $batchnum } ); +my $credit_transactions = "EXISTS (SELECT 1 FROM cust_pay_batch WHERE batchnum = $batchnum AND paycode = 'C') AS arecredits"; +my $pay_batch = qsearchs({ 'select' => "*, $credit_transactions", + 'table' => 'pay_batch', + 'hashref' => { batchnum => $batchnum }, + }); die "Batch not found: '$batchnum'" if !$pay_batch;