27 require_once DOL_DOCUMENT_ROOT.
'/core/modules/asset/modules_asset.php';
38 public $version =
'dolibarr';
40 public $prefix =
'ASSET';
50 public $name =
'standard';
61 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
72 return $this->prefix.
"0501-0001";
85 global $conf, $langs, $db;
90 $posindice = strlen($this->prefix) + 6;
91 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
92 $sql .=
" FROM ".MAIN_DB_PREFIX.
"asset_asset";
93 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
94 if ($object->ismultientitymanaged == 1) {
95 $sql .=
" AND entity = ".$conf->entity;
96 } elseif ($object->ismultientitymanaged == 2) {
100 $resql = $db->query($sql);
102 $row = $db->fetch_row(
$resql);
104 $coyymm = substr($row[0], 0, 6); $max = $row[0];
107 if ($coyymm && !preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
108 $langs->load(
"errors");
109 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
127 $posindice = strlen($this->prefix) + 6;
128 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
129 $sql .=
" FROM ".MAIN_DB_PREFIX.
"asset";
130 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
131 if ($object->ismultientitymanaged == 1) {
132 $sql .=
" AND entity = ".$conf->entity;
133 } elseif ($object->ismultientitymanaged == 2) {
137 $resql = $db->query($sql);
139 $obj = $db->fetch_object(
$resql);
141 $max = intval($obj->max);
146 dol_syslog(
"mod_asset_standard::getNextValue", LOG_DEBUG);
151 $date = $object->date_creation;
152 $yymm = strftime(
"%y%m", $date);
154 if ($max >= (pow(10, 4) - 1)) {
157 $num = sprintf(
"%04s", $max + 1);
160 dol_syslog(
"mod_asset_standard::getNextValue return ".$this->prefix.$yymm.
"-".$num);
161 return $this->prefix.$yymm.
"-".$num;
Parent class to manage numbering of Asset.
Class to manage the Standard numbering rule for Asset.
info()
Return description of numbering module.
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.
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.