From fe3fb72e5eea18a5853bccb925cdbc04f1a4f192 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnter=20Lukas?= Date: Sat, 30 Nov 2024 10:54:32 +0100 Subject: [PATCH 1/4] Fix #32161 --- htdocs/comm/propal/card.php | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 2b5f8dcc5bf..d4d969c0a07 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1766,6 +1766,7 @@ if ($action == 'create') { $fk_account = GETPOST('fk_account', 'int'); // Load objectsrc + $soc = NULL; if (!empty($origin) && !empty($originid)) { // Parse element/subelement (ex: project_task) $element = $subelement = $origin; @@ -1777,6 +1778,14 @@ if ($action == 'create') { if ($element == 'project') { $projectid = $originid; + + // Fetch project and thirdparty + $project = new Project($db); + $project->fetch($projectid); + if ($project->socid > 0) { + $soc = new Societe($db); + $soc->fetch($project->socid); + } } else { // For compatibility if ($element == 'order' || $element == 'commande') { @@ -1808,9 +1817,9 @@ if ($action == 'create') { $soc = $objectsrc->thirdparty; - $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)); - $warehouse_id = (!empty($objectsrc->warehouse_id) ? $objectsrc->warehouse_id : (!empty($soc->warehouse_id) ? $soc->warehouse_id : 0)); + $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)); + $warehouse_id = (!empty($objectsrc->warehouse_id) ? $objectsrc->warehouse_id : (!empty($soc->warehouse_id) ? $soc->warehouse_id : 0)); // Replicate extrafields $objectsrc->fetch_optionals(); @@ -1825,7 +1834,10 @@ if ($action == 'create') { } } } - } else { + } + + // Load default values from thirdparty + if (!empty($soc)) { $cond_reglement_id = empty($soc->cond_reglement_id) ? $cond_reglement_id : $soc->cond_reglement_id; $deposit_percent = empty($soc->deposit_percent) ? $deposit_percent : $soc->deposit_percent; $mode_reglement_id = empty($soc->mode_reglement_id) ? $mode_reglement_id : $soc->mode_reglement_id; @@ -1838,7 +1850,7 @@ if ($action == 'create') { $currency_code = $soc->multicurrency_code; } } - + // If form was posted (but error returned), we must reuse the value posted in priority (standard Dolibarr behaviour) if (!GETPOST('changecompany')) { if (GETPOSTISSET('cond_reglement_id')) { From f5d639b8416474a245dc5094f073a9792a16978e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnter=20Lukas?= Date: Sat, 30 Nov 2024 11:04:35 +0100 Subject: [PATCH 2/4] Update card.php --- htdocs/comm/propal/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index d4d969c0a07..b5f287fdbe7 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1766,7 +1766,7 @@ if ($action == 'create') { $fk_account = GETPOST('fk_account', 'int'); // Load objectsrc - $soc = NULL; + $soc = null; if (!empty($origin) && !empty($originid)) { // Parse element/subelement (ex: project_task) $element = $subelement = $origin; From 677525a663d55fbf6a248bf2f5b66d75ec762f97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnter=20Lukas?= Date: Sat, 30 Nov 2024 11:08:17 +0100 Subject: [PATCH 3/4] Update card.php --- htdocs/comm/propal/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index b5f287fdbe7..828b96311e9 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1850,7 +1850,7 @@ if ($action == 'create') { $currency_code = $soc->multicurrency_code; } } - + // If form was posted (but error returned), we must reuse the value posted in priority (standard Dolibarr behaviour) if (!GETPOST('changecompany')) { if (GETPOSTISSET('cond_reglement_id')) { From 23617a11fc556cc45affb42f32b82f3fc168833b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnter=20Lukas?= Date: Sat, 30 Nov 2024 13:34:17 +0100 Subject: [PATCH 4/4] Update card.php --- htdocs/comm/propal/card.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 828b96311e9..3ab1b2bf2b9 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1766,7 +1766,6 @@ if ($action == 'create') { $fk_account = GETPOST('fk_account', 'int'); // Load objectsrc - $soc = null; if (!empty($origin) && !empty($originid)) { // Parse element/subelement (ex: project_task) $element = $subelement = $origin;