28require_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_order/modules_commandefournisseur.php';
40 public $version =
'dolibarr';
52 public $nom =
'Muguet';
57 public $name =
'Muguet';
59 public $prefix =
'PO';
78 public function info($langs)
81 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
92 return $this->prefix.
"0501-0001";
105 global $conf, $langs, $db;
110 $posindice = strlen($this->prefix) + 6;
111 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
112 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur";
113 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
114 $sql .=
" AND entity = ".$conf->entity;
115 $resql = $db->query($sql);
117 $row = $db->fetch_row($resql);
119 $coyymm = substr($row[0], 0, 6);
123 if (!$coyymm || preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
126 $langs->load(
"errors");
127 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
144 $posindice = strlen($this->prefix) + 6;
145 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
146 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur";
147 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
148 $sql .=
" AND entity = ".$conf->entity;
150 $resql = $db->query($sql);
152 $obj = $db->fetch_object($resql);
154 $max = intval($obj->max);
161 $date =
$object->date_commande;
167 if ($max >= (pow(10, 4) - 1)) {
170 $num = sprintf(
"%04d", $max + 1);
173 return $this->prefix.$yymm.
"-".$num;
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Parent Class of numbering models of suppliers orders references.
Class 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, $object)
Return next value.
info($langs)
Return description of numbering module.
__construct()
Constructor.
getExample()
Return an example of numbering.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int 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).