From bab42b7f7f6ee4e21c9122760e4c04e7b4e1c5b6 Mon Sep 17 00:00:00 2001 From: sparkyx Date: Sat, 6 Dec 2025 10:09:37 +0100 Subject: [PATCH] fix : sale : numbering invoice --- include/class/acc_document.class.php | 7 +++++-- include/class/document.class.php | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/class/acc_document.class.php b/include/class/acc_document.class.php index a74cfd813..f0b9aaf43 100644 --- a/include/class/acc_document.class.php +++ b/include/class/acc_document.class.php @@ -237,11 +237,14 @@ class Acc_Document extends Document { // var e_pj (string) receipt nb $p_array['e_pj'] = $this->db->get_value("select jr_pj_number from jrn where jr_id=$1" , [$this->d_id]); - $filename = ""; + // $filename (string) compute filename based on the template + $filename=$this->db->get_value ("select md_filename from document_modele where md_id=$1", + [$this->md_id]); + $filename = $p_array['e_pj']."-".$filename; // generate the document and set d_lob,d_mimetype, // this function will call saveGenerated and save in DB - $this->generate($p_array, $p_array['e_pj']); + $this->generate($p_array, $filename); // Update the comment with invoice number, if the comment is empty if (!isset($p_array['e_comm']) || noalyss_strlentrim($p_array['e_comm']) == 0) { diff --git a/include/class/document.class.php b/include/class/document.class.php index 8510ff06e..f328a1e48 100644 --- a/include/class/document.class.php +++ b/include/class/document.class.php @@ -189,7 +189,7 @@ class Document chdir($dirname); - $filename=$row['md_filename']; + $filename=($p_filename == "")?$row['md_filename']:$p_filename; $exp=$this->db->lo_export($row['md_lob'], $dirname.DIRECTORY_SEPARATOR.$filename); if ($exp===false) {