24require_once DOL_DOCUMENT_ROOT.
'/core/modules/reception/modules_reception.php';
31 public $version =
'dolibarr';
32 public $prefix =
'RCP';
34 public $nom =
'Beryl';
45 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
56 return $this->prefix.
"0501-0001";
67 global $conf, $langs, $db;
72 $posindice = strlen($this->prefix) + 6;
73 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
74 $sql .=
" FROM ".MAIN_DB_PREFIX.
"reception";
75 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
76 $sql .=
" AND entity = ".$conf->entity;
78 $resql = $db->query($sql);
80 $row = $db->fetch_row($resql);
82 $coyymm = substr($row[0], 0, 6);
86 if ($coyymm && !preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
87 $langs->load(
"errors");
88 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
106 $posindice = strlen($this->prefix) + 6;
107 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
108 $sql .=
" FROM ".MAIN_DB_PREFIX.
"reception";
109 $sql .=
" WHERE ref like '".$db->escape($this->prefix).
"____-%'";
110 $sql .=
" AND entity = ".$conf->entity;
112 $resql = $db->query($sql);
114 $obj = $db->fetch_object($resql);
116 $max = intval($obj->max);
121 dol_syslog(
"mod_reception_beryl::getNextValue", LOG_DEBUG);
126 $yymm = strftime(
"%y%m", $date);
128 if ($max >= (pow(10, 4) - 1)) {
131 $num = sprintf(
"%04s", $max + 1);
134 dol_syslog(
"mod_reception_beryl::getNextValue return ".$this->prefix.$yymm.
"-".$num);
135 return $this->prefix.$yymm.
"-".$num;
Parent Class of numbering models of sending receipts references.
Class to manage reception numbering rules Beryl.
getExample()
Return numbering example.
getNextValue($objsoc, $reception)
Return next value.
canBeActivated()
Test if existing numbers make problems with numbering.
info()
Return default description of numbering model.
reception_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.