FIX: Reload page on supplier change and keeping the values of the input already set in the form

This commit is contained in:
kkhelifa 2022-11-04 16:18:19 +01:00
parent ff16d74bd2
commit 7baf98d6aa
2 changed files with 17 additions and 15 deletions

View File

@ -1616,12 +1616,13 @@ if ($action == 'create') {
print img_picto('', 'company').$form->select_company((empty($socid) ? '' : $socid), 'socid', 's.fournisseur=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300'); print img_picto('', 'company').$form->select_company((empty($socid) ? '' : $socid), 'socid', 's.fournisseur=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300');
// reload page to retrieve customer informations // reload page to retrieve customer informations
if (!empty($conf->global->RELOAD_PAGE_ON_SUPPLIER_CHANGE)) { if (!empty($conf->global->RELOAD_PAGE_ON_SUPPLIER_CHANGE)) {
print '<script> print '<script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {
$("#socid").change(function() { $("#socid").change(function() {
var socid = $(this).val(); console.log("We have changed the company - Reload page");
// reload page // reload page
window.location.href = "'.$_SERVER["PHP_SELF"].'?action=create&socid="+socid; $("input[name=action]").val("create");
$("form[name=add]").submit();
}); });
}); });
</script>'; </script>';

View File

@ -1947,9 +1947,10 @@ if ($action == 'create') {
print '<script type="text/javascript"> print '<script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {
$("#socid").change(function() { $("#socid").change(function() {
var socid = $(this).val(); console.log("We have changed the company - Reload page");
// reload page // reload page
window.location.href = "'.$_SERVER["PHP_SELF"].'?action=create&socid="+socid; $("input[name=action]").val("create");
$("form[name=add]").submit();
}); });
}); });
</script>'; </script>';