27require_once DOL_DOCUMENT_ROOT .
'/core/modules/hrm/modules_evaluation.php';
39 public $version =
'dolibarr';
41 public $prefix =
'EVAL';
51 public $name =
'standard';
60 public function info($langs)
63 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
74 return $this->prefix.
"0501-0001";
87 global
$conf, $langs, $db;
92 $posindice = strlen($this->prefix) + 6;
93 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
94 $sql .=
" FROM ".MAIN_DB_PREFIX.
"hrm_evaluation";
95 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
96 if (
$object->ismultientitymanaged == 1) {
97 $sql .=
" AND entity = ".$conf->entity;
98 } elseif (
$object->ismultientitymanaged == 2) {
102 $resql = $db->query($sql);
104 $row = $db->fetch_row($resql);
106 $coyymm = substr($row[0], 0, 6);
110 if ($coyymm && !preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
111 $langs->load(
"errors");
112 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
130 $posindice = strlen($this->prefix) + 6;
131 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
132 $sql .=
" FROM ".MAIN_DB_PREFIX.
"hrm_evaluation";
133 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
134 if (
$object->ismultientitymanaged == 1) {
135 $sql .=
" AND entity = ".$conf->entity;
136 } elseif (
$object->ismultientitymanaged == 2) {
140 $resql = $db->query($sql);
142 $obj = $db->fetch_object($resql);
144 $max = intval($obj->max);
149 dol_syslog(
"mod_evaluation_standard::getNextValue", LOG_DEBUG);
154 $date =
$object->date_creation;
157 if ($max >= (pow(10, 4) - 1)) {
160 $num = sprintf(
"%04d", $max + 1);
163 dol_syslog(
"mod_evaluation_standard::getNextValue return ".$this->prefix.$yymm.
"-".$num);
164 return $this->prefix.$yymm.
"-".$num;
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Parent class to manage numbering of Evaluation.
Class to manage the Standard numbering rule for HR evaluation.
getExample()
Return an example of numbering.
canBeActivated($object)
Checks if the numbers already in the database do not cause conflicts that would prevent this numberin...
info($langs)
Return description of numbering module.
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).
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...