diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index b2d8e47fa9ee0724ec9de0e04de249aa795852d5..91694fdf8cd96ebf9e4bf4f5b479b16f672d602f 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1960,7 +1960,7 @@ if ($action == 'create') if (empty($socid)) $soc = $objectsrc->thirdparty; - $cond_reglement_id = (! empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(! empty($soc->cond_reglement_id)?$soc->cond_reglement_id:1)); + $cond_reglement_id = (! empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(! empty($soc->cond_reglement_id)?$soc->cond_reglement_id:0)); $mode_reglement_id = (! empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(! empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0)); $fk_account = (! empty($objectsrc->fk_account)?$objectsrc->fk_account:(! empty($soc->fk_account)?$soc->fk_account:0)); $remise_percent = (! empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(! empty($soc->remise_percent)?$soc->remise_percent:0)); @@ -1989,7 +1989,7 @@ if ($action == 'create') if (!empty($conf->multicurrency->enabled) && !empty($soc->multicurrency_code)) $currency_code = $soc->multicurrency_code; } - + if(!empty($soc->id)) $absolute_discount = $soc->getAvailableDiscounts(); if (! empty($conf->use_javascript_ajax)) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 5e99ed7f7f21a5023811c516ffc36a8a1f23a596..0369bd767892967fc270d8cbba570d3671c6ab07 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2757,20 +2757,23 @@ class Form /** * Return list of payment modes * - * @param string $selected Id du type de paiement pre-selectionne + * @param int $selected Id of payment term to preselect by default * @param string $htmlname Nom de la zone select * @param int $filtertype Not used * @param int $addempty Add an empty entry * @return void */ - function select_conditions_paiements($selected='',$htmlname='condid',$filtertype=-1,$addempty=0) + function select_conditions_paiements($selected=0, $htmlname='condid', $filtertype=-1, $addempty=0) { - global $langs,$user; + global $langs, $user, $conf; dol_syslog(__METHOD__." selected=".$selected.", htmlname=".$htmlname, LOG_DEBUG); $this->load_cache_conditions_paiements(); + // Set default value if not already set by caller + if (empty($selected) && ! empty($conf->global->MAIN_DEFAULT_PAYMENT_TERM_ID)) $selected = $conf->global->MAIN_DEFAULT_PAYMENT_TERM_ID; + print '<select class="flat" name="'.$htmlname.'">'; if ($addempty) print '<option value="0"> </option>'; foreach($this->cache_conditions_paiements as $id => $arrayconditions)