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 {
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
if (!empty($conf->global->RELOAD_PAGE_ON_SUPPLIER_CHANGE)) {
if (empty($conf->global->RELOAD_PAGE_ON_SUPPLIER_CHANGE_DISABLED)) {
print '<script>
$(document).ready(function() {
$("#socid").change(function() {
var socid = $(this).val();
var prjid = $("#projectid").val();
console.log("We have changed the company - 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>';

View File

@ -2099,13 +2099,14 @@ if ($action == 'create') {
} 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');
// 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">
$(document).ready(function() {
$("#socid").change(function() {
var socid = $(this).val();
var fac_rec = $(\'#fac_rec\').val();
window.location.href = "'.$_SERVER["PHP_SELF"].'?action=create&socid="+socid+"&fac_rec="+fac_rec;
console.log("We have changed the company - Reload page");
// reload page
$("input[name=action]").val("create");
$("form[name=add]").submit();
});
});
</script>';
@ -2168,10 +2169,9 @@ if ($action == 'create') {
$(document).ready(function() {
$("#fac_rec").change(function() {
console.log("We have changed the template invoice - Reload page");
var fac_rec = $(this).val();
var socid = $(\'#socid\').val();
// 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.
window.location.href = "'.$_SERVER["PHP_SELF"].'?action=create&socid="+socid+"&fac_rec="+fac_rec;
// reload page
$("input[name=action]").val("create");
$("form[name=add]").submit();
});
});
</script>';