From 8128ed05561cf70ad6ea791cc869b00cae6150a4 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Tue, 20 Aug 2013 12:00:16 +0200 Subject: [PATCH 1/4] define user permissions on margin module update changelog --- ChangeLog | 2 ++ htdocs/core/modules/modMargin.class.php | 25 ++++++++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index bc94a498d33..9ed9538ae20 100644 --- a/ChangeLog +++ b/ChangeLog @@ -49,6 +49,8 @@ For users: - New : Add pdf link into supplier invoice list and supplier order list - New : Genrate auto the PDF for supplier invoice - New : Add category into filter webservice thirdparty method getListOfThirdParties +- New : Allow to define margin or mark rate during quoting, ordering, invoicing +- New : User permissions on margin module For translators: - Qual: Normalized sort order of all languages files with english reference files. diff --git a/htdocs/core/modules/modMargin.class.php b/htdocs/core/modules/modMargin.class.php index 4aceaa1f73d..eea8a988efc 100644 --- a/htdocs/core/modules/modMargin.class.php +++ b/htdocs/core/modules/modMargin.class.php @@ -79,8 +79,8 @@ class modMargin extends DolibarrModules // New pages on tabs $this->tabs = array( - 'product:+margin:Margins:margins:$conf->margin->enabled:/margin/tabs/productMargins.php?id=__ID__', - 'thirdparty:+margin:Margins:margins:$conf->margin->enabled && empty($user->societe_id):/margin/tabs/thirdpartyMargins.php?socid=__ID__' + 'product:+margin:Margins:margins:$user->rights->margins->liretous:/margin/tabs/productMargins.php?id=__ID__', + 'thirdparty:+margin:Margins:margins:empty($user->societe_id) && $user->rights->margins->liretous:/margin/tabs/thirdpartyMargins.php?socid=__ID__' ); @@ -106,11 +106,30 @@ class modMargin extends DolibarrModules 'url'=>'/margin/index.php', 'langs'=>'margins', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position'=>100, - 'enabled'=>'$conf->margin->enabled', // Define condition to show or hide menu entry. Use '$conf->monmodule->enabled' if entry must be visible if module is enabled. + 'enabled'=>'$user->rights->margins->liretous', // Define condition to show or hide menu entry. Use '$conf->monmodule->enabled' if entry must be visible if module is enabled. 'perms'=>'1', // Use 'perms'=>'$user->rights->monmodule->level1->level2' if you want your menu with a permission rules 'target'=>'', 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both $r++; + + // Permissions + $this->rights = array(); + $this->rights_class = 'margins'; + $r=0; + + $r++; + $this->rights[$r][0] = 59001; // id de la permission + $this->rights[$r][1] = 'Visualiser les marges'; // libelle de la permission + $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) + $this->rights[$r][3] = 1; // La permission est-elle une permission par defaut + $this->rights[$r][4] = 'liretous'; + + $r++; + $this->rights[$r][0] = 59002; // id de la permission + $this->rights[$r][1] = 'Définir les marges'; // libelle de la permission + $this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour) + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut + $this->rights[$r][4] = 'creer'; } /** From 220f9b7e9f3e3546e5daea2bec7cfc5dc26eedd3 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Tue, 20 Aug 2013 12:01:52 +0200 Subject: [PATCH 2/4] define global user variables so templates can manage user permissions --- htdocs/core/class/commonobject.class.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 48663a65b59..8e6970f754d 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2609,6 +2609,7 @@ abstract class CommonObject { global $conf,$langs,$object,$hookmanager; global $form,$bcnd,$var; + global $user; //Line extrafield require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafieldsline = new ExtraFields($this->db); @@ -2633,6 +2634,7 @@ abstract class CommonObject { global $conf,$langs,$object,$hookmanager; global $form,$bcnd,$var; + global $user; //Line extrafield require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -2658,6 +2660,7 @@ abstract class CommonObject { global $conf,$user,$langs,$object,$hookmanager; global $form,$bcnd,$var; + global $user; //Line extrafield require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -3220,3 +3223,4 @@ abstract class CommonObject } } ?> + From 06b8e939bd070ec6e28869ac86d0743196aba2a2 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Tue, 20 Aug 2013 12:04:01 +0200 Subject: [PATCH 3/4] manage user permissions for margin rate --- .../core/tpl/freeproductline_create.tpl.php | 34 +++++++++-- .../tpl/predefinedproductline_create.tpl.php | 59 ++++++++++++++----- 2 files changed, 73 insertions(+), 20 deletions(-) diff --git a/htdocs/core/tpl/freeproductline_create.tpl.php b/htdocs/core/tpl/freeproductline_create.tpl.php index 85d310c39c7..2bf8a55a3d0 100644 --- a/htdocs/core/tpl/freeproductline_create.tpl.php +++ b/htdocs/core/tpl/freeproductline_create.tpl.php @@ -61,13 +61,21 @@ if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($ob ?> global->DISPLAY_MARGIN_RATES)) + if ($user->rights->margins->creer) { - echo ''.$langs->trans('MarginRate').''; + if(! empty($conf->global->DISPLAY_MARGIN_RATES)) + { + echo ''.$langs->trans('MarginRate').''; + } + if(! empty($conf->global->DISPLAY_MARK_RATES)) + { + echo ''.$langs->trans('MarkRate').''; + } } - if(! empty($conf->global->DISPLAY_MARK_RATES)) + else { - echo ''.$langs->trans('MarkRate').''; + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++; + if (! empty($conf->global->DISPLAY_MARK_RATES)) $colspan++; } } ?> @@ -125,12 +133,26 @@ if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($ob value=""> rights->margins->creer) + { if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { echo '%'; } elseif (! empty($conf->global->DISPLAY_MARK_RATES)) { echo '%'; } + } + else + { + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { + $colspan++; + $coldisplay++; + } + if (! empty($conf->global->DISPLAY_MARK_RATES)) { + $colspan++; + $coldisplay++; + } + } } ?> @@ -190,7 +212,9 @@ if (! empty($conf->service->enabled) && $dateSelector) -margin->enabled) { ?> +margin->enabled && $user->rights->margins->creer) +{ +?>