summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FS/FS/cust_bill.pm12
-rw-r--r--httemplate/elements/header-popup.html3
-rw-r--r--httemplate/elements/progress-init.html8
-rw-r--r--httemplate/elements/progress-popup.html4
-rwxr-xr-xhttemplate/search/bill_batch.cgi2
-rw-r--r--httemplate/view/bill_batch.cgi71
6 files changed, 71 insertions, 29 deletions
diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm
index 0ba6cdf..fd3b638 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<FS::cust_bill_batch>) 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<FS::cust_bill_pkg>) for this invoice.
diff --git a/httemplate/elements/header-popup.html b/httemplate/elements/header-popup.html
index bd17d2f..d009f6b 100644
--- a/httemplate/elements/header-popup.html
+++ b/httemplate/elements/header-popup.html
@@ -27,7 +27,7 @@ Example:
<META HTTP-Equiv="Expires" Content="0">
<% $head %>
</HEAD>
- <BODY BGCOLOR="#f8f8f8" <% $etc %>>
+ <BODY <% $etc %>>
<link href="<%$fsurl%>elements/freeside.css" type="text/css" rel="stylesheet">
<FONT SIZE=6>
<CENTER><% $title |h %></CENTER>
@@ -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 <HEAD> 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 8b8da66..9f17370 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
) %>
</FORM>
<SCRIPT TYPE="text/javascript>process();</SCRIPT>
@@ -118,6 +124,8 @@ if ( ref($url_or_message) ) { #its a message or something
$url_or_message_link = 'message='. uri_escape( $url_or_message->{'message'} );
$url_or_message_link .= ';url='. uri_escape( $url_or_message->{'url'} )
if $url_or_message->{'url'};
+ $url_or_message_link = 'popup_url=' .uri_escape( $url_or_message->{'popup_url'} )
+ if $url_or_message->{'popup_url'};
} else {
$url_or_message_link = "url=$url_or_message";
}
diff --git a/httemplate/elements/progress-popup.html b/httemplate/elements/progress-popup.html
index a292102..42e4641 100644
--- a/httemplate/elements/progress-popup.html
+++ b/httemplate/elements/progress-popup.html
@@ -2,6 +2,7 @@
% my $jobnum = $cgi->param('jobnum');
% my $url = $cgi->param('url');
% my $message = $cgi->param('message');
+% my $popup_url = $cgi->param('popup_url');
% my $formname = scalar($cgi->param('formname'));
%
@@ -64,11 +65,12 @@ function updateStatus( status_statustext ) {
% } elsif ( $url ) {
window.top.location.href = '<% $url %>';
+% } elsif ( $popup_url ) {
+ document.parentWindow.location.replace('<% $popup_url %>');
% } else {
alert('job done but no url or message specified');
% }
-
} else if ( status.indexOf('done') > -1 ) {
document.getElementById("progress_message").innerHTML = "Loading report";
diff --git a/httemplate/search/bill_batch.cgi b/httemplate/search/bill_batch.cgi
index e5abc89..72e5d3a 100755
--- a/httemplate/search/bill_batch.cgi
+++ b/httemplate/search/bill_batch.cgi
@@ -57,7 +57,7 @@ my $count_query = 'SELECT COUNT(*) FROM bill_batch';
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;".
+ [ "${p}view/bill_batch.cgi?start_download=1;".
(shift->status eq 'O' ? 'close=1;' : '').
'batchnum=',
'batchnum']
diff --git a/httemplate/view/bill_batch.cgi b/httemplate/view/bill_batch.cgi
index 3fca6eb..cfd44fe 100644
--- a/httemplate/view/bill_batch.cgi
+++ b/httemplate/view/bill_batch.cgi
@@ -1,20 +1,4 @@
-% if($magic eq 'print') {
-<% include('/elements/header.html', "Download Batch") %>
-<FORM NAME="OneTrueForm">
-<INPUT TYPE="hidden" NAME="batchnum" VALUE="<% $batchnum %>">
-% $cgi->delete('magic');
-<% include('/elements/progress-init.html',
- 'OneTrueForm',
- [ 'batchnum' ],
- $p.'misc/process/bill_batch-print.html',
- {'url' => $cgi->self_url . ';magic=download'},
- '',
-) %></FORM>
-<SCRIPT TYPE="text/javascript">process();</SCRIPT>
-<% 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"' } &>
+<SCRIPT type="text/javascript">
+function start() {
+window.open('<% $cgi->self_url . ';magic=download' %>');
+parent.nd(1);
+}
+</SCRIPT>
+<TABLE WIDTH="100%"><TR><TD STYLE="text-align:center;vertical-align:middle">
+<FONT SIZE="+1">
+<A HREF="javascript:start()">Download batch #<% $batchnum %></A>
+</FONT>
+</TD></TR></TABLE>
+<& /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 = '<A HREF="'.$cgi->self_url.'">Download this batch</A><BR>';
- if($batch->status eq 'O') {
+my $html_init = '';
+my $html_foot = '';
+if ( !$magic ) {
+ $html_init .= qq!<FORM NAME="OneTrueForm">
+ <INPUT TYPE="hidden" NAME="batchnum" VALUE="$batchnum">!;
+ $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 .= '</FORM>
+<A HREF="javascript:process()">Download this batch</A></BR>';
+ if ( $batch->status eq 'O' ) {
$cgi->param('close' => 1);
- $cgi->delete('magic');
$html_init .= '<A HREF="'.$cgi->self_url.'">Close this batch</A><BR>';
}
$html_init .= '<BR>';
+ if ( $cgi->param('start_download') ) {
+ $cgi->delete('start_download');
+ $html_foot = '<SCRIPT TYPE="text/javascript">process();</SCRIPT>';
+ }
}
my $link = [ "$p/view/cust_bill.cgi?", 'invnum' ];