27require_once DOL_DOCUMENT_ROOT.
'/core/modules/payment/modules_payment.php';
38 public $version =
'dolibarr';
43 public $prefix =
'PAY';
55 public $nom =
'Cicada';
60 public $name =
'Cicada';
65 public $position = 30;
74 public function info($langs)
77 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
88 return $this->prefix.
"0501-0001";
101 global
$conf, $langs, $db;
106 $posindice = strlen($this->prefix) + 6;
107 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
108 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiement";
109 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
110 $sql .=
" AND entity = ".$conf->entity;
112 $resql =
$db->query($sql);
114 $row =
$db->fetch_row($resql);
116 $payyymm = substr($row[0], 0, 6);
120 if ($payyymm && !preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $payyymm)) {
121 $langs->load(
"errors");
122 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
141 $posindice = strlen($this->prefix) + 6;
142 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
143 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiement";
144 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
145 $sql .=
" AND entity = ".$conf->entity;
147 $resql =
$db->query($sql);
149 $obj =
$db->fetch_object($resql);
151 $max = intval($obj->max);
164 if ($max >= (pow(10, 4) - 1)) {
167 $num = sprintf(
"%04d", $max + 1);
170 dol_syslog(__METHOD__.
" return ".$this->prefix.$yymm.
"-".$num);
171 return $this->prefix.$yymm.
"-".$num;
if(! $sortfield) if(! $sortorder) $object
Payment numbering references mother class.
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...
getNextValue($objsoc, $object)
Return next free value.
payment_get_num($objsoc, $objforref)
Return next free value.
getExample()
Return an example of numbering.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
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.