28require_once DOL_DOCUMENT_ROOT.
'/core/modules/project/task/modules_task.php';
40 public $version =
'dolibarr';
42 public $prefix =
'TK';
54 public $nom =
'Simple';
59 public $name =
'Simple';
68 public function info($langs)
71 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
82 return $this->prefix.
"0501-0001";
95 global $conf, $langs, $db;
100 $posindice = strlen($this->prefix) + 6;
101 $sql =
"SELECT MAX(CAST(SUBSTRING(task.ref FROM ".$posindice.
") AS SIGNED)) as max";
102 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet_task AS task, ";
103 $sql .= MAIN_DB_PREFIX.
"projet AS project WHERE task.fk_projet=project.rowid";
104 $sql .=
" AND task.ref LIKE '".$db->escape($this->prefix).
"____-%'";
105 $sql .=
" AND project.entity = ".$conf->entity;
106 $resql = $db->query($sql);
108 $row = $db->fetch_row($resql);
110 $coyymm = substr($row[0], 0, 6);
114 if (!$coyymm || preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
117 $langs->load(
"errors");
118 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
136 $posindice = strlen($this->prefix) + 6;
137 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
138 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet_task";
139 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
141 $resql = $db->query($sql);
143 $obj = $db->fetch_object($resql);
145 $max = intval($obj->max);
150 dol_syslog(
"mod_task_simple::getNextValue", LOG_DEBUG);
157 if ($max >= (pow(10, 4) - 1)) {
160 $num = sprintf(
"%04d", $max + 1);
163 dol_syslog(
"mod_task_simple::getNextValue return ".$this->prefix.$yymm.
"-".$num);
164 return $this->prefix.$yymm.
"-".$num;
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $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='auto')
Return date for now.
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.