Code comment

This commit is contained in:
Laurent Destailleur 2022-04-06 16:49:59 +02:00
parent 5a8d5618f2
commit 33b5605a72

View File

@ -918,7 +918,7 @@ class BonPrelevement extends CommonObject
if (!$error) {
$ref = substr($year, -2).$month;
$sql = "SELECT substring(ref from char_length(ref) - 1)";
$sql = "SELECT substring(ref from char_length(ref) - 1)"; // To extract "YYMMXX" from "TYYMMXX"
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons";
$sql .= " WHERE ref LIKE '%".$this->db->escape($ref)."%'";
$sql .= " AND entity = ".((int) $conf->entity);
@ -929,8 +929,14 @@ class BonPrelevement extends CommonObject
if ($resql) {
$row = $this->db->fetch_row($resql);
$ref = "T".$ref.str_pad(dol_substr("00".intval($row[0]) + 1, 0, 2), 2, "0", STR_PAD_LEFT);
// Build the new ref
$ref = "T".$ref.str_pad(dol_substr("00".(intval($row[0]) + 1), 0, 2), 2, "0", STR_PAD_LEFT);
// $conf->abc->dir_output may be:
// /home/ldestailleur/git/dolibarr_15.0/documents/abc/
// or
// /home/ldestailleur/git/dolibarr_15.0/documents/X/abc with X >= 2 with multicompany.
if ($type != 'bank-transfer') {
$dir = $conf->prelevement->dir_output.'/receipts';
} else {
@ -947,7 +953,7 @@ class BonPrelevement extends CommonObject
$sql .= "ref, entity, datec, type";
$sql .= ") VALUES (";
$sql .= "'".$this->db->escape($ref)."'";
$sql .= ", ".$conf->entity;
$sql .= ", ".((int) $conf->entity);
$sql .= ", '".$this->db->idate($now)."'";
$sql .= ", '".($type == 'bank-transfer' ? 'bank-transfer' : 'debit-order')."'";
$sql .= ")";