25 require_once DOL_DOCUMENT_ROOT.
'/core/modules/mrp/modules_mo.php';
36 public $version =
'dolibarr';
38 public $prefix =
'MO';
48 public $name =
'standard';
59 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
70 return $this->prefix.
"0501-0001";
82 global $conf, $langs, $db;
84 $coyymm =
''; $max =
'';
86 $posindice = strlen($this->prefix) + 6;
87 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
88 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mrp_mo";
89 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
90 $sql .=
" AND entity = ".$conf->entity;
95 $row = $db->fetch_row(
$resql);
96 if ($row) { $coyymm = substr($row[0], 0, 6); $max = $row[0]; }
98 if ($coyymm && !preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $coyymm))
100 $langs->load(
"errors");
101 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
120 $posindice = strlen($this->prefix) + 6;
121 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
122 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mrp_mo";
123 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
124 $sql .=
" AND entity = ".$conf->entity;
126 $resql = $db->query($sql);
129 $obj = $db->fetch_object(
$resql);
130 if ($obj) $max = intval($obj->max);
133 dol_syslog(
"mod_mo_standard::getNextValue", LOG_DEBUG);
138 $date = $object->date_creation;
139 $yymm = strftime(
"%y%m", $date);
141 if ($max >= (pow(10, 4) - 1)) $num = $max + 1;
142 else $num = sprintf(
"%04s", $max + 1);
144 dol_syslog(
"mod_mo_standard::getNextValue return ".$this->prefix.$yymm.
"-".$num);
145 return $this->prefix.$yymm.
"-".$num;
info()
Return description of numbering module.
canBeActivated()
Checks if the numbers already in the database do not cause conflicts that would prevent this numberin...
getNextValue($objprod, $object)
Return next free value.
Class to manage MO numbering rules standard.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
getExample()
Return an example of numbering.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Parent class to manage numbering of MOs.