25 require_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;
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;
getExample()
Return an example of numbering.
info()
Return description of numbering module.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
getNextValue($objprod, $object)
Return next free value.
if(isModEnabled('facture')&&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur')&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)&&$user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice')&&$user->rights->supplier_invoice->lire)) if(isModEnabled('don')&&!empty($user->rights->don->lire)) if(isModEnabled('tax')&&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture')&&isModEnabled('commande')&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Class to manage customer order numbering rules standard.
canBeActivated()
Checks if the numbers already in the database do not cause conflicts that would prevent this numberin...