38 public $version =
'dolibarr';
44 public $prefix =
'TC';
55 public $nom =
'Simple';
66 $textinfo = $langs->trans(
'SimpleNumRefModelDesc', $this->prefix.
'0-');
67 $textinfo .=
'<br>'.$langs->trans(
'EachTerminalHasItsOwnCounter');
79 return $this->prefix.
'0-0501-0001';
90 global $conf, $langs, $db;
98 $posindice = strlen($this->prefix.$pos_source.
'-____-') + 1;
100 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
101 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture";
102 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix.$pos_source.
"-____-%").
"'";
103 $sql .=
" AND entity = ".$conf->entity;
105 $resql = $db->query($sql);
107 $row = $db->fetch_row(
$resql);
109 $pryymm = substr($row[0], 0, 6);
114 if (!$pryymm || preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $pryymm)) {
117 $langs->load(
"errors");
118 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
134 public function getNextValue($objsoc = null, $invoice = null, $mode =
'next')
138 $pos_source = is_object($invoice) && $invoice->pos_source > 0 ? $invoice->pos_source : 0;
141 $posindice = strlen($this->prefix.$pos_source.
'-____-') + 1;
142 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
143 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture";
144 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix.$pos_source.
"-____-%").
"'";
145 $sql .=
" AND entity IN (".getEntity(
'invoicenumber', 1, $invoice).
")";
148 $resql = $db->query($sql);
150 $obj = $db->fetch_object(
$resql);
152 $max = intval($obj->max);
157 dol_syslog(get_class($this).
"::getNextValue", LOG_DEBUG);
161 if ($mode ==
'last') {
162 if ($max >= (pow(10, 4) - 1)) {
165 $num = sprintf(
"%04s", $max);
169 $sql =
"SELECT ref as ref";
170 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture";
171 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix.$pos_source.
"-____-".$num).
"'";
172 $sql .=
" AND entity IN (".getEntity(
'invoicenumber', 1, $invoice).
")";
173 $sql .=
" ORDER BY ref DESC";
175 $resql = $db->query($sql);
177 $obj = $db->fetch_object(
$resql);
186 } elseif ($mode ==
'next') {
187 $date = $invoice->date;
188 $yymm = strftime(
"%y%m", $date);
190 if ($max >= (pow(10, 4) - 1)) {
193 $num = sprintf(
"%04s", $max + 1);
196 dol_syslog(get_class($this).
"::getNextValue return ".$this->prefix.$pos_source.
'-'.$yymm.
'-'.$num);
197 return $this->prefix.$pos_source.
'-'.$yymm.
'-'.$num;
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname= '')
Make an include_once using default root and alternate root if it fails.
getNextValue($objsoc=null, $invoice=null, $mode= 'next')
Return next value.
canBeActivated()
Test si les numeros deja en vigueur dans la base ne provoquent pas de de conflits qui empechera cette...
info()
Return description of numbering module.
Class to manage ref numbering of takepos cards with rule Simple.
Classe mere des modeles de numerotation des tickets de caisse.
getExample()
Return an example of numbering module values.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
getNumRef($objsoc, $objforref)
Return next free value.
if(isModEnabled('facture')&&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur')&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)&&$user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice')&&$user->rights->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->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...