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,15 +1616,16 @@ if ($action == 'create') {
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
if (!empty($conf->global->RELOAD_PAGE_ON_SUPPLIER_CHANGE)) {
print '<script>
$(document).ready(function() {
$("#socid").change(function() {
var socid = $(this).val();
// reload page
window.location.href = "'.$_SERVER["PHP_SELF"].'?action=create&socid="+socid;
print '<script type="text/javascript">
$(document).ready(function() {
$("#socid").change(function() {
console.log("We have changed the company - Reload page");
// reload page
$("input[name=action]").val("create");
$("form[name=add]").submit();
});
});
});
</script>';
</script>';
}
print ' <a href="'.DOL_URL_ROOT.'/societe/card.php?action=create&client=0&fournisseur=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create').'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans("AddThirdParty").'"></span></a>';
}

View File

@ -1945,14 +1945,15 @@ if ($action == 'create') {
// reload page to retrieve supplier informations
if (!empty($conf->global->RELOAD_PAGE_ON_SUPPLIER_CHANGE)) {
print '<script type="text/javascript">
$(document).ready(function() {
$("#socid").change(function() {
var socid = $(this).val();
// reload page
window.location.href = "'.$_SERVER["PHP_SELF"].'?action=create&socid="+socid;
$(document).ready(function() {
$("#socid").change(function() {
console.log("We have changed the company - Reload page");
// reload page
$("input[name=action]").val("create");
$("form[name=add]").submit();
});
});
});
</script>';
</script>';
}
print ' <a href="'.DOL_URL_ROOT.'/societe/card.php?action=create&client=0&fournisseur=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create').'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans("AddThirdParty").'"></span></a>';
}