Fix: Maxi bug. Value for date used in object numbering module was current date instead of date of object.
This commit is contained in:
parent
2ec5ffee48
commit
6d8755edd4
@ -159,7 +159,7 @@ if ($_POST["action"] == 'set_use_customer_contact_as_recipient')
|
||||
|
||||
|
||||
/*
|
||||
* Affichage page
|
||||
* View
|
||||
*/
|
||||
|
||||
llxHeader();
|
||||
@ -225,7 +225,8 @@ if ($handle)
|
||||
print '</td>';
|
||||
|
||||
$commande=new Commande($db);
|
||||
|
||||
$commande->initAsSpecimen();
|
||||
|
||||
// Info
|
||||
$htmltooltip='';
|
||||
$htmltooltip.='<b>'.$langs->trans("Version").'</b>: '.$module->getVersion().'<br>';
|
||||
|
||||
@ -281,7 +281,8 @@ while (($file = readdir($handle))!==false)
|
||||
print '</td>';
|
||||
|
||||
$facture=new Facture($db);
|
||||
|
||||
$facture->initAsSpecimen();
|
||||
|
||||
// Example for standard invoice
|
||||
$htmltooltip='';
|
||||
$htmltooltip.='<b>'.$langs->trans("Version").'</b>: '.$module->getVersion().'<br>';
|
||||
|
||||
@ -226,12 +226,13 @@ if ($handle)
|
||||
print '</td>';
|
||||
|
||||
$livraison=new Livraison($db);
|
||||
$livraison->initAsSpecimen();
|
||||
|
||||
// Info
|
||||
$htmltooltip='';
|
||||
$htmltooltip.='<b>'.$langs->trans("Version").'</b>: '.$module->getVersion().'<br>';
|
||||
$facture->type=0;
|
||||
$nextval=$module->getNextValue($mysoc,$propale);
|
||||
$nextval=$module->getNextValue($mysoc,$livraison);
|
||||
if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval
|
||||
{
|
||||
$htmltooltip.='<b>'.$langs->trans("NextValue").'</b>: ';
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
||||
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
||||
* 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
|
||||
* 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');
|
||||
|
||||
/*
|
||||
* Module num<EFBFBD>rotation
|
||||
* Module numerotation
|
||||
*/
|
||||
print "<br>";
|
||||
print_titre($langs->trans("ProposalsNumberingModules"));
|
||||
@ -249,6 +249,7 @@ if ($handle)
|
||||
print '</td>';
|
||||
|
||||
$propale=new Propal($db);
|
||||
$propale->initAsSpecimen();
|
||||
|
||||
// Info
|
||||
$htmltooltip='';
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -57,7 +57,10 @@ class Facture extends CommonObject
|
||||
var $client;
|
||||
var $number;
|
||||
var $author;
|
||||
//! Invoice date
|
||||
var $date;
|
||||
var $date_creation;
|
||||
var $date_validation;
|
||||
var $ref;
|
||||
var $ref_client;
|
||||
//! 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);
|
||||
|
||||
$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.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.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.= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_facture';
|
||||
$sql.= ', cf.fk_commande';
|
||||
@ -453,6 +458,8 @@ class Facture extends CommonObject
|
||||
$this->ref_client = $obj->ref_client;
|
||||
$this->type = $obj->type;
|
||||
$this->date = $obj->df;
|
||||
$this->date_creation = $obj->datec;
|
||||
$this->date_validation = $obj->datev;
|
||||
$this->amount = $obj->amount;
|
||||
$this->remise_percent = $obj->remise_percent;
|
||||
$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
|
||||
* \param user Utilisateur qui valide la facture
|
||||
* \param soc Ne sert plus \\TODO A virer
|
||||
* \param force_number Référence à forcer de la facture
|
||||
* \return int <0 si ko, >0 si ok
|
||||
* \brief Tag la facture comme validée + appel trigger BILL_VALIDATE
|
||||
* \param user Utilisateur qui valide la facture
|
||||
* \param soc Ne sert plus. \\TODO A virer
|
||||
* \param force_number Référence à forcer de la facture
|
||||
* \return int <0 si ko, >0 si ok
|
||||
*/
|
||||
function set_valid($user, $soc='', $force_number='')
|
||||
{
|
||||
|
||||
@ -111,7 +111,7 @@ class mod_commande_fournisseur_orchidee extends ModeleNumRefSuppliersOrders
|
||||
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;
|
||||
}
|
||||
|
||||
@ -88,9 +88,9 @@ class mod_commande_marbre extends ModeleNumRefCommandes
|
||||
* \param commande Object order
|
||||
* \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é)
|
||||
$coyymm='';
|
||||
@ -129,22 +129,25 @@ class mod_commande_marbre extends ModeleNumRefCommandes
|
||||
{
|
||||
$max=0;
|
||||
}
|
||||
$yymm = strftime("%y%m",time());
|
||||
//$date=time();
|
||||
$date=$commande->date;
|
||||
$yymm = strftime("%y%m",$date);
|
||||
$num = sprintf("%04s",$max+1);
|
||||
|
||||
dolibarr_syslog("mod_commande_marbre::getNextValue return ".$this->prefix."$yymm-$num");
|
||||
return $this->prefix."$yymm-$num";
|
||||
dolibarr_syslog("mod_commande_marbre::getNextValue 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)
|
||||
/** \brief Return next free value
|
||||
* \param objsoc Object third party
|
||||
* \param objforref Object for number to search
|
||||
* \return string Next free value
|
||||
*/
|
||||
function commande_get_num($objsoc,$objforref)
|
||||
{
|
||||
return $this->getNextValue($objsoc);
|
||||
return $this->getNextValue($objsoc,$objforref);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -64,11 +64,13 @@ class mod_commande_opale extends ModeleNumRefCommandes
|
||||
}
|
||||
|
||||
|
||||
/** \brief Renvoi prochaine valeur attribuée
|
||||
* \return string Valeur
|
||||
*/
|
||||
function getNextValue()
|
||||
{
|
||||
/** \brief Return next value
|
||||
* \param objsoc Objet third party
|
||||
* \param commande Object order
|
||||
* \return string Value if OK, 0 if KO
|
||||
*/
|
||||
function getNextValue($objsoc,$commande)
|
||||
{
|
||||
global $db;
|
||||
|
||||
// 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;
|
||||
}
|
||||
$yy = strftime("%y",time());
|
||||
//$date=time();
|
||||
$date=$commande->date;
|
||||
$yy = strftime("%y",$date);
|
||||
$hex = strtoupper(dechex($max+1));
|
||||
$ref = substr("000000".($hex),-6);
|
||||
|
||||
return 'COM-'.substr($ref,0,3)."-".substr($ref,3,3);
|
||||
}
|
||||
|
||||
/** \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)
|
||||
{
|
||||
return $this->getNextValue();
|
||||
}
|
||||
/** \brief Return next free value
|
||||
* \param objsoc Object third party
|
||||
* \param objforref Object for number to search
|
||||
* \return string Next free value
|
||||
*/
|
||||
function commande_get_num($objsoc,$objforref)
|
||||
{
|
||||
return $this->getNextValue($objsoc,$objforref);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
@ -96,7 +96,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes
|
||||
* \param commande Object order
|
||||
* \return string Value if OK, 0 if KO
|
||||
*/
|
||||
function getNextValue($objsoc=0,$commande)
|
||||
function getNextValue($objsoc,$commande)
|
||||
{
|
||||
global $db,$conf;
|
||||
|
||||
@ -111,22 +111,22 @@ class mod_commande_saphir extends ModeleNumRefCommandes
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
/** \brief Renvoie la référence de commande suivante non utilisée
|
||||
* \param objsoc Objet société
|
||||
* \param commande Objet commande
|
||||
* \return string Texte descripif
|
||||
*/
|
||||
function commande_get_num($objsoc=0,$commande)
|
||||
/** \brief Return next free value
|
||||
* \param objsoc Object third party
|
||||
* \param objforref Object for number to search
|
||||
* \return string Next free value
|
||||
*/
|
||||
function commande_get_num($objsoc,$objforref)
|
||||
{
|
||||
return $this->getNextValue($objsoc,$commande);
|
||||
return $this->getNextValue($objsoc,$objforref);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@ -121,21 +121,21 @@ class mod_facture_mercure extends ModeleNumRefFactures
|
||||
if ($facture->type == 2) $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;
|
||||
}
|
||||
|
||||
|
||||
/** \brief Renvoie la reference de commande suivante non utilisee
|
||||
* \param objsoc Objet societe
|
||||
* \param facture Objet facture
|
||||
* \return string Texte descripif
|
||||
*/
|
||||
function getNumRef($objsoc=0,$facture)
|
||||
/** \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,$facture);
|
||||
return $this->getNextValue($objsoc,$objforref);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
@ -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 Regis Houssin <regis@dolibarr.fr>
|
||||
*
|
||||
* 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
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
* or see http://www.gnu.org/
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/includes/modules/facture/terre/terre.modules.php
|
||||
\ingroup facture
|
||||
\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");
|
||||
@ -145,9 +142,9 @@ class mod_facture_terre extends ModeleNumRefFactures
|
||||
{
|
||||
// Recherche rapide car restreint par un like sur champ indexé
|
||||
$posindice=8;
|
||||
$sql = "SELECT MAX(0+SUBSTRING(facnumber,$posindice))";
|
||||
$sql = "SELECT MAX(0+SUBSTRING(facnumber,".$posindice."))";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
|
||||
$sql.= " WHERE facnumber like '${fayymm}%'";
|
||||
$sql.= " WHERE facnumber like '".$fayymm."%'";
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@ -159,21 +156,24 @@ class mod_facture_terre extends ModeleNumRefFactures
|
||||
{
|
||||
$max=0;
|
||||
}
|
||||
$yymm = strftime("%y%m",time());
|
||||
|
||||
//$date=time();
|
||||
$date=$facture->date;
|
||||
$yymm = strftime("%y%m",$date);
|
||||
$num = sprintf("%04s",$max+1);
|
||||
|
||||
dolibarr_syslog("mod_facture_terre::getNextValue return ".$prefix."$yymm-$num");
|
||||
return $prefix."$yymm-$num";
|
||||
dolibarr_syslog("mod_facture_terre::getNextValue return ".$prefix.$yymm."-".$num);
|
||||
return $prefix.$yymm."-".$num;
|
||||
}
|
||||
|
||||
/** \brief Renvoie la référence de facture suivante non utilisée
|
||||
* \param objsoc Objet société
|
||||
* \param facture Objet facture
|
||||
* \return string Texte descripif
|
||||
*/
|
||||
function getNumRef($objsoc=0,$facture)
|
||||
{
|
||||
return $this->getNextValue($objsoc,$facture);
|
||||
/** \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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -116,20 +116,20 @@ class mod_arctic extends ModeleNumRefFicheinter
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
/** \brief Renvoie la référence de fichinter suivante non utilisée
|
||||
* \param objsoc Objet société
|
||||
* \param fichinter Objet fichinter
|
||||
* \return string Texte descripif
|
||||
*/
|
||||
function getNumRef($objsoc=0,$ficheinter='')
|
||||
/** \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,$ficheinter);
|
||||
return $this->getNextValue($objsoc,$objforref);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -16,16 +16,13 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
* or see http://www.gnu.org/
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/includes/modules/fichinter/mod_pacific.php
|
||||
\ingroup fiche intervention
|
||||
\brief Fichier contenant la classe du modèle de numérotation de référence de fiche intervention Pacific
|
||||
\version $Revision$
|
||||
\ingroup fiche intervention
|
||||
\brief Fichier contenant la classe du modèle de numérotation de référence de fiche intervention Pacific
|
||||
\version $Id$
|
||||
*/
|
||||
|
||||
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
|
||||
* \return string Valeur
|
||||
*/
|
||||
function getNextValue()
|
||||
{
|
||||
/** \brief Renvoi prochaine valeur attribuée
|
||||
* \param objsoc Objet société
|
||||
* \param ficheinter Object ficheinter
|
||||
* \return string Valeur
|
||||
*/
|
||||
function getNextValue($objsoc=0,$ficheinter='')
|
||||
{
|
||||
global $db;
|
||||
|
||||
// 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é
|
||||
$posindice=8;
|
||||
$sql = "SELECT MAX(0+SUBSTRING(ref,$posindice))";
|
||||
$sql = "SELECT MAX(0+SUBSTRING(ref,".$posindice."))";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."fichinter";
|
||||
$sql.= " WHERE ref like '${fayymm}%'";
|
||||
$sql.= " WHERE ref like '".$fayymm."%'";
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@ -137,19 +136,21 @@ class mod_pacific extends ModeleNumRefFicheinter
|
||||
{
|
||||
$max=0;
|
||||
}
|
||||
$yymm = strftime("%y%m",time());
|
||||
//$yymm = strftime("%y%m",time());
|
||||
$yymm = strftime("%y%m",$ficheinter->date);
|
||||
$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
|
||||
* \param objsoc Objet société
|
||||
* \return string Texte descripif
|
||||
*/
|
||||
function getNumRef($objsoc=0)
|
||||
{
|
||||
return $this->getNextValue();
|
||||
/** \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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -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 Regis Houssin <regis@dolibarr.fr>
|
||||
*
|
||||
* 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
|
||||
* \param objsoc Objet société
|
||||
* \return string Valeur
|
||||
*/
|
||||
function getNextValue($objsoc=0)
|
||||
/** \brief Return next value
|
||||
* \param objsoc Object third party
|
||||
* \param propal Object commercial proposal
|
||||
* \return string Valeur
|
||||
*/
|
||||
function getNextValue($objsoc,$propal)
|
||||
{
|
||||
global $db;
|
||||
|
||||
@ -114,9 +115,9 @@ class mod_propale_marbre extends ModeleNumRefPropales
|
||||
{
|
||||
// Recherche rapide car restreint par un like sur champ indexé
|
||||
$posindice=8;
|
||||
$sql = "SELECT MAX(0+SUBSTRING(ref,$posindice))";
|
||||
$sql = "SELECT MAX(0+SUBSTRING(ref,".$posindice."))";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."propal";
|
||||
$sql.= " WHERE ref like '${pryymm}%'";
|
||||
$sql.= " WHERE ref like '".$pryymm."%'";
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@ -128,20 +129,22 @@ class mod_propale_marbre extends ModeleNumRefPropales
|
||||
{
|
||||
$max=0;
|
||||
}
|
||||
$yymm = strftime("%y%m",time());
|
||||
//$yymm = strftime("%y%m",time());
|
||||
$yymm = strftime("%y%m",$propal->date);
|
||||
$num = sprintf("%04s",$max+1);
|
||||
|
||||
dolibarr_syslog("mod_propale_marbre::getNextValue return ".$this->prefix."$yymm-$num");
|
||||
return $this->prefix."$yymm-$num";
|
||||
dolibarr_syslog("mod_propale_marbre::getNextValue return ".$this->prefix.$yymm."-".$num);
|
||||
return $this->prefix.$yymm."-".$num;
|
||||
}
|
||||
|
||||
/** \brief Renvoie la référence de propale suivante non utilisée
|
||||
* \param objsoc Objet société
|
||||
* \return string Texte descripif
|
||||
*/
|
||||
function getNumRef($objsoc=0)
|
||||
{
|
||||
return $this->getNextValue();
|
||||
/** \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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ class mod_propale_saphir extends ModeleNumRefPropales
|
||||
* \param propal Object commercial proposal
|
||||
* \return string Value if OK, 0 if KO
|
||||
*/
|
||||
function getNextValue($objsoc,$propal='')
|
||||
function getNextValue($objsoc,$propal)
|
||||
{
|
||||
global $db,$conf;
|
||||
|
||||
@ -111,7 +111,7 @@ class mod_propale_saphir extends ModeleNumRefPropales
|
||||
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;
|
||||
}
|
||||
|
||||
@ -32,10 +32,16 @@
|
||||
* @param $mask
|
||||
* @param unknown_type $table
|
||||
* @param unknown_type $field
|
||||
* @param unknown_type $where
|
||||
* @param unknown_type $valueforccc
|
||||
* @param unknown_type $date
|
||||
* @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
|
||||
if (! eregi('\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}',$mask,$reg)) return 'ErrorBadMask';
|
||||
$masktri=$reg[1].$reg[2].$reg[3];
|
||||
@ -92,10 +98,10 @@ function get_next_value($db,$mask,$table,$field,$where='',$valueforccc='')
|
||||
$monthcomp=$maskraz;
|
||||
$yearoffset=0;
|
||||
$yearcomp=0;
|
||||
if (date("m") < $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]) == 2) $yearcomp=sprintf("%02d",date("y")+$yearoffset);
|
||||
if (strlen($reg[2]) == 1) $yearcomp=substr(date("y"),2,1)+$yearoffset;
|
||||
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",$date)+$yearoffset);
|
||||
if (strlen($reg[2]) == 2) $yearcomp=sprintf("%02d",date("y",$date)+$yearoffset);
|
||||
if (strlen($reg[2]) == 1) $yearcomp=substr(date("y",$date),2,1)+$yearoffset;
|
||||
|
||||
$sqlwhere='';
|
||||
$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;
|
||||
|
||||
// We replace special codes except refclient
|
||||
$numFinal = str_replace('{yyyy}',date("Y"),$numFinal);
|
||||
$numFinal = str_replace('{yy}',date("y"),$numFinal);
|
||||
$numFinal = str_replace('{y}' ,substr(date("y"),2,1),$numFinal);
|
||||
$numFinal = str_replace('{mm}',date("m"),$numFinal);
|
||||
$numFinal = str_replace('{dd}',date("d"),$numFinal);
|
||||
$numFinal = str_replace('{yyyy}',date("Y",$date),$numFinal);
|
||||
$numFinal = str_replace('{yy}',date("y",$date),$numFinal);
|
||||
$numFinal = str_replace('{y}' ,substr(date("y",$date),2,1),$numFinal);
|
||||
$numFinal = str_replace('{mm}',date("m",$date),$numFinal);
|
||||
$numFinal = str_replace('{dd}',date("d",$date),$numFinal);
|
||||
if ($maskclientcode) $numFinal = str_replace(('{'.$maskclientcode.'}'),$clientcode,$numFinal);
|
||||
|
||||
// Now we replace the counter
|
||||
|
||||
@ -15,16 +15,13 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
* or see http://www.gnu.org/
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/lib/propal.lib.php
|
||||
\brief Ensemble de fonctions de base pour le module propal
|
||||
\ingroup propal
|
||||
\version $Revision$
|
||||
\version $Id$
|
||||
|
||||
Ensemble de fonctions de base de dolibarr sous forme d'include
|
||||
*/
|
||||
|
||||
@ -47,6 +47,11 @@ class Livraison extends CommonObject
|
||||
var $origin_id;
|
||||
var $socid;
|
||||
|
||||
var $date_livraison;
|
||||
var $date_creation;
|
||||
var $date_valid;
|
||||
|
||||
|
||||
/**
|
||||
* Initialisation
|
||||
*
|
||||
@ -241,6 +246,7 @@ class Livraison extends CommonObject
|
||||
$obj = $this->db->fetch_object($result);
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
$this->date_livraison = $obj->date_livraison;
|
||||
$this->date_creation = $obj->date_creation;
|
||||
$this->date_valid = $obj->date_valid;
|
||||
$this->ref = $obj->ref;
|
||||
@ -251,7 +257,6 @@ class Livraison extends CommonObject
|
||||
$this->expedition_id = $obj->fk_expedition;
|
||||
$this->user_author_id = $obj->fk_user_author;
|
||||
$this->user_valid_id = $obj->fk_user_valid;
|
||||
$this->date_livraison = $obj->date_livraison;
|
||||
$this->adresse_livraison_id = $obj->fk_adresse_livraison;
|
||||
$this->note = $obj->note;
|
||||
$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');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \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';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -57,10 +57,12 @@ class mod_livraison_jade extends ModeleNumRefDeliveryOrder
|
||||
return "BL0600001";
|
||||
}
|
||||
|
||||
/** \brief Renvoi prochaine valeur attribuée
|
||||
* \return string Valeur
|
||||
*/
|
||||
function getNextValue()
|
||||
/** \brief Return next value
|
||||
* \param objsoc Object third party
|
||||
* \param livraison Object delivery
|
||||
* \return string Value if OK, 0 if KO
|
||||
*/
|
||||
function getNextValue($objsoc=0,$livraison='')
|
||||
{
|
||||
global $db;
|
||||
|
||||
@ -82,7 +84,7 @@ class mod_livraison_jade extends ModeleNumRefDeliveryOrder
|
||||
$posindice=5;
|
||||
$sql = "SELECT MAX(0+SUBSTRING(ref,$posindice))";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."livraison";
|
||||
$sql.= " WHERE ref like '${blyy}%'";
|
||||
$sql.= " WHERE ref like '".$blyy."%'";
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@ -94,7 +96,9 @@ class mod_livraison_jade extends ModeleNumRefDeliveryOrder
|
||||
{
|
||||
$max=0;
|
||||
}
|
||||
$yy = strftime("%y",time());
|
||||
//$date=time();
|
||||
$date=$livraison->date_livraison;
|
||||
$yy = strftime("%y",$date);
|
||||
$num = sprintf("%05s",$max+1);
|
||||
|
||||
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
|
||||
* \param objsoc Objet société
|
||||
* \param livraison Objet livraison
|
||||
* \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);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@ -92,7 +92,7 @@ class mod_livraison_saphir extends ModeleNumRefDeliveryOrder
|
||||
|
||||
/** \brief Return next value
|
||||
* \param objsoc Object third party
|
||||
* \param livraison Object proposal
|
||||
* \param livraison Object delivery
|
||||
* \return string Value if OK, 0 if KO
|
||||
*/
|
||||
function getNextValue($objsoc=0,$livraison='')
|
||||
@ -110,15 +110,26 @@ class mod_livraison_saphir extends ModeleNumRefDeliveryOrder
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** \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 commande Objet commande
|
||||
* \param livraison Objet livraison
|
||||
* \return string Texte descripif
|
||||
*/
|
||||
function livraison_get_num($objsoc=0,$livraison='')
|
||||
|
||||
@ -61,7 +61,10 @@ class Propal extends CommonObject
|
||||
var $ref;
|
||||
var $ref_client;
|
||||
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 $price; // Total HT
|
||||
var $tva; // Total TVA
|
||||
@ -75,7 +78,6 @@ class Propal extends CommonObject
|
||||
var $remise_absolue;
|
||||
var $note;
|
||||
var $note_public;
|
||||
var $date_livraison;
|
||||
var $adresse_livraison_id;
|
||||
var $adresse;
|
||||
|
||||
@ -685,9 +687,9 @@ class Propal extends CommonObject
|
||||
|
||||
$this->id = $rowid;
|
||||
|
||||
$this->date = $obj->dp;
|
||||
$this->datep = $obj->dp;
|
||||
$this->fin_validite = $obj->dfv;
|
||||
$this->date = $obj->dp;
|
||||
$this->ref = $obj->ref;
|
||||
$this->ref_client = $obj->ref_client;
|
||||
$this->remise = $obj->remise;
|
||||
@ -1693,8 +1695,7 @@ class Propal extends CommonObject
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initialise la propale avec valeurs fictives al<EFBFBD>atoire
|
||||
* Sert <EFBFBD> g<EFBFBD>n<EFBFBD>rer une facture pour l'aperu des mod<EFBFBD>les ou demo
|
||||
* \brief Initialise object with default value to be used as example
|
||||
*/
|
||||
function initAsSpecimen()
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user