28require_once DOL_DOCUMENT_ROOT.
'/core/modules/ticket/modules_ticket.php';
39 public $version =
'dolibarr';
41 public $prefix =
'TS';
53 public $nom =
'Simple';
58 public $name =
'Simple';
66 public function info($langs)
69 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(ref FROM ".$posindice.
") AS SIGNED)) as max";
98 $sql .=
" FROM ".MAIN_DB_PREFIX.
"ticket";
99 $search = $this->prefix.
"____-%";
100 $sql .=
" WHERE ref LIKE '".$db->escape($search).
"'";
101 $sql .=
" AND 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);
131 $posindice = strlen($this->prefix) + 6;
132 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
133 $sql .=
" FROM ".MAIN_DB_PREFIX.
"ticket";
134 $search = $this->prefix.
"____-%";
135 $sql .=
" WHERE ref LIKE '".$db->escape($search).
"'";
136 $sql .=
" AND entity IN (".getEntity(
'ticketnumber', 1, $ticket).
")";
138 $resql = $db->query($sql);
140 $obj = $db->fetch_object($resql);
142 $max = intval($obj->max);
147 dol_syslog(
"mod_ticket_simple::getNextValue", LOG_DEBUG);
151 $date = empty($ticket->datec) ?
dol_now() : $ticket->datec;
156 if ($max >= (pow(10, 4) - 1)) {
160 $num = sprintf(
"%04d", $max + 1);
163 dol_syslog(
"mod_ticket_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 the project reference numbering model classes.
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_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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...