From: mark Date: Fri, 27 May 2011 01:11:02 +0000 (+0000) Subject: invoice batch download fix, #11871 X-Git-Tag: freeside_2_3_0~202 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=82879083dd2efddf02192ad48ad0e46e1a16662b invoice batch download fix, #11871 --- diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index 0ba6cdfed..fd3b63820 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -245,6 +245,7 @@ sub delete { cust_pay_batch cust_bill_pay_batch cust_bill_pkg + cust_bill_batch )) { foreach my $linked ( $self->$table() ) { @@ -733,6 +734,17 @@ sub cust_credit_bill_pkg { } +=item cust_bill_batch + +Returns all invoice batch records (L) for this invoice. + +=cut + +sub cust_bill_batch { + my $self = shift; + qsearch('cust_bill_batch', { 'invnum' => $self->invnum }); +} + =item tax Returns the tax amount (see L) for this invoice. diff --git a/httemplate/elements/header-popup.html b/httemplate/elements/header-popup.html index bd17d2f7d..d009f6b04 100644 --- a/httemplate/elements/header-popup.html +++ b/httemplate/elements/header-popup.html @@ -27,7 +27,7 @@ Example: <% $head %> - > + >
<% $title |h %>
@@ -55,6 +55,7 @@ if ( ref($_[0]) ) { $etc = @_ ? shift : ''; #$etc is for things like onLoad= etc. $head = @_ ? shift : ''; #$head is for things that go in the section } +$etc .= 'BGCOLOR="#f8f8f8"' if (! $etc =~ /BGCOLOR/i ); my $conf = new FS::Conf; diff --git a/httemplate/elements/progress-init.html b/httemplate/elements/progress-init.html index 8b8da66c8..9f17370db 100644 --- a/httemplate/elements/progress-init.html +++ b/httemplate/elements/progress-init.html @@ -11,6 +11,12 @@ In misc/something.html: $p.'misc/process_something.html', { url => $p.'where_to_go_next.html' }, #or { message => 'Finished!' }, + #or { url => $p.'where_to_go.html', + message => 'Finished' }, + # which displays the message, then waits for confirmation before + # redirecting to the URL. + #or { popup_url => $p.'popup_contents.html' } + # which loads that URL into the popup after completion ) %> -<% include('/elements/footer.html') %> -% } -% -% elsif($magic eq 'download') { +% if($magic eq 'download') { % $m->clear_buffer; % $r->content_type('application/pdf'); % $r->headers_out->add('Content-Disposition' => 'attachment;filename="invoice_batch_'.$batchnum.'.pdf"'); @@ -23,6 +7,26 @@ % my $error = $batch->replace; % warn "error deleting cached PDF: '$error'\n" if $error; % } +% +% elsif ($magic eq 'download_popup') { +% +<& /elements/header-popup.html, + { 'etc' => 'BGCOLOR="#ccccff"' } &> + +
+ +Download batch #<% $batchnum %> + +
+<& /elements/footer.html &> +% +% } +% % else { <% include('/search/elements/search.html', 'title' => $close ? @@ -39,11 +43,11 @@ 'addl_from' => 'LEFT JOIN cust_bill USING ( invnum ) '. 'LEFT JOIN cust_main USING ( custnum )', - 'extra_sql' => '', - " WHERE batchnum = $batchnum", + 'extra_sql' => " WHERE batchnum = $batchnum", }, 'count_query' => "SELECT COUNT(*) FROM cust_bill_batch WHERE batchnum = $batchnum", 'html_init' => $html_init, + 'html_foot' => $html_foot, 'header' => [ 'Invoice #', 'Amount', 'Date', @@ -75,21 +79,36 @@ $batch = FS::bill_batch->by_key($batchnum); die "Batch '$batchnum' not found!\n" if !$batch; my $magic = $cgi->param('magic'); -my $html_init = ''; +$cgi->delete('magic'); my $close = $cgi->param('close'); $batch->close if $close; -if(!$magic) { - $cgi->param('magic' => 'print'); - $cgi->delete('close'); - $html_init = 'Download this batch
'; - if($batch->status eq 'O') { +my $html_init = ''; +my $html_foot = ''; +if ( !$magic ) { + $html_init .= qq!
+ !; + $html_init .= include('/elements/progress-init.html', + 'OneTrueForm', + [ 'batchnum' ], + $p.'misc/process/bill_batch-print.html', + { + 'popup_url' => $cgi->self_url . ';magic=download_popup', + }, + '', + ); + $html_init .= '
+Download this batch
'; + if ( $batch->status eq 'O' ) { $cgi->param('close' => 1); - $cgi->delete('magic'); $html_init .= 'Close this batch
'; } $html_init .= '
'; + if ( $cgi->param('start_download') ) { + $cgi->delete('start_download'); + $html_foot = ''; + } } my $link = [ "$p/view/cust_bill.cgi?", 'invnum' ];