From 73da011461922b97fa3e7f5974b39b5fe63cf986 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?=
 <marcosgdf@gmail.com>
Date: Mon, 16 Nov 2015 13:16:54 +0100
Subject: [PATCH] FIX #3997 Wrong permission key used for Margins > Read all

---
 htdocs/margin/agentMargins.php    | 4 ++--
 htdocs/margin/lib/margins.lib.php | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php
index 32525114ee3..efea924b280 100644
--- a/htdocs/margin/agentMargins.php
+++ b/htdocs/margin/agentMargins.php
@@ -36,7 +36,7 @@ $langs->load("margins");
 
 // Security check
 
-if ($user->rights->margin->read->all) {
+if ($user->rights->margins->read->all) {
 	$agentid = GETPOST('agentid', 'int');
 } else {
 	$agentid = $user->id;
@@ -91,7 +91,7 @@ dol_fiche_head($head, 'agentMargins', $titre, 0, $picto);
 print '<form method="post" name="sel" action="'.$_SERVER['PHP_SELF'].'">';
 print '<table class="border" width="100%">';
 
-if ($user->rights->margin->read->all) {
+if ($user->rights->margins->read->all) {
 	print '<tr><td width="20%">'.$langs->trans('SalesRepresentative').'</td>';
 	print '<td colspan="4">';
 	print $form->select_dolusers($agentid, 'agentid', 1);
diff --git a/htdocs/margin/lib/margins.lib.php b/htdocs/margin/lib/margins.lib.php
index 1478dd9dcb0..ce100d49390 100644
--- a/htdocs/margin/lib/margins.lib.php
+++ b/htdocs/margin/lib/margins.lib.php
@@ -77,7 +77,7 @@ function marges_prepare_head()
 		$h++;
 	}
 
-	if ($user->rights->margin->read->all) {
+	if ($user->rights->margins->read->all) {
 		$title = 'UserMargins';
 	} else {
 		$title = 'SalesRepresentativeMargins';
-- 
GitLab