Merge pull request #13081 from bb2a/patch-14

Constant MAIN_DEFAULT_PAYMENT_TYPE_ID can used to set default value
This commit is contained in:
Laurent Destailleur 2020-02-12 18:46:08 +01:00 committed by GitHub
commit 4678c7ef7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3502,6 +3502,7 @@ class Form
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of payment methods
* Constant MAIN_DEFAULT_PAYMENT_TYPE_ID can used to set default value but scope is all application, probably not what you want.
*
* @param string $selected Id du mode de paiement pre-selectionne
* @param string $htmlname Nom de la zone select
@ -3517,7 +3518,7 @@ class Form
public function select_types_paiements($selected = '', $htmlname = 'paiementtype', $filtertype = '', $format = 0, $empty = 1, $noadmininfo = 0, $maxlength = 0, $active = 1, $morecss = '')
{
// phpcs:enable
global $langs, $user;
global $langs, $user, $conf;
dol_syslog(__METHOD__." ".$selected.", ".$htmlname.", ".$filtertype.", ".$format, LOG_DEBUG);
@ -3527,6 +3528,9 @@ class Form
elseif ($filtertype != '' && $filtertype != '-1') $filterarray = explode(',', $filtertype);
$this->load_cache_types_paiements();
// Set default value if not already set by caller
if (empty($selected) && !empty($conf->global->MAIN_DEFAULT_PAYMENT_TYPE_ID)) $selected = $conf->global->MAIN_DEFAULT_PAYMENT_TYPE_ID;
print '<select id="select'.$htmlname.'" class="flat selectpaymenttypes'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'">';
if ($empty) print '<option value="">&nbsp;</option>';