25require_once DOL_DOCUMENT_ROOT.
'/core/modules/bom/modules_bom.php';
36 public $version =
'dolibarr';
38 public $prefix =
'BOM';
48 public $name =
'standard';
57 public function info($langs)
60 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
71 return $this->prefix.
"0501-0001";
84 global $conf, $langs, $db;
89 $posindice = strlen($this->prefix) + 6;
90 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
91 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bom";
92 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
93 $sql .=
" AND entity = ".$conf->entity;
95 $resql = $db->query($sql);
97 $row = $db->fetch_row($resql);
99 $coyymm = substr($row[0], 0, 6);
103 if ($coyymm && !preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
104 $langs->load(
"errors");
105 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
124 $posindice = strlen($this->prefix) + 6;
125 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
126 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bom_bom";
127 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
128 $sql .=
" AND entity = ".$conf->entity;
130 $resql = $db->query($sql);
132 $obj = $db->fetch_object($resql);
134 $max = intval($obj->max);
139 dol_syslog(
"mod_bom_standard::getNextValue", LOG_DEBUG);
144 $date = $object->date_creation;
147 if ($max >= (pow(10, 4) - 1)) {
150 $num = sprintf(
"%04s", $max + 1);
153 dol_syslog(
"mod_bom_standard::getNextValue return ".$this->prefix.$yymm.
"-".$num);
154 return $this->prefix.$yymm.
"-".$num;
Parent class to manage numbering of BOMs.
Class to manage the Standard numbering rule for BOM.
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.
getNextValue($objprod, $object)
Return next free value.
info($langs)
Return description of numbering module.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
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.