phpcompta-dev
[Top][All Lists]
Advanced

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

[Phpcompta-dev] r5239 - phpcompta/trunk/include


From: phpcompta-dev
Subject: [Phpcompta-dev] r5239 - phpcompta/trunk/include
Date: Sat, 11 May 2013 21:49:01 +0200 (CEST)

Author: danydb
Date: 2013-05-11 21:49:00 +0200 (Sat, 11 May 2013)
New Revision: 5239

Modified:
   phpcompta/trunk/include/class_acc_ledger.php
   phpcompta/trunk/include/class_document.php
Log:
task #0000820: Nom des documents g?\195?\169n?\195?\169r?\195?\169s

Modified: phpcompta/trunk/include/class_acc_ledger.php
===================================================================
--- phpcompta/trunk/include/class_acc_ledger.php        2013-05-11 19:48:34 UTC 
(rev 5238)
+++ phpcompta/trunk/include/class_acc_ledger.php        2013-05-11 19:49:00 UTC 
(rev 5239)
@@ -2305,7 +2305,7 @@
                        $value = 0;
                return $value;
        }
-
+       
        /**
         * @brief create the invoice and saved it as attachment to the
         * operation,
@@ -2321,7 +2321,8 @@
                $doc->f_id = $e_client;
                $doc->md_id = $gen_doc;
                $doc->ag_id = 0;
-               $doc->Generate($p_array);
+               $filename="";
+               $doc->Generate($p_array,$p_array['e_pj']);
                // Move the document to the jrn
                $doc->MoveDocumentPj($internal);
                // Update the comment with invoice number, if the comment is 
empty

Modified: phpcompta/trunk/include/class_document.php
===================================================================
--- phpcompta/trunk/include/class_document.php  2013-05-11 19:48:34 UTC (rev 
5238)
+++ phpcompta/trunk/include/class_document.php  2013-05-11 19:49:00 UTC (rev 
5239)
@@ -62,16 +62,28 @@
         $this->db->exec_sql($sql);
 
     }
-
+       function compute_filename($pj,$filename)
+       {
+               foreach (array('/','*','<','>',';',',','\\','.',':') as $i) {
+                       $pj= str_replace($i, "-",$pj);
+               }
+               // save the suffix
+               $pos_prefix=strrpos($filename,".");
+               if ($pos_prefix == 0) $pos_prefix=strlen($filename);
+               $filename_no=substr($filename,0,$pos_prefix);
+               $filename_suff=substr($filename,$pos_prefix,strlen($filename));
+               $new_filename=  strtolower($filename_no."-".$pj.$filename_suff);
+               return $new_filename;
+       }
     /*!
      * \brief Generate the document, Call $this-\>Replace to replace
      *        tag by value
-     *\p_array contains the data normally it is the $_POST
-     *
+     address@hidden p_array contains the data normally it is the $_POST
+     address@hidden contains the new filename
      * \return an array : the url where the generated doc can be found, the 
name
      * of the file and his mimetype
      */
-    function Generate($p_array)
+    function Generate($p_array,$p_filename="")
     {
         // create a temp directory in /tmp to unpack file and to parse it
         $dirname=tempnam($_ENV['TMP'],'doc_');
@@ -144,7 +156,10 @@
 
             $file_to_parse=$filename;
         }
+               if ( $p_filename !="") {
 
+                       $this->d_filename=$this->compute_filename($p_filename, 
$this->d_filename);
+               }
         $this->SaveGenerated($dirname.DIRECTORY_SEPARATOR.$file_to_parse);
         // Invoice
         $ret='<A class="mtitle" 
HREF="show_document.php?d_id='.$this->d_id.'&'.dossier::get().'">Document 
g&eacute;n&eacute;r&eacute;</A>';
@@ -244,7 +259,7 @@
                        if ( strpos($value,'ERROR') != false )            
$value="";
                         /*
                          * Change type of cell to numeric
-                         *  allow numeric cel in ODT for the formatting and 
formula 
+                         *  allow numeric cel in ODT for the formatting and 
formula
                          */
                        if ( is_numeric($value) && $p_type=='OOo')
                          {



---
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]