26require_once DOL_DOCUMENT_ROOT.
'/core/modules/reception/modules_reception.php';
33 public $version =
'dolibarr';
34 public $prefix =
'RCP';
36 public $nom =
'Beryl';
45 public function info($langs)
48 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
59 return $this->prefix.
"0501-0001";
71 global $conf, $langs, $db;
76 $posindice = strlen($this->prefix) + 6;
77 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
78 $sql .=
" FROM ".MAIN_DB_PREFIX.
"reception";
79 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
80 $sql .=
" AND entity = ".$conf->entity;
82 $resql = $db->query($sql);
84 $row = $db->fetch_row($resql);
86 $coyymm = substr($row[0], 0, 6);
90 if ($coyymm && !preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
91 $langs->load(
"errors");
92 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
110 $posindice = strlen($this->prefix) + 6;
111 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
112 $sql .=
" FROM ".MAIN_DB_PREFIX.
"reception";
113 $sql .=
" WHERE ref like '".$db->escape($this->prefix).
"____-%'";
114 $sql .=
" AND entity = ".$conf->entity;
116 $resql = $db->query($sql);
118 $obj = $db->fetch_object($resql);
120 $max = intval($obj->max);
125 dol_syslog(
"mod_reception_beryl::getNextValue", LOG_DEBUG);
132 if ($max >= (pow(10, 4) - 1)) {
135 $num = sprintf(
"%04d", $max + 1);
138 dol_syslog(
"mod_reception_beryl::getNextValue return ".$this->prefix.$yymm.
"-".$num);
139 return $this->prefix.$yymm.
"-".$num;
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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.
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.