From ca42be7478553b07c782e2421338cb1abbc114b7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Jul 2022 22:35:56 +0200 Subject: [PATCH] Fix error management --- htdocs/compta/facture/class/facture.class.php | 6 ++++-- htdocs/takepos/invoice.php | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 345ffd10acb..74595267a7c 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3140,6 +3140,7 @@ class Facture extends CommonInvoice } else { $num = $this->ref; } + $this->newref = dol_sanitizeFileName($num); if ($num) { @@ -3147,7 +3148,7 @@ class Facture extends CommonInvoice // Validate $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; - $sql .= " SET ref='".$num."', fk_statut = ".self::STATUS_VALIDATED.", fk_user_valid = ".($user->id > 0 ? $user->id : "null").", date_valid = '".$this->db->idate($now)."'"; + $sql .= " SET ref = '".$this->db->escape($num)."', fk_statut = ".self::STATUS_VALIDATED.", fk_user_valid = ".($user->id > 0 ? $user->id : "null").", date_valid = '".$this->db->idate($now)."'"; if (!empty($conf->global->FAC_FORCE_DATE_VALIDATION)) { // If option enabled, we force invoice date $sql .= ", datef='".$this->db->idate($this->date)."'"; $sql .= ", date_lim_reglement='".$this->db->idate($this->date_lim_reglement)."'"; @@ -4383,7 +4384,6 @@ class Facture extends CommonInvoice $mybool = false; - $file = $addon.'.php'; $classname = $addon; @@ -4421,8 +4421,10 @@ class Facture extends CommonInvoice } $obj = new $classname(); + $numref = $obj->getNextValue($soc, $this, $mode); + /** * $numref can be empty in case we ask for the last value because if there is no invoice created with the * set up mask. diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 35855b60e23..bdc11c79b2f 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -177,6 +177,7 @@ if (!empty($conf->multicurrency->enabled) && !empty($_SESSION["takeposcustomercu } } + /* * Actions */ @@ -278,7 +279,8 @@ if (empty($reshook)) { $res = $invoice->validate($user); if ($res < 0) { $error++; - dol_htmloutput_errors($invoice->error, $invoice->errors, 1); + $langs->load("admin"); + dol_htmloutput_errors($invoice->error == 'NotConfigured' ? $langs->trans("NotConfigured").' (TakePos numbering module)': $invoice->error, $invoice->errors, 1); } }