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 = ".$conf->entity;
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.
getExample()
Return an example of numbering module values.
info()
Return description of numbering module.
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.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
getNextValue($objsoc, $ticket)
Return next value.
Class to manage the numbering module Simple for ticket references.
canBeActivated()
Checks if the numbers already in the database do not cause conflicts that would prevent this numberin...