27require_once DOL_DOCUMENT_ROOT.
'/core/modules/bom/modules_bom.php';
38 public $version =
'dolibarr';
40 public $prefix =
'BOM';
50 public $name =
'standard';
59 public function info($langs)
62 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
73 return $this->prefix.
"0501-0001";
86 global
$conf, $langs, $db;
91 $posindice = strlen($this->prefix) + 6;
92 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
93 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bom";
94 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
95 $sql .=
" AND entity = ".$conf->entity;
97 $resql = $db->query($sql);
99 $row = $db->fetch_row($resql);
101 $coyymm = substr($row[0], 0, 6);
105 if ($coyymm && !preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
106 $langs->load(
"errors");
107 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
126 $posindice = strlen($this->prefix) + 6;
127 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
128 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bom_bom";
129 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
130 $sql .=
" AND entity = ".$conf->entity;
132 $resql = $db->query($sql);
134 $obj = $db->fetch_object($resql);
136 $max = intval($obj->max);
141 dol_syslog(
"mod_bom_standard::getNextValue", LOG_DEBUG);
146 $date =
$object->date_creation;
149 if ($max >= (pow(10, 4) - 1)) {
152 $num = sprintf(
"%04d", $max + 1);
155 dol_syslog(
"mod_bom_standard::getNextValue return ".$this->prefix.$yymm.
"-".$num);
156 return $this->prefix.$yymm.
"-".$num;
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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=null, $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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...