25require_once DOL_DOCUMENT_ROOT.
'/core/modules/cheque/modules_chequereceipts.php';
36 public $version =
'dolibarr';
38 public $prefix =
'CHK';
45 public $name =
'Mint';
54 public function info($langs)
57 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
68 return $this->prefix.
"0501-0001";
81 global $conf, $langs, $db;
86 $posindice = strlen($this->prefix) + 6;
87 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
88 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bordereau_cheque";
89 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
90 $sql .=
" AND entity = ".$conf->entity;
92 $resql = $db->query($sql);
94 $row = $db->fetch_row($resql);
96 $payyymm = substr($row[0], 0, 6);
100 if ($payyymm && !preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $payyymm)) {
101 $langs->load(
"errors");
102 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
121 $posindice = strlen($this->prefix) + 6;
122 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
123 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bordereau_cheque";
124 $sql .=
" WHERE ref like '".$db->escape($this->prefix).
"____-%'";
125 $sql .=
" AND entity = ".$conf->entity;
127 $resql = $db->query($sql);
129 $obj = $db->fetch_object($resql);
131 $max = intval($obj->max);
141 $date = $object->date_bordereau;
144 if ($max >= (pow(10, 4) - 1)) {
147 $num = sprintf(
"%04s", $max + 1);
150 dol_syslog(__METHOD__.
" return ".$this->prefix.$yymm.
"-".$num);
151 return $this->prefix.$yymm.
"-".$num;
Class parent for 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.
canBeActivated($object)
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.
info($langs)
Return description of numbering module.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.