From 7b20e703eea131fd84ee8ce938cd927d84572ec3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 17 Oct 2020 15:53:31 +0200 Subject: [PATCH] Clean code --- htdocs/comm/action/card.php | 3 +-- htdocs/comm/propal/card.php | 6 ++--- htdocs/core/class/html.form.class.php | 12 ++++++---- htdocs/langs/en_US/admin.lang | 2 +- htdocs/societe/admin/societe.php | 32 ++++++++++++++------------ htdocs/societe/class/societe.class.php | 2 +- 6 files changed, 31 insertions(+), 26 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index cf816db19a5..cda1d54b38b 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1122,8 +1122,7 @@ if ($action == 'create') { // Related company print ''.$langs->trans("ActionOnCompany").''; - if (GETPOST('socid', 'int') > 0) - { + if (GETPOST('socid', 'int') > 0) { $societe = new Societe($db); $societe->fetch(GETPOST('socid', 'int')); print $societe->getNomUrl(1); diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 9caf2c8483c..c8d7a5a9e90 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1504,9 +1504,6 @@ if ($action == 'create') print $soc->getNomUrl(1); print ''; print ''; - if (!empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD) && !empty($soc->shipping_method_id)) { - $shipping_method_id = $soc->shipping_method_id; - } } else { print ''; print $form->select_company('', 'socid', '(s.client = 1 OR s.client = 2 OR s.client = 3) AND status=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300 maxwidth500'); @@ -1587,6 +1584,9 @@ if ($action == 'create') // Shipping Method if (!empty($conf->expedition->enabled)) { + if (!empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD) && !empty($soc->shipping_method_id)) { + $shipping_method_id = $soc->shipping_method_id; + } print ''.$langs->trans('SendingMethod').''; print $form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1); print ''; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 266a6e2fd9a..ee8b12f073f 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1249,7 +1249,7 @@ class Form if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty); else $textifempty .= $langs->trans("All"); } - if ($showempty) $out .= ''."\n"; + if ($showempty) $out .= ''."\n"; $num = $this->db->num_rows($resql); $i = 0; @@ -1284,10 +1284,10 @@ class Form if ($obj->client || $obj->fournisseur) $label .= ')'; } - if ($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST) { - $label .= '-'.$obj->address.'-'.$obj->zip.' '.$obj->town; + if (! empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) { + $label .= ($obj->address ? ' - '.$obj->address : '').($obj->zip ? ' - '.$obj->zip : '').($obj->town ? ' '.$obj->town : ''); if (!empty($obj->country_code)) { - $label .= ' '.$langs->trans('Country'.$obj->country_code); + $label .= ', '.$langs->trans('Country'.$obj->country_code); } } @@ -3274,6 +3274,7 @@ class Form } print ''; if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + print ajax_combobox($htmlname); } /** @@ -3357,6 +3358,7 @@ class Form } print ''; if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + print ajax_combobox('select_'.$htmlname); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -3706,6 +3708,8 @@ class Form } print ""; if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + + print ajax_combobox('select'.$htmlname); } else { print $langs->trans("NoShippingMethodDefined"); } diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index e59a4c54f07..7a4aee9856a 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2009,7 +2009,7 @@ DisabledResourceLinkContact=Disable feature to link a resource to contacts EnableResourceUsedInEventCheck=Enable feature to check if a resource is in use in an event ConfirmUnactivation=Confirm module reset OnMobileOnly=On small screen (smartphone) only -DisableProspectCustomerType=Disable the "Prospect + Customer" third party type (so third party must be Prospect or Customer but can't be both) +DisableProspectCustomerType=Disable the "Prospect + Customer" third party type (so third party must be "Prospect" or "Customer", but can't be both) MAIN_OPTIMIZEFORTEXTBROWSER=Simplify interface for blind person MAIN_OPTIMIZEFORTEXTBROWSERDesc=Enable this option if you are a blind person, or if you use the application from a text browser like Lynx or Links. MAIN_OPTIMIZEFORCOLORBLIND=Change interface's color for color blind person diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php index d27ebd79207..d61312dd8d1 100644 --- a/htdocs/societe/admin/societe.php +++ b/htdocs/societe/admin/societe.php @@ -800,22 +800,24 @@ if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) print ''; print ''; - - -print ''; -print ''.$langs->trans("AskForPreferredShippingMethod").''; -print ' '; -print ''; -if (!empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD)) -{ - print ''; - print img_picto($langs->trans("Activated"), 'switch_on'); -} else { - print ''; - print img_picto($langs->trans("Disabled"), 'switch_off'); +if (!empty($conf->expedition->enabled)) { + if (! empty($conf->global->MAIN_FEATURES_LEVEL)) { // Visible on experimental only because seems to not be implemented everywhere (only on proposal) + print ''; + print ''.$langs->trans("AskForPreferredShippingMethod").''; + print ' '; + print ''; + if (!empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD)) + { + print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + } else { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + } + print ''; + print ''; + } } -print ''; -print ''; // Disable Prospect/Customer thirdparty type print ''; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 5efabc066e4..9078b2146d4 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -764,7 +764,7 @@ class Societe extends CommonObject $this->tva_assuj = 1; $this->status = 1; - if ($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST) { + if (! empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) { $this->fields['address']['showoncombobox'] = $conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST; $this->fields['zip']['showoncombobox'] = $conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST; $this->fields['town']['showoncombobox'] = $conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST;