27require_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_payment/modules_supplier_payment.php';
38 public $version =
'dolibarr';
40 public $prefix =
'SPAY';
52 public $nom =
'Bronan';
57 public $name =
'Bronan';
66 public function info($langs)
69 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
80 return $this->prefix.
"0501-0001";
93 global $conf, $langs, $db;
98 $posindice = strlen($this->prefix) + 6;
99 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
100 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiementfourn";
101 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
102 $sql .=
" AND entity = ".$conf->entity;
104 $resql = $db->query($sql);
106 $row = $db->fetch_row($resql);
108 $payyymm = substr($row[0], 0, 6);
112 if ($payyymm && !preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $payyymm)) {
113 $langs->load(
"errors");
114 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
133 $posindice = strlen($this->prefix) + 6;
134 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
135 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiementfourn";
136 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
137 $sql .=
" AND entity = ".$conf->entity;
139 $resql = $db->query($sql);
141 $obj = $db->fetch_object($resql);
143 $max = intval($obj->max);
156 if ($max >= (pow(10, 4) - 1)) {
159 $num = sprintf(
"%04d", $max + 1);
162 dol_syslog(__METHOD__.
" return ".$this->prefix.$yymm.
"-".$num);
163 return $this->prefix.$yymm.
"-".$num;
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
ModeleNumRefSupplierPayments.
Class to manage customer payment numbering rules Cicada.
info($langs)
Return description of numbering module.
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=null, $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.