26require_once DOL_DOCUMENT_ROOT .
'/core/modules/workstation/modules_workstation.php';
37 public $version =
'dolibarr';
39 public $prefix =
'WKSTATION';
49 public $name =
'standard';
58 public function info($langs)
61 return $langs->trans(
"SimpleNumRefNoDateModelDesc", $this->prefix);
72 return $this->prefix.
"-0001";
85 global $conf, $langs, $db;
89 $posindice = strlen($this->prefix) + 2;
90 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
91 $sql .=
" FROM ".MAIN_DB_PREFIX.
"workstation_workstation";
92 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"-%'";
93 if ($object->ismultientitymanaged == 1) {
94 $sql .=
" AND entity = ".$conf->entity;
95 } elseif ($object->ismultientitymanaged == 2) {
99 $resql = $db->query($sql);
101 $row = $db->fetch_row($resql);
126 $posindice = strlen($this->prefix) + 2;
127 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
128 $sql .=
" FROM ".MAIN_DB_PREFIX.
"workstation_workstation";
129 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"-%'";
132 $resql = $db->query($sql);
134 $obj = $db->fetch_object($resql);
136 $max = intval($obj->max);
141 dol_syslog(
"mod_workstation_standard::getNextValue", LOG_DEBUG);
145 if ($max >= (pow(10, 4) - 1)) {
148 $num = sprintf(
"%04s", $max + 1);
151 dol_syslog(
"mod_workstation_standard::getNextValue return ".$this->prefix.
"-".$num);
152 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($langs)
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.