27require_once DOL_DOCUMENT_ROOT.
'/core/modules/delivery/modules_delivery.php';
41 public $version =
'dolibarr';
58 public $name =
'Jade';
60 public $prefix =
'BL';
69 public function info($langs)
72 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
82 return $this->prefix.
"0501-0001";
94 global $langs, $conf, $db;
96 $langs->load(
"bills");
102 $posindice = strlen($this->prefix) + 6;
103 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
104 $sql .=
" FROM ".MAIN_DB_PREFIX.
"delivery";
105 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
106 $sql .=
" AND entity = ".$conf->entity;
108 $resql = $db->query($sql);
110 $row = $db->fetch_row($resql);
112 $fayymm = substr($row[0], 0, 6);
116 if ($fayymm && !preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $fayymm)) {
117 $langs->load(
"errors");
118 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
137 $posindice = strlen($this->prefix) + 6;
138 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
139 $sql .=
" FROM ".MAIN_DB_PREFIX.
"delivery";
140 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
141 $sql .=
" AND entity = ".$conf->entity;
143 $resql = $db->query($sql);
144 dol_syslog(
"mod_delivery_jade::getNextValue", LOG_DEBUG);
146 $obj = $db->fetch_object($resql);
148 $max = intval($obj->max);
156 $date = $object->date_delivery;
162 if ($max >= (pow(10, 4) - 1)) {
165 $num = sprintf(
"%04s", $max + 1);
168 dol_syslog(
"mod_delivery_jade::getNextValue return ".$this->prefix.$yymm.
"-".$num);
169 return $this->prefix.$yymm.
"-".$num;
Classe mere des modeles de numerotation des references de bon de livraison.
Classe 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.
delivery_get_num($objsoc=0, $object='')
Return next free ref.
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_now($mode='auto')
Return date for now.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.