26 require_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';
66 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
76 return $this->prefix.
"0501-0001";
87 global $conf, $langs, $db;
92 $posindice = strlen($this->prefix) + 6;
93 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
94 $sql .=
" FROM ".MAIN_DB_PREFIX.
"ticket";
95 $search = $this->prefix.
"____-%";
96 $sql .=
" WHERE ref LIKE '".$db->escape($search).
"'";
97 $sql .=
" AND entity = ".$conf->entity;
100 $row = $db->fetch_row(
$resql);
102 $coyymm = substr($row[0], 0, 6);
106 if (!$coyymm || preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
109 $langs->load(
"errors");
110 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
127 $posindice = strlen($this->prefix) + 6;
128 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
129 $sql .=
" FROM ".MAIN_DB_PREFIX.
"ticket";
130 $search = $this->prefix.
"____-%";
131 $sql .=
" WHERE ref LIKE '".$db->escape($search).
"'";
132 $sql .=
" AND entity IN (".getEntity(
'ticketnumber', 1, $ticket).
")";
134 $resql = $db->query($sql);
136 $obj = $db->fetch_object(
$resql);
138 $max = intval($obj->max);
143 dol_syslog(
"mod_ticket_simple::getNextValue", LOG_DEBUG);
147 $date = empty($ticket->datec) ?
dol_now() : $ticket->datec;
150 $yymm = strftime(
"%y%m", $date);
152 if ($max >= (pow(10, 4) - 1)) {
156 $num = sprintf(
"%04s", $max + 1);
159 dol_syslog(
"mod_ticket_simple::getNextValue return ".$this->prefix.$yymm.
"-".$num);
160 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()
Return description of numbering module.
canBeActivated()
Checks if the numbers already in the database do not cause conflicts that would prevent this numberin...
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
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.