25require_once DOL_DOCUMENT_ROOT.
'/core/modules/cheque/modules_chequereceipts.php';
36 public $version =
'dolibarr';
38 public $prefix =
'CHK';
45 public $name =
'Mint';
56 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
67 return $this->prefix.
"0501-0001";
79 global $conf, $langs, $db;
84 $posindice = strlen($this->prefix) + 6;
85 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
86 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bordereau_cheque";
87 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
88 $sql .=
" AND entity = ".$conf->entity;
90 $resql = $db->query($sql);
92 $row = $db->fetch_row($resql);
94 $payyymm = substr($row[0], 0, 6);
98 if ($payyymm && !preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $payyymm)) {
99 $langs->load(
"errors");
100 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
119 $posindice = strlen($this->prefix) + 6;
120 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
121 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bordereau_cheque";
122 $sql .=
" WHERE ref like '".$db->escape($this->prefix).
"____-%'";
123 $sql .=
" AND entity = ".$conf->entity;
125 $resql = $db->query($sql);
127 $obj = $db->fetch_object($resql);
129 $max = intval($obj->max);
139 $date = $object->date_bordereau;
140 $yymm = strftime(
"%y%m", $date);
142 if ($max >= (pow(10, 4) - 1)) {
145 $num = sprintf(
"%04s", $max + 1);
148 dol_syslog(__METHOD__.
" return ".$this->prefix.$yymm.
"-".$num);
149 return $this->prefix.$yymm.
"-".$num;
Cheque Receipts numbering references mother class.
Class to manage cheque receipts numbering rules Mint.
getExample()
Return an example of numbering.
getNextValue($objsoc, $object)
Return next free value.
info()
Return description of numbering module.
canBeActivated()
Checks if the numbers already in the database do not cause conflicts that would prevent this numberin...
chequereceipt_get_num($objsoc, $objforref)
Return next free value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.