26require_once DOL_DOCUMENT_ROOT.
'/core/modules/product_batch/modules_product_batch.class.php';
37 public $version =
'dolibarr';
39 public $prefix =
'LOT';
49 public $name =
'lot_standard';
60 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
71 return $this->prefix.
"0501-0001";
83 global $conf, $langs, $db;
85 $coyymm =
''; $max =
'';
87 $posindice = strlen($this->prefix) + 6;
88 $sql =
"SELECT MAX(CAST(SUBSTRING(batch FROM ".$posindice.
") AS SIGNED)) as max";
89 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_lot";
90 $sql .=
" WHERE batch LIKE '".$db->escape($this->prefix).
"____-%'";
91 $sql .=
" AND entity = ".$conf->entity;
93 $resql = $db->query($sql);
95 $obj = $db->fetch_object($resql);
97 $max = intval($obj->max);
102 if ($max && !preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $max)) {
103 $langs->load(
"errors");
104 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
123 $posindice = strlen($this->prefix) + 6;
124 $sql =
"SELECT MAX(CAST(SUBSTRING(batch FROM ".$posindice.
") AS SIGNED)) as max";
125 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_lot";
126 $sql .=
" WHERE batch LIKE '".$db->escape($this->prefix).
"____-%'";
127 $sql .=
" AND entity = ".$conf->entity;
129 $resql = $db->query($sql);
131 $obj = $db->fetch_object($resql);
133 $max = intval($obj->max);
138 dol_syslog(
"mod_lot_standard::getNextValue", LOG_DEBUG);
144 $yymm = strftime(
"%y%m", $date);
146 if ($max >= (pow(10, 4) - 1)) $num = $max + 1;
147 else $num = sprintf(
"%04s", $max + 1);
149 dol_syslog(
"mod_lot_standard::getNextValue return ".$this->prefix.$yymm.
"-".$num);
150 return $this->prefix.$yymm.
"-".$num;
Parent class to manage numbering of batch products.
Class to manage MO numbering rules standard.
canBeActivated()
Checks if the numbers already in the database do not cause conflicts that would prevent this numberin...
getNextValue($objsoc, $object)
Return next free value.
getExample()
Return an example of numbering.
info()
Return description of numbering module.
dol_now($mode='auto')
Return date for now.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.