From b064e4c272baac22de921e0e6460da6f21268238 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 30 Jul 2006 01:55:08 +0000 Subject: [PATCH] =?UTF-8?q?New:=20Ajout=20module=20num=E9rotation=20pour?= =?UTF-8?q?=20les=20fiche=20interventions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/admin/commande.php | 10 +- htdocs/admin/expedition.php | 10 +- htdocs/admin/facture.php | 2 - htdocs/admin/fichinter.php | 80 ++++++++- htdocs/admin/fournisseur.php | 10 +- htdocs/admin/livraison.php | 10 +- htdocs/admin/propale.php | 10 +- htdocs/fichinter/fiche.php | 44 ++--- .../modules/commande/mod_commande_ivoire.php | 12 +- .../modules/fichinter/mod_pacific.php | 156 ++++++++++++++++++ mysql/data/data.sql | 1 + mysql/migration/2.0.0-2.1.0.sql | 1 + 12 files changed, 265 insertions(+), 81 deletions(-) create mode 100644 htdocs/includes/modules/fichinter/mod_pacific.php diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index 679436efe36..5444907fb3c 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -99,8 +99,6 @@ if ($_GET["action"] == 'setdoc') if (dolibarr_set_const($db, "COMMANDE_ADDON_PDF",$_GET["value"])) { - // La constante qui a été lue en avant du nouveau set - // on passe donc par une variable pour avoir un affichage cohérent $conf->global->COMMANDE_ADDON_PDF = $_GET["value"]; } @@ -126,13 +124,7 @@ if ($_GET["action"] == 'setmod') // \todo Verifier si module numerotation choisi peut etre activé // par appel methode canBeActivated - - if (dolibarr_set_const($db, "COMMANDE_ADDON",$_GET["value"])) - { - // la constante qui a été lue en avant du nouveau set - // on passe donc par une variable pour avoir un affichage cohérent - $conf->global->COMMANDE_ADDON = $_GET["value"]; - } + dolibarr_set_const($db, "COMMANDE_ADDON",$_GET["value"]); } diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index 245641453a9..938469c3d13 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -73,8 +73,6 @@ if ($_GET["action"] == 'setdoc') if (dolibarr_set_const($db, "EXPEDITION_ADDON_PDF",$_GET["value"])) { - // La constante qui a été lue en avant du nouveau set - // on passe donc par une variable pour avoir un affichage cohérent $conf->global->EXPEDITION_ADDON_PDF = $_GET["value"]; } @@ -119,13 +117,7 @@ if ($_GET["action"] == 'setmod') // \todo Verifier si module numerotation choisi peut etre activé // par appel methode canBeActivated - - if (dolibarr_set_const($db, "EXPEDITION_ADDON",$_GET["value"])) - { - // la constante qui a été lue en avant du nouveau set - // on passe donc par une variable pour avoir un affichage cohérent - $conf->global->EXPEDITION_ADDON = $_GET["value"]; - } + dolibarr_set_const($db, "EXPEDITION_ADDON",$_GET["value"]); } diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index d6216622daf..bae77fbf4b8 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -99,8 +99,6 @@ if ($_GET["action"] == 'setdoc') if (dolibarr_set_const($db, "FACTURE_ADDON_PDF",$_GET["value"])) { - // La constante qui a été lue en avant du nouveau set - // on passe donc par une variable pour avoir un affichage cohérent $conf->global->FACTURE_ADDON_PDF = $_GET["value"]; } diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php index 3549a0325ac..08490d2b839 100644 --- a/htdocs/admin/fichinter.php +++ b/htdocs/admin/fichinter.php @@ -93,6 +93,15 @@ if ($_GET["action"] == 'setdoc') } } +if ($_GET["action"] == 'setmod') +{ + // \todo Verifier si module numerotation choisi peut etre activé + // par appel methode canBeActivated + + dolibarr_set_const($db, "FICHEINTER_ADDON",$_GET["value"]); +} + + /* * Affichage page @@ -100,13 +109,82 @@ if ($_GET["action"] == 'setdoc') llxHeader(); -$dir = "../includes/modules/fichinter/"; +$dir=DOL_DOCUMENT_ROOT."/includes/modules/fichinter/"; $html=new Form($db); print_titre($langs->trans("InterventionsSetup")); print "
"; + +print_titre($langs->trans("FicheinterNumberingModules")); + +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print "\n"; + +clearstatcache(); + +$handle = opendir($dir); +if ($handle) +{ + $var=true; + + while (($file = readdir($handle))!==false) + { + if (eregi('^(mod_.*)\.php$',$file,$reg)) + { + $file = $reg[1]; + + require_once($dir.$file.".php"); + + $module = new $file; + + $var=!$var; + print ''; + + // Examples + print '\n"; + + print ''; + + // Info + $htmltooltip=''; + $nextval=$module->getNextValue(); + if ($nextval != $langs->trans("NotAvailable")) + { + $htmltooltip=''.$langs->trans("NextValue").': '.$nextval; + } + print ''; + + print ''; + } + } + closedir($handle); +} + +print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Example").''.$langs->trans("Activated").''.$langs->trans("Info").'
'.$module->nom."\n"; + print $module->info(); + print ''.$module->getExample()."'; + if ("mod_".$conf->global->FICHEINTER_ADDON == $file) + { + print img_tick($langs->trans("Activated")); + } + else + { + print ''.$langs->trans("Activate").''; + } + print 'tooltip_properties($htmltooltip).'>'; + print ($htmltooltip?img_help(0):''); + print '

'; + + + print_titre($langs->trans("TemplatePDFInterventions")); // Defini tableau def des modeles diff --git a/htdocs/admin/fournisseur.php b/htdocs/admin/fournisseur.php index 4115c79aa6d..8ff3e967eb8 100644 --- a/htdocs/admin/fournisseur.php +++ b/htdocs/admin/fournisseur.php @@ -73,8 +73,6 @@ if ($_GET["action"] == 'setdoc') if (dolibarr_set_const($db, "COMMANDE_SUPPLIER_ADDON_PDF",$_GET["value"])) { - // La constante qui a été lue en avant du nouveau set - // on passe donc par une variable pour avoir un affichage cohérent $conf->global->COMMANDE_SUPPLIER_ADDON_PDF = $_GET["value"]; } @@ -100,13 +98,7 @@ if ($_GET["action"] == 'setmod') // \todo Verifier si module numerotation choisi peut etre activé // par appel methode canBeActivated - - if (dolibarr_set_const($db, "COMMANDE_SUPPLIER_ADDON",$_GET["value"])) - { - // la constante qui a été lue en avant du nouveau set - // on passe donc par une variable pour avoir un affichage cohérent - $conf->global->COMMANDE_SUPPLIER_ADDON = $_GET["value"]; - } + dolibarr_set_const($db, "COMMANDE_SUPPLIER_ADDON",$_GET["value"]); } diff --git a/htdocs/admin/livraison.php b/htdocs/admin/livraison.php index d52f3fcf431..79e5f45ab58 100644 --- a/htdocs/admin/livraison.php +++ b/htdocs/admin/livraison.php @@ -73,8 +73,6 @@ if ($_GET["action"] == 'setdoc') if (dolibarr_set_const($db, "LIVRAISON_ADDON_PDF",$_GET["value"])) { - // La constante qui a été lue en avant du nouveau set - // on passe donc par une variable pour avoir un affichage cohérent $conf->global->LIVRAISON_ADDON_PDF = $_GET["value"]; } @@ -100,13 +98,7 @@ if ($_GET["action"] == 'setmod') // \todo Verifier si module numerotation choisi peut etre activé // par appel methode canBeActivated - - if (dolibarr_set_const($db, "LIVRAISON_ADDON",$_GET["value"])) - { - // la constante qui a été lue en avant du nouveau set - // on passe donc par une variable pour avoir un affichage cohérent - $conf->global->LIVRAISON_ADDON = $_GET["value"]; - } + dolibarr_set_const($db, "LIVRAISON_ADDON",$_GET["value"]); } diff --git a/htdocs/admin/propale.php b/htdocs/admin/propale.php index c0e73018bbe..6881c1a03b5 100644 --- a/htdocs/admin/propale.php +++ b/htdocs/admin/propale.php @@ -118,8 +118,6 @@ if ($_GET["action"] == 'setdoc') if (dolibarr_set_const($db, "PROPALE_ADDON_PDF",$_GET["value"])) { - // La constante qui a été lue en avant du nouveau set - // on passe donc par une variable pour avoir un affichage cohérent $conf->global->PROPALE_ADDON_PDF = $_GET["value"]; } @@ -145,13 +143,7 @@ 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 - // on passe donc par une variable pour avoir un affichage cohérent - $conf->global->PROPALE_ADDON = $_GET["value"]; - } + dolibarr_set_const($db, "PROPALE_ADDON",$_GET["value"]); } diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php index 09dd6847e4e..7da16542ddb 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -31,9 +31,9 @@ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/fichinter/fichinter.class.php"); require_once(DOL_DOCUMENT_ROOT."/includes/modules/fichinter/modules_fichinter.php"); require_once(DOL_DOCUMENT_ROOT."/project.class.php"); -if (defined("FICHEINTER_ADDON") && is_readable(DOL_DOCUMENT_ROOT ."/includes/modules/ficheinter/".FICHEINTER_ADDON.".php")) +if (defined("FICHEINTER_ADDON") && is_readable(DOL_DOCUMENT_ROOT ."/includes/modules/fichinter/mod_".FICHEINTER_ADDON.".php")) { - require_once(DOL_DOCUMENT_ROOT ."/includes/modules/ficheinter/".FICHEINTER_ADDON.".php"); + require_once(DOL_DOCUMENT_ROOT ."/includes/modules/fichinter/mod_".FICHEINTER_ADDON.".php"); } $langs->load("companies"); @@ -138,18 +138,20 @@ if ($_GET["action"] == 'create') { print_titre($langs->trans("AddIntervention")); - // \todo Utiliser un module de numérotation - + if (! $conf->global->FICHEINTER_ADDON) + { + dolibarr_print_error($db,$langs->trans("Error")." ".$langs->trans("Error_FICHEINTER_ADDON_NotDefined")); + exit; + } $fix = new Fichinter($db); - $obj = $conf->global->FICHEINTER_ADDON; + $file = "mod_".$conf->global->FICHEINTER_ADDON.".php"; - // \todo Quand module numerotation fiche inter sera dispo - // $modFicheinter = new $obj; - // $numpr = $modFicheinter->getNextValue($soc); + $obj = "mod_".$conf->global->FICHEINTER_ADDON; + $modFicheinter = new $obj; + $numpr = $modFicheinter->getNextValue($societe); - $numpr = $fix->get_new_num($societe); print "
"; @@ -167,16 +169,7 @@ if ($_GET["action"] == 'create') print ""; print "".$langs->trans("Ref").""; - - // en attendant le module de numérotation - if ($societe->prefix_comm) - { - print "\n"; - } - else - { - print "".img_warning().$langs->trans("CustomerDoesNotHavePrefix")."\n"; - } + print "\n"; print "".$langs->trans("Duration")." (".$langs->trans("days").")\n"; @@ -223,13 +216,9 @@ if ($_GET["action"] == 'create') print ""; print ''; - // en attendant le module de numérotation - if ($societe->prefix_comm) - { - print ''; - print ''; - print ''; - } + print ''; + print ''; + print ''; print ''; print '
'; @@ -410,5 +399,6 @@ if ($_GET["id"] && $_GET["action"] != 'edit') } $db->close(); -llxFooter(); + +llxFooter('$Date$ - $Revision$'); ?> diff --git a/htdocs/includes/modules/commande/mod_commande_ivoire.php b/htdocs/includes/modules/commande/mod_commande_ivoire.php index 4b065e7755a..85e19896a16 100644 --- a/htdocs/includes/modules/commande/mod_commande_ivoire.php +++ b/htdocs/includes/modules/commande/mod_commande_ivoire.php @@ -39,12 +39,12 @@ include_once("modules_commande.php"); class mod_commande_ivoire extends ModeleNumRefCommandes { - /** \brief Constructeur - */ - function mod_commande_ivoire() - { - $this->nom = "Ivoire"; - } + /** \brief Constructeur + */ + function mod_commande_ivoire() + { + $this->nom = "Ivoire"; + } /** \brief Renvoi la description du modele de numérotation diff --git a/htdocs/includes/modules/fichinter/mod_pacific.php b/htdocs/includes/modules/fichinter/mod_pacific.php new file mode 100644 index 00000000000..f8731e151e5 --- /dev/null +++ b/htdocs/includes/modules/fichinter/mod_pacific.php @@ -0,0 +1,156 @@ + + * Copyright (C) 2005 Regis Houssin + * + * 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/fichinter/mod_pacific.php + \ingroup facture + \brief Fichier contenant la classe du modèle de numérotation de référence de fiche intervention Pacific + \version $Revision$ +*/ + +require_once(DOL_DOCUMENT_ROOT ."/includes/modules/fichinter/modules_fichinter.php"); + +/** \class mod_facture_terre + \brief Classe du modèle de numérotation de référence de fiche intervention Pacific +*/ + +class mod_pacific extends ModeleNumRefFicheinter +{ + var $prefix='FI'; + var $error=''; + + + /** \brief Constructeur + */ + function mod_pacific() + { + $this->nom = "pacific"; + } + + + /** \brief Renvoi la description du modele de numérotation + * \return string Texte descripif + */ + function info() + { + global $langs; + + $langs->load("bills"); + + return $langs->trans('PacificNumRefModelDesc1',$this->prefix); + } + + /** \brief Renvoi un exemple de numérotation + * \return string Example + */ + function getExample() + { + return $this->prefix."0501-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() + { + global $langs; + + $langs->load("bills"); + + $fayymm=''; + + $sql = "SELECT MAX(ref)"; + $sql.= " FROM ".MAIN_DB_PREFIX."fichinter"; + $resql=$db->query($sql); + if ($resql) + { + $row = $db->fetch_row($resql); + if ($row) $fayymm = substr($row[0],0,6); + } + if (! $fayymm || eregi($this->prefix.'[0-9][0-9][0-9][0-9]',$fayymm)) + { + return true; + } + else + { + $this->error=$langs->trans('PacificNumRefModelError'); + 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(ref)"; + $sql.= " FROM ".MAIN_DB_PREFIX."fichinter"; + $resql=$db->query($sql); + if ($resql) + { + $row = $db->fetch_row($resql); + if ($row) $fayymm = substr($row[0],0,6); + } + + // 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()); + $num = sprintf("%04s",$max+1); + + return $this->prefix."$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/mysql/data/data.sql b/mysql/data/data.sql index c8985dd5946..55d102ea146 100644 --- a/mysql/data/data.sql +++ b/mysql/data/data.sql @@ -170,6 +170,7 @@ insert into llx_const (name, value, type, visible) values ('COMMANDE_SUPPLIER_AD insert into llx_const (name, value, type, visible) values ('COMMANDE_SUPPLIER_ADDON_PDF', 'muscadet','chaine',0); insert into llx_const (name, value, type, visible) values ('EXPEDITION_ADDON', 'enlevement','chaine',0); insert into llx_const (name, value, type, visible) values ('EXPEDITION_ADDON_PDF','rouget','chaine',0); +insert into llx_const (name, value, type, visible) values ('FICHEINTER_ADDON', 'pacific','chaine',0); insert into llx_const (name, value, type, visible) values ('FICHEINTER_ADDON_PDF','soleil','chaine',0); insert into llx_const (name, value, type, visible) values ('FACTURE_ADDON', 'terre','chaine',0); insert into llx_const (name, value, type, visible) values ('FACTURE_ADDON_PDF', 'crabe','chaine',0); diff --git a/mysql/migration/2.0.0-2.1.0.sql b/mysql/migration/2.0.0-2.1.0.sql index 0b3632f77d8..0093e8625e9 100644 --- a/mysql/migration/2.0.0-2.1.0.sql +++ b/mysql/migration/2.0.0-2.1.0.sql @@ -207,6 +207,7 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (29 update llx_const set value='neptune' where value='pluton' and name = 'FACTURE_ADDON'; update llx_const set value='azur' where value='orange' and name = 'PROPALE_ADDON'; update llx_const set value='mod_commande_diamant' where value='mod_commande_jade' and name ='COMMANDE_ADDON'; +insert into llx_const (name, value, type, visible) values ('FICHEINTER_ADDON', 'pacific','chaine',0); alter table llx_propal_model_pdf rename to llx_document_model; alter table llx_document_model DROP PRIMARY KEY;