26dol_include_once(
'/knowledgemanagement/core/modules/knowledgemanagement/modules_knowledgerecord.php');
38 public $version =
'dolibarr';
43 public $prefix =
'KM';
53 public $name =
'standard';
62 public function info($langs)
64 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
75 return $this->prefix.
"0501-0001";
88 global $conf, $langs, $db;
93 $posindice = strlen($this->prefix) + 6;
94 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
95 $sql .=
" FROM ".MAIN_DB_PREFIX.
"knowledgemanagement_knowledgerecord";
96 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
97 if (
$object->ismultientitymanaged == 1) {
98 $sql .=
" AND entity = ".$conf->entity;
99 } elseif (
$object->ismultientitymanaged == 2) {
103 $resql = $db->query($sql);
105 $row = $db->fetch_row($resql);
107 $coyymm = substr($row[0], 0, 6);
111 if ($coyymm && !preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
112 $langs->load(
"errors");
113 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
131 $posindice = strlen($this->prefix) + 6;
132 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
133 $sql .=
" FROM ".MAIN_DB_PREFIX.
"knowledgemanagement_knowledgerecord";
134 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
135 if (
$object->ismultientitymanaged == 1) {
136 $sql .=
" AND entity = ".$conf->entity;
137 } elseif (
$object->ismultientitymanaged == 2) {
141 $resql = $db->query($sql);
143 $obj = $db->fetch_object($resql);
145 $max = intval($obj->max);
150 dol_syslog(
"mod_knowledgerecord_standard::getNextValue", LOG_DEBUG);
155 $date =
$object->date_creation;
158 if ($max >= (pow(10, 4) - 1)) {
161 $num = sprintf(
"%04d", $max + 1);
164 dol_syslog(
"mod_knowledgerecord_standard::getNextValue return ".$this->prefix.$yymm.
"-".$num);
165 return $this->prefix.$yymm.
"-".$num;
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Class to manage the knowledgerecord numbering rules standard.
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.
info($langs)
Returns the default description of the numbering template.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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.