24require_once DOL_DOCUMENT_ROOT.
'/core/modules/reception/modules_reception.php';
31 public $version =
'dolibarr';
32 public $prefix =
'RCP';
34 public $nom =
'Beryl';
43 public function info($langs)
46 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
57 return $this->prefix.
"0501-0001";
69 global $conf, $langs, $db;
74 $posindice = strlen($this->prefix) + 6;
75 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
76 $sql .=
" FROM ".MAIN_DB_PREFIX.
"reception";
77 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
78 $sql .=
" AND entity = ".$conf->entity;
80 $resql = $db->query($sql);
82 $row = $db->fetch_row($resql);
84 $coyymm = substr($row[0], 0, 6);
88 if ($coyymm && !preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
89 $langs->load(
"errors");
90 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
108 $posindice = strlen($this->prefix) + 6;
109 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
110 $sql .=
" FROM ".MAIN_DB_PREFIX.
"reception";
111 $sql .=
" WHERE ref like '".$db->escape($this->prefix).
"____-%'";
112 $sql .=
" AND entity = ".$conf->entity;
114 $resql = $db->query($sql);
116 $obj = $db->fetch_object($resql);
118 $max = intval($obj->max);
123 dol_syslog(
"mod_reception_beryl::getNextValue", LOG_DEBUG);
130 if ($max >= (pow(10, 4) - 1)) {
133 $num = sprintf(
"%04s", $max + 1);
136 dol_syslog(
"mod_reception_beryl::getNextValue return ".$this->prefix.$yymm.
"-".$num);
137 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($object)
Test if existing numbers make problems with numbering.
info($langs)
Return default description of numbering model.
reception_get_num($objsoc, $objforref)
Return next free value.
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.