26require_once DOL_DOCUMENT_ROOT.
'/core/modules/propale/modules_propale.php';
38 public $version =
'dolibarr';
40 public $prefix =
'PR';
52 public $nom =
'Marbre';
57 public $name =
'Marbre';
66 public function info($langs)
69 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
80 return $this->prefix.
"0501-0001";
93 global $conf, $langs, $db;
98 $posindice = strlen($this->prefix) + 6;
99 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
100 $sql .=
" FROM ".MAIN_DB_PREFIX.
"propal";
101 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
102 $sql .=
" AND entity = ".$conf->entity;
104 $resql = $db->query($sql);
106 $row = $db->fetch_row($resql);
108 $pryymm = substr($row[0], 0, 6);
113 if (!$pryymm || preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $pryymm)) {
116 $langs->load(
"errors");
117 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
134 $posindice = strlen($this->prefix) + 6;
135 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
136 $sql .=
" FROM ".MAIN_DB_PREFIX.
"propal";
137 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
138 $sql .=
" AND entity IN (".getEntity(
'proposalnumber', 1, $propal).
")";
140 $resql = $db->query($sql);
142 $obj = $db->fetch_object($resql);
144 $max = intval($obj->max);
149 dol_syslog(get_class($this).
"::getNextValue", LOG_DEBUG);
156 if ($max >= (pow(10, 4) - 1)) {
159 $num = sprintf(
"%04s", $max + 1);
162 dol_syslog(get_class($this).
"::getNextValue return ".$this->prefix.$yymm.
"-".$num);
163 return $this->prefix.$yymm.
"-".$num;
Parent class for numbering rules of proposals.
Class to manage business proposition rules Marbre.
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.
getNumRef($objsoc, $objforref)
Return next free value.
getNextValue($objsoc, $propal)
Return next value.
info($langs)
Return description of numbering module.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $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.