25require_once DOL_DOCUMENT_ROOT.
'/core/modules/mrp/modules_mo.php';
36 public $version =
'dolibarr';
38 public $prefix =
'MO';
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.
"mrp_mo";
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.
"mrp_mo";
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_mo_standard::getNextValue", LOG_DEBUG);
144 $date = $object->date_creation;
145 $yymm = strftime(
"%y%m", $date);
147 if ($max >= (pow(10, 4) - 1)) {
150 $num = sprintf(
"%04s", $max + 1);
153 dol_syslog(
"mod_mo_standard::getNextValue return ".$this->prefix.$yymm.
"-".$num);
154 return $this->prefix.$yymm.
"-".$num;
Parent class to manage numbering of MOs.
Class to manage MO numbering rules standard.
getExample()
Return an example of numbering.
canBeActivated($object)
Checks if the numbers already in the database do not cause conflicts that would prevent this numberin...
getNextValue($objprod, $object)
Return next free value.
info($langs)
Return description of numbering module.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.