Fix: Maxi bug. Value for date used in object numbering module was current date instead of date of object.

This commit is contained in:
Laurent Destailleur 2008-07-05 14:20:03 +00:00
parent 2ec5ffee48
commit 6d8755edd4
22 changed files with 769 additions and 641 deletions

View File

@ -159,7 +159,7 @@ if ($_POST["action"] == 'set_use_customer_contact_as_recipient')
/* /*
* Affichage page * View
*/ */
llxHeader(); llxHeader();
@ -225,7 +225,8 @@ if ($handle)
print '</td>'; print '</td>';
$commande=new Commande($db); $commande=new Commande($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>';

View File

@ -281,7 +281,8 @@ while (($file = readdir($handle))!==false)
print '</td>'; print '</td>';
$facture=new Facture($db); $facture=new Facture($db);
$facture->initAsSpecimen();
// Example for standard invoice // Example for standard invoice
$htmltooltip=''; $htmltooltip='';
$htmltooltip.='<b>'.$langs->trans("Version").'</b>: '.$module->getVersion().'<br>'; $htmltooltip.='<b>'.$langs->trans("Version").'</b>: '.$module->getVersion().'<br>';

View File

@ -226,12 +226,13 @@ if ($handle)
print '</td>'; print '</td>';
$livraison=new Livraison($db); $livraison=new Livraison($db);
$livraison->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,$livraison);
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>: ';

View File

@ -5,7 +5,7 @@
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be> * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr> * Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.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
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -195,7 +195,7 @@ $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToM
print_fiche_titre($langs->trans("PropalSetup"),$linkback,'setup'); print_fiche_titre($langs->trans("PropalSetup"),$linkback,'setup');
/* /*
* Module num<EFBFBD>rotation * Module numerotation
*/ */
print "<br>"; print "<br>";
print_titre($langs->trans("ProposalsNumberingModules")); print_titre($langs->trans("ProposalsNumberingModules"));
@ -249,6 +249,7 @@ if ($handle)
print '</td>'; print '</td>';
$propale=new Propal($db); $propale=new Propal($db);
$propale->initAsSpecimen();
// Info // Info
$htmltooltip=''; $htmltooltip='';

File diff suppressed because it is too large Load Diff

View File

@ -57,7 +57,10 @@ class Facture extends CommonObject
var $client; var $client;
var $number; var $number;
var $author; var $author;
//! Invoice date
var $date; var $date;
var $date_creation;
var $date_validation;
var $ref; var $ref;
var $ref_client; var $ref_client;
//! 0=Facture normale, 1=Facture remplacement, 2=Facture avoir, 3=Facture récurrente //! 0=Facture normale, 1=Facture remplacement, 2=Facture avoir, 3=Facture récurrente
@ -423,11 +426,13 @@ class Facture extends CommonObject
dolibarr_syslog("Facture::Fetch rowid=".$rowid.", societe_id=".$societe_id, LOG_DEBUG); dolibarr_syslog("Facture::Fetch rowid=".$rowid.", societe_id=".$societe_id, LOG_DEBUG);
$sql = 'SELECT f.facnumber,f.ref_client,f.type,f.fk_soc,f.amount,f.tva,f.total,f.total_ttc,f.remise_percent,f.remise_absolue,f.remise'; $sql = 'SELECT f.facnumber,f.ref_client,f.type,f.fk_soc,f.amount,f.tva,f.total,f.total_ttc,f.remise_percent,f.remise_absolue,f.remise';
$sql.= ','.$this->db->pdate('f.datef').' as df, f.fk_projet'; $sql.= ','.$this->db->pdate('f.datef').' as df';
$sql.= ','.$this->db->pdate('f.date_lim_reglement').' as dlr'; $sql.= ','.$this->db->pdate('f.date_lim_reglement').' as dlr';
$sql.= ','.$this->db->pdate('f.datec').' as datec';
$sql.= ','.$this->db->pdate('f.date_valid').' as datev';
$sql.= ', f.note, f.note_public, f.fk_statut, f.paye, f.close_code, f.close_note, f.fk_user_author, f.model_pdf'; $sql.= ', f.note, f.note_public, f.fk_statut, f.paye, f.close_code, f.close_note, f.fk_user_author, f.model_pdf';
$sql.= ', f.fk_facture_source'; $sql.= ', f.fk_facture_source';
$sql.= ', f.fk_mode_reglement, f.fk_cond_reglement'; $sql.= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet';
$sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; $sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle';
$sql.= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_facture'; $sql.= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_facture';
$sql.= ', cf.fk_commande'; $sql.= ', cf.fk_commande';
@ -453,6 +458,8 @@ class Facture extends CommonObject
$this->ref_client = $obj->ref_client; $this->ref_client = $obj->ref_client;
$this->type = $obj->type; $this->type = $obj->type;
$this->date = $obj->df; $this->date = $obj->df;
$this->date_creation = $obj->datec;
$this->date_validation = $obj->datev;
$this->amount = $obj->amount; $this->amount = $obj->amount;
$this->remise_percent = $obj->remise_percent; $this->remise_percent = $obj->remise_percent;
$this->remise_absolue = $obj->remise_absolue; $this->remise_absolue = $obj->remise_absolue;
@ -995,11 +1002,11 @@ class Facture extends CommonObject
} }
/** /**
* \brief Tag la facture comme validée + appel trigger BILL_VALIDATE * \brief Tag la facture comme validée + appel trigger BILL_VALIDATE
* \param user Utilisateur qui valide la facture * \param user Utilisateur qui valide la facture
* \param soc Ne sert plus \\TODO A virer * \param soc Ne sert plus. \\TODO A virer
* \param force_number Référence à forcer de la facture * \param force_number Référence à forcer de la facture
* \return int <0 si ko, >0 si ok * \return int <0 si ko, >0 si ok
*/ */
function set_valid($user, $soc='', $force_number='') function set_valid($user, $soc='', $force_number='')
{ {

View File

@ -111,7 +111,7 @@ class mod_commande_fournisseur_orchidee extends ModeleNumRefSuppliersOrders
return 0; return 0;
} }
$numFinal=get_next_value($db,$mask,'commande_fournisseur','ref','',$objsoc->code_client); $numFinal=get_next_value($db,$mask,'commande_fournisseur','ref','',$objsoc->code_client,$commande->date_commande);
return $numFinal; return $numFinal;
} }

View File

@ -88,9 +88,9 @@ class mod_commande_marbre extends ModeleNumRefCommandes
* \param commande Object order * \param commande Object order
* \return string Value if OK, 0 if KO * \return string Value if OK, 0 if KO
*/ */
function getNextValue($objsoc=0,$commande) function getNextValue($objsoc,$commande)
{ {
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=''; $coyymm='';
@ -129,22 +129,25 @@ class mod_commande_marbre extends ModeleNumRefCommandes
{ {
$max=0; $max=0;
} }
$yymm = strftime("%y%m",time()); //$date=time();
$date=$commande->date;
$yymm = strftime("%y%m",$date);
$num = sprintf("%04s",$max+1); $num = sprintf("%04s",$max+1);
dolibarr_syslog("mod_commande_marbre::getNextValue return ".$this->prefix."$yymm-$num"); dolibarr_syslog("mod_commande_marbre::getNextValue return ".$this->prefix.$yymm."-".$num);
return $this->prefix."$yymm-$num"; return $this->prefix.$yymm."-".$num;
} }
/** \brief Renvoie la référence de commande suivante non utilisée /** \brief Return next free value
* \param objsoc Objet société * \param objsoc Object third party
* \return string Texte descripif * \param objforref Object for number to search
*/ * \return string Next free value
function commande_get_num($objsoc=0) */
function commande_get_num($objsoc,$objforref)
{ {
return $this->getNextValue($objsoc); return $this->getNextValue($objsoc,$objforref);
} }
} }
?> ?>

View File

@ -64,11 +64,13 @@ class mod_commande_opale extends ModeleNumRefCommandes
} }
/** \brief Renvoi prochaine valeur attribuée /** \brief Return next value
* \return string Valeur * \param objsoc Objet third party
*/ * \param commande Object order
function getNextValue() * \return string Value if OK, 0 if KO
{ */
function getNextValue($objsoc,$commande)
{
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é)
@ -90,20 +92,24 @@ class mod_commande_opale extends ModeleNumRefCommandes
{ {
$max=0; $max=0;
} }
$yy = strftime("%y",time()); //$date=time();
$date=$commande->date;
$yy = strftime("%y",$date);
$hex = strtoupper(dechex($max+1)); $hex = strtoupper(dechex($max+1));
$ref = substr("000000".($hex),-6); $ref = substr("000000".($hex),-6);
return 'COM-'.substr($ref,0,3)."-".substr($ref,3,3); return 'COM-'.substr($ref,0,3)."-".substr($ref,3,3);
} }
/** \brief Renvoie la référence de commande suivante non utilisée /** \brief Return next free value
* \param objsoc Objet société * \param objsoc Object third party
* \return string Texte descripif * \param objforref Object for number to search
*/ * \return string Next free value
function commande_get_num($objsoc=0) */
{ function commande_get_num($objsoc,$objforref)
return $this->getNextValue(); {
} return $this->getNextValue($objsoc,$objforref);
}
} }
?> ?>

View File

@ -96,7 +96,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes
* \param commande Object order * \param commande Object order
* \return string Value if OK, 0 if KO * \return string Value if OK, 0 if KO
*/ */
function getNextValue($objsoc=0,$commande) function getNextValue($objsoc,$commande)
{ {
global $db,$conf; global $db,$conf;
@ -111,22 +111,22 @@ class mod_commande_saphir extends ModeleNumRefCommandes
return 0; return 0;
} }
$numFinal=get_next_value($db,$mask,'commande','ref','',$objsoc->code_client); $numFinal=get_next_value($db,$mask,'commande','ref','',$objsoc->code_client,$commande->date);
return $numFinal; return $numFinal;
} }
/** \brief Renvoie la référence de commande suivante non utilisée /** \brief Return next free value
* \param objsoc Objet société * \param objsoc Object third party
* \param commande Objet commande * \param objforref Object for number to search
* \return string Texte descripif * \return string Next free value
*/ */
function commande_get_num($objsoc=0,$commande) function commande_get_num($objsoc,$objforref)
{ {
return $this->getNextValue($objsoc,$commande); return $this->getNextValue($objsoc,$objforref);
} }
} }
?> ?>

View File

@ -121,21 +121,21 @@ class mod_facture_mercure extends ModeleNumRefFactures
if ($facture->type == 2) $where.= " AND type = 2"; if ($facture->type == 2) $where.= " AND type = 2";
else $where.=" AND type != 2"; else $where.=" AND type != 2";
$numFinal=get_next_value($db,$mask,'facture','facnumber',$where,$objsoc->code_client); $numFinal=get_next_value($db,$mask,'facture','facnumber',$where,$objsoc->code_client,$facture->date);
return $numFinal; return $numFinal;
} }
/** \brief Renvoie la reference de commande suivante non utilisee /** \brief Return next free value
* \param objsoc Objet societe * \param objsoc Object third party
* \param facture Objet facture * \param objforref Object for number to search
* \return string Texte descripif * \return string Next free value
*/ */
function getNumRef($objsoc=0,$facture) function getNumRef($objsoc,$objforref)
{ {
return $this->getNextValue($objsoc,$facture); return $this->getNextValue($objsoc,$objforref);
} }
} }
?> ?>

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 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005 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
@ -16,16 +16,13 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* or see http://www.gnu.org/ * or see http://www.gnu.org/
*
* $Id$
* $Source$
*/ */
/** /**
\file htdocs/includes/modules/facture/terre/terre.modules.php \file htdocs/includes/modules/facture/terre/terre.modules.php
\ingroup facture \ingroup facture
\brief Fichier contenant la classe du modèle de numérotation de référence de facture Terre \brief Fichier contenant la classe du modèle de numérotation de référence de facture Terre
\version $Revision$ \version $Id$
*/ */
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/facture/modules_facture.php"); require_once(DOL_DOCUMENT_ROOT ."/includes/modules/facture/modules_facture.php");
@ -145,9 +142,9 @@ class mod_facture_terre extends ModeleNumRefFactures
{ {
// Recherche rapide car restreint par un like sur champ indexé // Recherche rapide car restreint par un like sur champ indexé
$posindice=8; $posindice=8;
$sql = "SELECT MAX(0+SUBSTRING(facnumber,$posindice))"; $sql = "SELECT MAX(0+SUBSTRING(facnumber,".$posindice."))";
$sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " FROM ".MAIN_DB_PREFIX."facture";
$sql.= " WHERE facnumber like '${fayymm}%'"; $sql.= " WHERE facnumber like '".$fayymm."%'";
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
{ {
@ -159,21 +156,24 @@ class mod_facture_terre extends ModeleNumRefFactures
{ {
$max=0; $max=0;
} }
$yymm = strftime("%y%m",time());
//$date=time();
$date=$facture->date;
$yymm = strftime("%y%m",$date);
$num = sprintf("%04s",$max+1); $num = sprintf("%04s",$max+1);
dolibarr_syslog("mod_facture_terre::getNextValue return ".$prefix."$yymm-$num"); dolibarr_syslog("mod_facture_terre::getNextValue return ".$prefix.$yymm."-".$num);
return $prefix."$yymm-$num"; return $prefix.$yymm."-".$num;
} }
/** \brief Renvoie la référence de facture suivante non utilisée /** \brief Return next free value
* \param objsoc Objet société * \param objsoc Object third party
* \param facture Objet facture * \param objforref Object for number to search
* \return string Texte descripif * \return string Next free value
*/ */
function getNumRef($objsoc=0,$facture) function getNumRef($objsoc,$objforref)
{ {
return $this->getNextValue($objsoc,$facture); return $this->getNextValue($objsoc,$objforref);
} }
} }

View File

@ -116,20 +116,20 @@ class mod_arctic extends ModeleNumRefFicheinter
return 0; return 0;
} }
$numFinal=get_next_value($db,$mask,'fichinter','ref','',$objsoc->code_client); $numFinal=get_next_value($db,$mask,'fichinter','ref','',$objsoc->code_client,$ficheinter->date);
return $numFinal; return $numFinal;
} }
/** \brief Renvoie la référence de fichinter suivante non utilisée /** \brief Return next free value
* \param objsoc Objet société * \param objsoc Object third party
* \param fichinter Objet fichinter * \param objforref Object for number to search
* \return string Texte descripif * \return string Next free value
*/ */
function getNumRef($objsoc=0,$ficheinter='') function getNumRef($objsoc,$objforref)
{ {
return $this->getNextValue($objsoc,$ficheinter); return $this->getNextValue($objsoc,$objforref);
} }
} }

View File

@ -16,16 +16,13 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* or see http://www.gnu.org/ * or see http://www.gnu.org/
*
* $Id$
* $Source$
*/ */
/** /**
\file htdocs/includes/modules/fichinter/mod_pacific.php \file htdocs/includes/modules/fichinter/mod_pacific.php
\ingroup fiche intervention \ingroup fiche intervention
\brief Fichier contenant la classe du modèle de numérotation de référence de fiche intervention Pacific \brief Fichier contenant la classe du modèle de numérotation de référence de fiche intervention Pacific
\version $Revision$ \version $Id$
*/ */
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/fichinter/modules_fichinter.php"); require_once(DOL_DOCUMENT_ROOT ."/includes/modules/fichinter/modules_fichinter.php");
@ -100,11 +97,13 @@ class mod_pacific extends ModeleNumRefFicheinter
} }
} }
/** \brief Renvoi prochaine valeur attribuée /** \brief Renvoi prochaine valeur attribuée
* \return string Valeur * \param objsoc Objet société
*/ * \param ficheinter Object ficheinter
function getNextValue() * \return string Valeur
{ */
function getNextValue($objsoc=0,$ficheinter='')
{
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é)
@ -123,9 +122,9 @@ class mod_pacific extends ModeleNumRefFicheinter
{ {
// Recherche rapide car restreint par un like sur champ indexé // Recherche rapide car restreint par un like sur champ indexé
$posindice=8; $posindice=8;
$sql = "SELECT MAX(0+SUBSTRING(ref,$posindice))"; $sql = "SELECT MAX(0+SUBSTRING(ref,".$posindice."))";
$sql.= " FROM ".MAIN_DB_PREFIX."fichinter"; $sql.= " FROM ".MAIN_DB_PREFIX."fichinter";
$sql.= " WHERE ref like '${fayymm}%'"; $sql.= " WHERE ref like '".$fayymm."%'";
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
{ {
@ -137,19 +136,21 @@ class mod_pacific extends ModeleNumRefFicheinter
{ {
$max=0; $max=0;
} }
$yymm = strftime("%y%m",time()); //$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;
} }
/** \brief Renvoie la référence de fiche d'intervention suivante non utilisée /** \brief Return next free value
* \param objsoc Objet société * \param objsoc Object third party
* \return string Texte descripif * \param objforref Object for number to search
*/ * \return string Next free value
function getNumRef($objsoc=0) */
{ function getNumRef($objsoc,$objforref)
return $this->getNextValue(); {
return $this->getNextValue($objsoc,$objforref);
} }
} }

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 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005 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
@ -85,11 +85,12 @@ class mod_propale_marbre extends ModeleNumRefPropales
} }
} }
/** \brief Renvoi prochaine valeur attribuée /** \brief Return next value
* \param objsoc Objet société * \param objsoc Object third party
* \return string Valeur * \param propal Object commercial proposal
*/ * \return string Valeur
function getNextValue($objsoc=0) */
function getNextValue($objsoc,$propal)
{ {
global $db; global $db;
@ -114,9 +115,9 @@ class mod_propale_marbre extends ModeleNumRefPropales
{ {
// Recherche rapide car restreint par un like sur champ indexé // Recherche rapide car restreint par un like sur champ indexé
$posindice=8; $posindice=8;
$sql = "SELECT MAX(0+SUBSTRING(ref,$posindice))"; $sql = "SELECT MAX(0+SUBSTRING(ref,".$posindice."))";
$sql.= " FROM ".MAIN_DB_PREFIX."propal"; $sql.= " FROM ".MAIN_DB_PREFIX."propal";
$sql.= " WHERE ref like '${pryymm}%'"; $sql.= " WHERE ref like '".$pryymm."%'";
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
{ {
@ -128,20 +129,22 @@ class mod_propale_marbre extends ModeleNumRefPropales
{ {
$max=0; $max=0;
} }
$yymm = strftime("%y%m",time()); //$yymm = strftime("%y%m",time());
$yymm = strftime("%y%m",$propal->date);
$num = sprintf("%04s",$max+1); $num = sprintf("%04s",$max+1);
dolibarr_syslog("mod_propale_marbre::getNextValue return ".$this->prefix."$yymm-$num"); dolibarr_syslog("mod_propale_marbre::getNextValue return ".$this->prefix.$yymm."-".$num);
return $this->prefix."$yymm-$num"; return $this->prefix.$yymm."-".$num;
} }
/** \brief Renvoie la référence de propale suivante non utilisée /** \brief Return next free value
* \param objsoc Objet société * \param objsoc Object third party
* \return string Texte descripif * \param objforref Object for number to search
*/ * \return string Next free value
function getNumRef($objsoc=0) */
{ function getNumRef($objsoc,$objforref)
return $this->getNextValue(); {
return $this->getNextValue($objsoc,$objforref);
} }
} }

View File

@ -96,7 +96,7 @@ class mod_propale_saphir extends ModeleNumRefPropales
* \param propal Object commercial proposal * \param propal Object commercial proposal
* \return string Value if OK, 0 if KO * \return string Value if OK, 0 if KO
*/ */
function getNextValue($objsoc,$propal='') function getNextValue($objsoc,$propal)
{ {
global $db,$conf; global $db,$conf;
@ -111,7 +111,7 @@ class mod_propale_saphir extends ModeleNumRefPropales
return 0; return 0;
} }
$numFinal=get_next_value($db,$mask,'propal','ref','',$objsoc->code_client); $numFinal=get_next_value($db,$mask,'propal','ref','',$objsoc->code_client,$propal->date);
return $numFinal; return $numFinal;
} }

View File

@ -32,10 +32,16 @@
* @param $mask * @param $mask
* @param unknown_type $table * @param unknown_type $table
* @param unknown_type $field * @param unknown_type $field
* @param unknown_type $where
* @param unknown_type $valueforccc
* @param unknown_type $date
* @return string New value * @return string New value
*/ */
function get_next_value($db,$mask,$table,$field,$where='',$valueforccc='') function get_next_value($db,$mask,$table,$field,$where='',$valueforccc='',$date='')
{ {
// Clean parameters
if ($date == '') $date=time();
// Extract value for mask counter, mask raz and mask offset // Extract value for mask counter, mask raz and mask offset
if (! eregi('\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}',$mask,$reg)) return 'ErrorBadMask'; if (! eregi('\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}',$mask,$reg)) return 'ErrorBadMask';
$masktri=$reg[1].$reg[2].$reg[3]; $masktri=$reg[1].$reg[2].$reg[3];
@ -92,10 +98,10 @@ function get_next_value($db,$mask,$table,$field,$where='',$valueforccc='')
$monthcomp=$maskraz; $monthcomp=$maskraz;
$yearoffset=0; $yearoffset=0;
$yearcomp=0; $yearcomp=0;
if (date("m") < $maskraz) { $yearoffset=-1; } // If current month lower that month of return to zero, year is previous year if (date("m",$date) < $maskraz) { $yearoffset=-1; } // If current month lower that month of return to zero, year is previous year
if (strlen($reg[2]) == 4) $yearcomp=sprintf("%04d",date("Y")+$yearoffset); if (strlen($reg[2]) == 4) $yearcomp=sprintf("%04d",date("Y",$date)+$yearoffset);
if (strlen($reg[2]) == 2) $yearcomp=sprintf("%02d",date("y")+$yearoffset); if (strlen($reg[2]) == 2) $yearcomp=sprintf("%02d",date("y",$date)+$yearoffset);
if (strlen($reg[2]) == 1) $yearcomp=substr(date("y"),2,1)+$yearoffset; if (strlen($reg[2]) == 1) $yearcomp=substr(date("y",$date),2,1)+$yearoffset;
$sqlwhere=''; $sqlwhere='';
$sqlwhere.='SUBSTRING('.$field.', '.(strlen($reg[1])+1).', '.strlen($reg[2]).') >= '.$yearcomp; $sqlwhere.='SUBSTRING('.$field.', '.(strlen($reg[1])+1).', '.strlen($reg[2]).') >= '.$yearcomp;
@ -191,11 +197,11 @@ function get_next_value($db,$mask,$table,$field,$where='',$valueforccc='')
$numFinal = $mask; $numFinal = $mask;
// We replace special codes except refclient // We replace special codes except refclient
$numFinal = str_replace('{yyyy}',date("Y"),$numFinal); $numFinal = str_replace('{yyyy}',date("Y",$date),$numFinal);
$numFinal = str_replace('{yy}',date("y"),$numFinal); $numFinal = str_replace('{yy}',date("y",$date),$numFinal);
$numFinal = str_replace('{y}' ,substr(date("y"),2,1),$numFinal); $numFinal = str_replace('{y}' ,substr(date("y",$date),2,1),$numFinal);
$numFinal = str_replace('{mm}',date("m"),$numFinal); $numFinal = str_replace('{mm}',date("m",$date),$numFinal);
$numFinal = str_replace('{dd}',date("d"),$numFinal); $numFinal = str_replace('{dd}',date("d",$date),$numFinal);
if ($maskclientcode) $numFinal = str_replace(('{'.$maskclientcode.'}'),$clientcode,$numFinal); if ($maskclientcode) $numFinal = str_replace(('{'.$maskclientcode.'}'),$clientcode,$numFinal);
// Now we replace the counter // Now we replace the counter

View File

@ -15,16 +15,13 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* or see http://www.gnu.org/ * or see http://www.gnu.org/
*
* $Id$
* $Source$
*/ */
/** /**
\file htdocs/lib/propal.lib.php \file htdocs/lib/propal.lib.php
\brief Ensemble de fonctions de base pour le module propal \brief Ensemble de fonctions de base pour le module propal
\ingroup propal \ingroup propal
\version $Revision$ \version $Id$
Ensemble de fonctions de base de dolibarr sous forme d'include Ensemble de fonctions de base de dolibarr sous forme d'include
*/ */

View File

@ -47,6 +47,11 @@ class Livraison extends CommonObject
var $origin_id; var $origin_id;
var $socid; var $socid;
var $date_livraison;
var $date_creation;
var $date_valid;
/** /**
* Initialisation * Initialisation
* *
@ -241,6 +246,7 @@ class Livraison extends CommonObject
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
$this->id = $obj->rowid; $this->id = $obj->rowid;
$this->date_livraison = $obj->date_livraison;
$this->date_creation = $obj->date_creation; $this->date_creation = $obj->date_creation;
$this->date_valid = $obj->date_valid; $this->date_valid = $obj->date_valid;
$this->ref = $obj->ref; $this->ref = $obj->ref;
@ -251,7 +257,6 @@ class Livraison extends CommonObject
$this->expedition_id = $obj->fk_expedition; $this->expedition_id = $obj->fk_expedition;
$this->user_author_id = $obj->fk_user_author; $this->user_author_id = $obj->fk_user_author;
$this->user_valid_id = $obj->fk_user_valid; $this->user_valid_id = $obj->fk_user_valid;
$this->date_livraison = $obj->date_livraison;
$this->adresse_livraison_id = $obj->fk_adresse_livraison; $this->adresse_livraison_id = $obj->fk_adresse_livraison;
$this->note = $obj->note; $this->note = $obj->note;
$this->note_public = $obj->note_public; $this->note_public = $obj->note_public;
@ -695,7 +700,58 @@ class Livraison extends CommonObject
if ($statut==1) return img_picto($langs->trans('StatusSendingValidated'),'statut4').' '.$langs->trans('StatusSendingValidated'); if ($statut==1) return img_picto($langs->trans('StatusSendingValidated'),'statut4').' '.$langs->trans('StatusSendingValidated');
} }
} }
/**
* \brief Initialise object with default value to be used as example
*/
function initAsSpecimen()
{
global $user,$langs;
// Charge tableau des id de soci<63>t<EFBFBD> socids
$socids = array();
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe WHERE client=1 LIMIT 10";
$resql = $this->db->query($sql);
if ($resql)
{
$num_socs = $this->db->num_rows($resql);
$i = 0;
while ($i < $num_socs)
{
$i++;
$row = $this->db->fetch_row($resql);
$socids[$i] = $row[0];
}
}
// Charge tableau des produits prodids
$prodids = array();
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product WHERE envente=1";
$resql = $this->db->query($sql);
if ($resql)
{
$num_prods = $this->db->num_rows($resql);
$i = 0;
while ($i < $num_prods)
{
$i++;
$row = $this->db->fetch_row($resql);
$prodids[$i] = $row[0];
}
}
// Initialise parametres
$this->id=0;
$this->ref = 'SPECIMEN';
$this->specimen=1;
$socid = rand(1, $num_socs);
$this->socid = $socids[$socid];
$this->date_livraison = time();
$this->note_public='SPECIMEN';
}
} }

View File

@ -57,10 +57,12 @@ class mod_livraison_jade extends ModeleNumRefDeliveryOrder
return "BL0600001"; return "BL0600001";
} }
/** \brief Renvoi prochaine valeur attribuée /** \brief Return next value
* \return string Valeur * \param objsoc Object third party
*/ * \param livraison Object delivery
function getNextValue() * \return string Value if OK, 0 if KO
*/
function getNextValue($objsoc=0,$livraison='')
{ {
global $db; global $db;
@ -82,7 +84,7 @@ class mod_livraison_jade extends ModeleNumRefDeliveryOrder
$posindice=5; $posindice=5;
$sql = "SELECT MAX(0+SUBSTRING(ref,$posindice))"; $sql = "SELECT MAX(0+SUBSTRING(ref,$posindice))";
$sql.= " FROM ".MAIN_DB_PREFIX."livraison"; $sql.= " FROM ".MAIN_DB_PREFIX."livraison";
$sql.= " WHERE ref like '${blyy}%'"; $sql.= " WHERE ref like '".$blyy."%'";
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
{ {
@ -94,7 +96,9 @@ class mod_livraison_jade extends ModeleNumRefDeliveryOrder
{ {
$max=0; $max=0;
} }
$yy = strftime("%y",time()); //$date=time();
$date=$livraison->date_livraison;
$yy = strftime("%y",$date);
$num = sprintf("%05s",$max+1); $num = sprintf("%05s",$max+1);
return "BL$yy$num"; return "BL$yy$num";
@ -103,11 +107,12 @@ class mod_livraison_jade extends ModeleNumRefDeliveryOrder
/** \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 Objet société
* \param livraison Objet livraison
* \return string Texte descripif * \return string Texte descripif
*/ */
function livraison_get_num($objsoc=0) function livraison_get_num($objsoc=0,$livraison='')
{ {
return $this->getNextValue(); return $this->getNextValue($objsoc,$livraison);
} }
} }
?> ?>

View File

@ -92,7 +92,7 @@ class mod_livraison_saphir extends ModeleNumRefDeliveryOrder
/** \brief Return next value /** \brief Return next value
* \param objsoc Object third party * \param objsoc Object third party
* \param livraison Object proposal * \param livraison Object delivery
* \return string Value if OK, 0 if KO * \return string Value if OK, 0 if KO
*/ */
function getNextValue($objsoc=0,$livraison='') function getNextValue($objsoc=0,$livraison='')
@ -110,15 +110,26 @@ class mod_livraison_saphir extends ModeleNumRefDeliveryOrder
return 0; return 0;
} }
$numFinal=get_next_value($db,$mask,'livraison','ref','',$objsoc->code_client); $numFinal=get_next_value($db,$mask,'livraison','ref','',$objsoc->code_client,$livraison->date_livraison);
return $numFinal; return $numFinal;
} }
/** \brief Renvoie la référence de commande suivante non utilisée /** \brief Return next free value
* \param objsoc Object third party
* \param objforref Object for number to search
* \return string Next free value
*/
function getNumRef($objsoc,$objforref)
{
return $this->getNextValue($objsoc,$objforref);
}
/** \brief Renvoie la référence de commande suivante non utilisée
* \param objsoc Objet société * \param objsoc Objet société
* \param commande Objet commande * \param livraison Objet livraison
* \return string Texte descripif * \return string Texte descripif
*/ */
function livraison_get_num($objsoc=0,$livraison='') function livraison_get_num($objsoc=0,$livraison='')

View File

@ -61,7 +61,10 @@ class Propal extends CommonObject
var $ref; var $ref;
var $ref_client; var $ref_client;
var $statut; // 0, 1, 2, 3, 4 var $statut; // 0, 1, 2, 3, 4
var $datep; var $date; // Date of proposal
var $datep; // Duplicate with date
var $date_livraison;
var $fin_validite; var $fin_validite;
var $price; // Total HT var $price; // Total HT
var $tva; // Total TVA var $tva; // Total TVA
@ -75,7 +78,6 @@ class Propal extends CommonObject
var $remise_absolue; var $remise_absolue;
var $note; var $note;
var $note_public; var $note_public;
var $date_livraison;
var $adresse_livraison_id; var $adresse_livraison_id;
var $adresse; var $adresse;
@ -685,9 +687,9 @@ class Propal extends CommonObject
$this->id = $rowid; $this->id = $rowid;
$this->date = $obj->dp;
$this->datep = $obj->dp; $this->datep = $obj->dp;
$this->fin_validite = $obj->dfv; $this->fin_validite = $obj->dfv;
$this->date = $obj->dp;
$this->ref = $obj->ref; $this->ref = $obj->ref;
$this->ref_client = $obj->ref_client; $this->ref_client = $obj->ref_client;
$this->remise = $obj->remise; $this->remise = $obj->remise;
@ -1693,8 +1695,7 @@ class Propal extends CommonObject
/** /**
* \brief Initialise la propale avec valeurs fictives al<EFBFBD>atoire * \brief Initialise object with default value to be used as example
* Sert <EFBFBD> g<EFBFBD>n<EFBFBD>rer une facture pour l'aperu des mod<EFBFBD>les ou demo
*/ */
function initAsSpecimen() function initAsSpecimen()
{ {