From 45dd8421db2f836922af9c3d52f4e2d195df9cae Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Tue, 15 Jun 2010 08:43:50 +0000 Subject: [PATCH] Fix: Move widthrawal module configuration to setup modules area --- htdocs/admin/prelevement.php | 280 +++++++++++++++++ htdocs/compta/prelevement/config.php | 289 ------------------ htdocs/includes/menus/barre_left/eldy.lib.php | 3 +- .../includes/modules/modPrelevement.class.php | 3 + 4 files changed, 285 insertions(+), 290 deletions(-) create mode 100644 htdocs/admin/prelevement.php delete mode 100644 htdocs/compta/prelevement/config.php diff --git a/htdocs/admin/prelevement.php b/htdocs/admin/prelevement.php new file mode 100644 index 00000000000..9d685676af4 --- /dev/null +++ b/htdocs/admin/prelevement.php @@ -0,0 +1,280 @@ + + * Copyright (C) 2005 Laurent Destailleur + * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 2010 Juanjo Menent + * + * 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. + */ + +/** + * \file htdocs/admin/prelevement.php + * \ingroup prelevement + * \brief Page configuration des prelevements + * \version $Id$ + */ + +require('../main.inc.php'); +require_once(DOL_DOCUMENT_ROOT."/compta/prelevement/class/bon-prelevement.class.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php"); + +$langs->load("admin"); +$langs->load("withdrawals"); +$langs->load("banks"); +$langs->load("bills"); + +// Security check +if (!$user->admin) +accessforbidden(); + +/*if ($user->societe_id) $socid=$user->societe_id; +$result = restrictedArea($user, 'prelevement', '', '', 'bons');*/ + + +if ($_GET["action"] == "set") +{ + for ($i = 1 ; $i < 7 ; $i++) + { + dolibarr_set_const($db, $_POST["nom$i"], $_POST["value$i"],'chaine',0,'',$conf->entity); + } + + Header("Location: prelevement.php"); + exit; +} + +if ($_GET["action"] == "addnotif") +{ + $bon = new BonPrelevement($db); + $bon->AddNotification($_POST["user"],$_POST["action"]); + + Header("Location: prelevement.php"); + exit; +} + +if ($_GET["action"] == "deletenotif") +{ + $bon = new BonPrelevement($db); + $bon->DeleteNotificationById($_GET["notif"]); + + Header("Location: prelevement.php"); + exit; +} + +/* + * View + */ + +llxHeader('',$langs->trans("WithdrawalsSetup")); + +$linkback=''.$langs->trans("BackToModuleList").''; + +print_fiche_titre($langs->trans("WithdrawalsSetup"),$linkback,'setup'); + +print '
'; +print ''; + +print ''; +print ''; +print ''; +print ''; + +print ''; +print "\n"; + +print ''; + +print ''; + +print ''; + +print ''; + +print ''; + +print ''; + +print ''; + +print ''; + +print ''; + +print ''; + +print ''; + +print ''; + +print ''; +print ''; + +print ''; + +print ''; +print ''; + +print ''; + +print '<'; + +print '
'.$langs->trans("Parameter").''.$langs->trans("Value").''.$langs->trans("CurrentValue").'
'.$langs->trans("NumeroNationalEmetter").''; +print ''; +print ''.PRELEVEMENT_NUMERO_NATIONAL_EMETTEUR.'
'.$langs->trans("Name").''; +print ''; +print ''.PRELEVEMENT_RAISON_SOCIALE.'
'.$langs->trans("BankCode").''; +print ''; +print ''.PRELEVEMENT_CODE_BANQUE.'
'.$langs->trans("DeskCode").''; +print ''; +print ''.PRELEVEMENT_CODE_GUICHET.'
'.$langs->trans("AccountNumber").''; +print ''; +print ''.PRELEVEMENT_NUMERO_COMPTE.'
'.$langs->trans("ResponsibleUser").''; +print ''; +print ''; +if (defined("PRELEVEMENT_USER") && PRELEVEMENT_USER > 0) +{ + $cuser = new User($db); + $cuser->fetch(PRELEVEMENT_USER); + print $cuser->fullname; +} +else +{ + print PRELEVEMENT_USER; +} + +print '
'; + +print '
'; + +print '
'; + + +/* + * Notifications + * TODO Use notification module instead + */ + +if ($conf->global->MAIN_MODULE_NOTIFICATION) +{ + $langs->load("mails"); + print_titre($langs->trans("Notifications")); + + print '
'; + print ''; + + print ''; + print ''; + print ''; + print ''; + + print ''; + print "\n"; + + print ''; + + print ''; + + print ''; +} + + +$sql = "SELECT u.name, u.firstname"; +$sql.= ", pn.action, pn.rowid"; +$sql.= " FROM ".MAIN_DB_PREFIX."user as u"; +$sql.= ", ".MAIN_DB_PREFIX."prelevement_notifications as pn"; +$sql.= " WHERE u.rowid = pn.fk_user"; +$sql.= " AND u.entity IN (0,".$conf->entity.")"; + +$resql = $db->query($sql); +if ($resql) +{ + $num = $db->num_rows($resql); + $i = 0; + $var = false; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + + $var=!$var; + print ""; + + print ''; + print ''; + + if ($user->rights->prelevement->bons->configurer) + { + print ''; + } + else + { + print ''; + } + $i++; + } + $db->free($resql); +} +print '
'.$langs->trans("User").''.$langs->trans("Value").''.$langs->trans("Action").'
'; + print ''; + print ''; + print '
'.$obj->firstname." ".$obj->name.''.$obj->action.'rowid.'">'.img_delete().'
'; + +print '
'; + +$db->close(); + +llxFooter('$Date$ - $Revision$'); +?> diff --git a/htdocs/compta/prelevement/config.php b/htdocs/compta/prelevement/config.php deleted file mode 100644 index 551859e674c..00000000000 --- a/htdocs/compta/prelevement/config.php +++ /dev/null @@ -1,289 +0,0 @@ - - * Copyright (C) 2005 Laurent Destailleur - * Copyright (C) 2005-2010 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. - */ - -/** - * \file htdocs/compta/prelevement/config.php - * \ingroup prelevement - * \brief Page configuration des prelevements - * \version $Id$ - */ - -require('../../main.inc.php'); -require_once(DOL_DOCUMENT_ROOT."/compta/prelevement/class/bon-prelevement.class.php"); -require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php"); - -// Security check -if ($user->societe_id) $socid=$user->societe_id; -$result = restrictedArea($user, 'prelevement', '', '', 'bons'); - - -if ($_GET["action"] == "set" && $user->rights->prelevement->bons->configurer) -{ - for ($i = 1 ; $i < 7 ; $i++) - { - dolibarr_set_const($db, $_POST["nom$i"], $_POST["value$i"],'chaine',0,'',$conf->entity); - } - - Header("Location: config.php"); - exit; -} - -if ($_GET["action"] == "addnotif" && $user->rights->prelevement->bons->configurer) -{ - $bon = new BonPrelevement($db); - $bon->AddNotification($_POST["user"],$_POST["action"]); - - Header("Location: config.php"); - exit; -} - -if ($_GET["action"] == "deletenotif" && $user->rights->prelevement->bons->configurer) -{ - $bon = new BonPrelevement($db); - $bon->DeleteNotificationById($_GET["notif"]); - - Header("Location: config.php"); - exit; -} - -/* - * View - */ - -llxHeader('',$langs->trans("WithdrawalsSetup")); - -print_fiche_titre($langs->trans("WithdrawalsSetup")); - - -if ($user->rights->prelevement->bons->configurer) -print '
'; -print ''; - -print ''; -print ''; -print ''; -if ($user->rights->prelevement->bons->configurer) -print ''; - -print ''; -print "\n"; - -print ''; -if ($user->rights->prelevement->bons->configurer) -{ - print ''; -} -print ''; - -print ''; -if ($user->rights->prelevement->bons->configurer) -{ - print ''; -} -print ''; - -print ''; -if ($user->rights->prelevement->bons->configurer) -{ - print ''; -} -print ''; - -print ''; -if ($user->rights->prelevement->bons->configurer) -{ - print ''; -} -print ''; - -print ''; -if ($user->rights->prelevement->bons->configurer) -{ - print ''; -} -print ''; - -print ''; -if ($user->rights->prelevement->bons->configurer) -{ - print ''; -} -print ''; - -if ($user->rights->prelevement->bons->configurer) -print ''; - -print '
'.$langs->trans("Parameter").''.$langs->trans("Value").''.$langs->trans("CurrentValue").'
'.$langs->trans("NumeroNationalEmetter").''; - print ''; - print ''.PRELEVEMENT_NUMERO_NATIONAL_EMETTEUR.'
'.$langs->trans("Name").''; - print ''; - print ''.PRELEVEMENT_RAISON_SOCIALE.'
'.$langs->trans("BankCode").''; - print ''; - print ''.PRELEVEMENT_CODE_BANQUE.'
'.$langs->trans("DeskCode").''; - print ''; - print ''.PRELEVEMENT_CODE_GUICHET.'
'.$langs->trans("AccountNumber").''; - print ''; - print ''.PRELEVEMENT_NUMERO_COMPTE.'
'.$langs->trans("ResponsibleUser").''; - print ''; - print ''; -if (defined("PRELEVEMENT_USER") && PRELEVEMENT_USER > 0) -{ - $cuser = new User($db); - $cuser->fetch(PRELEVEMENT_USER); - print $cuser->fullname; -} -else -{ - print PRELEVEMENT_USER; -} - -print '
'; - -if ($user->rights->prelevement->bons->configurer) -print '
'; - -print '
'; - - - - -/* - * Notifications - * TODO Use notification module instead - */ - -if ($conf->global->MAIN_MODULE_NOTIFICATION) -{ - print_titre($langs->trans("Notifications")); - - if ($user->rights->prelevement->bons->configurer) - print '
'; - print ''; - - print ''; - print ''; - print ''; - print ''; - if ($user->rights->prelevement->bons->configurer) - print ''; - print "\n"; - - if ($user->rights->prelevement->bons->configurer) - { - print ''; - - print ''; - - print ''; - } - - - $sql = "SELECT u.name, u.firstname"; - $sql.= ", pn.action, pn.rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; - $sql.= ", ".MAIN_DB_PREFIX."prelevement_notifications as pn"; - $sql.= " WHERE u.rowid = pn.fk_user"; - $sql.= " AND u.entity IN (0,".$conf->entity.")"; - - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; - $var = false; - while ($i < $num) - { - $obj = $db->fetch_object($resql); - - $var=!$var; - print ""; - - print ''; - print ''; - - if ($user->rights->prelevement->bons->configurer) - { - print ''; - } - else - { - print ''; - } - $i++; - } - $db->free($resql); - } - print '
'.$langs->trans("User").''.$langs->trans("Value").''.$langs->trans("Action").'
'; - print ''; - print ''; - print '
'.$obj->firstname." ".$obj->name.''.$obj->action.'rowid.'">'.img_delete().'
'; - - if ($user->rights->prelevement->bons->configurer) - print '
'; -} - - -$db->close(); - -llxFooter('$Date$ - $Revision$'); -?> diff --git a/htdocs/includes/menus/barre_left/eldy.lib.php b/htdocs/includes/menus/barre_left/eldy.lib.php index f7c294139e5..890d05c1927 100644 --- a/htdocs/includes/menus/barre_left/eldy.lib.php +++ b/htdocs/includes/menus/barre_left/eldy.lib.php @@ -1,5 +1,6 @@ + * Copyright (C) 2010 Juanjo Menent * * 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 @@ -523,7 +524,7 @@ function print_left_eldy_menu($db,$menu_array) if ($leftmenu=="withdraw") $newmenu->add(DOL_URL_ROOT."/compta/prelevement/rejets.php",$langs->trans("Rejects"),1,$user->rights->prelevement->bons->lire); if ($leftmenu=="withdraw") $newmenu->add(DOL_URL_ROOT."/compta/prelevement/stats.php",$langs->trans("Statistics"),1,$user->rights->prelevement->bons->lire); - if ($leftmenu=="withdraw") $newmenu->add(DOL_URL_ROOT."/compta/prelevement/config.php",$langs->trans("Setup"),1,$user->rights->prelevement->bons->configurer); + //if ($leftmenu=="withdraw") $newmenu->add(DOL_URL_ROOT."/compta/prelevement/config.php",$langs->trans("Setup"),1,$user->rights->prelevement->bons->configurer); } // Gestion cheques diff --git a/htdocs/includes/modules/modPrelevement.class.php b/htdocs/includes/modules/modPrelevement.class.php index 15a069cbb44..6928ed1e07f 100644 --- a/htdocs/includes/modules/modPrelevement.class.php +++ b/htdocs/includes/modules/modPrelevement.class.php @@ -70,6 +70,9 @@ class modPrelevement extends DolibarrModules // Dependancies $this->depends = array("modFacture"); $this->requiredby = array(); + + // Config pages + $this->config_page_url = array("prelevement.php"); // Constantes $this->const = array();