From 2f4fe9d6190e0e6cf2ec260a0e781be8965ae090 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 19 Apr 2023 09:07:55 +0200 Subject: [PATCH] use isModEnabled --- htdocs/commande/list_det.php | 14 +++++++------- htdocs/compta/paiement/card.php | 8 ++++---- htdocs/contrat/card.php | 2 +- htdocs/core/get_info.php | 2 +- htdocs/core/modules/modMargin.class.php | 2 +- htdocs/product/fournisseurs.php | 2 +- htdocs/supplier_proposal/card.php | 7 +++---- 7 files changed, 18 insertions(+), 19 deletions(-) diff --git a/htdocs/commande/list_det.php b/htdocs/commande/list_det.php index c0855371f6d..5b1a85f3f43 100644 --- a/htdocs/commande/list_det.php +++ b/htdocs/commande/list_det.php @@ -40,7 +40,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; -if (!empty($conf->margin->enabled)) { +if (isModEnabled('margin')) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php'; } require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; @@ -203,10 +203,10 @@ $arrayfields = array( 'c.fk_warehouse'=>array('label'=>'Warehouse', 'checked'=>0, 'enabled'=>(empty($conf->stock->enabled) && empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER) ? 0 : 1), 'position'=>110), 'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>115), 'sale_representative'=>array('label'=>"SaleRepresentativesOfThirdParty", 'checked'=>0, 'position'=>116), - 'total_pa' => array('label' => (getDolGlobalString('MARGIN_TYPE') == '1' ? 'BuyingPrice' : 'CostPrice'), 'checked' => 0, 'position' => 300, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous ? 0 : 1)), - 'total_margin' => array('label' => 'Margin', 'checked' => 0, 'position' => 301, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous ? 0 : 1)), - 'total_margin_rate' => array('label' => 'MarginRate', 'checked' => 0, 'position' => 302, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous || empty($conf->global->DISPLAY_MARGIN_RATES) ? 0 : 1)), - 'total_mark_rate' => array('label' => 'MarkRate', 'checked' => 0, 'position' => 303, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous || empty($conf->global->DISPLAY_MARK_RATES) ? 0 : 1)), + 'total_pa' => array('label' => (getDolGlobalString('MARGIN_TYPE') == '1' ? 'BuyingPrice' : 'CostPrice'), 'checked' => 0, 'position' => 300, 'enabled' => (!isModEnabled('margin') || !$user->rights->margins->liretous ? 0 : 1)), + 'total_margin' => array('label' => 'Margin', 'checked' => 0, 'position' => 301, 'enabled' => (!isModEnabled('margin') || !$user->rights->margins->liretous ? 0 : 1)), + 'total_margin_rate' => array('label' => 'MarginRate', 'checked' => 0, 'position' => 302, 'enabled' => (!isModEnabled('margin') || !$user->rights->margins->liretous || empty($conf->global->DISPLAY_MARGIN_RATES) ? 0 : 1)), + 'total_mark_rate' => array('label' => 'MarkRate', 'checked' => 0, 'position' => 303, 'enabled' => (!isModEnabled('margin') || !$user->rights->margins->liretous || empty($conf->global->DISPLAY_MARK_RATES) ? 0 : 1)), 'c.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>120), 'c.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>125), 'c.date_cloture'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>130), @@ -338,7 +338,7 @@ $form = new Form($db); $formother = new FormOther($db); $formfile = new FormFile($db); $formmargin = null; -if (!empty($conf->margin->enabled)) { +if (isModEnabled('margin')) { $formmargin = new FormMargin($db); } $companystatic = new Societe($db); @@ -1402,7 +1402,7 @@ if ($resql) { $i = 0; $with_margin_info = false; - if (!empty($conf->margin->enabled) && ( + if (isModEnabled('margin') && ( !empty($arrayfields['total_pa']['checked']) || !empty($arrayfields['total_margin']['checked']) || !empty($arrayfields['total_margin_rate']['checked']) diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php index 4fb3cfa41aa..865ce719291 100644 --- a/htdocs/compta/paiement/card.php +++ b/htdocs/compta/paiement/card.php @@ -36,7 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; if (isModEnabled("banque")) { require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; } -if (!empty($conf->margin->enabled)) { +if (isModEnabled('margin')) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php'; } @@ -436,7 +436,7 @@ if ($resql) { print ''.$langs->trans('Entity').''; } //Add Margin - if (!empty($conf->margin->enabled) && getDolGlobalInt('MARGIN_SHOW_MARGIN_ON_PAYMENT')) { + if (isModEnabled('margin') && getDolGlobalInt('MARGIN_SHOW_MARGIN_ON_PAYMENT')) { print ''.$langs->trans('Margin').''; } print ''.$langs->trans('ExpectedToPay').''; @@ -455,7 +455,7 @@ if ($resql) { $invoice->fetch($objp->facid); // Add Margin - if (!empty($conf->margin->enabled) && getDolGlobalInt('MARGIN_SHOW_MARGIN_ON_PAYMENT')) { + if (isModEnabled('margin') && getDolGlobalInt('MARGIN_SHOW_MARGIN_ON_PAYMENT')) { $formmargin = new FormMargin($db); $marginInfo = array(); $invoice->fetch_lines(); @@ -489,7 +489,7 @@ if ($resql) { } // Add margin - if (!empty($conf->margin->enabled) && getDolGlobalInt('MARGIN_SHOW_MARGIN_ON_PAYMENT')) { + if (isModEnabled('margin') && getDolGlobalInt('MARGIN_SHOW_MARGIN_ON_PAYMENT')) { print ''.price($marginInfo['total_margin']).''; } diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index a6177876bf7..e5ab9664e09 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -1966,7 +1966,7 @@ if ($action == 'create') { print ''; print ''; - print ''.$langs->trans("Comment").''; + print ''.$langs->trans("Comment").''; print ''; print '   '; print ''; diff --git a/htdocs/core/get_info.php b/htdocs/core/get_info.php index 067372c26ff..92cb2b8735e 100644 --- a/htdocs/core/get_info.php +++ b/htdocs/core/get_info.php @@ -137,7 +137,7 @@ if (!isset($form) || !is_object($form)) { } // Link to module builder -if (!empty($conf->modulebuilder->enabled)) { +if (isModEnabled('modulebuilder')) { $text = ''; //$text.= img_picto(":".$langs->trans("ModuleBuilder"), 'printer_top.png', 'class="printer"'); $text .= ''; diff --git a/htdocs/core/modules/modMargin.class.php b/htdocs/core/modules/modMargin.class.php index 55f2a5ed927..6c8dfda12c9 100644 --- a/htdocs/core/modules/modMargin.class.php +++ b/htdocs/core/modules/modMargin.class.php @@ -113,7 +113,7 @@ 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'=>'isModEnabled("margin")', // Define condition to show or hide menu entry. Use '$conf->monmodule->enabled' if entry must be visible if module is enabled. 'perms'=>'$user->rights->margins->liretous', // 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 diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index eaac0f303e7..58c98f791cf 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -77,7 +77,7 @@ if ($user->socid) { $socid = $user->socid; } -if (empty($user->rights->fournisseur->lire) && (empty($conf->margin->enabled) && !$user->hasRight("margin", "liretous"))) { +if (empty($user->rights->fournisseur->lire) && (!isModEnabled('margin') && !$user->hasRight("margin", "liretous"))) { accessforbidden(); } diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index a11a10e6bcf..8f66ba035c4 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -1770,8 +1770,7 @@ if ($action == 'create') { } /* Not for supplier proposals - if ($soc->outstanding_limit) - { + if ($soc->outstanding_limit) { // Outstanding Bill print ''; print $langs->trans('OutstandingBill'); @@ -1861,8 +1860,8 @@ if ($action == 'create') { print ''; // Margin Infos - /*if (!empty($conf->margin->enabled)) { - $formmargin->displayMarginInfos($object); + /*if (isModEnabled('margin')) { + $formmargin->displayMarginInfos($object); }*/ print '';