noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 05/07: Task #0002164 : rename receipt also fo


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 05/07: Task #0002164 : rename receipt also for analytical accountancy
Date: Sat, 27 Aug 2022 08:03:46 -0400 (EDT)

sparkyx pushed a commit to branch master
in repository noalyss.

commit fb893104f259a13ed206222c04d10dd45079ac2b
Author: sparkyx <danydb@noalyss.eu>
AuthorDate: Thu Aug 25 15:21:45 2022 +0200

    Task #0002164 : rename receipt also for analytical accountancy
---
 include/class/document_export.class.php | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/include/class/document_export.class.php 
b/include/class/document_export.class.php
index f3c71164c..86b1aa38f 100644
--- a/include/class/document_export.class.php
+++ b/include/class/document_export.class.php
@@ -57,7 +57,7 @@ class Document_Export
         try
         {
             $this->check_file();
-            $stmt=PDFTK." ".$this->store_pdf.'/*-stamp_*pdf  output 
'.$this->store_pdf.'/result.pdf';
+            $stmt=PDFTK." ".$this->store_pdf.'/*pdf  output 
'.$this->store_pdf.'/result.pdf';
             $status=0;
             echo $stmt;
             passthru($stmt, $status);
@@ -91,7 +91,7 @@ class Document_Export
             throw new Exception ( __FILE__.":".__LINE__."cannot recreate zip");
         }
         chdir($this->store_pdf);
-        $zip->addGlob("*-stamp_*pdf");
+        $zip->addGlob("*.pdf");
         $zip->close();
 
     }
@@ -102,9 +102,16 @@ class Document_Export
      * @throws Exception
      */
 
-    function move_file($p_source, $target)
+    function move_file($p_source, $p_target)
     {
         $this->check_file();
+        $i=1;
+        $target=$p_target;
+        // do not overwrite a document already present
+        while (file_exists($target)) {
+            $target = sprintf("%d-%s",$i,$p_target);
+            $i++;
+        }
         copy($p_source, $this->store_pdf . '/' . $target);
     }
     /**
@@ -254,7 +261,7 @@ class Document_Export
             rename($output2, $output);
 
             // Move the PDF into another temp directory 
-            $this->move_file($output, $order.'-stamp_'.$file_pdf);
+            $this->move_file($output, $file_pdf);
             $order++;
         }
 
@@ -324,7 +331,10 @@ class Document_Export
 
 
         $filename=clean_filename($file[0]['jr_pj_name']);
-        
+        $receipt=clean_filename($file[0]['jr_pj_number']);
+        $receipt=str_replace('.','-',$receipt);
+        $filename=$receipt.'-'.$filename;
+
         $cn->start();
         $cn->lo_export($file[0]['jr_pj'], $this->store_convert.'/'.$filename);
         $cn->commit();



reply via email to

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