29require_once DOL_DOCUMENT_ROOT.
'/core/modules/delivery/modules_delivery.php';
43 public $version =
'dolibarr';
60 public $name =
'Jade';
62 public $prefix =
'BL';
71 public function info($langs)
74 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
84 return $this->prefix.
"0501-0001";
96 global $langs, $conf, $db;
98 $langs->load(
"bills");
104 $posindice = strlen($this->prefix) + 6;
105 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
106 $sql .=
" FROM ".MAIN_DB_PREFIX.
"delivery";
107 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
108 $sql .=
" AND entity = ".$conf->entity;
110 $resql = $db->query($sql);
112 $row = $db->fetch_row($resql);
114 $fayymm = substr($row[0], 0, 6);
118 if ($fayymm && !preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $fayymm)) {
119 $langs->load(
"errors");
120 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
139 $posindice = strlen($this->prefix) + 6;
140 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
141 $sql .=
" FROM ".MAIN_DB_PREFIX.
"delivery";
142 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
143 $sql .=
" AND entity = ".$conf->entity;
145 $resql = $db->query($sql);
146 dol_syslog(
"mod_delivery_jade::getNextValue", LOG_DEBUG);
148 $obj = $db->fetch_object($resql);
150 $max = intval($obj->max);
158 $date =
$object->date_delivery;
164 if ($max >= (pow(10, 4) - 1)) {
167 $num = sprintf(
"%04d", $max + 1);
170 dol_syslog(
"mod_delivery_jade::getNextValue return ".$this->prefix.$yymm.
"-".$num);
171 return $this->prefix.$yymm.
"-".$num;
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $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='auto')
Return date for now.
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.