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>';
$commande=new CommandeFournisseur($db);
$commande->initAsSpecimen();
// Info
$htmltooltip='';
$htmltooltip.='<b>'.$langs->trans("Version").'</b>: '.$module->getVersion().'<br>';
$facture->type=0;
$nextval=$module->getNextValue($mysoc,$propale);
$nextval=$module->getNextValue($mysoc,$commande);
if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval
{
$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
\brief Fichier contenant la classe du modèle de numérotation de référence de commande fournisseur Muguet
\version $Id$
@ -84,57 +84,46 @@ class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders
}
}
/** \brief Renvoi prochaine valeur attribuée
* \return string Valeur
*/
function getNextValue()
/** \brief Return next value
* \param objsoc Object third party
* \param object Object
* \return string Valeur
*/
function getNextValue($objsoc=0,$object='')
{
global $db;
// D'abord on récupère la valeur max (réponse immédiate car champ indéxé)
$coyymm='';
$sql = "SELECT MAX(ref)";
$posindice=8;
$sql = "SELECT MAX(0+SUBSTRING(ref,".$posindice.")) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur";
$resql=$db->query($sql);
$sql.= " WHERE ref like '".$this->prefix."%'";
$resql=$db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
if ($row) $coyymm = substr($row[0],0,6);
$obj = $db->fetch_object($resql);
if ($obj) $max = $obj->max;
else $max=0;
}
// Si champ respectant le modèle a été trouvée
if (eregi('^'+$this->prefix+'[0-9][0-9][0-9][0-9]',$coyymm))
{
// 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());
//$date=time();
$date=$object->date_commande;
$yymm = strftime("%y%m",$date);
$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
* \param objsoc Objet société
* \return string Texte descripif
*/
function commande_get_num($objsoc=0)
* \param objsoc Object third party
* \param object Object
* \return string Texte descripif
*/
function commande_get_num($objsoc=0,$object='')
{
return $this->getNextValue();
return $this->getNextValue($objsoc,$object);
}
}

View File

@ -1,6 +1,6 @@
<?php
/* 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) 2005-2008 Regis Houssin <regis@dolibarr.fr>
*
@ -446,7 +446,7 @@ class CommandeFournisseur extends Commande
}
else
{
dolibarr_print_error($db,"Facture::getNextNumRef ".$obj->error);
dolibarr_print_error($db,"CommandeFournisseur::getNextNumRef ".$obj->error);
return -1;
}
}

View File

@ -1,5 +1,5 @@
<?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>
*
* This program is free software; you can redistribute it and/or modify
@ -107,37 +107,22 @@ class mod_pacific extends ModeleNumRefFicheinter
global $db;
// D'abord on récupère la valeur max (réponse immédiate car champ indéxé)
$fayymm='';
$sql = "SELECT MAX(ref)";
$posindice=8;
$sql = "SELECT MAX(0+SUBSTRING(ref,".$posindice.")) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."fichinter";
$resql=$db->query($sql);
$sql.= " WHERE ref like '".$this->prefix."%'";
$resql=$db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
if ($row) $fayymm = substr($row[0],0,6);
$obj = $db->fetch_object($resql);
if ($obj) $max = $obj->max;
else $max=0;
}
// Si champ respectant le modèle a été trouvée
if (eregi('^'.$this->prefix.'[0-9][0-9][0-9][0-9]',$fayymm))
{
// 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);
//$date=time();
$date=$ficheinter->date;
$yymm = strftime("%y%m",$date);
$num = sprintf("%04s",$max+1);
return $this->prefix.$yymm."-".$num;