26require_once DOL_DOCUMENT_ROOT.
'/core/modules/expedition/modules_expedition.php';
37 public $version =
'dolibarr';
39 public $prefix =
'SH';
51 public $nom =
'Safor';
56 public $name =
'Safor';
65 public function info($langs)
68 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
79 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.
"expedition";
99 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
100 $sql .=
" AND entity = ".$conf->entity;
102 $resql = $db->query($sql);
104 $row = $db->fetch_row($resql);
106 $coyymm = substr($row[0], 0, 6);
110 if ($coyymm && !preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
111 $langs->load(
"errors");
112 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
130 $posindice = strlen($this->prefix) + 6;
131 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
132 $sql .=
" FROM ".MAIN_DB_PREFIX.
"expedition";
133 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
134 $sql .=
" AND entity = ".$conf->entity;
136 $resql = $db->query($sql);
138 $obj = $db->fetch_object($resql);
140 $max = intval($obj->max);
145 dol_syslog(
"mod_expedition_safor::getNextValue", LOG_DEBUG);
149 $date = $shipment->date_creation;
152 if ($max >= (pow(10, 4) - 1)) {
155 $num = sprintf(
"%04d", $max + 1);
158 dol_syslog(
"mod_expedition_safor::getNextValue return ".$this->prefix.$yymm.
"-".$num);
159 return $this->prefix.$yymm.
"-".$num;
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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.
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=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.