From 1d8d8fce9a0ae2109c9b211062543b0c6bed871d Mon Sep 17 00:00:00 2001 From: Anthony Berton Date: Thu, 6 Jul 2023 11:59:16 +0200 Subject: [PATCH] FIX - Default values (on creation forms) is not aplicate for propal or orders --- htdocs/comm/propal/card.php | 30 ++++++++++++++---------------- htdocs/commande/card.php | 6 +++--- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 419f552cecc..0b689aacbd0 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1040,6 +1040,7 @@ if (empty($reshook)) { $pu_ttc_devise = 0; $price_min = 0; $price_min_ttc = 0; + $tva_npr=0; $price_base_type = (GETPOST('price_base_type', 'alpha') ? GETPOST('price_base_type', 'alpha') : 'HT'); $db->begin(); @@ -1698,15 +1699,14 @@ if ($action == 'create') { $soc = new Societe($db); if ($socid > 0) { $res = $soc->fetch($socid); - - if (GETPOSTINT('cond_reglement_id') == 0) { - $cond_reglement_id = $soc->cond_reglement_id; - } - if (GETPOSTINT('mode_reglement_id') == 0) { - $mode_reglement_id = $soc->mode_reglement_id; - } } + $currency_code = $conf->currency; + + $cond_reglement_id = GETPOST('cond_reglement_id', 'int'); + $deposit_percent = GETPOST('cond_reglement_id_deposit_percent', 'alpha'); + $mode_reglement_id = GETPOST('mode_reglement_id', 'int'); + // Load objectsrc if (!empty($origin) && !empty($originid)) { // Parse element/subelement (ex: project_task) @@ -1771,20 +1771,18 @@ if ($action == 'create') { } } } else { + $cond_reglement_id = !empty($soc->cond_reglement_id)?$soc->cond_reglement_id:$cond_reglement_id; + $deposit_percent = !empty($soc->deposit_percent)?$soc->deposit_percent:$deposit_percent; + $mode_reglement_id = !empty($soc->mode_reglement_id)?$soc->mode_reglement_id:$mode_reglement_id; + $shipping_method_id = $soc->shipping_method_id; + $warehouse_id = $soc->fk_warehouse; + $remise_percent = $soc->remise_percent; + if (isModEnabled("multicurrency") && !empty($soc->multicurrency_code)) { $currency_code = $soc->multicurrency_code; } } - // when payment term is empty (means not override by payment mode form a other object, like third-party), try to use default value - if (empty($cond_reglement_id)) { - $cond_reglement_id = GETPOST("cond_reglement_id", 'int'); - } - // when payment mode is empty (means not override by payment mode form a other object, like third-party), try to use default value - if (empty($mode_reglement_id)) { - $mode_reglement_id = GETPOST("mode_reglement_id", 'int'); - } - //Warehouse default if null if ($soc->fk_warehouse > 0) { $warehouse_id = $soc->fk_warehouse; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 971c7472a9a..9d60fdbc13c 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1727,9 +1727,9 @@ if ($action == 'create' && $usercancreate) { $srccontactslist = $objectsrc->liste_contact(-1, 'external', 1); } } else { - $cond_reglement_id = $soc->cond_reglement_id; - $deposit_percent = $soc->deposit_percent; - $mode_reglement_id = $soc->mode_reglement_id; + $cond_reglement_id = !empty($soc->cond_reglement_id)?$soc->cond_reglement_id:$cond_reglement_id; + $deposit_percent = !empty($soc->deposit_percent)?$soc->deposit_percent:$deposit_percent; + $mode_reglement_id = !empty($soc->mode_reglement_id)?$soc->mode_reglement_id:$mode_reglement_id; $fk_account = $soc->fk_account; $availability_id = 0; $shipping_method_id = $soc->shipping_method_id;