25 require_once DOL_DOCUMENT_ROOT.
'/core/modules/member/modules_member.class.php';
37 public $version =
'dolibarr';
39 public $prefix =
'MEM';
51 public $nom =
'Simple';
56 public $name =
'Simple';
67 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
78 return $this->prefix.
"0501-0001";
90 global $conf, $langs, $db;
95 $posindice = strlen($this->prefix) + 6;
96 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
97 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent";
98 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
99 $sql .=
" AND entity = ".$conf->entity;
100 $resql = $db->query($sql);
102 $row = $db->fetch_row(
$resql);
104 $coyymm = substr($row[0], 0, 6);
108 if (!$coyymm || preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
111 $langs->load(
"errors");
112 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
166 $sql =
"SELECT MAX(rowid) as max";
167 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent";
169 $resql = $db->query($sql);
171 $obj = $db->fetch_object(
$resql);
173 $max = intval($obj->max);
178 dol_syslog(
"mod_member_simple::getNextValue", LOG_DEBUG);