26require_once DOL_DOCUMENT_ROOT.
'/core/modules/project/task/modules_task.php';
38 public $version =
'dolibarr';
40 public $prefix =
'TK';
52 public $nom =
'Simple';
57 public $name =
'Simple';
66 public function info($langs)
69 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
80 return $this->prefix.
"0501-0001";
93 global $conf, $langs, $db;
98 $posindice = strlen($this->prefix) + 6;
99 $sql =
"SELECT MAX(CAST(SUBSTRING(task.ref FROM ".$posindice.
") AS SIGNED)) as max";
100 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet_task AS task, ";
101 $sql .= MAIN_DB_PREFIX.
"projet AS project WHERE task.fk_projet=project.rowid";
102 $sql .=
" AND task.ref LIKE '".$db->escape($this->prefix).
"____-%'";
103 $sql .=
" AND project.entity = ".$conf->entity;
104 $resql = $db->query($sql);
106 $row = $db->fetch_row($resql);
108 $coyymm = substr($row[0], 0, 6);
112 if (!$coyymm || preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
115 $langs->load(
"errors");
116 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
134 $posindice = strlen($this->prefix) + 6;
135 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
136 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet_task";
137 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
139 $resql = $db->query($sql);
141 $obj = $db->fetch_object($resql);
143 $max = intval($obj->max);
148 dol_syslog(
"mod_task_simple::getNextValue", LOG_DEBUG);
152 $date = empty($object->date_c) ?
dol_now() : $object->date_c;
155 if ($max >= (pow(10, 4) - 1)) {
158 $num = sprintf(
"%04s", $max + 1);
161 dol_syslog(
"mod_task_simple::getNextValue return ".$this->prefix.$yymm.
"-".$num);
162 return $this->prefix.$yymm.
"-".$num;
Parent class of task reference numbering models.
Class to manage the numbering module Simple for project references.
getExample()
Return an example of numbering module values.
info($langs)
Return description of numbering module.
getNextValue($objsoc, $object)
Return next value.
canBeActivated($object)
Checks if the numbers already in the database do not cause conflicts that would prevent this numberin...
task_get_num($objsoc=0, $object='')
Return next reference not yet used as a reference.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.