27require_once DOL_DOCUMENT_ROOT.
'/core/modules/member/modules_member.class.php';
36 public $name =
'Advanced';
37 public $version =
'dolibarr';
44 public $prefix =
'MEM';
60 public function info($langs)
63 return $langs->trans(
"AdvancedNumRefModelDesc", $this->prefix);
74 return $this->prefix.
"2301-0001";
87 global $conf, $langs, $db;
92 $posindice = strlen($this->prefix) + 6;
93 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
94 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent";
95 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
96 $sql .=
" AND entity = ".$conf->entity;
97 $resql = $db->query($sql);
99 $row = $db->fetch_row($resql);
101 $coyymm = substr($row[0], 0, 6);
105 if (!$coyymm || preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
108 $langs->load(
"errors");
109 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
127 $posindice = strlen($this->prefix) + 6;
128 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
129 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent";
130 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
131 $sql .=
" AND entity = ".$conf->entity;
133 $resql = $db->query($sql);
135 $obj = $db->fetch_object($resql);
137 $max = intval($obj->max);
142 dol_syslog(
"mod_member_advanced::getNextValue", LOG_DEBUG);
150 if ($max >= (pow(10, 4) - 1)) {
153 $num = sprintf(
"%04d", $max + 1);
156 dol_syslog(
"mod_member_advanced::getNextValue return ".$this->prefix.$yymm.
"-".$num, LOG_INFO);
157 return $this->prefix.$yymm.
"-".$num;
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $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='auto')
Return date for now.
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.