25require_once DOL_DOCUMENT_ROOT.
'/core/modules/bom/modules_bom.php';
36 public $version =
'dolibarr';
38 public $prefix =
'BOM';
48 public $name =
'standard';
59 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
70 return $this->prefix.
"0501-0001";
82 global $conf, $langs, $db;
87 $posindice = strlen($this->prefix) + 6;
88 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
89 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bom";
90 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
91 $sql .=
" AND entity = ".$conf->entity;
93 $resql = $db->query($sql);
95 $row = $db->fetch_row($resql);
97 $coyymm = substr($row[0], 0, 6);
101 if ($coyymm && !preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
102 $langs->load(
"errors");
103 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
122 $posindice = strlen($this->prefix) + 6;
123 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
124 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bom_bom";
125 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
126 $sql .=
" AND entity = ".$conf->entity;
128 $resql = $db->query($sql);
130 $obj = $db->fetch_object($resql);
132 $max = intval($obj->max);
137 dol_syslog(
"mod_bom_standard::getNextValue", LOG_DEBUG);
142 $date = $object->date_creation;
143 $yymm = strftime(
"%y%m", $date);
145 if ($max >= (pow(10, 4) - 1)) {
148 $num = sprintf(
"%04s", $max + 1);
151 dol_syslog(
"mod_bom_standard::getNextValue return ".$this->prefix.$yymm.
"-".$num);
152 return $this->prefix.$yymm.
"-".$num;
Parent class to manage numbering of BOMs.
Class to manage the Standard numbering rule for BOM.
getExample()
Return an example of numbering.
getNextValue($objprod, $object)
Return next free value.
canBeActivated()
Checks if the numbers already in the database do not cause conflicts that would prevent this numberin...
info()
Return description of numbering module.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.