28require_once DOL_DOCUMENT_ROOT .
'/core/modules/stocktransfer/modules_stocktransfer.php';
40 public $version =
'dolibarr';
45 public $prefix =
'ST';
55 public $name =
'standard';
60 public $position = 40;
69 public function info($langs)
72 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
83 return $this->prefix.
"0501-0001";
96 global
$conf, $langs, $db;
101 $posindice = strlen($this->prefix) + 6;
102 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
103 $sql .=
" FROM ".MAIN_DB_PREFIX.
"stocktransfer_stocktransfer";
104 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
105 if (
$object->ismultientitymanaged == 1) {
106 $sql .=
" AND entity = ".$conf->entity;
107 } elseif (!is_numeric(
$object->ismultientitymanaged)) {
111 $resql =
$db->query($sql);
113 $row =
$db->fetch_row($resql);
115 $coyymm = substr($row[0], 0, 6);
119 if ($coyymm && !preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
120 $langs->load(
"errors");
121 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
139 $posindice = strlen($this->prefix) + 6;
140 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
141 $sql .=
" FROM ".MAIN_DB_PREFIX.
"stocktransfer_stocktransfer";
142 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
143 if (
$object->ismultientitymanaged == 1) {
144 $sql .=
" AND entity = ".$conf->entity;
145 } elseif (!is_numeric(
$object->ismultientitymanaged)) {
149 $resql =
$db->query($sql);
151 $obj =
$db->fetch_object($resql);
153 $max = intval($obj->max);
158 dol_syslog(
"mod_stocktransfer_standard::getNextValue", LOG_DEBUG);
163 $date =
$object->date_creation;
166 if ($max >= (pow(10, 4) - 1)) {
169 $num = sprintf(
"%04d", $max + 1);
172 dol_syslog(
"mod_stocktransfer_standard::getNextValue return ".$this->prefix.$yymm.
"-".$num);
173 return $this->prefix.$yymm.
"-".$num;
if(! $sortfield) if(! $sortorder) $object
Parent class to manage numbering of StockTransfer.
Class to manage the Standard numbering rule for Stock.
getNextValue($object)
Return next free value.
info($langs)
Return description of numbering module.
canBeActivated($object)
Checks if the numbers already in the database do not cause conflicts that would prevent this numberin...
getExample()
Return an example of numbering.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
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.