phpcompta-dev
[Top][All Lists]
Advanced

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

[Phpcompta-dev] r629 - in trunk/rapport_avance: . include


From: phpcompta-dev
Subject: [Phpcompta-dev] r629 - in trunk/rapport_avance: . include
Date: Fri, 20 Dec 2013 12:24:24 +0100 (CET)

Author: danydb
Date: 2013-12-20 12:24:24 +0100 (Fri, 20 Dec 2013)
New Revision: 629

Modified:
   trunk/rapport_avance/include/class_rapav_listing_compute.php
   trunk/rapport_avance/raw.php
Log:
Task #0000944: Listing : Propose de t?\195?\169l?\195?\169charger tous les 
documents dans un ZIP
Task #944 - Listing : Propose de  t?\195?\169l?\195?\169charger tous les 
documents dans un ZIP

Modified: trunk/rapport_avance/include/class_rapav_listing_compute.php
===================================================================
--- trunk/rapport_avance/include/class_rapav_listing_compute.php        
2013-12-20 10:32:23 UTC (rev 628)
+++ trunk/rapport_avance/include/class_rapav_listing_compute.php        
2013-12-20 11:24:24 UTC (rev 629)
@@ -451,4 +451,41 @@
         $cn->commit();
         return $a_result;
     }
+    function create_zip()
+    {
+        global $cn;
+        $ofiche = new RAPAV_Listing_Compute_Fiche();
+        $r_fiche = $ofiche->seek(" where 
+                coalesce(lf_filename,'') <> '' 
+                and lc_id = $1", array($this->data->lc_id));
+        $nb_fiche = Database::num_row($r_fiche);
+        // -- no doc to download
+        if ($nb_fiche == 0)
+            return "";
+
+        $dirname = tempnam($_ENV['TMP'],'download_');
+        unlink($dirname);
+        mkdir($dirname);
+
+        /* For each card */
+        $cn->start();
+        for ($i = 0; $i < $nb_fiche; $i++)
+        {
+            $fiche = $ofiche->next($r_fiche, $i);
+            $file = $dirname . '/' . $fiche->lf_filename;
+            $cn->lo_export($fiche->lf_lob, $file);
+        }
+        $zip = new Zip_Extended;
+        $file_download = $_ENV['TMP'].'/all_document-' . microtime(true) . 
".zip";
+        $res = $zip->open($file_download, ZipArchive::CREATE);
+        if ($res !== TRUE)
+        {
+            echo __FILE__ . ":" . __LINE__ . "cannot recreate zip";
+            exit;
+        }
+        $zip->add_recurse_folder($dirname . DIRECTORY_SEPARATOR);
+        $zip->close();
+        $cn->commit();
+        return $file_download;
+    }
 }

Modified: trunk/rapport_avance/raw.php
===================================================================
--- trunk/rapport_avance/raw.php        2013-12-20 10:32:23 UTC (rev 628)
+++ trunk/rapport_avance/raw.php        2013-12-20 11:24:24 UTC (rev 629)
@@ -233,5 +233,26 @@
 
        $cn->commit();
 }
+if ($act == 'export_download_all')
+{
+    $compute = new RAPAV_Listing_compute();
+    $compute->load($_GET['lc_id']);
+    $filename = $compute->create_zip();
+    if ($filename == "") exit();
+    ini_set('zlib.output_compression', 'Off');
+    header("Pragma: public");
+    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
+    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
+    header("Cache-Control: must-revalidate");
+    header('Content-type: application/zip');
+    header('Content-Disposition: attachment;filename="' . $filename.'"' , 
FALSE);
+    header("Accept-Ranges: bytes");
+    $file = fopen($filename, 'r');
+    while (!feof($file))
+        echo fread($file, 8192);
 
+    fclose($file);
+
+    unlink($filename);
+}
 ?>



---
PhpCompta est un logiciel de comptabilité libre en ligne (full web)
Projet opensource http://www.phpcompta.eu



reply via email to

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