From 9772bbeff3107d6dc0ab89629f97a8865056f4cf Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 25 Sep 2022 21:58:40 +0200 Subject: [PATCH 01/17] Use isModEnabled --- htdocs/comm/mailing/card.php | 8 ++++---- htdocs/compta/facture/card.php | 2 +- htdocs/core/class/html.formmail.class.php | 6 +++--- htdocs/core/lib/oauth.lib.php | 2 +- htdocs/core/lib/payments.lib.php | 6 +++--- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index e59389a87b7..2372f24a929 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -227,13 +227,13 @@ if (empty($reshook)) { $substitutionarray['__UNSUBSCRIBE_URL__'] = DOL_MAIN_URL_ROOT.'/public/emailing/mailing-unsubscribe.php?tag='.urlencode($obj->tag).'&unsuscrib=1&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'&email='.urlencode($obj->email).'&mtid='.$obj->rowid; $onlinepaymentenabled = 0; - if (!empty($conf->paypal->enabled)) { + if (isModEnabled('paypal')) { $onlinepaymentenabled++; } - if (!empty($conf->paybox->enabled)) { + if (isModEnabled('paybox')) { $onlinepaymentenabled++; } - if (!empty($conf->stripe->enabled)) { + if (isModEnabled('stripe')) { $onlinepaymentenabled++; } if ($onlinepaymentenabled && !empty($conf->global->PAYMENT_SECURITY_TOKEN)) { @@ -263,7 +263,7 @@ if (empty($reshook)) { $substitutionarray['__PUBLICLINK_NEWMEMBERFORM__'] = ''.$langs->trans('BlankSubscriptionForm'). ''; } /* For backward compatibility, deprecated */ - if (!empty($conf->paypal->enabled) && !empty($conf->global->PAYPAL_SECURITY_TOKEN)) { + if (isModEnabled('paypal') && !empty($conf->global->PAYPAL_SECURITY_TOKEN)) { $substitutionarray['__SECUREKEYPAYPAL__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) { diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 0fe82b9e7f1..1465b60b2f6 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -5802,7 +5802,7 @@ if ($action == 'create') { // Show online payment link - $useonlinepayment = (!empty($conf->paypal->enabled) || !empty($conf->stripe->enabled) || !empty($conf->paybox->enabled)); + $useonlinepayment = (isModEnabled('paypal') || isModEnabled('stripe') || isModEnabled('paybox')); if ($object->statut != Facture::STATUS_DRAFT && $useonlinepayment) { print '
'."\n"; diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index a2abdbb7cc6..ad25db01fa6 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1619,13 +1619,13 @@ class FormMail extends Form //,'__PERSONALIZED__' => 'Personalized' // Hidden because not used yet in mass emailing $onlinepaymentenabled = 0; - if (!empty($conf->paypal->enabled)) { + if (isModEnabled('paypal')) { $onlinepaymentenabled++; } - if (!empty($conf->paybox->enabled)) { + if (isModEnabled('paybox')) { $onlinepaymentenabled++; } - if (!empty($conf->stripe->enabled)) { + if (isModEnabled('stripe')) { $onlinepaymentenabled++; } if ($onlinepaymentenabled && !empty($conf->global->PAYMENT_SECURITY_TOKEN)) { diff --git a/htdocs/core/lib/oauth.lib.php b/htdocs/core/lib/oauth.lib.php index d48775fe84e..83359ef1c65 100644 --- a/htdocs/core/lib/oauth.lib.php +++ b/htdocs/core/lib/oauth.lib.php @@ -27,7 +27,7 @@ $supportedoauth2array = array( 'OAUTH_GOOGLE_NAME'=>array('callbackfile' => 'google', 'picto' => 'google', 'urlforapp' => 'OAUTH_GOOGLE_DESC', 'name'=>'Google', 'urlforcredentials'=>'https://console.developers.google.com/', 'availablescopes'=> 'userinfo_email,userinfo_profile,openid,email,profile,cloud_print,admin_directory_user,gmail_full'), ); -if (!empty($conf->stripe->enabled)) { +if (isModEnabled('stripe')) { $supportedoauth2array['OAUTH_STRIPE_TEST_NAME'] = array('callbackfile' => 'stripetest', 'picto' => 'stripe', 'urlforapp' => '', 'name'=>'StripeTest', 'urlforcredentials'=>'', 'availablescopes'=>'read_write'); $supportedoauth2array['OAUTH_STRIPE_LIVE_NAME'] = array('callbackfile' => 'stripelive', 'picto' => 'stripe', 'urlforapp' => '', 'name'=>'StripeLive', 'urlforcredentials'=>'', 'availablescopes'=>'read_write'); } diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php index 19a251d1b38..44691f7c2c4 100644 --- a/htdocs/core/lib/payments.lib.php +++ b/htdocs/core/lib/payments.lib.php @@ -150,15 +150,15 @@ function getValidOnlinePaymentMethods($paymentmethod = '') $validpaymentmethod = array(); - if ((empty($paymentmethod) || $paymentmethod == 'paypal') && !empty($conf->paypal->enabled)) { + if ((empty($paymentmethod) || $paymentmethod == 'paypal') && isModEnabled('paypal')) { $langs->load("paypal"); $validpaymentmethod['paypal'] = 'valid'; } - if ((empty($paymentmethod) || $paymentmethod == 'paybox') && !empty($conf->paybox->enabled)) { + if ((empty($paymentmethod) || $paymentmethod == 'paybox') && isModEnabled('paybox')) { $langs->load("paybox"); $validpaymentmethod['paybox'] = 'valid'; } - if ((empty($paymentmethod) || $paymentmethod == 'stripe') && !empty($conf->stripe->enabled)) { + if ((empty($paymentmethod) || $paymentmethod == 'stripe') && isModEnabled('stripe')) { $langs->load("stripe"); $validpaymentmethod['stripe'] = 'valid'; } From da55ed782c1faed7bd3eac12402728fdcf1f107d Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 25 Sep 2022 21:58:56 +0200 Subject: [PATCH 02/17] Use isModEnabled --- htdocs/core/modules/facture/doc/pdf_crabe.modules.php | 6 +++--- htdocs/core/modules/facture/doc/pdf_sponge.modules.php | 6 +++--- htdocs/don/card.php | 2 +- htdocs/partnership/admin/website.php | 6 +++--- htdocs/public/eventorganization/subscriptionok.php | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index ee4e43bb444..168e293cc90 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -1180,13 +1180,13 @@ class pdf_crabe extends ModelePDFFactures if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CB' || $object->mode_reglement_code == 'VAD') { $useonlinepayment = 0; if (!empty($conf->global->PDF_SHOW_LINK_TO_ONLINE_PAYMENT)) { - if (!empty($conf->paypal->enabled)) { + if (isModEnabled('paypal')) { $useonlinepayment++; } - if (!empty($conf->stripe->enabled)) { + if (isModEnabled('stripe')) { $useonlinepayment++; } - if (!empty($conf->paybox->enabled)) { + if (isModEnabled('paybox')) { $useonlinepayment++; } } diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 1efca9070d0..5da53c41121 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -1290,13 +1290,13 @@ class pdf_sponge extends ModelePDFFactures if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CB' || $object->mode_reglement_code == 'VAD') { $useonlinepayment = 0; if (!empty($conf->global->PDF_SHOW_LINK_TO_ONLINE_PAYMENT)) { - if (!empty($conf->paypal->enabled)) { + if (isModEnabled('paypal')) { $useonlinepayment++; } - if (!empty($conf->stripe->enabled)) { + if (isModEnabled('stripe')) { $useonlinepayment++; } - if (!empty($conf->paybox->enabled)) { + if (isModEnabled('paybox')) { $useonlinepayment++; } } diff --git a/htdocs/don/card.php b/htdocs/don/card.php index ae73fdfd15a..7c18073907e 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -914,7 +914,7 @@ if (!empty($id) && $action != 'edit') { $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); // Show online payment link - $useonlinepayment = (!empty($conf->paypal->enabled) || !empty($conf->stripe->enabled) || !empty($conf->paybox->enabled)); + $useonlinepayment = (isModEnabled('paypal') || isModEnabled('stripe') || isModEnabled('paybox')); if ($useonlinepayment) { //$object->statut != Facture::STATUS_DRAFT && print '
'."\n"; diff --git a/htdocs/partnership/admin/website.php b/htdocs/partnership/admin/website.php index b3bccf9fa00..bb86f95269b 100644 --- a/htdocs/partnership/admin/website.php +++ b/htdocs/partnership/admin/website.php @@ -189,13 +189,13 @@ if (!empty($conf->global->PARTNERSHIP_ENABLE_PUBLIC)) { $listofval = array(); $listofval['-1'] = $langs->trans('No'); $listofval['all'] = $langs->trans('Yes').' ('.$langs->trans("VisitorCanChooseItsPaymentMode").')'; - if (!empty($conf->paybox->enabled)) { + if (isModEnabled('paybox')) { $listofval['paybox'] = 'Paybox'; } - if (!empty($conf->paypal->enabled)) { + if (isModEnabled('paypal')) { $listofval['paypal'] = 'PayPal'; } - if (!empty($conf->stripe->enabled)) { + if (isModEnabled('stripe')) { $listofval['stripe'] = 'Stripe'; } print $form->selectarray("PARTNERSHIP_NEWFORM_PAYONLINE", $listofval, (!empty($conf->global->PARTNERSHIP_NEWFORM_PAYONLINE) ? $conf->global->PARTNERSHIP_NEWFORM_PAYONLINE : ''), 0); diff --git a/htdocs/public/eventorganization/subscriptionok.php b/htdocs/public/eventorganization/subscriptionok.php index 745c9885647..043e0e8d021 100644 --- a/htdocs/public/eventorganization/subscriptionok.php +++ b/htdocs/public/eventorganization/subscriptionok.php @@ -53,7 +53,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; -if (!empty($conf->paypal->enabled)) { +if (isModEnabled('paypal')) { require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php'; require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypalfunctions.lib.php'; } From a7a39cba97b278314dabdbc6abfe7b1cdd1428bb Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 25 Sep 2022 21:59:46 +0200 Subject: [PATCH 03/17] Use isModEnabled --- htdocs/public/payment/newpayment.php | 24 ++++++++++++------------ htdocs/public/payment/paymentko.php | 14 +++++++------- htdocs/public/payment/paymentok.php | 16 ++++++++-------- htdocs/societe/paymentmodes.php | 18 +++++++++--------- htdocs/stripe/admin/stripe.php | 2 +- 5 files changed, 37 insertions(+), 37 deletions(-) diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 9d5fb5f122f..d3b08e9672b 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -247,7 +247,7 @@ $urlko = preg_replace('/&$/', '', $urlko); // Remove last & // Make special controls -if ((empty($paymentmethod) || $paymentmethod == 'paypal') && !empty($conf->paypal->enabled)) { +if ((empty($paymentmethod) || $paymentmethod == 'paypal') && isModEnabled('paypal')) { require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php'; require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypalfunctions.lib.php'; @@ -273,10 +273,10 @@ if ((empty($paymentmethod) || $paymentmethod == 'paypal') && !empty($conf->paypa return -1; } } -if ((empty($paymentmethod) || $paymentmethod == 'paybox') && !empty($conf->paybox->enabled)) { +if ((empty($paymentmethod) || $paymentmethod == 'paybox') && isModEnabled('paybox')) { // No specific test for the moment } -if ((empty($paymentmethod) || $paymentmethod == 'stripe') && !empty($conf->stripe->enabled)) { +if ((empty($paymentmethod) || $paymentmethod == 'stripe') && isModEnabled('stripe')) { require_once DOL_DOCUMENT_ROOT.'/stripe/config.php'; // This include also /stripe/lib/stripe.lib.php, /includes/stripe/stripe-php/init.php, ... } @@ -481,7 +481,7 @@ if ($action == 'dopayment') { // Called when choosing Stripe mode. // When using the old Charge API architecture, this code is called after clicking the 'dopayment' with the Charge API architecture. // When using the PaymentIntent API architecture, the Stripe customer was already created when creating PaymentIntent when showing payment page, and the payment is already ok when action=charge. -if ($action == 'charge' && !empty($conf->stripe->enabled)) { +if ($action == 'charge' && isModEnabled('stripe')) { $amountstripe = $amount; // Correct the amount according to unit of currency @@ -844,10 +844,10 @@ if ($source && in_array($ref, array('member_ref', 'contractline_ref', 'invoice_r // Show sandbox warning -if ((empty($paymentmethod) || $paymentmethod == 'paypal') && !empty($conf->paypal->enabled) && (!empty($conf->global->PAYPAL_API_SANDBOX) || GETPOST('forcesandbox', 'int'))) { // We can force sand box with param 'forcesandbox' +if ((empty($paymentmethod) || $paymentmethod == 'paypal') && isModEnabled('paypal') && (!empty($conf->global->PAYPAL_API_SANDBOX) || GETPOST('forcesandbox', 'int'))) { // We can force sand box with param 'forcesandbox' dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Paypal'), '', 'warning'); } -if ((empty($paymentmethod) || $paymentmethod == 'stripe') && !empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'int'))) { +if ((empty($paymentmethod) || $paymentmethod == 'stripe') && isModEnabled('stripe') && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'int'))) { dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning'); } @@ -911,14 +911,14 @@ if (!empty($conf->global->MAIN_IMAGE_PUBLIC_PAYMENT)) { print ''."\n"; print ''."\n"; // Additionnal information for each payment system -if (!empty($conf->paypal->enabled)) { +if (isModEnabled('paypal')) { print ''."\n"; print ''."\n"; } -if (!empty($conf->paybox->enabled)) { +if (isModEnabled('paybox')) { print ''."\n"; } -if (!empty($conf->stripe->enabled)) { +if (isModEnabled('stripe')) { print ''."\n"; } print ''."\n"; @@ -2043,7 +2043,7 @@ if ($action != 'dopayment') { 'paymentmethod' => $paymentmethod ]; $reshook = $hookmanager->executeHooks('doAddButton', $parameters, $object, $action); - if ((empty($paymentmethod) || $paymentmethod == 'paybox') && !empty($conf->paybox->enabled)) { + if ((empty($paymentmethod) || $paymentmethod == 'paybox') && isModEnabled('paybox')) { print '
'; print '
'; print ''.$langs->trans("CreditOrDebitCard").''; @@ -2062,7 +2062,7 @@ if ($action != 'dopayment') { '; } - if ((empty($paymentmethod) || $paymentmethod == 'stripe') && !empty($conf->stripe->enabled)) { + if ((empty($paymentmethod) || $paymentmethod == 'stripe') && isModEnabled('stripe')) { print '
'; print ''; print '
'; @@ -2083,7 +2083,7 @@ if ($action != 'dopayment') { '; } - if ((empty($paymentmethod) || $paymentmethod == 'paypal') && !empty($conf->paypal->enabled)) { + if ((empty($paymentmethod) || $paymentmethod == 'paypal') && isModEnabled('paypal')) { if (empty($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY)) { $conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY = 'integral'; } diff --git a/htdocs/public/payment/paymentko.php b/htdocs/public/payment/paymentko.php index 5bf9b6115ed..29adb2947d0 100644 --- a/htdocs/public/payment/paymentko.php +++ b/htdocs/public/payment/paymentko.php @@ -51,14 +51,14 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; -if (!empty($conf->paypal->enabled)) { +if (isModEnabled('paypal')) { require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php'; require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypalfunctions.lib.php'; } $langs->loadLangs(array("main", "other", "dict", "bills", "companies", "paybox", "paypal", "stripe")); -if (!empty($conf->paypal->enabled)) { +if (isModEnabled('paypal')) { $PAYPALTOKEN = GETPOST('TOKEN'); if (empty($PAYPALTOKEN)) { $PAYPALTOKEN = GETPOST('token'); @@ -68,9 +68,9 @@ if (!empty($conf->paypal->enabled)) { $PAYPALPAYERID = GETPOST('PayerID'); } } -if (!empty($conf->paybox->enabled)) { +if (isModEnabled('paybox')) { } -if (!empty($conf->stripe->enabled)) { +if (isModEnabled('stripe')) { } $FULLTAG = GETPOST('FULLTAG'); @@ -96,13 +96,13 @@ if (empty($paymentmethod)) { $validpaymentmethod = array(); -if (!empty($conf->paypal->enabled)) { +if (isModEnabled('paypal')) { $validpaymentmethod['paypal'] = 'paypal'; } -if (!empty($conf->paybox->enabled)) { +if (isModEnabled('paybox')) { $validpaymentmethod['paybox'] = 'paybox'; } -if (!empty($conf->stripe->enabled)) { +if (isModEnabled('stripe')) { $validpaymentmethod['stripe'] = 'stripe'; } diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index b8e4e9d4e19..4d1336351b3 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -57,7 +57,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php'; require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php'; -if (!empty($conf->paypal->enabled)) { +if (isModEnabled('paypal')) { require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php'; require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypalfunctions.lib.php'; } @@ -65,7 +65,7 @@ if (!empty($conf->paypal->enabled)) { $langs->loadLangs(array("main", "other", "dict", "bills", "companies", "paybox", "paypal")); // Clean parameters -if (!empty($conf->paypal->enabled)) { +if (isModEnabled('paypal')) { $PAYPAL_API_USER = ""; if (!empty($conf->global->PAYPAL_API_USER)) { $PAYPAL_API_USER = $conf->global->PAYPAL_API_USER; @@ -127,13 +127,13 @@ dol_syslog("***** paymentok.php is called paymentmethod=".$paymentmethod." FULLT $validpaymentmethod = array(); -if (!empty($conf->paypal->enabled)) { +if (isModEnabled('paypal')) { $validpaymentmethod['paypal'] = 'paypal'; } -if (!empty($conf->paybox->enabled)) { +if (isModEnabled('paybox')) { $validpaymentmethod['paybox'] = 'paybox'; } -if (!empty($conf->stripe->enabled)) { +if (isModEnabled('stripe')) { $validpaymentmethod['stripe'] = 'stripe'; } @@ -236,7 +236,7 @@ if (!empty($conf->global->MAIN_IMAGE_PUBLIC_PAYMENT)) { print '


'; -if (!empty($conf->paypal->enabled)) { +if (isModEnabled('paypal')) { if ($paymentmethod == 'paypal') { // We call this page only if payment is ok on payment system if ($PAYPALTOKEN) { // Get on url call @@ -316,14 +316,14 @@ if (!empty($conf->paypal->enabled)) { } } -if (!empty($conf->paybox->enabled)) { +if (isModEnabled('paybox')) { if ($paymentmethod == 'paybox') { // TODO Add a check to validate that payment is ok. $ispaymentok = true; // We call this page only if payment is ok on payment system } } -if (!empty($conf->stripe->enabled)) { +if (isModEnabled('stripe')) { if ($paymentmethod == 'stripe') { // TODO Add a check to validate that payment is ok. We can request Stripe with payment_intent and payment_intent_client_secret $ispaymentok = true; // We call this page only if payment is ok on payment system diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 6110fc7a5e5..2ba271cd936 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -84,7 +84,7 @@ $permissiontoadd = $user->rights->societe->creer; // Used by the include of acti $permissiontoaddupdatepaymentinformation = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $permissiontoadd) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->societe->thirdparty_paymentinformation_advance->write))); -if (!empty($conf->stripe->enabled)) { +if (isModEnabled('stripe')) { $service = 'StripeTest'; $servicestatus = 0; if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'alpha')) { @@ -493,7 +493,7 @@ if (empty($reshook)) { $id = $savid; // Action for stripe - if (!empty($conf->stripe->enabled) && class_exists('Stripe')) { + if (isModEnabled('stripe') && class_exists('Stripe')) { if ($action == 'synccustomertostripe') { if ($object->client == 0) { $error++; @@ -782,11 +782,11 @@ llxHeader('', $title, $help_url); $head = societe_prepare_head($object); // Show sandbox warning -/*if (!empty($conf->paypal->enabled) && (!empty($conf->global->PAYPAL_API_SANDBOX) || GETPOST('forcesandbox','alpha'))) // We can force sand box with param 'forcesandbox' +/*if (isModEnabled('paypal') && (!empty($conf->global->PAYPAL_API_SANDBOX) || GETPOST('forcesandbox','alpha'))) // We can force sand box with param 'forcesandbox' { dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode','Paypal'),'','warning'); }*/ -if (!empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) { +if (isModEnabled('stripe') && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) { dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning'); } @@ -885,13 +885,13 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' $elementTypeArray['contract'] = $langs->transnoentitiesnoconv('Contracts'); } - if (!empty($conf->stripe->enabled)) { + if (isModEnabled('stripe')) { // Stripe customer key 'cu_....' stored into llx_societe_account print ''; print $form->editfieldkey("StripeCustomerId", 'key_account', $stripecu, $object, $permissiontoaddupdatepaymentinformation, 'string', '', 0, 2, 'socid'); print ''; print $form->editfieldval("StripeCustomerId", 'key_account', $stripecu, $object, $permissiontoaddupdatepaymentinformation, 'string', '', null, null, '', 2, '', 'socid'); - if (!empty($conf->stripe->enabled) && $stripecu && $action != 'editkey_account') { + if (isModEnabled('stripe') && $stripecu && $action != 'editkey_account') { $connect = ''; if (!empty($stripeacc)) { $connect = $stripeacc.'/'; @@ -947,7 +947,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' } } - if (!empty($conf->stripe->enabled) && !empty($conf->stripeconnect->enabled) && getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { + if (isModEnabled('stripe') && !empty($conf->stripeconnect->enabled) && getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { $stripesupplieracc = $stripe->getStripeAccount($service, $object->id); // Get Stripe OAuth connect account (no network access here) // Stripe customer key 'cu_....' stored into llx_societe_account @@ -955,7 +955,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print $form->editfieldkey("StripeConnectAccount", 'key_account_supplier', $stripesupplieracc, $object, $permissiontoaddupdatepaymentinformation, 'string', '', 0, 2, 'socid'); print ''; print $form->editfieldval("StripeConnectAccount", 'key_account_supplier', $stripesupplieracc, $object, $permissiontoaddupdatepaymentinformation, 'string', '', null, null, '', 2, '', 'socid'); - if (!empty($conf->stripe->enabled) && $stripesupplieracc && $action != 'editkey_account_supplier') { + if (isModEnabled('stripe') && $stripesupplieracc && $action != 'editkey_account_supplier') { $connect = ''; $url = 'https://dashboard.stripe.com/test/connect/accounts/'.$stripesupplieracc; @@ -1338,7 +1338,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' } // List of Stripe connect accounts - if (!empty($conf->stripe->enabled) && !empty($conf->stripeconnect->enabled) && !empty($stripesupplieracc)) { + if (isModEnabled('stripe') && !empty($conf->stripeconnect->enabled) && !empty($stripesupplieracc)) { print load_fiche_titre($langs->trans('StripeBalance').($stripesupplieracc ? ' (Stripe connection with StripeConnect account '.$stripesupplieracc.')' : ' (Stripe connection with keys from Stripe module setup)'), $morehtmlright, 'stripe-s'); $balance = \Stripe\Balance::retrieve(array("stripe_account" => $stripesupplieracc)); print ''."\n"; diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index 33536271115..6cbefc14185 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -399,7 +399,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code if (!empty($site_account)) { \Stripe\Stripe::setApiKey($site_account); } - if (!empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) { + if (isModEnabled('stripe') && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) { $service = 'StripeTest'; $servicestatus = '0'; dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning'); From abcd68071e52ab5d8a9528cb0acc3831401bdf10 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 25 Sep 2022 22:00:20 +0200 Subject: [PATCH 04/17] Use isModEnabled --- htdocs/stripe/charge.php | 4 ++-- htdocs/stripe/class/actions_stripe.class.php | 2 +- htdocs/stripe/payout.php | 2 +- htdocs/stripe/transaction.php | 2 +- htdocs/takepos/admin/terminal.php | 6 +++--- htdocs/takepos/pay.php | 8 ++++---- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/htdocs/stripe/charge.php b/htdocs/stripe/charge.php index 522445334eb..f598275177e 100644 --- a/htdocs/stripe/charge.php +++ b/htdocs/stripe/charge.php @@ -68,7 +68,7 @@ $stripe = new Stripe($db); llxHeader('', $langs->trans("StripeChargeList")); -if (!empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) { +if (isModEnabled('stripe') && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) { $service = 'StripeTest'; $servicestatus = '0'; dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning'); @@ -225,7 +225,7 @@ if (!$rowid) { // Stripe customer print "'; - if (!empty($conf->stripe->enabled) && !empty($conf->global->STRIPE_CARD_PRESENT)) { + if (isModEnabled('stripe') && !empty($conf->global->STRIPE_CARD_PRESENT)) { print ''; // Force Stripe Terminal print '
"; - if (!empty($conf->stripe->enabled) && !empty($stripeacc)) { + if (isModEnabled('stripe') && !empty($stripeacc)) { $connect = $stripeacc.'/'; } $url = 'https://dashboard.stripe.com/'.$connect.'test/customers/'.$charge->customer; diff --git a/htdocs/stripe/class/actions_stripe.class.php b/htdocs/stripe/class/actions_stripe.class.php index 0d8b5e03435..8e5cd833a71 100644 --- a/htdocs/stripe/class/actions_stripe.class.php +++ b/htdocs/stripe/class/actions_stripe.class.php @@ -71,7 +71,7 @@ class ActionsStripeconnect { global $db, $conf, $user, $langs, $form; - if (!empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) { + if (isModEnabled('stripe') && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) { $service = 'StripeTest'; dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning'); } else { diff --git a/htdocs/stripe/payout.php b/htdocs/stripe/payout.php index 81baa5db4ac..1965c8ab73d 100644 --- a/htdocs/stripe/payout.php +++ b/htdocs/stripe/payout.php @@ -72,7 +72,7 @@ $stripe = new Stripe($db); llxHeader('', $langs->trans("StripePayoutList")); -if (!empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) { +if (isModEnabled('stripe') && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) { $service = 'StripeTest'; $servicestatus = '0'; dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning'); diff --git a/htdocs/stripe/transaction.php b/htdocs/stripe/transaction.php index c36c061b91e..29eec246af8 100644 --- a/htdocs/stripe/transaction.php +++ b/htdocs/stripe/transaction.php @@ -71,7 +71,7 @@ $stripe = new Stripe($db); llxHeader('', $langs->trans("StripeTransactionList")); -if (!empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) { +if (isModEnabled('stripe') && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) { $service = 'StripeTest'; $servicestatus = '0'; dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning'); diff --git a/htdocs/takepos/admin/terminal.php b/htdocs/takepos/admin/terminal.php index eb43455216c..9cd1a5fd5f0 100644 --- a/htdocs/takepos/admin/terminal.php +++ b/htdocs/takepos/admin/terminal.php @@ -79,7 +79,7 @@ if (GETPOST('action', 'alpha') == 'set') { $res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CASH".$terminaltouse, (GETPOST('CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse, 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse, 'alpha') : ''), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CHEQUE".$terminaltouse, (GETPOST('CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse, 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse, 'alpha') : ''), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CB".$terminaltouse, (GETPOST('CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse, 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse, 'alpha') : ''), 'chaine', 0, '', $conf->entity); - if (!empty($conf->stripe->enabled) && !empty($conf->global->STRIPE_CARD_PRESENT)) { + if (isModEnabled('stripe') && !empty($conf->global->STRIPE_CARD_PRESENT)) { $res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL".$terminaltouse, GETPOST('CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity); } if (getDolGlobalInt('TAKEPOS_ENABLE_SUMUP')) { @@ -189,7 +189,7 @@ if (isModEnabled("banque")) { } print '
'.$langs->trans("CashDeskBankAccountForStripeTerminal").''; $service = 'StripeTest'; @@ -201,7 +201,7 @@ if (isModEnabled("banque")) { global $stripearrayofkeysbyenv; $site_account = $stripearrayofkeysbyenv[$servicestatus]['secret_key']; \Stripe\Stripe::setApiKey($site_account); - if (!empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) { + if (isModEnabled('stripe') && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) { $service = 'StripeTest'; $servicestatus = '0'; dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning'); diff --git a/htdocs/takepos/pay.php b/htdocs/takepos/pay.php index 1222ccd1786..affcfaa50de 100644 --- a/htdocs/takepos/pay.php +++ b/htdocs/takepos/pay.php @@ -80,7 +80,7 @@ top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); stripe->enabled)) { +if (isModEnabled('stripe')) { $service = 'StripeTest'; $servicestatus = 0; if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'alpha')) { @@ -130,7 +130,7 @@ function fetchConnectionToken() { stripe->enabled) && isset($keyforstripeterminalbank) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) { +if (isModEnabled('stripe') && isset($keyforstripeterminalbank) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) { dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning', 1); } @@ -535,7 +535,7 @@ $action_buttons = array( ), ); $numpad = $conf->global->TAKEPOS_NUMPAD; -if (!empty($conf->stripe->enabled) && isset($keyforstripeterminalbank) && !empty($conf->global->STRIPE_CARD_PRESENT)) { +if (isModEnabled('stripe') && isset($keyforstripeterminalbank) && !empty($conf->global->STRIPE_CARD_PRESENT)) { print ''; dol_htmloutput_mesg($langs->trans('ConnectingToStripeTerminal', 'Stripe'), '', 'warning', 1); print ''; @@ -646,7 +646,7 @@ while ($i < count($arrayOfValidPaymentModes)) { $i = $i + 1; } -if (!empty($conf->stripe->enabled) && isset($keyforstripeterminalbank) && !empty($conf->global->STRIPE_CARD_PRESENT)) { +if (isModEnabled('stripe') && isset($keyforstripeterminalbank) && !empty($conf->global->STRIPE_CARD_PRESENT)) { $keyforstripeterminalbank = "CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL".$_SESSION["takeposterminal"]; print ''; if (!empty($conf->global->$keyforstripeterminalbank)) { From ef94f2af70a40e8d5d3f4c059a20ade6b75ef8fd Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 25 Sep 2022 22:45:10 +0200 Subject: [PATCH 05/17] Use isModEnabled --- htdocs/comm/propal/card.php | 4 ++-- htdocs/comm/propal/list.php | 4 ++-- htdocs/commande/list.php | 14 +++++++------- htdocs/compta/facture/list.php | 8 ++++---- htdocs/contrat/card.php | 10 +++++----- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 3c478ff5a2c..44f7e00bdce 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -64,7 +64,7 @@ $langs->loadLangs(array('companies', 'propal', 'compta', 'bills', 'orders', 'pro if (!empty($conf->incoterm->enabled)) { $langs->load('incoterm'); } -if (!empty($conf->margin->enabled)) { +if (isModEnabled('margin')) { $langs->load('margins'); } @@ -2737,7 +2737,7 @@ if ($action == 'create') { print '
'; // Margin Infos - if (!empty($conf->margin->enabled)) { + if (isModEnabled('margin')) { $formmargin->displayMarginInfos($object); } diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 5b678a0f7ac..76c4a42ddce 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -536,7 +536,7 @@ $formother = new FormOther($db); $formfile = new FormFile($db); $formpropal = new FormPropal($db); $formmargin = null; -if (!empty($conf->margin->enabled)) { +if (isModEnabled('margin')) { $formmargin = new FormMargin($db); } $companystatic = new Societe($db); @@ -1573,7 +1573,7 @@ if ($resql) { $typenArray = null; $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/commande/list.php b/htdocs/commande/list.php index 5cde78cd09f..58a6ce70f0f 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -42,7 +42,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'; @@ -199,10 +199,10 @@ $arrayfields = array( 'c.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(!isModEnabled("multicurrency") ? 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), @@ -778,7 +778,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); @@ -1850,7 +1850,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/facture/list.php b/htdocs/compta/facture/list.php index ddfe7e5429f..1d6dbd9f03b 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -245,10 +245,10 @@ $arrayfields = array( 'f.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(!isModEnabled('multicurrency') ? 0 : 1), 'position'=>292), 'multicurrency_dynamount_payed'=>array('label'=>'MulticurrencyAlreadyPaid', 'checked'=>0, 'enabled'=>(!isModEnabled('multicurrency') ? 0 : 1), 'position'=>295), 'multicurrency_rtp'=>array('label'=>'MulticurrencyRemainderToPay', 'checked'=>0, 'enabled'=>(!isModEnabled('multicurrency') ? 0 : 1), 'position'=>296), // Not enabled by default because slow - 'total_pa' => array('label' => ((isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == '1') ? 'BuyingPrice' : 'CostPrice'), 'checked' => 0, 'position' => 300, 'enabled' => (empty($conf->margin->enabled) || empty($user->rights->margins->liretous) ? 0 : 1)), - 'total_margin' => array('label' => 'Margin', 'checked' => 0, 'position' => 301, 'enabled' => (empty($conf->margin->enabled) || empty($user->rights->margins->liretous) ? 0 : 1)), - 'total_margin_rate' => array('label' => 'MarginRate', 'checked' => 0, 'position' => 302, 'enabled' => (empty($conf->margin->enabled) || empty($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) || empty($user->rights->margins->liretous) || empty($conf->global->DISPLAY_MARK_RATES) ? 0 : 1)), + 'total_pa' => array('label' => ((isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == '1') ? 'BuyingPrice' : 'CostPrice'), 'checked' => 0, 'position' => 300, 'enabled' => (!isModEnabled('margin') || empty($user->rights->margins->liretous) ? 0 : 1)), + 'total_margin' => array('label' => 'Margin', 'checked' => 0, 'position' => 301, 'enabled' => (!isModEnabled('margin') || empty($user->rights->margins->liretous) ? 0 : 1)), + 'total_margin_rate' => array('label' => 'MarginRate', 'checked' => 0, 'position' => 302, 'enabled' => (!isModEnabled('margin') || empty($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') || empty($user->rights->margins->liretous) || empty($conf->global->DISPLAY_MARK_RATES) ? 0 : 1)), 'f.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), 'f.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>502), 'f.note_public'=>array('label'=>'NotePublic', 'checked'=>0, 'position'=>510, 'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PUBLIC_NOTES))), diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 3509134c70f..b452b20154a 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -1476,7 +1476,7 @@ if ($action == 'create') { $productstatic = new Product($db); $usemargins = 0; - if (!empty($conf->margin->enabled) && !empty($object->element) && in_array($object->element, array('facture', 'propal', 'commande'))) { + if (isModEnabled('margin') && !empty($object->element) && in_array($object->element, array('facture', 'propal', 'commande'))) { $usemargins = 1; } @@ -1522,7 +1522,7 @@ if ($action == 'create') { print ''.$langs->trans("Unit").''; } print ''.$langs->trans("ReductionShort").''; - if (!empty($conf->margin->enabled) && !empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) { + if (isModEnabled('margin') && !empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) { print ''.$langs->trans("BuyingPrice").''; } print ' '; @@ -1592,7 +1592,7 @@ if ($action == 'create') { } // Margin - if (!empty($conf->margin->enabled) && !empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) { + if (isModEnabled('margin') && !empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) { print ''.price($objp->pa_ht).''; } @@ -1749,7 +1749,7 @@ if ($action == 'create') { print ''; $colspan = 6; - if (!empty($conf->margin->enabled) && !empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) { + if (isModEnabled('margin') && !empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) { $colspan++; } if (!empty($conf->global->PRODUCT_USE_UNITS)) { @@ -2237,7 +2237,7 @@ $db->close(); ?> margin->enabled) && $action == 'editline') { +if (isModEnabled('margin') && $action == 'editline') { // TODO Why this ? To manage margin on contracts ? ?>