From 4c4627b8ebb33205df631cd4e876503c3f023a0e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Aug 2006 22:06:10 +0000 Subject: [PATCH] Fix: Pb test sur habilitations des charges et menu banque --- htdocs/compta/bank/pre.inc.php | 12 ++--- htdocs/compta/charges/index.php | 11 +++-- htdocs/compta/sociales/index.php | 4 +- .../menus/barre_left/eldy_backoffice.php | 3 +- htdocs/langs/en_US/main.lang | 1 + htdocs/langs/fr_FR/main.lang | 1 + htdocs/product.class.php | 45 +++++++++++++++++-- 7 files changed, 58 insertions(+), 19 deletions(-) diff --git a/htdocs/compta/bank/pre.inc.php b/htdocs/compta/bank/pre.inc.php index c53e711f6ba..c71fc09a380 100644 --- a/htdocs/compta/bank/pre.inc.php +++ b/htdocs/compta/bank/pre.inc.php @@ -56,7 +56,7 @@ function llxHeader($head = "") while ($i < $numr) { $objp = $db->fetch_object($resql); - $menu->add(DOL_URL_ROOT."/compta/bank/fiche.php?id=".$objp->rowid, $objp->label); + $menu->add(DOL_URL_ROOT."/compta/bank/fiche.php?id=".$objp->rowid,$objp->label,0,$user->rights->banque->lire); /* $menu->add_submenu(DOL_URL_ROOT."/compta/bank/annuel.php?account=".$objp->rowid ,$langs->trans("IOMonthlyReporting")); $menu->add_submenu(DOL_URL_ROOT."/compta/bank/graph.php?account=".$objp->rowid ,$langs->trans("Graph")); @@ -67,18 +67,18 @@ function llxHeader($head = "") } $db->free($resql); } - $menu->add(DOL_URL_ROOT."/compta/bank/index.php",$langs->trans("MenuBankCash")); + $menu->add(DOL_URL_ROOT."/compta/bank/index.php",$langs->trans("MenuBankCash"),0,$user->rights->banque->lire); $menu->add_submenu(DOL_URL_ROOT."/compta/bank/fiche.php?action=create",$langs->trans("MenuNewFinancialAccount"),1,$user->rights->banque->configurer); $menu->add_submenu(DOL_URL_ROOT."/compta/bank/categ.php",$langs->trans("Categories"),1,$user->rights->banque->configurer); - $menu->add_submenu(DOL_URL_ROOT."/compta/bank/search.php",$langs->trans("SearchTransaction")); - $menu->add_submenu(DOL_URL_ROOT."/compta/bank/budget.php",$langs->trans("ByCategories")); - $menu->add_submenu(DOL_URL_ROOT."/compta/bank/bilan.php","Bilan"); + $menu->add_submenu(DOL_URL_ROOT."/compta/bank/search.php",$langs->trans("SearchTransaction"),1,$user->rights->banque->lire); + $menu->add_submenu(DOL_URL_ROOT."/compta/bank/budget.php",$langs->trans("ByCategories"),1,$user->rights->banque->lire); + $menu->add_submenu(DOL_URL_ROOT."/compta/bank/bilan.php","Bilan",1,$user->rights->banque->lire); if ($user->rights->banque->modifier) { - $menu->add_submenu(DOL_URL_ROOT."/compta/bank/virement.php",$langs->trans("Virements")); + $menu->add_submenu(DOL_URL_ROOT."/compta/bank/virement.php",$langs->trans("Virements"),1,$user->rights->banque->modifier); } if ($conf->global->COMPTA_ONLINE_PAYMENT_BPLC) diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index 3be0893c4d2..4b360e412d7 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2005 Laurent Destailleur + * Copyright (C) 2004-2006 Laurent Destailleur * * 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 @@ -18,7 +18,6 @@ * * $Id$ * $Source$ - * */ /** @@ -30,18 +29,18 @@ require("./pre.inc.php"); -llxHeader(); - $user->getrights('compta'); -if (!$user->admin && !$user->rights->compta->charges) +if (!$user->admin && !$user->rights->tax->charges->lire) accessforbidden(); - $year=$_GET["year"]; $filtre=$_GET["filtre"]; if (! $year) { $year=date("Y", time()); } + +llxHeader(); + print_fiche_titre($langs->trans("Charges"),($year?"".img_previous()." ".$langs->trans("Year")." $year ".img_next()."":"")); print "
"; diff --git a/htdocs/compta/sociales/index.php b/htdocs/compta/sociales/index.php index 4f757bd70fe..b2e663bb9ea 100644 --- a/htdocs/compta/sociales/index.php +++ b/htdocs/compta/sociales/index.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2005 Laurent Destailleur + * Copyright (C) 2004-2006 Laurent Destailleur * * 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 @@ -34,7 +34,7 @@ require(DOL_DOCUMENT_ROOT."/chargesociales.class.php"); $user->getrights('facture'); $user->getrights('compta'); -if (!$user->admin && !$user->rights->compta->charges->lire) +if (!$user->admin && ! $user->rights->tax->charges->lire) accessforbidden(); diff --git a/htdocs/includes/menus/barre_left/eldy_backoffice.php b/htdocs/includes/menus/barre_left/eldy_backoffice.php index a3fce6a7ba3..50c27f8768e 100644 --- a/htdocs/includes/menus/barre_left/eldy_backoffice.php +++ b/htdocs/includes/menus/barre_left/eldy_backoffice.php @@ -356,12 +356,11 @@ class MenuLeft { $langs->load("trips"); $newmenu->add(DOL_URL_ROOT."/compta/deplacement/index.php?leftmenu=deplacement&mainmenu=accountancy", $langs->trans("Trips"), 0, $user->rights->deplacement->lire); } - // Charges sociales if ($conf->tax->enabled) { $newmenu->add(DOL_URL_ROOT."/compta/charges/index.php?leftmenu=charges&mainmenu=accountancy",$langs->trans("Charges"), 0, $user->rights->tax->charges->lire); - if ($leftmenu=="charges") $newmenu->add_submenu(DOL_URL_ROOT."/compta/sociales/index.php",$langs->trans("SocialContributions"), 1, $user->rights->tax->charges->creer); + if ($leftmenu=="charges") $newmenu->add_submenu(DOL_URL_ROOT."/compta/sociales/index.php",$langs->trans("SocialContributions"), 1, $user->rights->tax->charges->lire); } // Charges tva diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index b1a6cae514a..1088bc9a297 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -292,6 +292,7 @@ AmountInCurrency=Amount in %s currency Example=Example NoExample=No example FindBug=Report a bug +NbOfThirdParties=Number of third parties NbOfCustomers=Number of customers NbOfLines=Number of lines NbOfObjects=Number of objects diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang index 79073fc1736..b25c7bbefac 100644 --- a/htdocs/langs/fr_FR/main.lang +++ b/htdocs/langs/fr_FR/main.lang @@ -292,6 +292,7 @@ AmountInCurrency=Montants exprim Example=Exemple NoExample=Pas d'exemple FindBug=Signaler un bug +NbOfThirdParties=Nombre de tiers NbOfCustomers=Nombre de clients NbOfLines=Nombre de lignes NbOfObjects=Nombre d'objets diff --git a/htdocs/product.class.php b/htdocs/product.class.php index a0f5625064a..87e50f153ab 100644 --- a/htdocs/product.class.php +++ b/htdocs/product.class.php @@ -1044,7 +1044,7 @@ class Product } else { - $this->error=$this->db->error(); + $this->error=$this->db->error().' sql='.$sql; return -1; } } @@ -1084,7 +1084,7 @@ class Product } else { - $this->error=$this->db->error(); + $this->error=$this->db->error().' sql='.$sql; return -1; } } @@ -1129,7 +1129,46 @@ class Product } } - + /** + * \brief Charge tableau des stats facture pour le produit/service + * \param socid Id societe + * \return array Tableau des stats + */ + function load_stats_facture_fournisseur($socid=0) + { + global $conf; + global $user; + + $sql = "SELECT COUNT(DISTINCT f.fk_soc) as nb_suppliers, COUNT(DISTINCT f.rowid) as nb,"; + $sql.= " COUNT(pd.rowid) as nb_rows, SUM(pd.qty) as qty"; + $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as pd,"; + $sql.= " ".MAIN_DB_PREFIX."facture_fourn as f"; + if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE f.rowid = pd.fk_facture_fourn AND pd.fk_product = ".$this->id; + if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; + //$sql.= " AND f.fk_statut != 0"; + if ($socid > 0) + { + $sql .= " AND f.fk_soc = $socid"; + } + + $result = $this->db->query($sql) ; + if ( $result ) + { + $obj=$this->db->fetch_object($result); + $this->stats_facture_fournisseur['suppliers']=$obj->nb_suppliers; + $this->stats_facture_fournisseur['nb']=$obj->nb; + $this->stats_facture_fournisseur['rows']=$obj->nb_rows; + $this->stats_facture_fournisseur['qty']=$obj->qty?$obj->qty:0; + return 1; + } + else + { + $this->error=$this->db->error(); + return -1; + } + } + /** * \brief Renvoie tableau des stats pour une requete donnée * \param sql Requete a exécuter