noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 05/15: NEW #0001886: ANC/ANCIMP/ANCGL >> Expo


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 05/15: NEW #0001886: ANC/ANCIMP/ANCGL >> Export PDF
Date: Mon, 25 Jan 2021 18:56:20 -0500 (EST)

sparkyx pushed a commit to branch master
in repository noalyss.

commit 293055b621d45a44fc59773e308b7e5f4d42cb32
Author: sparkyx <danydb@noalyss.eu>
AuthorDate: Fri Jan 22 18:33:16 2021 +0100

    NEW #0001886: ANC/ANCIMP/ANCGL >> Export PDF
---
 include/anc_great_ledger.inc.php          | 22 +++++++-----
 include/class/anc_grandlivre.class.php    | 18 ++++------
 include/class/document_export.class.php   | 60 +++++++++++++++++++++++++++----
 include/export/export_anc_receipt_pdf.php |  5 ++-
 4 files changed, 78 insertions(+), 27 deletions(-)

diff --git a/include/anc_great_ledger.inc.php b/include/anc_great_ledger.inc.php
index cfec336..c79f15e 100644
--- a/include/anc_great_ledger.inc.php
+++ b/include/anc_great_ledger.inc.php
@@ -10,7 +10,7 @@ if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas 
permis');
 echo '<div style="content">';
 global $http;
 require_once NOALYSS_INCLUDE.'/class/anc_grandlivre.class.php';
-
+$cn=Dossier::connect();
 $grandLivre=new Anc_Grandlivre($cn);
 
 $grandLivre->get_request();
@@ -35,18 +35,24 @@ if ($result != null)
           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="return 
start_export_anc_receipt_pdf(\'%s\',\'%s\');">',
-                $task_id,
-                _("Le traitement est en cours ,  merci de patienter sans 
recharger la page")
-               );
+        echo $grandLivre->button_export_csv();
+        printf ('<form method="GET" id="export_anc_receipt_pdf" 
action="export.php" 
+            style="display:inline" onsubmit="return 
start_export_anc_receipt_pdf(\'%s\',\'%s\');">',
+            $task_id,
+            _("Le traitement est en cours ,  merci de patienter sans recharger 
la page")
+            );
         echo HtmlInput::hidden("task_id",$task_id);
+        $type_pdf=new Select_Box("type_pdf",_("Type export PDF"));
+        $type_pdf->add_value(_("Un seul PDF"),1);
+        $type_pdf->add_value(_("Un PDF par opération"),2);
+        echo $type_pdf->input();
+
         echo $grandLivre->button_export_pdf();
         echo $grandLivre->display_html();
-        echo $grandLivre->button_export_pdf();
         echo HtmlInput::get_to_hidden(array('ac','gDossier','sa'));
+        echo $grandLivre->button_export_pdf();
         echo '</form>';
-        echo $grandLivre->show_button();
+        echo $grandLivre->button_export_csv();
         ?>
 <script>
     function start_export_anc_receipt_pdf(p_task_id,p_message)
diff --git a/include/class/anc_grandlivre.class.php 
b/include/class/anc_grandlivre.class.php
index f6f8aad..d6a0fe7 100644
--- a/include/class/anc_grandlivre.class.php
+++ b/include/class/anc_grandlivre.class.php
@@ -24,6 +24,7 @@
  */
 require_once NOALYSS_INCLUDE.'/class/anc_print.class.php';
 require_once NOALYSS_INCLUDE.'/lib/impress.class.php';
+require_once NOALYSS_INCLUDE."/lib/select_box.class.php";
 
 class Anc_GrandLivre extends Anc_Print
 {
@@ -162,7 +163,7 @@ class Anc_GrandLivre extends Anc_Print
     {
         if (CONVERT_GIF_PDF <> 'NOT' && PDFTK <> 'NOT')
         {
-            $r = "";
+            $r="";
             $r.= HtmlInput::hidden("to", $this->to);
             $r.= HtmlInput::hidden("from", $this->from);
             $r.= HtmlInput::hidden("pa_id", $this->pa_id);
@@ -201,7 +202,7 @@ class Anc_GrandLivre extends Anc_Print
         {
             return 0;
         }
-        $r.= '<table class="result" style="width:100%">';
+        $r.= '<table class="result" 
style="width:100%;border-color:transparent">';
         $ix = 0;
         $prev = 'xx';
         $idx = 0;
@@ -220,7 +221,7 @@ class Anc_GrandLivre extends Anc_Print
                    $r.=td('') . td('') . td('');
                     $r.=td('') . td('') . td('') . td('') . td('') . 
td(nbm($tot_deb), ' class="num"') . td(nbm($tot_cred), ' class="num"') . 
td(nbm($tot_solde) . $sign, ' class="num"');
                 }
-                $r.='<tr>' . '<td colspan="7" style="width:auto">' . '<h2>' . 
h($row['po_name'] . ' ' . $row['po_description']) . '</td></tr>';
+                $r.='<tr>' . '<td colspan="12" style="width:auto">' . '<h2>' . 
h($row['po_name'] . ' ' . $row['po_description']) . '</td></tr>';
                 $r.= '<tr>' .
                         '<th>' . '</th>' .
                         '<th>' . _('Date') . '</th>' .
@@ -304,15 +305,10 @@ class Anc_GrandLivre extends Anc_Print
         return $r;
     }
       /*!
-     * \brief Show the button to export in PDF or CSV
-     * \param $url_csv url of the csv
-     * \param $url_pdf url of the pdf
-     * \param $p_string hidden data to include in the form
-     *
-     *
+     * \brief Show the button to export  CSV
      * \return string with the button
      */
-    function show_button($p_string="")
+    function button_export_csv($p_string="")
     {
         $r="";
         $r.= '<form method="GET" action="export.php"  style="display:inline">';
@@ -324,7 +320,7 @@ class Anc_GrandLivre extends Anc_Print
         $r.= HtmlInput::hidden("to_poste",$this->to_poste);
         $r.= $p_string;
         $r.= dossier::hidden();
-        $r.=HtmlInput::submit('bt_csv',"Export en CSV");
+        $r.=HtmlInput::submit('bt_csv',_("Export en CSV"));
         $r.= '</form>';
         return $r;
     }
diff --git a/include/class/document_export.class.php 
b/include/class/document_export.class.php
index 66d5382..3b36d98 100644
--- a/include/class/document_export.class.php
+++ b/include/class/document_export.class.php
@@ -78,6 +78,29 @@ class Document_Export
         }
     }
 
+    /**
+     * Make a zip file
+     */
+    function make_zip()
+    {
+        $zip=new Zip_Extended();
+        $res=$zip->open("{$this->store_pdf}/result.zip",ZipArchive::CREATE);
+        if ($res !== true) {
+            error_log("DE89 cannot create zip file");
+            throw new Exception ( __FILE__.":".__LINE__."cannot recreate zip");
+        }
+        chdir($this->store_pdf);
+        $zip->addGlob("stamp*pdf");
+        $zip->close();
+
+    }
+    /**
+     * copy the file
+     * @param $p_source
+     * @param $target
+     * @throws Exception
+     */
+
     function move_file($p_source, $target)
     {
         $this->check_file();
@@ -95,6 +118,17 @@ class Document_Export
         echo file_get_contents($this->store_pdf . '/result.pdf');
     }
     /**
+     * @brief send the resulting PDF to the browser
+     */
+    function send_zip()
+    {
+        header('Content-Type: application/x-download');
+        header('Content-Disposition: attachment; filename="result.zip"');
+        header('Cache-Control: private, max-age=0, must-revalidate');
+        header('Pragma: public');
+        echo file_get_contents($this->store_pdf . '/result.zip');
+    }
+    /**
      * @brief remove folder and its content
      */
     function clean_folder()
@@ -118,8 +152,10 @@ class Document_Export
      * @brief export all the pieces in PDF and transform them into a PDF with
      * a stamp. If an error occurs then $this->feedback won't be empty
      * @param $p_array contents all the jr_id
+     * @param Progress_Bar $progress is the progress bar
+     * @param int $p_separate 1 everything in a single PDF or a ZIP with all 
PDF
      */
-    function export_all($p_array, Progress_Bar $progress)
+    function export_all($p_array, Progress_Bar $progress,$p_separate=1)
     {
         $this->check_file();
         if ( count($p_array)==0) return;
@@ -268,12 +304,21 @@ class Document_Export
         }
         
         $progress->set_value(93);
-        // concatenate all pdf into one
-        $this->concatenate_pdf();
-        
-        
-        ob_clean();
-        $this->send_pdf();
+
+        if ( $p_separate == 1) {
+            // concatenate all pdf into one
+            $this->concatenate_pdf();
+
+
+            ob_clean();
+            $this->send_pdf();
+
+        } else {
+            // Put all PDF In a zip file
+            $this->make_zip();
+            ob_clean();
+            $this->send_zip();
+        }
 
         $progress->set_value(100);
         // remove files from "conversion folder"
@@ -299,4 +344,5 @@ class Document_Export
             throw ($ex);
         }
     }
+
 }
diff --git a/include/export/export_anc_receipt_pdf.php 
b/include/export/export_anc_receipt_pdf.php
index d6d6b47..0c6e525 100644
--- a/include/export/export_anc_receipt_pdf.php
+++ b/include/export/export_anc_receipt_pdf.php
@@ -39,6 +39,9 @@ if ($ck == 0)
     exit();
 }
 $anc=new Document_Export();
+$type_pdf=$http->get("type_pdf","number",1);
+
 $task_id=$http->request("task_id");
 $progress=new Progress_Bar($task_id);
-$anc->export_all($ck,$progress);
+$anc->export_all($ck,$progress,$type_pdf);
+



reply via email to

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