26require_once DOL_DOCUMENT_ROOT.
'/core/modules/payment/modules_payment.php';
37 public $version =
'dolibarr';
39 public $prefix =
'PAY';
51 public $nom =
'Cicada';
56 public $name =
'Cicada';
65 public function info($langs)
68 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
79 return $this->prefix.
"0501-0001";
92 global
$conf, $langs, $db;
97 $posindice = strlen($this->prefix) + 6;
98 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
99 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiement";
100 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
101 $sql .=
" AND entity = ".$conf->entity;
103 $resql = $db->query($sql);
105 $row = $db->fetch_row($resql);
107 $payyymm = substr($row[0], 0, 6);
111 if ($payyymm && !preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $payyymm)) {
112 $langs->load(
"errors");
113 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
132 $posindice = strlen($this->prefix) + 6;
133 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
134 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiement";
135 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
136 $sql .=
" AND entity = ".$conf->entity;
138 $resql = $db->query($sql);
140 $obj = $db->fetch_object($resql);
142 $max = intval($obj->max);
155 if ($max >= (pow(10, 4) - 1)) {
158 $num = sprintf(
"%04d", $max + 1);
161 dol_syslog(__METHOD__.
" return ".$this->prefix.$yymm.
"-".$num);
162 return $this->prefix.$yymm.
"-".$num;
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $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)
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...