26 require_once DOL_DOCUMENT_ROOT .
'/core/modules/stocktransfer/modules_stocktransfer.php';
38 public $version =
'dolibarr';
40 public $prefix =
'ST';
50 public $name =
'standard';
61 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
72 return $this->prefix.
"0501-0001";
85 global $conf, $langs, $db;
87 $coyymm =
''; $max =
'';
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.
"stocktransfer_stocktransfer";
92 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
93 if ($object->ismultientitymanaged == 1) {
94 $sql .=
" AND entity = ".$conf->entity;
95 } elseif ($object->ismultientitymanaged == 2) {
101 $row = $db->fetch_row(
$resql);
102 if ($row) { $coyymm = substr($row[0], 0, 6); $max = $row[0]; }
104 if ($coyymm && !preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
105 $langs->load(
"errors");
106 $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.
"stocktransfer_stocktransfer";
127 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
128 if ($object->ismultientitymanaged == 1) {
129 $sql .=
" AND entity = ".$conf->entity;
130 } elseif ($object->ismultientitymanaged == 2) {
134 $resql = $db->query($sql);
136 $obj = $db->fetch_object(
$resql);
137 if ($obj) $max = intval($obj->max);
140 dol_syslog(
"mod_stocktransfer_standard::getNextValue", LOG_DEBUG);
145 $date = $object->date_creation;
146 $yymm = strftime(
"%y%m", $date);
148 if ($max >= (pow(10, 4) - 1)) $num = $max + 1;
149 else $num = sprintf(
"%04s", $max + 1);
151 dol_syslog(
"mod_stocktransfer_standard::getNextValue return ".$this->prefix.$yymm.
"-".$num);
152 return $this->prefix.$yymm.
"-".$num;
Parent class to manage numbering of StockTransfer.
Class to manage the Standard numbering rule for Stock.
getNextValue($object)
Return next free value.
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.
info()
Return description of numbering module.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("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->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.