26require_once DOL_DOCUMENT_ROOT.
'/core/modules/reception/modules_reception.php';
33 public $version =
'dolibarr';
37 public $prefix =
'RCP';
42 public $nom =
'Beryl';
51 public function info($langs)
54 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
65 return $this->prefix.
"0501-0001";
77 global
$conf, $langs, $db;
82 $posindice = strlen($this->prefix) + 6;
83 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
84 $sql .=
" FROM ".MAIN_DB_PREFIX.
"reception";
85 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
86 $sql .=
" AND entity = ".$conf->entity;
88 $resql = $db->query($sql);
90 $row = $db->fetch_row($resql);
92 $coyymm = substr($row[0], 0, 6);
96 if ($coyymm && !preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
97 $langs->load(
"errors");
98 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
116 $posindice = strlen($this->prefix) + 6;
117 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
118 $sql .=
" FROM ".MAIN_DB_PREFIX.
"reception";
119 $sql .=
" WHERE ref like '".$db->escape($this->prefix).
"____-%'";
120 $sql .=
" AND entity = ".$conf->entity;
122 $resql = $db->query($sql);
124 $obj = $db->fetch_object($resql);
126 $max = intval($obj->max);
131 dol_syslog(
"mod_reception_beryl::getNextValue", LOG_DEBUG);
138 if ($max >= (pow(10, 4) - 1)) {
141 $num = sprintf(
"%04d", $max + 1);
144 dol_syslog(
"mod_reception_beryl::getNextValue return ".$this->prefix.$yymm.
"-".$num);
145 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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...