From d5bb63df5da9ea8615b5ee12846377d79205bad6 Mon Sep 17 00:00:00 2001 From: thomas-Ngr Date: Tue, 14 Nov 2023 22:39:18 +0100 Subject: [PATCH] Reception dispatch : copy previous entrepot (#26597) --- htdocs/fourn/js/lib_dispatch.js.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/js/lib_dispatch.js.php b/htdocs/fourn/js/lib_dispatch.js.php index d8df7dc2da8..1b4b799fc8f 100644 --- a/htdocs/fourn/js/lib_dispatch.js.php +++ b/htdocs/fourn/js/lib_dispatch.js.php @@ -125,7 +125,10 @@ function addDispatchLine(index, type, mode) { //create new select2 to avoid duplicate id of cloned one $row.find("select[name='" + 'entrepot_' + nbrTrs + '_' + index + "']").select2(); - // TODO find solution to copy selected option to new select + // Copy selected option to new select + let $prevRow = $("tr[name^='" + type + "_'][name$='_" + index + "']:last") + let $prevEntr = Number($prevRow.find("select[name='" + 'entrepot_' + (nbrTrs-1) + '_' + index + "']").val()) + $row.find("select[name='" + 'entrepot_' + nbrTrs + '_' + index + "']").val($prevEntr) // TODO find solution to keep new tr's after page refresh //clear value $row.find("input[name^='qty']").val('');