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';
63 public function info($langs)
66 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
77 return $this->prefix.
"0501-0001";
89 global $conf, $langs, $db;
94 $posindice = strlen($this->prefix) + 6;
95 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
96 $sql .=
" FROM ".MAIN_DB_PREFIX.
"expedition";
97 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
98 $sql .=
" AND entity = ".$conf->entity;
100 $resql = $db->query($sql);
102 $row = $db->fetch_row($resql);
104 $coyymm = substr($row[0], 0, 6);
108 if ($coyymm && !preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
109 $langs->load(
"errors");
110 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
128 $posindice = strlen($this->prefix) + 6;
129 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
130 $sql .=
" FROM ".MAIN_DB_PREFIX.
"expedition";
131 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
132 $sql .=
" AND entity = ".$conf->entity;
134 $resql = $db->query($sql);
136 $obj = $db->fetch_object($resql);
138 $max = intval($obj->max);
143 dol_syslog(
"mod_expedition_safor::getNextValue", LOG_DEBUG);
147 $date = $shipment->date_creation;
150 if ($max >= (pow(10, 4) - 1)) {
153 $num = sprintf(
"%04s", $max + 1);
156 dol_syslog(
"mod_expedition_safor::getNextValue return ".$this->prefix.$yymm.
"-".$num);
157 return $this->prefix.$yymm.
"-".$num;
Parent Class of numbering models of sending receipts references.
Class to manage expedition numbering rules Safor.
canBeActivated($object)
Test if existing numbers make problems with numbering.
expedition_get_num($objsoc, $objforref)
Return next free value.
info($langs)
Return default description of numbering model.
getExample()
Return numbering example.
getNextValue($objsoc, $shipment)
Return next value.
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.