26require_once DOL_DOCUMENT_ROOT.
'/core/modules/ticket/modules_ticket.php';
37 public $version =
'dolibarr';
39 public $prefix =
'TS';
51 public $nom =
'Simple';
56 public $name =
'Simple';
64 public function info($langs)
67 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
77 return $this->prefix.
"0501-0001";
89 global $conf, $langs, $db;
94 $posindice = strlen($this->prefix) + 6;
95 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
96 $sql .=
" FROM ".MAIN_DB_PREFIX.
"ticket";
97 $search = $this->prefix.
"____-%";
98 $sql .=
" WHERE ref LIKE '".$db->escape($search).
"'";
99 $sql .=
" AND entity = ".$conf->entity;
100 $resql = $db->query($sql);
102 $row = $db->fetch_row($resql);
104 $coyymm = substr($row[0], 0, 6);
108 if (!$coyymm || preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
111 $langs->load(
"errors");
112 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
129 $posindice = strlen($this->prefix) + 6;
130 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
131 $sql .=
" FROM ".MAIN_DB_PREFIX.
"ticket";
132 $search = $this->prefix.
"____-%";
133 $sql .=
" WHERE ref LIKE '".$db->escape($search).
"'";
134 $sql .=
" AND entity IN (".getEntity(
'ticketnumber', 1, $ticket).
")";
136 $resql = $db->query($sql);
138 $obj = $db->fetch_object($resql);
140 $max = intval($obj->max);
145 dol_syslog(
"mod_ticket_simple::getNextValue", LOG_DEBUG);
149 $date = empty($ticket->datec) ?
dol_now() : $ticket->datec;
154 if ($max >= (pow(10, 4) - 1)) {
158 $num = sprintf(
"%04s", $max + 1);
161 dol_syslog(
"mod_ticket_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 ticket references.
getExample()
Return an example of numbering module values.
getNextValue($objsoc, $ticket)
Return next value.
info($langs)
Return description of numbering module.
canBeActivated($object)
Checks if the numbers already in the database do not cause conflicts that would prevent this numberin...
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.