28require_once DOL_DOCUMENT_ROOT .
'/core/modules/stocktransfer/modules_stocktransfer.php';
40 public $version =
'dolibarr';
45 public $prefix =
'ST';
55 public $name =
'standard';
64 public function info($langs)
67 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
78 return $this->prefix.
"0501-0001";
91 global
$conf, $langs, $db;
96 $posindice = strlen($this->prefix) + 6;
97 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
98 $sql .=
" FROM ".MAIN_DB_PREFIX.
"stocktransfer_stocktransfer";
99 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
100 if (
$object->ismultientitymanaged == 1) {
101 $sql .=
" AND entity = ".$conf->entity;
102 } elseif (!is_numeric(
$object->ismultientitymanaged)) {
106 $resql = $db->query($sql);
108 $row = $db->fetch_row($resql);
110 $coyymm = substr($row[0], 0, 6);
114 if ($coyymm && !preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
115 $langs->load(
"errors");
116 $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.
"stocktransfer_stocktransfer";
137 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
138 if (
$object->ismultientitymanaged == 1) {
139 $sql .=
" AND entity = ".$conf->entity;
140 } elseif (!is_numeric(
$object->ismultientitymanaged)) {
144 $resql = $db->query($sql);
146 $obj = $db->fetch_object($resql);
148 $max = intval($obj->max);
153 dol_syslog(
"mod_stocktransfer_standard::getNextValue", LOG_DEBUG);
158 $date =
$object->date_creation;
161 if ($max >= (pow(10, 4) - 1)) {
164 $num = sprintf(
"%04d", $max + 1);
167 dol_syslog(
"mod_stocktransfer_standard::getNextValue return ".$this->prefix.$yymm.
"-".$num);
168 return $this->prefix.$yymm.
"-".$num;
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Parent class to manage numbering of StockTransfer.
Class to manage the Standard numbering rule for Stock.
getNextValue($object)
Return next free value.
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.
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...