26require_once DOL_DOCUMENT_ROOT .
'/core/modules/workstation/modules_workstation.php';
37 public $version =
'dolibarr';
39 public $prefix =
'WKSTATION';
49 public $name =
'standard';
60 return $langs->trans(
"SimpleNumRefNoDateModelDesc", $this->prefix);
71 return $this->prefix.
"-0001";
84 global $conf, $langs, $db;
88 $posindice = strlen($this->prefix) + 2;
89 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
90 $sql .=
" FROM ".MAIN_DB_PREFIX.
"workstation_workstation";
91 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"-%'";
92 if ($object->ismultientitymanaged == 1) {
93 $sql .=
" AND entity = ".$conf->entity;
94 } elseif ($object->ismultientitymanaged == 2) {
98 $resql = $db->query($sql);
100 $row = $db->fetch_row($resql);
125 $posindice = strlen($this->prefix) + 2;
126 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
127 $sql .=
" FROM ".MAIN_DB_PREFIX.
"workstation_workstation";
128 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"-%'";
131 $resql = $db->query($sql);
133 $obj = $db->fetch_object($resql);
135 $max = intval($obj->max);
140 dol_syslog(
"mod_workstation_standard::getNextValue", LOG_DEBUG);
144 if ($max >= (pow(10, 4) - 1)) {
147 $num = sprintf(
"%04s", $max + 1);
150 dol_syslog(
"mod_workstation_standard::getNextValue return ".$this->prefix.
"-".$num);
151 return $this->prefix.
"-".$num;
Parent class to manage numbering of Workstation.
Class to manage the Standard numbering rule for Workstation.
getExample()
Return an example of numbering.
canBeActivated($object)
Checks if the numbers already in the database do not cause conflicts that would prevent this numberin...
info()
Return description of numbering module.
getNextValue($object)
Return next free value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.