27require_once DOL_DOCUMENT_ROOT.
'/core/modules/member/modules_member.class.php';
36 public $name =
'Advanced';
37 public $version =
'dolibarr';
42 public $position = 40;
49 public $prefix =
'MEM';
65 public function info($langs)
68 return $langs->trans(
"AdvancedNumRefModelDesc", $this->prefix);
79 return $this->prefix.
"2301-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.
"adherent";
100 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
101 $sql .=
" AND entity = ".$conf->entity;
102 $resql = $db->query($sql);
104 $row = $db->fetch_row($resql);
106 $coyymm = substr($row[0], 0, 6);
110 if (!$coyymm || preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
113 $langs->load(
"errors");
114 $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.
"adherent";
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);
147 dol_syslog(
"mod_member_advanced::getNextValue", LOG_DEBUG);
155 if ($max >= (pow(10, 4) - 1)) {
158 $num = sprintf(
"%04d", $max + 1);
161 dol_syslog(
"mod_member_advanced::getNextValue return ".$this->prefix.$yymm.
"-".$num, LOG_INFO);
162 return $this->prefix.$yymm.
"-".$num;
if(! $sortfield) if(! $sortorder) $object
Class mere des modeles de numerotation des references de members.
Class to manage the numbering module Advanced for member references.
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 module values.
getNextValue($objsoc, $object)
Return next value.
__construct()
Constructor.
dol_now($mode='gmt')
Return date for now.
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.