From 0327c1bb8294aa4d48200bf0bb0154375a1a3fb3 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 17 Mar 2006 12:24:41 +0000 Subject: [PATCH] =?UTF-8?q?d=E9but=20de=20l'ajout=20du=20module=20"avoir"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/admin/avoir.php | 279 ++++++++++++++++++ htdocs/admin/propale.php | 2 +- htdocs/includes/modules/modAvoir.class.php | 18 +- htdocs/includes/modules/modCommande.class.php | 16 +- htdocs/langs/en_US/admin.lang | 10 +- htdocs/langs/fr_FR/admin.lang | 8 + mysql/migration/2.0.0-2.1.0.sql | 7 + mysql/tables/llx_avoir_model_pdf.sql | 30 ++ 8 files changed, 357 insertions(+), 13 deletions(-) create mode 100644 htdocs/admin/avoir.php create mode 100644 mysql/tables/llx_avoir_model_pdf.sql diff --git a/htdocs/admin/avoir.php b/htdocs/admin/avoir.php new file mode 100644 index 00000000000..2f3cc2aa87f --- /dev/null +++ b/htdocs/admin/avoir.php @@ -0,0 +1,279 @@ + + * Copyright (C) 2004-2005 Laurent Destailleur + * Copyright (C) 2005-2006 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. + * + * $Id$ + * $Source$ + */ + +/** + \file htdocs/admin/avoir.php + \ingroup avoir + \brief Page d'administration/configuration du module Avoir + \version $Revision$ +*/ + +require("./pre.inc.php"); + +$langs->load("admin"); +$langs->load("discount"); + +if (!$user->admin) + accessforbidden(); + + +if ($_GET["action"] == 'set') +{ + $sql = "INSERT INTO ".MAIN_DB_PREFIX."avoir_model_pdf (nom) VALUES ('".$_GET["value"]."')"; + + if ($db->query($sql)) + { + + } +} +if ($_GET["action"] == 'del') +{ + $sql = "DELETE FROM ".MAIN_DB_PREFIX."avoir_model_pdf WHERE nom='".$_GET["value"]."'"; + + if ($db->query($sql)) + { + + } +} + + +$avoir_addon_var_pdf = $conf->global->AVOIR_ADDON_PDF; + +if ($_GET["action"] == 'setpdf') +{ + if (dolibarr_set_const($db, "AVOIR_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 + $avoir_addon_var_pdf = $_GET["value"]; + } + + // On active le modele + $sql_del = "delete from ".MAIN_DB_PREFIX."avoir_model_pdf where nom = '".$_GET["value"]."';"; + $db->query($sql_del); + + $sql = "INSERT INTO ".MAIN_DB_PREFIX."avoir_model_pdf (nom) VALUES ('".$_GET["value"]."')"; + if ($db->query($sql)) + { + + } +} + +$avoir_addon_var = $conf->global->AVOIR_ADDON; + +if ($_GET["action"] == 'setmod') +{ + // \todo Verifier si module numerotation choisi peut etre activé + // par appel methode canBeActivated + + + + if (dolibarr_set_const($db, "AVOIR_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 + $avoir_addon_var = $_GET["value"]; + } +} + + +/* + * Affiche page + */ + +$dir = DOL_DOCUMENT_ROOT .'/avoir/modules/'; + + +llxHeader('',$langs->trans("DiscountSetup")); + +print_titre($langs->trans("DiscountSetup")); + + +/* + * Module numérotation + */ +print "
"; +print_titre($langs->trans("DiscountsNumberingModules")); + +print ''; +print ''; +print '\n"; +print '\n"; +print '\n"; +print ''; +print ''."\n"; + +clearstatcache(); + +$handle = opendir($dir); +if ($handle) +{ + $var=true; + while (($file = readdir($handle))!==false) + { + if (substr($file, 0, 10) == 'mod_avoir_' && substr($file, strlen($file)-3, 3) == 'php') + { + $file = substr($file, 0, strlen($file)-4); + + require_once(DOL_DOCUMENT_ROOT ."/avoir/modules/".$file.".php"); + + $modAvoir = new $file; + + $var=!$var; + print "\n "; + print "\n \n"; + print "\n \n"; + + print ''; + + + print "\n"; + } + } + closedir($handle); +} +print "
'.$langs->trans("Name")."'.$langs->trans("Description")."'.$langs->trans("Example")."'.$langs->trans("Activated").'
".$file."".$modAvoir->info()."".$modAvoir->getExample()."'; + if ($avoir_addon_var == "$file") + { + $title=''; + if ($modAvoir->getNextValue() != $langs->trans("NotAvailable")) + { + $title=$langs->trans("NextValue").': '.$modAvoir->getNextValue(); + } + print img_tick($title); + } + else + { + print "".$langs->trans("Activate").""; + } + print '

\n"; + + +/* + * PDF + */ + +print_titre($langs->trans("DiscountsPDFModules")); + +$def = array(); + +$sql = "SELECT nom FROM ".MAIN_DB_PREFIX."avoir_model_pdf"; +$resql=$db->query($sql); +if ($resql) +{ + $i = 0; + $num_rows=$db->num_rows($resql); + while ($i < $num_rows) + { + $array = $db->fetch_array($resql); + array_push($def, $array[0]); + $i++; + } +} +else +{ + dolibarr_print_error($db); +} + +$dir = DOL_DOCUMENT_ROOT .'/avoir/modules/pdf/'; + +print "\n"; +print "\n"; +print " \n"; +print " \n"; +print ' \n"; +print ' \n"; +print "\n"; + +clearstatcache(); + +$handle=opendir($dir); + +$var=true; +while (($file = readdir($handle))!==false) +{ + if (substr($file, strlen($file) -12) == '.modules.php' && substr($file,0,10) == 'pdf_avoir_') + { + $name = substr($file, 10, strlen($file) - 24); + $classname = substr($file, 0, strlen($file) -12); + + $var=!$var; + print "\n \n \n \n \n \n '; + } +} +closedir($handle); + +print '
".$langs->trans("Name")."".$langs->trans("Description")."'.$langs->trans("Activated")."'.$langs->trans("Default")."
"; + print "$name"; + print "\n"; + require_once($dir.$file); + $obj = new $classname($db); + + print $obj->description; + + print "\n"; + + if (in_array($name, $def)) + { + print img_tick(); + print ""; + print ''.$langs->trans("Disable").''; + } + else + { + print " "; + print ""; + print ''.$langs->trans("Activate").''; + } + + print ""; + + if ($avoir_addon_var_pdf == "$name") + { + print img_tick(); + } + else + { + print ''.$langs->trans("Activate").''; + } + print '
'; + +/* + * Repertoire + */ +print '
'; +print_titre($langs->trans("PathToDocuments")); + +print "\n"; +print "\n"; +print " \n"; +print " \n"; +print "\n"; +print "\n \n \n\n"; +print "
".$langs->trans("Name")."".$langs->trans("Value")."
".$langs->trans("Directory")."".$conf->avoir->dir_output."
\n
"; + + +$db->close(); + +llxFooter(); +?> diff --git a/htdocs/admin/propale.php b/htdocs/admin/propale.php index c21068ff625..1a0e6b140c9 100644 --- a/htdocs/admin/propale.php +++ b/htdocs/admin/propale.php @@ -270,7 +270,7 @@ print ''; * Repertoire */ print '
'; -print_titre("Chemins d'accés aux documents"); +print_titre($langs->trans("PathToDocuments")); print "\n"; print "\n"; diff --git a/htdocs/includes/modules/modAvoir.class.php b/htdocs/includes/modules/modAvoir.class.php index 48181d4f1eb..eeccd35a42f 100644 --- a/htdocs/includes/modules/modAvoir.class.php +++ b/htdocs/includes/modules/modAvoir.class.php @@ -73,19 +73,23 @@ class modAvoir extends DolibarrModules $this->requiredby = array(); // Config pages - //$this->config_page_url = "avoir.php"; + $this->config_page_url = "avoir.php"; // Constantes $this->const = array(); -/* - $this->const[0][0] = "FACTURE_ADDON_PDF"; - $this->const[0][1] = "chaine"; - $this->const[0][2] = "bulot"; - $this->const[1][0] = "FACTURE_ADDON"; + $this->const[0][0] = "AVOIR_ADDON_PDF"; + $this->const[0][1] = "chaine"; + $this->const[0][2] = "azur"; + $this->const[0][3] = 'Nom du gestionnaire de génération des avoirs en PDF'; + $this->const[0][4] = 0; + + $this->const[1][0] = "AVOIR_ADDON"; $this->const[1][1] = "chaine"; $this->const[1][2] = "pluton"; -*/ + $this->const[1][3] = 'Nom du gestionnaire de numérotation des avoirs'; + $this->const[1][4] = 0; + // Boites $this->boxes = array(); diff --git a/htdocs/includes/modules/modCommande.class.php b/htdocs/includes/modules/modCommande.class.php index 601da30c5d1..11ebc66f9bc 100644 --- a/htdocs/includes/modules/modCommande.class.php +++ b/htdocs/includes/modules/modCommande.class.php @@ -76,12 +76,20 @@ class modCommande extends DolibarrModules $this->const[0][0] = "COMMANDE_ADDON_PDF"; $this->const[0][1] = "chaine"; $this->const[0][2] = "azur"; + $this->const[0][3] = 'Nom du gestionnaire de génération des commandes en PDF'; + $this->const[0][4] = 0; - $this->const[1][0] = "COM_ADD_PROD_DESC"; + $this->const[1][0] = "COMMANDE_ADDON"; $this->const[1][1] = "chaine"; - $this->const[1][2] = "0"; - $this->const[1][3] = "Mettre à 1 pour voir la description d\'un produit dans une commande"; - $this->const[1][4] = 1; + $this->const[1][2] = "mod_commande_jade"; + $this->const[1][3] = 'Nom du gestionnaire de numérotation des commandes'; + $this->const[1][4] = 0; + + $this->const[2][0] = "COM_ADD_PROD_DESC"; + $this->const[2][1] = "chaine"; + $this->const[2][2] = "0"; + $this->const[2][3] = "Mettre à 1 pour voir la description d\'un produit dans une commande"; + $this->const[2][4] = 1; // Boites $this->boxes = array(); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index cc3911376d1..af6ecec0476 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -220,6 +220,10 @@ Permission302=Delete bar codes Permission331=Read bookmarks Permission332=Create/modify bookmarks Permission333=Delete bookmarks +Permission401=Read discounts +Permission402=Create/modify discounts +Permission403=Validate discounts +Permission404=Delete discounts Permission700=Read donations Permission701=Create/modify donations Permission702=Delete donations @@ -427,4 +431,8 @@ ExternalRSSSetup=External RSS imports setup NewRSS=New RSS ##### Mailing ##### MailingSetup=Mailing module setup -MailingEMailFrom=Sender EMail (From) for emails sent by emailing module \ No newline at end of file +MailingEMailFrom=Sender EMail (From) for emails sent by emailing module +##### Discount setup ##### +DiscountSetup=Discount module setup +DiscountsNumberingModules=Discount numbering modules +DiscountsPDFModules=Discount PDF modules \ No newline at end of file diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 412b2dcee7c..bf7f3fe20e2 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -220,6 +220,10 @@ Permission302=Supprimer les codes barres Permission331=Lire les bookmarks Permission332=Créer/modifier les bookmarks Permission333=Supprimer les bookmarks +Permission401=Consulter les avoirs +Permission402=Créer/modifier les avoirs +Permission403=Valider les avoirs +Permission404=Supprimer les avoirs Permission700=Consulter les dons Permission701=Créer/modifier les dons Permission702=Supprimer les dons @@ -428,4 +432,8 @@ NewRSS=Syndication d'un nouveau flux RSS ##### Mailing ##### MailingSetup=Configuration du module EMailing MailingEMailFrom=Email emetteur (From) des mails envoyés par EMailing +##### Discount setup ##### +DiscountSetup=Configuration du module Avoirs +DiscountsNumberingModules=Modules de numérotation des avoirs +DiscountsPDFModules=Modules d'avoirs PDF diff --git a/mysql/migration/2.0.0-2.1.0.sql b/mysql/migration/2.0.0-2.1.0.sql index 91c16be4258..97f3eea9802 100644 --- a/mysql/migration/2.0.0-2.1.0.sql +++ b/mysql/migration/2.0.0-2.1.0.sql @@ -83,3 +83,10 @@ ALTER TABLE `llx_commande` ADD `date_livraison` DATE; ALTER TABLE llx_facture_fourn_det ADD INDEX idx_facture_fourn_det_fk_facture (fk_facture_fourn); ALTER TABLE llx_facture_fourn_det ADD CONSTRAINT fk_facture_fourn_det_fk_facture FOREIGN KEY (fk_facture_fourn) REFERENCES llx_facture_fourn (rowid); + +create table llx_avoir_model_pdf +( + nom varchar(50) PRIMARY KEY, + libelle varchar(255), + description text +)type=innodb; \ No newline at end of file diff --git a/mysql/tables/llx_avoir_model_pdf.sql b/mysql/tables/llx_avoir_model_pdf.sql new file mode 100644 index 00000000000..51fefc0e37d --- /dev/null +++ b/mysql/tables/llx_avoir_model_pdf.sql @@ -0,0 +1,30 @@ +-- =================================================================== +-- Copyright (C) 2001-2003 Rodolphe Quiedeville +-- +-- 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. +-- +-- $Id$ +-- $Source$ +-- +-- Liste des modeles d'avoir pdf disponibles +-- +-- =================================================================== + +create table llx_avoir_model_pdf +( + nom varchar(50) PRIMARY KEY, + libelle varchar(255), + description text +)type=innodb;