26dol_include_once(
'/knowledgemanagement/core/modules/knowledgemanagement/modules_knowledgerecord.php');
 
   38  public $version = 
'dolibarr'; 
 
   40  public $prefix = 
'KM';
 
   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.
"knowledgemanagement_knowledgerecord";
 
   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);
 
  108    if ($coyymm && !preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
 
  109      $langs->load(
"errors");
 
  110      $this->error = $langs->trans(
'ErrorNumRefModel', $max);
 
 
  128    $posindice = strlen($this->prefix) + 6;
 
  129    $sql = 
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
 
  130    $sql .= 
" FROM ".MAIN_DB_PREFIX.
"knowledgemanagement_knowledgerecord";
 
  131    $sql .= 
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
 
  132    if (
$object->ismultientitymanaged == 1) {
 
  133      $sql .= 
" AND entity = ".$conf->entity;
 
  134    } elseif (
$object->ismultientitymanaged == 2) {
 
  138    $resql = $db->query($sql);
 
  140      $obj = $db->fetch_object($resql);
 
  142        $max = intval($obj->max);
 
  147      dol_syslog(
"mod_knowledgerecord_standard::getNextValue", LOG_DEBUG);
 
  152    $date = 
$object->date_creation;
 
  155    if ($max >= (pow(10, 4) - 1)) {
 
  158      $num = sprintf(
"%04d", $max + 1);
 
  161    dol_syslog(
"mod_knowledgerecord_standard::getNextValue return ".$this->prefix.$yymm.
"-".$num);
 
  162    return $this->prefix.$yymm.
"-".$num;
 
 
 
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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.
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.