Fix reload of page

This commit is contained in:
Laurent Destailleur 2023-02-16 22:01:05 +01:00
parent 3c3d221370
commit b021721b10
2 changed files with 12 additions and 12 deletions

View File

@ -1700,14 +1700,14 @@ if ($action == 'create') {
} else { } else {
print img_picto('', 'company').$form->select_company((empty($socid) ? '' : $socid), 'socid', '(s.fournisseur=1 AND s.status=1)', 'SelectThirdParty', 1, 0, null, 0, 'minwidth175 maxwidth500 widthcentpercentminusxx'); print img_picto('', 'company').$form->select_company((empty($socid) ? '' : $socid), 'socid', '(s.fournisseur=1 AND s.status=1)', 'SelectThirdParty', 1, 0, null, 0, 'minwidth175 maxwidth500 widthcentpercentminusxx');
// 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_DISABLED)) {
print '<script> print '<script>
$(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");
var prjid = $("#projectid").val();
// reload page // reload page
window.location.href = "'.$_SERVER["PHP_SELF"].'?action=create&socid="+socid+"&projectid="+prjid $("input[name=action]").val("create");
$("form[name=add]").submit();
}); });
}); });
</script>'; </script>';

View File

@ -2099,13 +2099,14 @@ if ($action == 'create') {
} else { } else {
print img_picto('', 'company').$form->select_company(empty($societe->id) ? 0 : $societe->id, 'socid', '(s.fournisseur = 1 AND s.status = 1)', 'SelectThirdParty', 1, 0, null, 0, 'minwidth175 widthcentpercentminusxx maxwidth500'); print img_picto('', 'company').$form->select_company(empty($societe->id) ? 0 : $societe->id, 'socid', '(s.fournisseur = 1 AND s.status = 1)', 'SelectThirdParty', 1, 0, null, 0, 'minwidth175 widthcentpercentminusxx maxwidth500');
// reload page to retrieve supplier informations // reload page to retrieve supplier informations
if (!empty($conf->global->RELOAD_PAGE_ON_SUPPLIER_CHANGE)) { if (empty($conf->global->RELOAD_PAGE_ON_SUPPLIER_CHANGE_DISABLED)) {
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");
var fac_rec = $(\'#fac_rec\').val(); // reload page
window.location.href = "'.$_SERVER["PHP_SELF"].'?action=create&socid="+socid+"&fac_rec="+fac_rec; $("input[name=action]").val("create");
$("form[name=add]").submit();
}); });
}); });
</script>'; </script>';
@ -2168,10 +2169,9 @@ if ($action == 'create') {
$(document).ready(function() { $(document).ready(function() {
$("#fac_rec").change(function() { $("#fac_rec").change(function() {
console.log("We have changed the template invoice - Reload page"); console.log("We have changed the template invoice - Reload page");
var fac_rec = $(this).val(); // reload page
var socid = $(\'#socid\').val(); $("input[name=action]").val("create");
// For template invoice change, we must reuse data of template, not input already done, so we call a GET with action=create, not a POST submit. $("form[name=add]").submit();
window.location.href = "'.$_SERVER["PHP_SELF"].'?action=create&socid="+socid+"&fac_rec="+fac_rec;
}); });
}); });
</script>'; </script>';