28 require_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_invoice/modules_facturefournisseur.php';
40 public $version =
'dolibarr';
52 public $nom =
'Cactus';
57 public $name =
'Cactus';
59 public $prefixinvoice =
'SI';
61 public $prefixcreditnote =
'SA';
63 public $prefixdeposit =
'SD';
74 $langs->load(
"bills");
75 return $langs->trans(
"CactusNumRefModelDesc1", $this->prefixinvoice, $this->prefixcreditnote, $this->prefixdeposit);
86 return $this->prefixinvoice.
"1301-0001";
97 global $conf, $langs, $db;
99 $langs->load(
"bills");
102 $siyymm =
''; $max =
'';
104 $posindice = strlen($this->prefixinvoice) + 6;
105 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
106 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn";
107 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefixinvoice).
"____-%'";
108 $sql .=
" AND entity = ".$conf->entity;
109 $resql = $db->query($sql);
112 $row = $db->fetch_row(
$resql);
113 if ($row) { $siyymm = substr($row[0], 0, 6); $max = $row[0]; }
115 if ($siyymm && !preg_match(
'/'.$this->prefixinvoice.
'[0-9][0-9][0-9][0-9]/i', $siyymm))
117 $langs->load(
"errors");
118 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
125 $posindice = strlen($this->prefixcreditnote) + 6;
126 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
127 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn";
128 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefixcreditnote).
"____-%'";
129 $sql .=
" AND entity = ".$conf->entity;
131 $resql = $db->query($sql);
134 $row = $db->fetch_row(
$resql);
135 if ($row) { $siyymm = substr($row[0], 0, 6); $max = $row[0]; }
137 if ($siyymm && !preg_match(
'/'.$this->prefixcreditnote.
'[0-9][0-9][0-9][0-9]/i', $siyymm))
139 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
146 $posindice = strlen($this->prefixdeposit) + 6;
147 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
148 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn";
149 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefixdeposit).
"____-%'";
150 $sql .=
" AND entity = ".$conf->entity;
152 $resql = $db->query($sql);
155 $row = $db->fetch_row(
$resql);
156 if ($row) { $siyymm = substr($row[0], 0, 6); $max = $row[0]; }
158 if ($siyymm && !preg_match(
'/'.$this->prefixdeposit.
'[0-9][0-9][0-9][0-9]/i', $siyymm))
160 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
177 $prefix = $this->prefixinvoice;
178 if ($object->type == 2) $prefix = $this->prefixcreditnote;
179 elseif ($object->type == 3) $prefix = $this->prefixdeposit;
182 $posindice = strlen($prefix) + 6;
183 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
184 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn";
185 $sql .=
" WHERE ref LIKE '".$db->escape($prefix).
"____-%'";
186 $sql .=
" AND entity = ".$conf->entity;
188 $resql = $db->query($sql);
189 dol_syslog(get_class($this).
"::getNextValue", LOG_DEBUG);
192 $obj = $db->fetch_object(
$resql);
193 if ($obj) $max = intval($obj->max);
201 if ($max >= (pow(10, 4) - 1)) $num = $max;
202 else $num = sprintf(
"%04s", $max);
205 $sql =
"SELECT ref as ref";
206 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn";
207 $sql .=
" WHERE ref LIKE '".$db->escape($prefix).
"____-".$num.
"'";
208 $sql .=
" AND entity = ".$conf->entity;
210 dol_syslog(get_class($this).
"::getNextValue", LOG_DEBUG);
211 $resql = $db->query($sql);
214 $obj = $db->fetch_object(
$resql);
215 if ($obj) $ref = $obj->ref;
219 } elseif ($mode ==
'next')
221 $date = $object->date;
222 $yymm = strftime(
"%y%m", $date);
224 if ($max >= (pow(10, 4) - 1)) $num = $max + 1;
225 else $num = sprintf(
"%04s", $max + 1);
227 dol_syslog(get_class($this).
"::getNextValue return ".$prefix.$yymm.
"-".$num);
228 return $prefix.$yymm.
"-".$num;
241 public function getNumRef($objsoc, $objforref, $mode =
'next')
getNumRef($objsoc, $objforref, $mode= 'next')
Return next free value.
getExample()
Returns a numbering example.
info()
Return description of numbering model.
Parent Class of numbering models of suppliers invoices references.
getNextValue($objsoc, $object, $mode= 'next')
Return next value.
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.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Cactus Class of numbering models of suppliers invoices references.
canBeActivated()
Tests if the numbers already in force in the database do not cause conflicts that would prevent this ...