25 dol_include_once(
'/knowledgemanagement/core/modules/knowledgemanagement/modules_knowledgerecord.php');
37 public $version =
'dolibarr';
39 public $prefix =
'KM';
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.
"knowledgemanagement_knowledgerecord";
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.
"knowledgemanagement_knowledgerecord";
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_knowledgerecord_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_knowledgerecord_standard::getNextValue return ".$this->prefix.$yymm.
"-".$num);
159 return $this->prefix.$yymm.
"-".$num;
Parent class to manage numbering of KnowledgeRecord.
Class to manage the knowledgerecord numbering rules standard.
info()
Return description of numbering module.
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.
getNextValue($object)
Return next free value.
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.
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.