38 public $version =
'dolibarr';
44 public $prefix =
'TC';
55 public $nom =
'Simple';
66 return $langs->trans(
'SimpleNumRefModelDesc', $this->prefix.
'0-');
76 return $this->prefix.
'0-0501-0001';
87 global $conf, $langs, $db;
95 $posindice = strlen($this->prefix.$pos_source.
'-____-') + 1;
97 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
98 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture";
99 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
100 $sql .=
" AND entity = ".$conf->entity;
102 $resql = $db->query($sql);
104 $row = $db->fetch_row(
$resql);
106 $pryymm = substr($row[0], 0, 6);
111 if (!$pryymm || preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $pryymm)) {
114 $langs->load(
"errors");
115 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
128 public function getNextValue($objsoc = null, $invoice = null, $mode =
'next')
132 $pos_source = is_object($invoice) && $invoice->pos_source > 0 ? $invoice->pos_source : 0;
135 $posindice = strlen($this->prefix.$pos_source.
'-____-') + 1;
136 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
137 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture";
138 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix.$pos_source).
"-____-%'";
139 $sql .=
" AND entity IN (".getEntity(
'invoicenumber', 1, $invoice).
")";
141 $resql = $db->query($sql);
143 $obj = $db->fetch_object(
$resql);
144 if ($obj) $max = intval($obj->max);
147 dol_syslog(get_class($this).
"::getNextValue", LOG_DEBUG);
153 if ($max >= (pow(10, 4) - 1)) $num = $max;
154 else $num = sprintf(
"%04s", $max);
157 $sql =
"SELECT ref as ref";
158 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture";
159 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix.$pos_source).
"-____-".$num.
"'";
160 $sql .=
" AND entity IN (".getEntity(
'invoicenumber', 1, $invoice).
")";
161 $sql .=
" ORDER BY ref DESC";
163 $resql = $db->query($sql);
165 $obj = $db->fetch_object(
$resql);
166 if ($obj) $ref = $obj->ref;
170 } elseif ($mode ==
'next')
172 $date = $invoice->date;
173 $yymm = strftime(
"%y%m", $date);
175 if ($max >= (pow(10, 4) - 1)) $num = $max + 1;
176 else $num = sprintf(
"%04s", $max + 1);
178 dol_syslog(get_class($this).
"::getNextValue return ".$this->prefix.$pos_source.
'-'.$yymm.
'-'.$num);
179 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(!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.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getNextValue()
Renvoi prochaine valeur attribuee.