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';
68 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
79 return $this->prefix.
"0501-0001";
91 global $conf, $langs, $db;
96 $posindice = strlen($this->prefix) + 6;
97 $sql =
"SELECT MAX(CAST(SUBSTRING(task.ref FROM ".$posindice.
") AS SIGNED)) as max";
98 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet_task AS task, ";
99 $sql .= MAIN_DB_PREFIX.
"projet AS project WHERE task.fk_projet=project.rowid";
100 $sql .=
" AND task.ref LIKE '".$db->escape($this->prefix).
"____-%'";
101 $sql .=
" AND project.entity = ".$conf->entity;
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)) {
113 $langs->load(
"errors");
114 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
132 $posindice = strlen($this->prefix) + 6;
133 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
134 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet_task";
135 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
137 $resql = $db->query($sql);
139 $obj = $db->fetch_object($resql);
141 $max = intval($obj->max);
146 dol_syslog(
"mod_task_simple::getNextValue", LOG_DEBUG);
150 $date = empty($object->date_c) ?
dol_now() : $object->date_c;
153 $yymm = strftime(
"%y%m", $date);
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;
Classe mere des modeles de numerotation des references de projets.
Class to manage the numbering module Simple for project references.
getExample()
Return an example of numbering module values.
info()
Return description of numbering module.
getNextValue($objsoc, $object)
Return next value.
canBeActivated()
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_now($mode='auto')
Return date for now.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.