[freeside-commits] freeside/httemplate/search bill_batch.cgi, 1.3, 1.3.2.1

Mark Wells mark at wavetail.420.am
Sat Jul 30 16:14:25 PDT 2011


Update of /home/cvs/cvsroot/freeside/httemplate/search
In directory wavetail.420.am:/tmp/cvs-serv19639/httemplate/search

Modified Files:
      Tag: FREESIDE_2_3_BRANCH
	bill_batch.cgi 
Log Message:
rearrange flow of batch download, #947

Index: bill_batch.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/bill_batch.cgi,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -u -w -d -r1.3 -r1.3.2.1
--- bill_batch.cgi	20 Jul 2011 18:34:19 -0000	1.3
+++ bill_batch.cgi	30 Jul 2011 23:14:23 -0000	1.3.2.1
@@ -1,3 +1,18 @@
+% my $batchnum = $cgi->param('download');
+% if ( $batchnum =~ /^\d+$/ ) {
+%   $cgi->delete('download');
+<HTML>
+<HEAD><TITLE>Starting download...</TITLE>
+<SCRIPT TYPE="text/javascript">
+function refreshParent() {
+  window.top.setTimeout("window.top.location.href = '<% $cgi->self_url %>'", 2000);
+  window.top.location.replace('<%$p%>misc/download-bill_batch.html?<%$batchnum%>');
+}
+</SCRIPT>
+</HEAD><BODY onload="refreshParent();">
+<& /elements/footer.html &>
+% }
+% else {
 <% include( 'elements/search.html',
                  'title'         => 'Invoice Batches',
 		 'name_singular' => 'batch',
@@ -25,21 +40,13 @@
 				      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,
@@ -49,6 +56,7 @@
       )
 
 %>
+%}
 <%init>
 
 my $curuser = $FS::CurrentUser::CurrentUser;
@@ -67,10 +75,28 @@
 
 #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?start_download=1;".
-      (shift->status eq 'O' ? 'close=1;' : '').
-      'batchnum=',
-    'batchnum'] 
-};
+
+my $download_id = int(rand(1000000));
+
+sub download_link {
+  my $batch = shift;
+  my $batchnum = $batch->batchnum;
+  my $close = ($batch->status eq 'O' ? ';close=1' : '');
+  my $html = qq!<FORM NAME="Download$batchnum" STYLE="display:inline">
+  <INPUT TYPE="hidden" NAME="batchnum" VALUE="$batchnum">
+  <INPUT TYPE="hidden" NAME="close" VALUE="1">
+  !;
+  $html .= include('/elements/progress-init.html',
+    "Download$batchnum",
+    [ 'batchnum', 'close' ],
+    $p.'misc/process/bill_batch-print.html',
+    { url => $p."search/bill_batch.cgi?download=$batchnum" },
+    "batch$batchnum" #key
+  );
+  $html .= '<A href="#" onclick="batch'.$batchnum.'process();">' .
+  ($batch->status eq 'O' ? '<B>Download and close</B>' : 'Download');
+  $html .= '</A></FORM>';
+  return $html;
+}
+
 </%init>



More information about the freeside-commits mailing list