noalyss-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Noalyss-commit] [noalyss] 117/323: Export PDF from ANC , add a progress


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 117/323: Export PDF from ANC , add a progress_bar
Date: Wed, 14 Mar 2018 17:38:35 -0400 (EDT)

sparkyx pushed a commit to branch master
in repository noalyss.

commit 83404ed02e083aed50a7d4ffdbe0c4602ece5920
Author: Dany De Bontridder <address@hidden>
Date:   Sat Feb 3 15:28:52 2018 +0100

    Export PDF from ANC , add a progress_bar
---
 include/anc_great_ledger.inc.php          |  9 ++++++---
 include/class/document_export.class.php   | 18 +++++++++++++-----
 include/export/export_anc_receipt_pdf.php |  9 ++++++---
 3 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/include/anc_great_ledger.inc.php b/include/anc_great_ledger.inc.php
index 0ecb747..3cf291b 100644
--- a/include/anc_great_ledger.inc.php
+++ b/include/anc_great_ledger.inc.php
@@ -34,10 +34,13 @@ if ($result != null)
         echo '<span style="display:block">';
           echo _('Tout sélectionner')." 
".ICheckBox::toggle_checkbox('export_pdf_bt1','export_anc_receipt_pdf');
         echo '</span>';
+        $task_id=uniqid();
         echo $grandLivre->show_button();
-        printf ('<form method="GET" id="export_anc_receipt_pdf" 
action="export.php" style="display:inline" onsubmit="smoke.signal(\'%s\', 
function(e){}, {duration: 3000,classname: \'custom-class\'});return true;">',
-                _("Le traitement est en cours ,  merci de patienter sans 
recharger la page"));
-
+        printf ('<form method="GET" id="export_anc_receipt_pdf" 
action="export.php" style="display:inline" 
onsubmit="progress_bar_start(\'%s\',\'%s\');return true;">',
+                $task_id,
+                _("Le traitement est en cours ,  merci de patienter sans 
recharger la page")
+               );
+        echo HtmlInput::hidden("task_id",$task_id);
         echo $grandLivre->button_export_pdf();
         echo $grandLivre->display_html();
         echo $grandLivre->button_export_pdf();
diff --git a/include/class/document_export.class.php 
b/include/class/document_export.class.php
index e0a96f3..ac632dd 100644
--- a/include/class/document_export.class.php
+++ b/include/class/document_export.class.php
@@ -19,6 +19,7 @@
 
 // Copyright Author Dany De Bontridder address@hidden
 require_once NOALYSS_INCLUDE.'/class/pdf_operation.class.php';
+require_once NOALYSS_INCLUDE.'/lib/progress_bar.class.php';
 /**
  * @brief Export DOCUMENT from Analytic accountancy, can transform into PDF
  * and add a stamp on each pages
@@ -118,16 +119,20 @@ class Document_Export
      * a stamp. If an error occurs then $this->feedback won't be empty
      * @param $p_array contents all the jr_id
      */
-    function export_all($p_array)
+    function export_all($p_array, Progress_Bar $progress)
     {
         $this->check_file();
+        if ( count($p_array)==0) return;
         ob_start();
         $cnt_feedback=0;
         global $cn;
-
+        // follow progress
+        $step=round(20/count($p_array));
+        
         $cn->start();
         foreach ($p_array as $value)
         {
+            $progress->increment($step);
             // For each file save it into the temp folder,
             $file = $cn->get_array('select 
jr_pj,jr_pj_name,jr_pj_number,jr_pj_type from jrn '
                     . ' where jr_id=$1', array($value));
@@ -173,7 +178,7 @@ class Document_Export
                 continue;
             }
       
-
+             $progress->increment($step);
             // 
             // remove extension
             $ext = strrpos($filename, ".");
@@ -210,6 +215,7 @@ class Document_Export
                 }
                 rename ($this->store_convert . '/' . 
$file_pdf.'.2',$this->store_convert . '/' . $file_pdf);
             }
+            $progress->increment($step);
             // output
             $output = $this->store_convert . '/stamp_' . $file_pdf;
             
@@ -238,7 +244,7 @@ class Document_Export
             // concatenate detail operation with the output
             $stmt = PDFTK . " " . $detail_operation->get_pdf_filename()." 
".$output. 
                     ' output ' . $output2;
-
+            $progress->increment($step);
             passthru($stmt, $status);
             if ($status <> 0)
             {
@@ -258,10 +264,12 @@ class Document_Export
             // Move the PDF into another temp directory 
             $this->move_file($output, 'stamp_' . $file_pdf);
         }
-        
+        $progress->set_value(93);
         // concatenate all pdf into one
         $this->concatenate_pdf();
         
+        $progress->set_value(100);
+        
         ob_clean();
         $this->send_pdf();
 
diff --git a/include/export/export_anc_receipt_pdf.php 
b/include/export/export_anc_receipt_pdf.php
index 890f950..d6d6b47 100644
--- a/include/export/export_anc_receipt_pdf.php
+++ b/include/export/export_anc_receipt_pdf.php
@@ -23,12 +23,14 @@
 if (!defined('ALLOWED'))
     die('Appel direct ne sont pas permis');
 
-
+// unlock session
+session_write_close();
 /**
  * export all the selected documents for Ana Accountancy in PDF
  */
 require_once NOALYSS_INCLUDE.'/class/document_export.class.php';
 require_once NOALYSS_INCLUDE.'/lib/http_input.class.php';
+require_once NOALYSS_INCLUDE.'/lib/progress_bar.class.php';
 $http=new HttpInput();
 $ck = $http->get('ck',"string", 0);
 if ($ck == 0)
@@ -37,5 +39,6 @@ if ($ck == 0)
     exit();
 }
 $anc=new Document_Export();
-
-$anc->export_all($ck);
+$task_id=$http->request("task_id");
+$progress=new Progress_Bar($task_id);
+$anc->export_all($ck,$progress);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]