X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fsearch%2Fbill_batch.cgi;h=b740bdc68ac9517e3c856b7f9a79cd725efff352;hp=e5abc8955c4f99843ccf42af30253d7908ef6e45;hb=f30eaaf66cd0a947f388a03edd4522ba92a367bb;hpb=0fb307c305e4bc2c9c27dc25a3308beae3a4d33c diff --git a/httemplate/search/bill_batch.cgi b/httemplate/search/bill_batch.cgi index e5abc8955..b740bdc68 100755 --- a/httemplate/search/bill_batch.cgi +++ b/httemplate/search/bill_batch.cgi @@ -1,12 +1,40 @@ -<% include( 'elements/search.html', +% my $batchnum = $cgi->param('download'); +% if ( $batchnum =~ /^\d+$/ ) { +% my $download = $p."misc/download-bill_batch.html?$batchnum"; + +Starting download... + + + + +
+Click here if your download does not start +
+<& /elements/footer.html &> +% } +% else { +%# delete existing download cookie +% my $cookie = CGI::Cookie->new( +% -name => 'bill_batch_download', +% -value => 0, +% -expires => '-1d', +% ); +% $r->headers_out->add( 'Set-Cookie' => $cookie->as_string ); +<& elements/search.html, 'title' => 'Invoice Batches', 'name_singular' => 'batch', 'query' => { 'table' => 'bill_batch', 'hashref' => $hashref, - 'extra_sql' => $extra_sql. - 'ORDER BY batchnum DESC', + #'extra_sql' => $extra_sql. + 'order_by' => 'ORDER BY batchnum DESC', }, - 'count_query' => "$count_query $extra_sql", + 'count_query' => $count_query, 'header' => [ 'Batch', 'Item Count', 'Status', @@ -25,41 +53,78 @@ sub { $statusmap{shift->status}; }, - sub { shift->status eq 'O' ? - 'Download and close' : 'Download' - }, + \&download_link, ], 'links' => [ $link, $link, $link, - $dlink, - ], - 'style' => [ - '', - '', '', - sub { shift->status eq 'O' ? "b" : '' }, - ], + ], 'really_disable_download' => 1, - ) + 'agent_virt' => 1, + 'agent_null_right' => [ 'Process global invoice batches', 'Configuration' ], + 'agent_pos' => 1, + 'html_foot' => include('.foot'), -%> +&> +%} +<%def .foot> + + <%init> +my $curuser = $FS::CurrentUser::CurrentUser; + die "access denied" - unless $FS::CurrentUser::CurrentUser->access_right('View invoices'); + unless $curuser->access_right('Process invoice batches') + || $curuser->access_right('Process global invoice batches') + || $curuser->access_right('Configuration'); #remove in 2.5 my %statusmap = ('O'=>'Open', 'R'=>'Closed'); my $hashref = {}; -my $count_query = 'SELECT COUNT(*) FROM bill_batch'; +my $count_query = "SELECT COUNT(*) FROM bill_batch WHERE". # $extra_sql AND " + $curuser->agentnums_sql( + 'null_right' => ['Process global invoice batches', 'Configuration' ], + ); -my $extra_sql = ''; # may add something here later +#my $extra_sql = ''; # may add something here later my $link = [ "${p}view/bill_batch.cgi?batchnum=", 'batchnum' ]; -my $dlink = sub { - [ "${p}view/bill_batch.cgi?magic=print;". - (shift->status eq 'O' ? 'close=1;' : ''). - 'batchnum=', - 'batchnum'] -}; + +sub download_link { + my $batch = shift; + my $batchnum = $batch->batchnum; + my $close = ($batch->status eq 'O' ? ';close=1' : ''); + my $html = qq!
+ + + !; + $html .= include('/elements/progress-init.html', + "Download$batchnum", + [ 'batchnum', 'close' ], + $p.'misc/process/bill_batch-print.html', + { popup_url => $p."search/bill_batch.cgi?download=$batchnum" }, + "batch$batchnum" #key + ); + $html .= '' . + ($batch->status eq 'O' ? 'Download and close' : 'Download'); + $html .= '
'; + return $html; +} +