Fix: Numbering errors

This commit is contained in:
Laurent Destailleur 2008-07-08 23:02:16 +00:00
parent 940cf2bc31
commit 17528986cb
5 changed files with 682 additions and 703 deletions

View File

@ -215,12 +215,13 @@ if ($handle)
print '</td>'; print '</td>';
$commande=new CommandeFournisseur($db); $commande=new CommandeFournisseur($db);
$commande->initAsSpecimen();
// Info // Info
$htmltooltip=''; $htmltooltip='';
$htmltooltip.='<b>'.$langs->trans("Version").'</b>: '.$module->getVersion().'<br>'; $htmltooltip.='<b>'.$langs->trans("Version").'</b>: '.$module->getVersion().'<br>';
$facture->type=0; $facture->type=0;
$nextval=$module->getNextValue($mysoc,$propale); $nextval=$module->getNextValue($mysoc,$commande);
if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval
{ {
$htmltooltip.='<b>'.$langs->trans("NextValue").'</b>: '; $htmltooltip.='<b>'.$langs->trans("NextValue").'</b>: ';

File diff suppressed because it is too large Load Diff

View File

@ -19,7 +19,7 @@
*/ */
/** /**
\file htdocs/four/commande/modules/mod_commande_fournisseur_muguet.php \file htdocs/fourn/commande/modules/mod_commande_fournisseur_muguet.php
\ingroup commande \ingroup commande
\brief Fichier contenant la classe du modèle de numérotation de référence de commande fournisseur Muguet \brief Fichier contenant la classe du modèle de numérotation de référence de commande fournisseur Muguet
\version $Id$ \version $Id$
@ -84,57 +84,46 @@ class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders
} }
} }
/** \brief Renvoi prochaine valeur attribuée /** \brief Return next value
* \return string Valeur * \param objsoc Object third party
*/ * \param object Object
function getNextValue() * \return string Valeur
*/
function getNextValue($objsoc=0,$object='')
{ {
global $db; global $db;
// D'abord on récupère la valeur max (réponse immédiate car champ indéxé) // D'abord on récupère la valeur max (réponse immédiate car champ indéxé)
$coyymm=''; $posindice=8;
$sql = "SELECT MAX(ref)"; $sql = "SELECT MAX(0+SUBSTRING(ref,".$posindice.")) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur"; $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur";
$resql=$db->query($sql); $sql.= " WHERE ref like '".$this->prefix."%'";
$resql=$db->query($sql);
if ($resql) if ($resql)
{ {
$row = $db->fetch_row($resql); $obj = $db->fetch_object($resql);
if ($row) $coyymm = substr($row[0],0,6); if ($obj) $max = $obj->max;
else $max=0;
} }
// Si champ respectant le modèle a été trouvée //$date=time();
if (eregi('^'+$this->prefix+'[0-9][0-9][0-9][0-9]',$coyymm)) $date=$object->date_commande;
{ $yymm = strftime("%y%m",$date);
// Recherche rapide car restreint par un like sur champ indexé
$posindice=8;
$sql = "SELECT MAX(0+SUBSTRING(ref,$posindice))";
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur";
$sql.= " WHERE ref like '${coyymm}%'";
$resql=$db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
$max = $row[0];
}
}
else
{
$max=0;
}
$yymm = strftime("%y%m",time());
$num = sprintf("%04s",$max+1); $num = sprintf("%04s",$max+1);
return $this->prefix."$yymm-$num"; return $this->prefix.$yymm."-".$num;
} }
/** \brief Renvoie la référence de commande suivante non utilisée /** \brief Renvoie la référence de commande suivante non utilisée
* \param objsoc Objet société * \param objsoc Object third party
* \return string Texte descripif * \param object Object
*/ * \return string Texte descripif
function commande_get_num($objsoc=0) */
function commande_get_num($objsoc=0,$object='')
{ {
return $this->getNextValue(); return $this->getNextValue($objsoc,$object);
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be> * Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
* Copyright (C) 2005-2008 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2008 Regis Houssin <regis@dolibarr.fr>
* *
@ -446,7 +446,7 @@ class CommandeFournisseur extends Commande
} }
else else
{ {
dolibarr_print_error($db,"Facture::getNextNumRef ".$obj->error); dolibarr_print_error($db,"CommandeFournisseur::getNextNumRef ".$obj->error);
return -1; return -1;
} }
} }

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2005-2006 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2005-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -107,37 +107,22 @@ class mod_pacific extends ModeleNumRefFicheinter
global $db; global $db;
// D'abord on récupère la valeur max (réponse immédiate car champ indéxé) // D'abord on récupère la valeur max (réponse immédiate car champ indéxé)
$fayymm=''; $posindice=8;
$sql = "SELECT MAX(ref)"; $sql = "SELECT MAX(0+SUBSTRING(ref,".$posindice.")) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."fichinter"; $sql.= " FROM ".MAIN_DB_PREFIX."fichinter";
$resql=$db->query($sql); $sql.= " WHERE ref like '".$this->prefix."%'";
$resql=$db->query($sql);
if ($resql) if ($resql)
{ {
$row = $db->fetch_row($resql); $obj = $db->fetch_object($resql);
if ($row) $fayymm = substr($row[0],0,6); if ($obj) $max = $obj->max;
else $max=0;
} }
// Si champ respectant le modèle a été trouvée //$date=time();
if (eregi('^'.$this->prefix.'[0-9][0-9][0-9][0-9]',$fayymm)) $date=$ficheinter->date;
{ $yymm = strftime("%y%m",$date);
// Recherche rapide car restreint par un like sur champ indexé
$posindice=8;
$sql = "SELECT MAX(0+SUBSTRING(ref,".$posindice."))";
$sql.= " FROM ".MAIN_DB_PREFIX."fichinter";
$sql.= " WHERE ref like '".$fayymm."%'";
$resql=$db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
$max = $row[0];
}
}
else
{
$max=0;
}
//$yymm = strftime("%y%m",time());
$yymm = strftime("%y%m",$ficheinter->date);
$num = sprintf("%04s",$max+1); $num = sprintf("%04s",$max+1);
return $this->prefix.$yymm."-".$num; return $this->prefix.$yymm."-".$num;