Fix error management

This commit is contained in:
Laurent Destailleur 2022-07-07 22:35:56 +02:00
parent 4086f3f36c
commit f6a39383d3
2 changed files with 7 additions and 3 deletions

View File

@ -3140,6 +3140,7 @@ class Facture extends CommonInvoice
} else { } else {
$num = $this->ref; $num = $this->ref;
} }
$this->newref = dol_sanitizeFileName($num); $this->newref = dol_sanitizeFileName($num);
if ($num) { if ($num) {
@ -3147,7 +3148,7 @@ class Facture extends CommonInvoice
// Validate // Validate
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; $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 if (!empty($conf->global->FAC_FORCE_DATE_VALIDATION)) { // If option enabled, we force invoice date
$sql .= ", datef='".$this->db->idate($this->date)."'"; $sql .= ", datef='".$this->db->idate($this->date)."'";
$sql .= ", date_lim_reglement='".$this->db->idate($this->date_lim_reglement)."'"; $sql .= ", date_lim_reglement='".$this->db->idate($this->date_lim_reglement)."'";
@ -4383,7 +4384,6 @@ class Facture extends CommonInvoice
$mybool = false; $mybool = false;
$file = $addon.'.php'; $file = $addon.'.php';
$classname = $addon; $classname = $addon;
@ -4421,8 +4421,10 @@ class Facture extends CommonInvoice
} }
$obj = new $classname(); $obj = new $classname();
$numref = $obj->getNextValue($soc, $this, $mode); $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 * $numref can be empty in case we ask for the last value because if there is no invoice created with the
* set up mask. * set up mask.

View File

@ -177,6 +177,7 @@ if (!empty($conf->multicurrency->enabled) && !empty($_SESSION["takeposcustomercu
} }
} }
/* /*
* Actions * Actions
*/ */
@ -278,7 +279,8 @@ if (empty($reshook)) {
$res = $invoice->validate($user); $res = $invoice->validate($user);
if ($res < 0) { if ($res < 0) {
$error++; $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);
} }
} }