28require_once DOL_DOCUMENT_ROOT.
'/core/modules/propale/modules_propale.php';
40 public $version =
'dolibarr';
45 public $prefix =
'PR';
55 public $position = 10;
62 public $nom =
'Marbre';
67 public $name =
'Marbre';
76 public function info($langs)
79 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
90 return $this->prefix.
"0501-0001";
103 global $conf, $langs, $db;
108 $posindice = strlen($this->prefix) + 6;
109 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
110 $sql .=
" FROM ".MAIN_DB_PREFIX.
"propal";
111 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
112 $sql .=
" AND entity = ".$conf->entity;
114 $resql = $db->query($sql);
116 $row = $db->fetch_row($resql);
118 $pryymm = substr($row[0], 0, 6);
123 if (!$pryymm || preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $pryymm)) {
126 $langs->load(
"errors");
127 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
144 $posindice = strlen($this->prefix) + 6;
145 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
146 $sql .=
" FROM ".MAIN_DB_PREFIX.
"propal";
147 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
148 $sql .=
" AND entity IN (".getEntity(
'proposalnumber', 1, $propal).
")";
150 $resql = $db->query($sql);
152 $obj = $db->fetch_object($resql);
154 $max = intval($obj->max);
159 dol_syslog(get_class($this).
"::getNextValue", LOG_DEBUG);
166 if ($max >= (pow(10, 4) - 1)) {
169 $num = sprintf(
"%04d", $max + 1);
172 dol_syslog(get_class($this).
"::getNextValue return ".$this->prefix.$yymm.
"-".$num);
173 return $this->prefix.$yymm.
"-".$num;
if(! $sortfield) if(! $sortorder) $object
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=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.