25require_once DOL_DOCUMENT_ROOT.
'/core/modules/payment/modules_payment.php';
36 public $version =
'dolibarr';
38 public $prefix =
'PAY';
50 public $nom =
'Cicada';
55 public $name =
'Cicada';
66 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
77 return $this->prefix.
"0501-0001";
89 global $conf, $langs, $db;
94 $posindice = strlen($this->prefix) + 6;
95 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
96 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiement";
97 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
98 $sql .=
" AND entity = ".$conf->entity;
100 $resql = $db->query($sql);
102 $row = $db->fetch_row($resql);
104 $payyymm = substr($row[0], 0, 6);
108 if ($payyymm && !preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $payyymm)) {
109 $langs->load(
"errors");
110 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
129 $posindice = strlen($this->prefix) + 6;
130 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
131 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiement";
132 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
133 $sql .=
" AND entity = ".$conf->entity;
135 $resql = $db->query($sql);
137 $obj = $db->fetch_object($resql);
139 $max = intval($obj->max);
149 $date = $object->datepaye;
150 $yymm = strftime(
"%y%m", $date);
152 if ($max >= (pow(10, 4) - 1)) {
155 $num = sprintf(
"%04s", $max + 1);
158 dol_syslog(__METHOD__.
" return ".$this->prefix.$yymm.
"-".$num);
159 return $this->prefix.$yymm.
"-".$num;
Payment numbering references mother class.
Class to manage customer payment numbering rules Cicada.
getNextValue($objsoc, $object)
Return next free value.
payment_get_num($objsoc, $objforref)
Return next free value.
info()
Return description of numbering module.
getExample()
Return an example of numbering.
canBeActivated()
Checks if the numbers already in the database do not cause conflicts that would prevent this numberin...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.