25require_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_payment/modules_supplier_payment.php';
36 public $version =
'dolibarr';
38 public $prefix =
'SPAY';
50 public $nom =
'Bronan';
55 public $name =
'Bronan';
64 public function info($langs)
67 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
78 return $this->prefix.
"0501-0001";
91 global $conf, $langs, $db;
96 $posindice = strlen($this->prefix) + 6;
97 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
98 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiementfourn";
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 $payyymm = substr($row[0], 0, 6);
110 if ($payyymm && !preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $payyymm)) {
111 $langs->load(
"errors");
112 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
131 $posindice = strlen($this->prefix) + 6;
132 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
133 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiementfourn";
134 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
135 $sql .=
" AND entity = ".$conf->entity;
137 $resql = $db->query($sql);
139 $obj = $db->fetch_object($resql);
141 $max = intval($obj->max);
151 $date = $object->datepaye;
154 if ($max >= (pow(10, 4) - 1)) {
157 $num = sprintf(
"%04s", $max + 1);
160 dol_syslog(__METHOD__.
" return ".$this->prefix.$yymm.
"-".$num);
161 return $this->prefix.$yymm.
"-".$num;
ModeleNumRefSupplierPayments.
Class to manage customer payment numbering rules Cicada.
info($langs)
Return description of numbering module.
payment_get_num($objsoc, $objforref)
Return next free value.
canBeActivated($object)
Checks if the numbers already in the database do not cause conflicts that would prevent this numberin...
getExample()
Return an example of numbering.
getNextValue($objsoc, $object)
Return next free value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.