26require_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_order/modules_commandefournisseur.php';
38 public $version =
'dolibarr';
50 public $nom =
'Muguet';
55 public $name =
'Muguet';
57 public $prefix =
'PO';
76 public function info($langs)
79 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
90 return $this->prefix.
"0501-0001";
103 global $conf, $langs, $db;
108 $posindice = strlen($this->prefix) + 6;
109 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
110 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur";
111 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
112 $sql .=
" AND entity = ".$conf->entity;
113 $resql = $db->query($sql);
115 $row = $db->fetch_row($resql);
117 $coyymm = substr($row[0], 0, 6);
121 if (!$coyymm || preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
124 $langs->load(
"errors");
125 $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.
"commande_fournisseur";
145 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
146 $sql .=
" AND entity = ".$conf->entity;
148 $resql = $db->query($sql);
150 $obj = $db->fetch_object($resql);
152 $max = intval($obj->max);
159 $date = $object->date_commande;
161 $date = $object->date;
165 if ($max >= (pow(10, 4) - 1)) {
168 $num = sprintf(
"%04s", $max + 1);
171 return $this->prefix.$yymm.
"-".$num;
Parent Class of numbering models of suppliers orders references.
Classe du modele de numerotation de reference de commande fournisseur Muguet.
canBeActivated($object)
Checks if the numbers already in the database do not cause conflicts that would prevent this numberin...
getNextValue($objsoc=0, $object='')
Return next value.
commande_get_num($objsoc=0, $object='')
Renvoie la reference de commande suivante non utilisee.
info($langs)
Return description of numbering module.
__construct()
Constructor.
getExample()
Return an example of numbering.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.