28require_once DOL_DOCUMENT_ROOT.
'/core/modules/propale/modules_propale.php';
40 public $version =
'dolibarr';
42 public $prefix =
'PR';
54 public $nom =
'Marbre';
59 public $name =
'Marbre';
68 public function info($langs)
71 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
82 return $this->prefix.
"0501-0001";
95 global $conf, $langs, $db;
100 $posindice = strlen($this->prefix) + 6;
101 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
102 $sql .=
" FROM ".MAIN_DB_PREFIX.
"propal";
103 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
104 $sql .=
" AND entity = ".$conf->entity;
106 $resql = $db->query($sql);
108 $row = $db->fetch_row($resql);
110 $pryymm = substr($row[0], 0, 6);
115 if (!$pryymm || preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $pryymm)) {
118 $langs->load(
"errors");
119 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
136 $posindice = strlen($this->prefix) + 6;
137 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
138 $sql .=
" FROM ".MAIN_DB_PREFIX.
"propal";
139 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
140 $sql .=
" AND entity IN (".getEntity(
'proposalnumber', 1, $propal).
")";
142 $resql = $db->query($sql);
144 $obj = $db->fetch_object($resql);
146 $max = intval($obj->max);
151 dol_syslog(get_class($this).
"::getNextValue", LOG_DEBUG);
158 if ($max >= (pow(10, 4) - 1)) {
161 $num = sprintf(
"%04d", $max + 1);
164 dol_syslog(get_class($this).
"::getNextValue return ".$this->prefix.$yymm.
"-".$num);
165 return $this->prefix.$yymm.
"-".$num;
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $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)
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.