27require_once DOL_DOCUMENT_ROOT.
'/core/modules/cheque/modules_chequereceipts.php';
38 public $version =
'dolibarr';
43 public $prefix =
'CHK';
50 public $name =
'Mint';
59 public function info($langs)
62 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
73 return $this->prefix.
"0501-0001";
86 global $conf, $langs, $db;
91 $posindice = strlen($this->prefix) + 6;
92 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
93 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bordereau_cheque";
94 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
95 $sql .=
" AND entity = ".$conf->entity;
97 $resql = $db->query($sql);
99 $row = $db->fetch_row($resql);
101 $payyymm = substr($row[0], 0, 6);
105 if ($payyymm && !preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $payyymm)) {
106 $langs->load(
"errors");
107 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
126 $posindice = strlen($this->prefix) + 6;
127 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
128 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bordereau_cheque";
129 $sql .=
" WHERE ref like '".$db->escape($this->prefix).
"____-%'";
130 $sql .=
" AND entity = ".((int) $conf->entity);
132 $resql = $db->query($sql);
134 $obj = $db->fetch_object($resql);
136 $max = intval($obj->max);
149 if ($max >= (pow(10, 4) - 1)) {
152 $num = sprintf(
"%04d", $max + 1);
155 dol_syslog(__METHOD__.
" return ".$this->prefix.$yymm.
"-".$num);
157 return $this->prefix.$yymm.
"-".$num;
if(! $sortfield) if(! $sortorder) $object
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...
info($langs)
Return description of numbering module.
dol_now($mode='gmt')
Return date for now.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
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.