diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index f3254c3a8dd..0a07fc9542f 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -32,18 +32,6 @@ require_once DOL_DOCUMENT_ROOT.'/margin/lib/margins.lib.php'; // Load translation files required by the page $langs->loadLangs(array('companies', 'bills', 'products', 'margins')); -// Security check -$socid = GETPOST('socid', 'int'); -$TSelectedProducts = GETPOST('products', 'array'); -$TSelectedCats = GETPOST('categories', 'array'); - -if (!empty($user->socid)) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'societe', '', ''); -$result = restrictedArea($user, 'margins'); - - // Load variable for pagination $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); @@ -74,6 +62,17 @@ if (GETPOST('enddatemonth')) { $object = new Societe($db); $hookmanager->initHooks(array('margincustomerlist')); +// Security check +$socid = GETPOST('socid', 'int'); +$TSelectedProducts = GETPOST('products', 'array'); +$TSelectedCats = GETPOST('categories', 'array'); + +if (!empty($user->socid)) { + $socid = $user->socid; +} +$result = restrictedArea($user, 'societe', '', ''); +$result = restrictedArea($user, 'margins'); + /* * View @@ -157,7 +156,7 @@ print img_picto('', 'product').$form->multiselectarray('products', $TProducts, $ print ''; // Categories -$TCats = $form->select_all_categories(0, array(), '', 64, 0, 1); +$TCats = $form->select_all_categories('product', array(), '', 64, 0, 1); print ''; print ''.$langs->trans('Category').''; diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index 5b2a7593d42..903613b8379 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -38,17 +38,7 @@ $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); $TSelectedCats = GETPOST('categories', 'array'); - -// Security check -$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); -$fieldtype = (!empty($ref) ? 'ref' : 'rowid'); -if (!empty($user->socid)) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); -if (empty($user->rights->margins->liretous)) { - accessforbidden(); -} +$socid = 0; $mesg = ''; @@ -85,6 +75,17 @@ if (GETPOST('enddatemonth')) { $object = new Product($db); $hookmanager->initHooks(array('marginproductlist')); +// Security check +$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); +$fieldtype = (!empty($ref) ? 'ref' : 'rowid'); +if (!empty($user->socid)) { + $socid = $user->socid; +} +$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); +if (empty($user->rights->margins->liretous)) { + accessforbidden(); +} + /* * View @@ -119,7 +120,7 @@ print img_picto('', 'product').$form->select_produits(($id > 0 ? $id : ''), 'id' print ''; // Categories -$TCats = $form->select_all_categories(0, array(), '', 64, 0, 1); +$TCats = $form->select_all_categories('product', array(), '', 64, 0, 1); print ''; print ''.$langs->trans('Category').'';