27require_once DOL_DOCUMENT_ROOT.
'/core/modules/cheque/modules_chequereceipts.php';
38 public $version =
'dolibarr';
40 public $prefix =
'CHK';
47 public $name =
'Mint';
56 public function info($langs)
59 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
70 return $this->prefix.
"0501-0001";
83 global $conf, $langs, $db;
88 $posindice = strlen($this->prefix) + 6;
89 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
90 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bordereau_cheque";
91 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
92 $sql .=
" AND entity = ".$conf->entity;
94 $resql = $db->query($sql);
96 $row = $db->fetch_row($resql);
98 $payyymm = substr($row[0], 0, 6);
102 if ($payyymm && !preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $payyymm)) {
103 $langs->load(
"errors");
104 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
123 $posindice = strlen($this->prefix) + 6;
124 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
125 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bordereau_cheque";
126 $sql .=
" WHERE ref like '".$db->escape($this->prefix).
"____-%'";
127 $sql .=
" AND entity = ".((int) $conf->entity);
129 $resql = $db->query($sql);
131 $obj = $db->fetch_object($resql);
133 $max = intval($obj->max);
146 if ($max >= (pow(10, 4) - 1)) {
149 $num = sprintf(
"%04d", $max + 1);
152 dol_syslog(__METHOD__.
" return ".$this->prefix.$yymm.
"-".$num);
154 return $this->prefix.$yymm.
"-".$num;
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $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='auto')
Return date for now.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $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.