diff --git a/include/class/document.class.php b/include/class/document.class.php index b87fb36d6..7e24b9839 100644 --- a/include/class/document.class.php +++ b/include/class/document.class.php @@ -84,17 +84,24 @@ class Document */ 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)); + + foreach (array('/', '*', '<', '>', ';', ',', '\\', '.', ':', '(', ')', ' ', '[', ']',"'") as $i) + { + $pj=str_replace($i, "-", $pj); + $filename_no=str_replace($i,"-",$filename_no); + } + + $new_filename=strtolower($filename_no."-".$pj.$filename_suff); + $pj=str_replace("---","-",$pj); + $pj=str_replace("--","-",$pj); + $new_filename=str_replace("---","-",$new_filename); + $new_filename=str_replace("--","-",$new_filename); return $new_filename; } @@ -596,8 +603,8 @@ class Document function get() { - $sql="select * from document where d_id=".$this->d_id; - $ret=$this->db->exec_sql($sql); + $sql="select * from document where d_id=$1"; + $ret=$this->db->exec_sql($sql,[$this->d_id]); if (Database::num_row($ret)==0) { return; @@ -1848,7 +1855,7 @@ class Document */ function transform2pdf() { - if (GENERATE_PDF == 'YES' && $pdf == 'on') { + if (GENERATE_PDF == 'NO' ) { \record_log(__FILE__."DOC37 : PDF not available"); throw new \Exception("Cannot not transform to PDF"); } @@ -1859,10 +1866,11 @@ class Document mkdir($dirname); $destination_file=$dirname."/".$this->d_filename; $this->export_file($destination_file); + passthru(OFFICE . escapeshellarg($destination_file), $status); if ($status != 0) { \record_log(__FILE__."DOC45 : Error cannot transform into PDF"); - throw new \Exception("Cannot not transform to PDF"); + throw new \Exception("DOC45 Cannot not transform to PDF"); } // remove extension $ext = strrpos($this->d_filename, "."); diff --git a/include/class/document_modele.class.php b/include/class/document_modele.class.php index a1722a9d2..42367acb1 100644 --- a/include/class/document_modele.class.php +++ b/include/class/document_modele.class.php @@ -186,16 +186,16 @@ class Document_modele } else { - echo "

Error

"; + echo "

"._("Erreur opération annulée")."

"; $this->cn->rollback(); - throw new Exception("Erreur".__FILE__.__LINE__); + throw new Exception("DM191 : error loading template".__FILE__.__LINE__); } } } catch (Exception $e) { record_log($e); - rollback($this->cn); + $this->cn->rollback(); return ; } } diff --git a/include/document_modele.inc.php b/include/document_modele.inc.php index 8e0ec87c8..5372654b5 100644 --- a/include/document_modele.inc.php +++ b/include/document_modele.inc.php @@ -23,7 +23,6 @@ if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis'); require_once NOALYSS_INCLUDE.'/class/document_modele.class.php'; -$sub_action=(isset ($_REQUEST['sa']))?$_REQUEST['sa']:""; $http=new HttpInput(); @@ -81,7 +80,7 @@ if ( $sub_action == 'mod_template') // Default action : Show the list //----------------------------------------------------- echo $doc->myList(); -echo '