mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-14 08:54:21 +01:00
Changement de mthode de numrotation
This commit is contained in:
@@ -86,11 +86,70 @@ class mod_commande_diamant extends ModeleNumRefCommandes
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** \brief Renvoi prochaine valeur attribu<62>e
|
||||
* \return string Valeur
|
||||
*/
|
||||
function getNextValue()
|
||||
{
|
||||
global $db;
|
||||
|
||||
// D'abord on r<>cup<75>re la valeur max (r<>ponse imm<6D>diate car champ ind<6E>x<EFBFBD>)
|
||||
$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<6F>le a <20>t<EFBFBD> trouv<75>e
|
||||
if (eregi('C[0-9][0-9]',$cyy))
|
||||
{
|
||||
// Recherche rapide car restreint par un like sur champ index<65>
|
||||
$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<EFBFBD>rence de commande suivante non utilis<69>e
|
||||
* \param objsoc Objet soci<63>t<EFBFBD>
|
||||
* \return string Texte descripif
|
||||
*/
|
||||
function commande_get_num($objsoc=0)
|
||||
{
|
||||
return $this->getNextValue();
|
||||
}
|
||||
|
||||
|
||||
/** \brief Renvoie le prochaine num<75>ro de r<>f<EFBFBD>rence de commande non utilis<69>
|
||||
\param obj_soc objet soci<63>t<EFBFBD>
|
||||
\return string num<75>ro de r<>f<EFBFBD>rence de commande non utilis<69>
|
||||
*/
|
||||
|
||||
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);
|
||||
}
|
||||
*/
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user