From 3d218cadb77a4aaed3b18459293344afb15eed9c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 29 Jan 2019 18:40:47 +0100 Subject: [PATCH] FIX last_main_doc var not saved Conflicts: htdocs/core/class/commonobject.class.php --- htdocs/core/class/commonobject.class.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index bc414ed722c..09df72c6543 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -311,6 +311,12 @@ abstract class CommonObject */ public $modelpdf; + /** + * @var string + * Contains relative path of last generated main file + */ + public $last_main_doc; + /** * @var int Bank account ID * @see SetBankAccount() @@ -4611,10 +4617,15 @@ abstract class CommonObject if (! empty($obj->update_main_doc_field)) $update_main_doc_field=1; if ($update_main_doc_field && ! empty($this->table_element)) { - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element." SET last_main_doc = '".($ecmfile->filepath.'/'.$ecmfile->filename)."'"; + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element." SET last_main_doc = '".$this->db->escape($ecmfile->filepath.'/'.$ecmfile->filename)."'"; $sql.= ' WHERE rowid = '.$this->id; + $resql = $this->db->query($sql); if (! $resql) dol_print_error($this->db); + else + { + $this->last_main_doc = $ecmfile->filepath.'/'.$ecmfile->filename; + } } } }