2
0
forked from Wavyzz/dolibarr

Add: modle de numrotation paramtrable "saphir" pour les bons de livraisons

Fix: uniformisation du code
This commit is contained in:
Regis Houssin
2007-05-19 12:53:48 +00:00
parent ba69404da8
commit 0b1d544dbd
8 changed files with 515 additions and 57 deletions

View File

@@ -75,8 +75,8 @@ function info()
// Param<61>trage du prefix des commandes
$texte.= '<tr><td>Pr<50>fix des commandes</td>';
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte.= '<input type="hidden" name="action" value="updatePrefixCommande">';
$texte.= '<td align="right"><input type="text" class="flat" size="30" name="prefixcommande" value="'.$conf->global->COMMANDE_NUM_PREFIX.'"></td>';
$texte.= '<input type="hidden" name="action" value="updatePrefix">';
$texte.= '<td align="right"><input type="text" class="flat" size="30" name="prefix" value="'.$conf->global->COMMANDE_NUM_PREFIX.'"></td>';
$texte.= '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
$texte.= '<td aligne="center">'.$form->textwithhelp('',$langs->trans("PrefixOrderDesc"),1,1).'</td>';
$texte.= '</tr></form>';
@@ -122,10 +122,10 @@ function info()
{
global $conf;
$this->prefixorder = $conf->global->COMMANDE_NUM_PREFIX;
$this->ordernummatrice = $conf->global->COMMANDE_NUM_MATRICE;
$this->prefix = $conf->global->COMMANDE_NUM_PREFIX;
$this->matrice = $conf->global->COMMANDE_NUM_MATRICE;
if ($this->ordernummatrice != '')
if ($this->matrice != '')
{
$resultatMatrice = Array();
$numMatrice = '';
@@ -143,7 +143,7 @@ function info()
);
// on d<>termine l'emplacement des tirets
$resultTiret = preg_split('/'.$matriceTiret.'/',$this->ordernummatrice, -1, PREG_SPLIT_OFFSET_CAPTURE);
$resultTiret = preg_split('/'.$matriceTiret.'/',$this->matrice, -1, PREG_SPLIT_OFFSET_CAPTURE);
$j = 0;
@@ -178,7 +178,7 @@ function info()
}
else if ($idMatrice == 'prefix' && $resultatMatrice[0] == 'PREF')
{
$prefix = $this->prefixorder;
$prefix = $this->prefix;
$numMatrice .= $prefix;
}
else if ($idMatrice == 'year')
@@ -236,10 +236,10 @@ function info()
{
global $db,$conf;
$this->prefixorder = $conf->global->COMMANDE_NUM_PREFIX;
$this->ordernummatrice = $conf->global->COMMANDE_NUM_MATRICE;
$this->prefix = $conf->global->COMMANDE_NUM_PREFIX;
$this->matrice = $conf->global->COMMANDE_NUM_MATRICE;
if ($this->ordernummatrice != '')
if ($this->matrice != '')
{
$resultatMatrice = Array();
$numMatrice = Array();
@@ -257,7 +257,7 @@ function info()
);
// on d<>termine l'emplacement des tirets
$resultTiret = preg_split('/'.$matriceTiret.'/',$this->ordernummatrice, -1, PREG_SPLIT_OFFSET_CAPTURE);
$resultTiret = preg_split('/'.$matriceTiret.'/',$this->matrice, -1, PREG_SPLIT_OFFSET_CAPTURE);
$j = 0;
$k = 0;
@@ -301,7 +301,7 @@ function info()
}
else if ($idMatrice == 'prefix' && $resultatMatrice[0] == 'PREF')
{
$prefix = $this->prefixorder;
$prefix = $this->prefix;
$numMatrice[$k] = '$prefix';
$searchLast .= $prefix;
$searchLastWithNoYear .= $prefix;
@@ -367,7 +367,7 @@ function info()
// On r<>cup<75>re la valeur max (r<>ponse imm<6D>diate car champ ind<6E>x<EFBFBD>)
$posindice = $numbitcounter;
$comyy='';
$searchyy='';
$sql = "SELECT MAX(ref)";
$sql.= " FROM ".MAIN_DB_PREFIX."commande";
if ($conf->global->COMMANDE_NUM_RESTART_BEGIN_YEAR) $sql.= " WHERE ref like '${searchLast}%'";
@@ -375,14 +375,14 @@ function info()
if ($resql)
{
$row = $db->fetch_row($resql);
if ($row) $comyy = substr($row[0],0,-$posindice);
if ($row) $searchyy = substr($row[0],0,-$posindice);
}
if ($conf->global->COMMANDE_NUM_DELTA != '')
{
//on v<>rifie si il y a une ann<6E>e pr<70>c<EFBFBD>dente
//pour <20>viter que le delta soit appliqu<71> de nouveau sur la nouvelle ann<6E>e
$lastyy='';
$previousyy='';
$sql = "SELECT MAX(ref)";
$sql.= " FROM ".MAIN_DB_PREFIX."commande";
$sql.= " WHERE ref like '${searchLastWithPreviousYear}%'";
@@ -390,17 +390,17 @@ function info()
if ($resql)
{
$row = $db->fetch_row($resql);
if ($row) $lastyy = substr($row[0],0,-$posindice);
if ($row) $previousyy = substr($row[0],0,-$posindice);
}
}
// Si au moins un champ respectant le mod<6F>le a <20>t<EFBFBD> trouv<75>e
if (eregi('^'.$searchLastWithNoYear.'',$comyy))
if (eregi('^'.$searchLastWithNoYear.'',$searchyy))
{
// Recherche rapide car restreint par un like sur champ index<65>
$sql = "SELECT MAX(0+SUBSTRING(ref,-".$posindice."))";
$sql.= " FROM ".MAIN_DB_PREFIX."commande";
$sql.= " WHERE ref like '${comyy}%'";
$sql.= " WHERE ref like '${searchyy}%'";
$resql=$db->query($sql);
if ($resql)
{
@@ -408,7 +408,7 @@ function info()
$max = $row[0];
}
}
else if ($conf->global->COMMANDE_NUM_DELTA != '' && !eregi('^'.$searchLastWithPreviousYear.'',$lastyy))
else if ($conf->global->COMMANDE_NUM_DELTA != '' && !eregi('^'.$searchLastWithPreviousYear.'',$previousyy))
{
// on applique le delta une seule fois
$max=$conf->global->COMMANDE_NUM_DELTA?$conf->global->COMMANDE_NUM_DELTA-1:0;
@@ -446,7 +446,7 @@ function info()
function commande_get_num($objsoc=0)
{
return $this->getNextValue($objsoc);
}
}
}
?>