26 require_once DOL_DOCUMENT_ROOT.
'/core/modules/asset/modules_asset.php';
37 public $version =
'dolibarr';
39 public $prefix =
'ASSET';
49 public $name =
'standard';
60 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
71 return $this->prefix.
"0501-0001";
84 global $conf, $langs, $db;
86 $coyymm =
''; $max =
'';
88 $posindice = strlen($this->prefix) + 6;
89 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
90 $sql .=
" FROM ".MAIN_DB_PREFIX.
"asset_asset";
91 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
92 if ($object->ismultientitymanaged == 1) {
93 $sql .=
" AND entity = ".$conf->entity;
94 } elseif ($object->ismultientitymanaged == 2) {
100 $row = $db->fetch_row(
$resql);
102 $coyymm = substr($row[0], 0, 6); $max = $row[0];
105 if ($coyymm && !preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
106 $langs->load(
"errors");
107 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
125 $posindice = strlen($this->prefix) + 6;
126 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
127 $sql .=
" FROM ".MAIN_DB_PREFIX.
"asset_asset";
128 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
129 if ($object->ismultientitymanaged == 1) {
130 $sql .=
" AND entity = ".$conf->entity;
131 } elseif ($object->ismultientitymanaged == 2) {
135 $resql = $db->query($sql);
137 $obj = $db->fetch_object(
$resql);
139 $max = intval($obj->max);
144 dol_syslog(
"mod_asset_standard::getNextValue", LOG_DEBUG);
149 $date = $object->date_creation;
150 $yymm = strftime(
"%y%m", $date);
152 if ($max >= (pow(10, 4) - 1)) {
155 $num = sprintf(
"%04s", $max + 1);
158 dol_syslog(
"mod_asset_standard::getNextValue return ".$this->prefix.$yymm.
"-".$num);
159 return $this->prefix.$yymm.
"-".$num;
canBeActivated($object)
Checks if the numbers already in the database do not cause conflicts that would prevent this numberin...
Parent class to manage numbering of Asset.
info()
Return description of numbering module.
getNextValue($object)
Return next free value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
Class to manage customer order numbering rules standard.
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.
getExample()
Return an example of numbering.