diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php
index 1db72516b9b..be729112cbf 100644
--- a/htdocs/admin/facture.php
+++ b/htdocs/admin/facture.php
@@ -91,6 +91,11 @@ if ($_GET["action"] == 'delete')
}
}
+
+/*
+ * Affiche page
+ */
+
$dir = "../includes/modules/facture/";
@@ -109,9 +114,10 @@ print '
';
print '';
print '| '.$langs->trans("Name").' | ';
print ''.$langs->trans("Description").' | ';
-print ''.$langs->trans("Example").' | ';
+print ''.$langs->trans("Example").' | ';
print ''.$langs->trans("Default").' | ';
-print "
\n";
+print ''.$langs->trans("NextValue").' | ';
+print ''."\n";
clearstatcache();
@@ -120,37 +126,39 @@ $handle=opendir($dir);
$var=True;
while (($file = readdir($handle))!==false)
{
- if (is_dir($dir.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
+ if (is_dir($dir.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
{
- $var = !$var;
- print '| ';
- echo "$file";
- print " | \n";
+ $var = !$var;
+ print ' |
| ';
+ echo "$file";
+ print " | \n";
- $filebis = $file."/".$file.".modules.php";
+ $filebis = $file."/".$file.".modules.php";
- // Chargement de la classe de numérotation
- $classname = "mod_facture_".$file;
- require_once($dir.$filebis);
+ // Chargement de la classe de numérotation
+ $classname = "mod_facture_".$file;
+ require_once($dir.$filebis);
- $obj = new $classname($db);
- print $obj->info();
+ $obj = new $classname($db);
+ print $obj->info();
- print ' | ';
+ print '';
- // Affiche example
- print ''.$obj->getExample().' | ';
-
- print '';
- if ($facture_addon_var == "$file")
- {
- print img_tick();
- }
- else
- {
- print ''.$langs->trans("Default").'';
- }
- print " |
\n";
+ // Affiche example
+ print ''.$obj->getExample().' | ';
+
+ print '';
+ if ($facture_addon_var == "$file")
+ {
+ print img_tick();
+ print " | ".$obj->getNextValue()." | \n";
+ }
+ else
+ {
+ print ''.$langs->trans("Default").'';
+ print " | \n";
+ }
+ print "\n";
}
}
closedir($handle);
diff --git a/htdocs/admin/propale.php b/htdocs/admin/propale.php
index 2ee9c0f2d6b..45fb77ef62b 100644
--- a/htdocs/admin/propale.php
+++ b/htdocs/admin/propale.php
@@ -23,7 +23,8 @@
* $Source$
*/
-/** \file htdocs/admin/propale.php
+/**
+ \file htdocs/admin/propale.php
\ingroup propale
\brief Page d'administration/configuration du module Propale
\version $Revision$
@@ -40,35 +41,30 @@ if (!$user->admin)
if ($_POST["action"] == 'nbprod')
{
- dolibarr_set_const($db, "PROPALE_NEW_FORM_NB_PRODUCT",$value);
- Header("Location: propale.php");
+ dolibarr_set_const($db, "PROPALE_NEW_FORM_NB_PRODUCT",$value);
+ Header("Location: propale.php");
}
-
-llxHeader();
-
-
if ($_GET["action"] == 'set')
{
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."propal_model_pdf (nom) VALUES ('".$_GET["value"]."')";
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."propal_model_pdf (nom) VALUES ('".$_GET["value"]."')";
- if ($db->query($sql))
+ if ($db->query($sql))
{
}
}
if ($_GET["action"] == 'del')
{
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."propal_model_pdf WHERE nom='".$_GET["value"]."'";
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."propal_model_pdf WHERE nom='".$_GET["value"]."'";
- if ($db->query($sql))
+ if ($db->query($sql))
{
}
}
-// positionne la variable pour le test d'affichage de l'icone
-$propale_addon_var_pdf = PROPALE_ADDON_PDF;
+$propale_addon_var_pdf = $conf->global->PROPALE_ADDON_PDF;
if ($_GET["action"] == 'setpdf')
{
@@ -90,10 +86,15 @@ if ($_GET["action"] == 'setpdf')
}
}
-$propale_addon_var = PROPALE_ADDON;
+$propale_addon_var = $conf->global->PROPALE_ADDON;
if ($_GET["action"] == 'setmod')
{
+ // \todo Verifier si module numerotation choisi peut etre activé
+ // par appel methode canBeActivated
+
+
+
if (dolibarr_set_const($db, "PROPALE_ADDON",$_GET["value"]))
{
// la constante qui a été lue en avant du nouveau set
@@ -103,62 +104,72 @@ if ($_GET["action"] == 'setmod')
}
-
/*
* Affiche page
*/
+$dir = "../includes/modules/propale/";
+
+
+llxHeader('',$langs->trans("PropalSetup"));
+
print_titre($langs->trans("PropalSetup"));
-print "
";
+/*
+ * Module numérotation
+ */
+print "
";
print_titre($langs->trans("ProposalsNumberingModules"));
-print "\n";
-print "\n";
-print " | ".$langs->trans("Name")." | \n";
-print " ".$langs->trans("Description")." | \n";
-print " ".$langs->trans("Example")." | \n";
-print " ".$langs->trans("Activated")." | \n";
-print "
\n";
+print '';
+print '';
+print '| '.$langs->trans("Name")." | \n";
+print ''.$langs->trans("Description")." | \n";
+print ''.$langs->trans("Example")." | \n";
+print ''.$langs->trans("Activated")." | \n";
+print ''.$langs->trans("NextValue")." | \n";
+print '
'."\n";
clearstatcache();
-$dir = "../includes/modules/propale/";
$handle = opendir($dir);
if ($handle)
{
- $var=true;
- while (($file = readdir($handle))!==false)
+ $var=true;
+ while (($file = readdir($handle))!==false)
{
- if (substr($file, 0, 12) == 'mod_propale_' && substr($file, strlen($file)-3, 3) == 'php')
- {
- $file = substr($file, 0, strlen($file)-4);
+ if (substr($file, 0, 12) == 'mod_propale_' && substr($file, strlen($file)-3, 3) == 'php')
+ {
+ $file = substr($file, 0, strlen($file)-4);
- require_once(DOL_DOCUMENT_ROOT ."/includes/modules/propale/".$file.".php");
+ require_once(DOL_DOCUMENT_ROOT ."/includes/modules/propale/".$file.".php");
- $modPropale = new $file;
+ $modPropale = new $file;
- $var=!$var;
- print "\n | ".$file." | ";
- print "\n ".$modPropale->info()." | \n";
- print "\n ".$modPropale->getExample()." | \n";
-
- if ($propale_addon_var == "$file")
- {
- print '';
- print img_tick();
- print ' | ';
- }
- else
- {
- print "".$langs->trans("Activate")." | \n";
- }
-
- print "
\n";
- }
+ $var=!$var;
+ print "\n | ".$file." | ";
+ print "\n ".$modPropale->info()." | \n";
+ print "\n ".$modPropale->getExample()." | \n";
+
+ if ($propale_addon_var == "$file")
+ {
+ print '';
+ print img_tick();
+ print ' | ';
+ print "\n ".$modPropale->getNextValue()." | \n";
+ }
+ else
+ {
+ print "".$langs->trans("Activate")." | \n";
+ print "\n | \n";
+ }
+
+
+ print "
\n";
+ }
}
- closedir($handle);
+ closedir($handle);
}
print "
\n";
diff --git a/htdocs/includes/modules/facture/modules_facture.php b/htdocs/includes/modules/facture/modules_facture.php
index ec8008f3a45..06e0b14bdbf 100644
--- a/htdocs/includes/modules/facture/modules_facture.php
+++ b/htdocs/includes/modules/facture/modules_facture.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2004 Laurent Destailleur
+ * Copyright (C) 2004-2005 Laurent Destailleur
* Copyright (C) 2004 Eric Seigne
* Copyright (C) 2005 Regis Houssin
*
@@ -21,10 +21,10 @@
*
* $Id$
* $Source$
- *
*/
-/** \file htdocs/includes/modules/facture/modules_facture.php
+/**
+ \file htdocs/includes/modules/facture/modules_facture.php
\ingroup facture
\brief Fichier contenant la classe mère de generation des factures en PDF
et la classe mère de numérotation des factures
@@ -83,14 +83,23 @@ class ModeleNumRefFactures
return $langs->trans("NoExample");
}
- /**
- \brief Renvoi le dernier message d'erreur de création de facture
- */
- function numreferror()
+ /** \brief Test si les numéros déjà en vigueur dans la base ne provoquent pas de
+ * de conflits qui empechera cette numérotation de fonctionner.
+ * \return boolean false si conflit, true si ok
+ */
+ function canBeActivated()
{
- return $this->error;
+ return true;
}
+ /** \brief Renvoi prochaine valeur attribuée
+ * \return string Valeur
+ */
+ function getNextValue()
+ {
+ global $langs;
+ return $langs->trans("NotAvailable");
+ }
}
@@ -235,8 +244,7 @@ function facture_get_num($soc, $prefixe_additionnel='')
}
else
{
- dolibarr_syslog("Erreur dans facture_get_num");
- dolibarr_print_error($db,$obj->numreferror());
+ dolibarr_print_error($db,"modules_facture::facture_get_num ".$obj->error);
return "";
}
}
diff --git a/htdocs/includes/modules/facture/terre/terre.modules.php b/htdocs/includes/modules/facture/terre/terre.modules.php
new file mode 100644
index 00000000000..d61ecf4b345
--- /dev/null
+++ b/htdocs/includes/modules/facture/terre/terre.modules.php
@@ -0,0 +1,135 @@
+
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * 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$
+*/
+
+
+/** \class mod_facture_terre
+ \brief Classe du modèle de numérotation de référence de facture Terre
+*/
+
+class mod_facture_terre extends ModeleNumRefFactures
+{
+
+ /** \brief Renvoi la description du modele de numérotation
+ * \return string Texte descripif
+ */
+ function info()
+ {
+ return "Renvoie le numéro sous la forme FAyymm-nnnn où yy est l'année, mm le mois et nnnn un compteur séquentiel sans rupture et sans remise à 0";
+ }
+
+ /** \brief Renvoi un exemple de numérotation
+ * \return string Example
+ */
+ function getExample()
+ {
+ return "FA0501-0001";
+ }
+
+ /** \brief Test si les numéros déjà en vigueur dans la base ne provoquent pas de
+ * de conflits qui empechera cette numérotation de fonctionner.
+ * \return boolean false si conflit, true si ok
+ */
+ function canBeActivated()
+ {
+ $fayymm='';
+
+ $sql = "SELECT MAX(facnumber)";
+ $sql.= " FROM ".MAIN_DB_PREFIX."facture";
+ $resql=$db->query($sql);
+ if ($resql)
+ {
+ $row = $db->fetch_row($resql);
+ if ($row) $fayymm = substr($row[0],0,6);
+ }
+ if (! $fayymm || eregi('FA[0-9][0-9][0-9][0-9]',$fayymm))
+ {
+ return true;
+ }
+ else
+ {
+ $this->error='Une facture commençant par $fayymm existe en base et est incompatible avec cette numérotation. Supprimer la ou renommer la pour activer ce module.';
+ return false;
+ }
+ }
+
+ /** \brief Renvoi prochaine valeur attribuée
+ * \return string Valeur
+ */
+ function getNextValue()
+ {
+ global $db;
+
+ // D'abord on récupère la valeur max (réponse immédiate car champ indéxé)
+ $fayymm='';
+ $sql = "SELECT MAX(facnumber)";
+ $sql.= " FROM ".MAIN_DB_PREFIX."facture";
+ $resql=$db->query($sql);
+ if ($resql)
+ {
+ $row = $db->fetch_row($resql);
+ if ($row) $fayymm = substr($row[0],0,6);
+ }
+
+ // Si au moins un champ respectant le modèle a été trouvée
+ if (eregi('FA[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+SUBSTR(facnumber,$posindice))";
+ $sql.= " FROM ".MAIN_DB_PREFIX."facture";
+ $sql.= " WHERE facnumber like '${fayymm}%'";
+ $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);
+
+ return "FA$yymm-$num";
+ }
+
+ /** \brief Renvoie la référence de facture suivante non utilisée
+ * \param objsoc Objet société
+ * \return string Texte descripif
+ */
+ function getNumRef($objsoc=0)
+ {
+ return $this->getNextValue();
+ }
+
+}
+
+?>
diff --git a/htdocs/includes/modules/fichinter/modules_fichinter.php b/htdocs/includes/modules/fichinter/modules_fichinter.php
index 64e6c5d759e..35a41dbb8ab 100644
--- a/htdocs/includes/modules/fichinter/modules_fichinter.php
+++ b/htdocs/includes/modules/fichinter/modules_fichinter.php
@@ -86,14 +86,6 @@ class ModeleNumRefFicheinter
return $langs->trans("NoExample");
}
- /**
- \brief Renvoi le dernier message d'erreur de création de fiche intervention
- */
- function numreferror()
- {
- return $this->error;
- }
-
}
diff --git a/htdocs/includes/modules/propale/mod_propale_ivoire.php b/htdocs/includes/modules/propale/mod_propale_ivoire.php
index 53a44da133c..53a2d231a37 100644
--- a/htdocs/includes/modules/propale/mod_propale_ivoire.php
+++ b/htdocs/includes/modules/propale/mod_propale_ivoire.php
@@ -60,7 +60,20 @@ class mod_propale_ivoire extends ModeleNumRefPropales
*/
function getNextValue()
{
- return $this->propale_get_num();
+ global $db;
+
+ $sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."propal";
+
+ if ( $db->query($sql) )
+ {
+ $row = $db->fetch_row(0);
+
+ $num = $row[0];
+ }
+
+ $y = strftime("%y",time());
+
+ return "PR" . "$y" . substr("000".$num, strlen("000".$num)-4,4);
}
@@ -70,21 +83,7 @@ class mod_propale_ivoire extends ModeleNumRefPropales
*/
function propale_get_num($objsoc=0)
{
- global $db;
-
- $sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."propal";
-
- if ( $db->query($sql) )
- {
- $row = $db->fetch_row(0);
-
- $num = $row[0];
- }
-
- $y = strftime("%y",time());
-
- return "PR" . "$y" . substr("000".$num, strlen("000".$num)-4,4);
-
+ return $this->propale_get_num();
}
}
diff --git a/htdocs/includes/modules/propale/mod_propale_jade.php b/htdocs/includes/modules/propale/mod_propale_jade.php
index 9a2c45ff3e1..8e9d7dddbe4 100644
--- a/htdocs/includes/modules/propale/mod_propale_jade.php
+++ b/htdocs/includes/modules/propale/mod_propale_jade.php
@@ -60,16 +60,6 @@ class mod_propale_jade extends ModeleNumRefPropales
* \return string Valeur
*/
function getNextValue()
- {
- return $this->propale_get_num();
- }
-
-
- /** \brief Renvoie la référence de propale suivante non utilisée
- * \param objsoc Objet société
- * \return string Texte descripif
- */
- function propale_get_num($objsoc=0)
{
global $db;
@@ -86,6 +76,16 @@ class mod_propale_jade extends ModeleNumRefPropales
return "PROP" . ($num+1);
}
+
+
+ /** \brief Renvoie la référence de propale suivante non utilisée
+ * \param objsoc Objet société
+ * \return string Texte descripif
+ */
+ function propale_get_num($objsoc=0)
+ {
+ return $this->propale_get_num();
+ }
}
?>
diff --git a/htdocs/includes/modules/propale/mod_propale_marbre.php b/htdocs/includes/modules/propale/mod_propale_marbre.php
index d22761174a2..a164190074d 100644
--- a/htdocs/includes/modules/propale/mod_propale_marbre.php
+++ b/htdocs/includes/modules/propale/mod_propale_marbre.php
@@ -131,20 +131,7 @@ class mod_propale_marbre extends ModeleNumRefPropales
*/
function propale_get_num($objsoc=0)
{
- global $db;
-
- $sql = "SELECT MAX(ref) as nb FROM ".MAIN_DB_PREFIX."propal";
- $resql=$db->query($sql);
- if ($resql)
- {
- $row = $db->fetch_row($resql);
- $num = $row[0];
- }
-
- $yymm = strftime("%y%m",time());
-
- return "PR$yymm-".$obj->prefix.'-'.substr("000".$num, 0,-4);
-
+ return $this->getNextValue();
}
}