Changement de mthode de numrotation
This commit is contained in:
parent
4ddca15e39
commit
feb235ad52
@ -86,11 +86,70 @@ class mod_commande_diamant extends ModeleNumRefCommandes
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** \brief Renvoi prochaine valeur attribuée
|
||||
* \return string Valeur
|
||||
*/
|
||||
function getNextValue()
|
||||
{
|
||||
global $db;
|
||||
|
||||
// D'abord on récupère la valeur max (réponse immédiate car champ indéxé)
|
||||
$cyy='';
|
||||
$sql = "SELECT MAX(ref)";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."commande";
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$row = $db->fetch_row($resql);
|
||||
if ($row) $cyy = substr($row[0],0,4);
|
||||
}
|
||||
|
||||
// Si au moins un champ respectant le modèle a été trouvée
|
||||
if (eregi('C[0-9][0-9]',$cyy))
|
||||
{
|
||||
// Recherche rapide car restreint par un like sur champ indexé
|
||||
$posindice=4;
|
||||
$sql = "SELECT MAX(0+SUBSTRING(ref,$posindice))";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."commande";
|
||||
$sql.= " WHERE ref like '${cyy}%'";
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$row = $db->fetch_row($resql);
|
||||
$max = $row[0];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$max=0;
|
||||
}
|
||||
|
||||
if (!defined("COMMANDE_DIAMANT_DELTA"))
|
||||
{
|
||||
define("COMMANDE_DIAMANT_DELTA", 0);
|
||||
}
|
||||
$max = $max + COMMANDE_DIAMANT_DELTA;
|
||||
$yy = strftime("%y",time());
|
||||
$num = sprintf("%05s",$max+1);
|
||||
|
||||
return "C$yy$num";
|
||||
}
|
||||
|
||||
|
||||
/** \brief Renvoie la référence de commande suivante non utilisée
|
||||
* \param objsoc Objet société
|
||||
* \return string Texte descripif
|
||||
*/
|
||||
function commande_get_num($objsoc=0)
|
||||
{
|
||||
return $this->getNextValue();
|
||||
}
|
||||
|
||||
|
||||
/** \brief Renvoie le prochaine numéro de référence de commande non utilisé
|
||||
\param obj_soc objet société
|
||||
\return string numéro de référence de commande non utilisé
|
||||
*/
|
||||
|
||||
function commande_get_num($obj_soc=0)
|
||||
{
|
||||
global $db;
|
||||
@ -117,5 +176,6 @@ class mod_commande_diamant extends ModeleNumRefCommandes
|
||||
|
||||
return 'C'.$y.substr("0000".$num, strlen("0000".$num)-5,5);
|
||||
}
|
||||
*/
|
||||
}
|
||||
?>
|
||||
|
||||
@ -55,6 +55,14 @@ class mod_commande_jade extends ModeleNumRefCommandes
|
||||
return "Renvoie le numéro sous la forme numérique CYY00001, CYY00002, CYY00003, ... où YY représente l'année. Le numéro d'incrément qui suit l'année n'est PAS remis à zéro en début d'année.";
|
||||
}
|
||||
|
||||
/** \brief Renvoi un exemple de numérotation
|
||||
* \return string Example
|
||||
*/
|
||||
function getExample()
|
||||
{
|
||||
return "C0600001";
|
||||
}
|
||||
|
||||
/** \brief Renvoi prochaine valeur attribuée
|
||||
* \return string Valeur
|
||||
*/
|
||||
|
||||
Loading…
Reference in New Issue
Block a user