29require_once DOL_DOCUMENT_ROOT.
'/core/modules/delivery/modules_delivery.php';
43 public $version =
'dolibarr';
60 public $name =
'Jade';
65 public $prefix =
'BL';
74 public function info($langs)
77 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
87 return $this->prefix.
"0501-0001";
99 global $langs, $conf, $db;
101 $langs->load(
"bills");
107 $posindice = strlen($this->prefix) + 6;
108 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
109 $sql .=
" FROM ".MAIN_DB_PREFIX.
"delivery";
110 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
111 $sql .=
" AND entity = ".$conf->entity;
113 $resql = $db->query($sql);
115 $row = $db->fetch_row($resql);
117 $fayymm = substr($row[0], 0, 6);
121 if ($fayymm && !preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $fayymm)) {
122 $langs->load(
"errors");
123 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
142 $posindice = strlen($this->prefix) + 6;
143 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
144 $sql .=
" FROM ".MAIN_DB_PREFIX.
"delivery";
145 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
146 $sql .=
" AND entity = ".$conf->entity;
148 $resql = $db->query($sql);
149 dol_syslog(
"mod_delivery_jade::getNextValue", LOG_DEBUG);
151 $obj = $db->fetch_object($resql);
153 $max = intval($obj->max);
161 $date =
$object->date_delivery;
167 if ($max >= (pow(10, 4) - 1)) {
170 $num = sprintf(
"%04d", $max + 1);
173 dol_syslog(
"mod_delivery_jade::getNextValue return ".$this->prefix.$yymm.
"-".$num);
174 return $this->prefix.$yymm.
"-".$num;
if(! $sortfield) if(! $sortorder) $object
Class mere des modeles de numerotation des references de bon de livraison.
Class du modele de numerotation de reference de bon de livraison Jade.
info($langs)
Returns the description of the numbering model.
canBeActivated($object)
Checks if the numbers already in the database do not cause conflicts that would prevent this numberin...
getNextValue($objsoc, $object)
Return next free value.
getExample()
Return an example of numbering.
dol_now($mode='gmt')
Return date for now.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
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.