24require_once DOL_DOCUMENT_ROOT.
'/core/modules/expedition/modules_expedition.php';
35 public $version =
'dolibarr';
37 public $prefix =
'SH';
49 public $nom =
'Safor';
54 public $name =
'Safor';
65 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
76 return $this->prefix.
"0501-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.
"expedition";
95 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
96 $sql .=
" AND entity = ".$conf->entity;
98 $resql = $db->query($sql);
100 $row = $db->fetch_row($resql);
102 $coyymm = substr($row[0], 0, 6);
106 if ($coyymm && !preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
107 $langs->load(
"errors");
108 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
126 $posindice = strlen($this->prefix) + 6;
127 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
128 $sql .=
" FROM ".MAIN_DB_PREFIX.
"expedition";
129 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
130 $sql .=
" AND entity = ".$conf->entity;
132 $resql = $db->query($sql);
134 $obj = $db->fetch_object($resql);
136 $max = intval($obj->max);
141 dol_syslog(
"mod_expedition_safor::getNextValue", LOG_DEBUG);
146 $yymm = strftime(
"%y%m", $date);
148 if ($max >= (pow(10, 4) - 1)) {
151 $num = sprintf(
"%04s", $max + 1);
154 dol_syslog(
"mod_expedition_safor::getNextValue return ".$this->prefix.$yymm.
"-".$num);
155 return $this->prefix.$yymm.
"-".$num;
Parent Class of numbering models of sending receipts references.
Class to manage expedition numbering rules Safor.
expedition_get_num($objsoc, $objforref)
Return next free value.
info()
Return default description of numbering model.
getExample()
Return numbering example.
canBeActivated()
Test if existing numbers make problems with numbering.
getNextValue($objsoc, $shipment)
Return next value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.