29require_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_order/modules_commandefournisseur.php';
41 public $version =
'dolibarr';
53 public $nom =
'Muguet';
58 public $name =
'Muguet';
63 public $prefix =
'PO';
82 public function info($langs)
85 return $langs->trans(
"SimpleNumRefModelDesc", $this->prefix);
96 return $this->prefix.
"0501-0001";
109 global $conf, $langs, $db;
114 $posindice = strlen($this->prefix) + 6;
115 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
116 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur";
117 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
118 $sql .=
" AND entity = ".$conf->entity;
119 $resql = $db->query($sql);
121 $row = $db->fetch_row($resql);
123 $coyymm = substr($row[0], 0, 6);
127 if (!$coyymm || preg_match(
'/'.$this->prefix.
'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
130 $langs->load(
"errors");
131 $this->error = $langs->trans(
'ErrorNumRefModel', $max);
148 $posindice = strlen($this->prefix) + 6;
149 $sql =
"SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.
") AS SIGNED)) as max";
150 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur";
151 $sql .=
" WHERE ref LIKE '".$db->escape($this->prefix).
"____-%'";
152 $sql .=
" AND entity = ".$conf->entity;
155 $resql = $db->query($sql);
157 $obj = $db->fetch_object($resql);
159 $max = intval($obj->max);
166 $date =
$object->date_commande;
172 if ($max >= (pow(10, 4) - 1)) {
175 $num = sprintf(
"%04d", $max + 1);
178 return $this->prefix.$yymm.
"-".$num;
if(! $sortfield) if(! $sortorder) $object
Parent Class of numbering models of supplier order 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, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).