28require_once DOL_DOCUMENT_ROOT.
'/core/modules/project/task/modules_task.php';
40 public $version =
'dolibarr';
45 public $prefix =
'TK';
57 public $nom =
'Simple';
62 public $name =
'Simple';
71 public function info($langs)
74 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
85 return $this->prefix.
"0501-0001";
98 global
$conf, $langs, $db;
103 $posindice = strlen($this->prefix) + 6;
104 $sql =
"SELECT MAX(CAST(SUBSTRING(task.ref FROM ".$posindice.
") AS SIGNED)) as max";
105 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet_task AS task, ";
106 $sql .= MAIN_DB_PREFIX.
"projet AS project WHERE task.fk_projet = project.rowid";
107 $sql .=
" AND task.ref LIKE '".$db->escape($this->prefix).
"____-%'";
108 $sql .=
" AND project.entity = ".((int)
$conf->entity);
109 $resql =
$db->query($sql);
111 $row =
$db->fetch_row($resql);
113 $coyymm = substr($row[0], 0, 6);
117 if (!$coyymm || preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
120 $langs->load(
"errors");
121 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
139 $posindice = strlen($this->prefix) + 6;
140 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
141 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet_task";
142 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
144 $resql =
$db->query($sql);
146 $obj =
$db->fetch_object($resql);
148 $max = intval($obj->max);
153 dol_syslog(
"mod_task_simple::getNextValue", LOG_DEBUG);
160 if ($max >= (pow(10, 4) - 1)) {
163 $num = sprintf(
"%04d", $max + 1);
166 dol_syslog(
"mod_task_simple::getNextValue return ".$this->prefix.$yymm.
"-".$num);
167 return $this->prefix.$yymm.
"-".$num;
if(! $sortfield) if(! $sortorder) $object
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...
dol_now($mode='gmt')
Return date for now.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
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.