25dol_include_once(
'/recruitment/core/modules/recruitment/modules_recruitmentcandidature.php');
37 public $version =
'dolibarr';
39 public $prefix =
'JOA';
49 public $name =
'standard';
58 public function info($langs)
60 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
71 return $this->prefix.
"0501-0001";
84 global $conf, $langs, $db;
89 $posindice = strlen($this->prefix) + 6;
90 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
91 $sql .=
" FROM ".MAIN_DB_PREFIX.
"recruitment_recruitmentcandidature";
92 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
93 if ($object->ismultientitymanaged == 1) {
94 $sql .=
" AND entity = ".$conf->entity;
95 } elseif ($object->ismultientitymanaged == 2) {
99 $resql = $db->query($sql);
101 $row = $db->fetch_row($resql);
103 $coyymm = substr($row[0], 0, 6);
107 if ($coyymm && !preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
108 $langs->load(
"errors");
109 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
127 $posindice = strlen($this->prefix) + 6;
128 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
129 $sql .=
" FROM ".MAIN_DB_PREFIX.
"recruitment_recruitmentcandidature";
130 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
131 if ($object->ismultientitymanaged == 1) {
132 $sql .=
" AND entity = ".$conf->entity;
133 } elseif ($object->ismultientitymanaged == 2) {
137 $resql = $db->query($sql);
139 $obj = $db->fetch_object($resql);
141 $max = intval($obj->max);
146 dol_syslog(
"mod_recruitmentcandidature_standard::getNextValue", LOG_DEBUG);
151 $date = $object->date_creation;
154 if ($max >= (pow(10, 4) - 1)) {
157 $num = sprintf(
"%04s", $max + 1);
160 dol_syslog(
"mod_recruitmentcandidature_standard::getNextValue return ".$this->prefix.$yymm.
"-".$num);
161 return $this->prefix.$yymm.
"-".$num;
Parent class to manage numbering of RecruitmentCandidature.
Class to manage the Standard numbering rule for Job application.
getExample()
Return an example of numbering.
getNextValue($object)
Return next free value.
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.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $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.