From af634b7f2b8d06787d4294dc5fc2afa4ee9a5bcd Mon Sep 17 00:00:00 2001 From: lvessiller Date: Fri, 18 Jun 2021 10:51:39 +0200 Subject: [PATCH] FIX 17965 - Keep enter key only to submit expense lines form --- htdocs/expensereport/card.php | 46 ++++++++++------------------------- 1 file changed, 13 insertions(+), 33 deletions(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 0f911e55ae3..d9450483423 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -159,7 +159,7 @@ if (empty($reshook)) { include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; - if (GETPOSTISSET('sendit')) { // If we just submit a file + if (!empty(GETPOST('sendit', 'alpha'))) { // If we just submit a file if ($action == 'updateline') { $action = 'editline'; // To avoid to make the updateline now } else { @@ -2191,33 +2191,23 @@ if ($action == 'create') { $( ".auploadnewfilenow" ).click(function() { jQuery(".truploadnewfilenow").toggle(); jQuery(".trattachnewfilenow").hide(); - if (jQuery(".truploadnewfilenow").is(":hidden")) { - jQuery("input[name=\"sendit\"]").prop("disabled", true); - } else { - jQuery("input[name=\"sendit\"]").prop("disabled", false); - } return false; }); $( ".aattachtodoc" ).click(function() { jQuery(".trattachnewfilenow").toggle(); jQuery(".truploadnewfilenow").hide(); - if (jQuery(".truploadnewfilenow").is(":hidden")) { - jQuery("input[name=\"sendit\"]").prop("disabled", true); - } else { - jQuery("input[name=\"sendit\"]").prop("disabled", false); - } return false; });'; if (is_array(GETPOST('attachfile', 'array')) && count(GETPOST('attachfile', 'array'))) { print 'jQuery(".trattachnewfilenow").toggle();'."\n"; } print ' - if (jQuery(".truploadnewfilenow").is(":hidden")) { - jQuery("input[name=\"sendit\"]").prop("disabled", true); - } else { - jQuery("input[name=\"sendit\"]").prop("disabled", false); - } - '; + jQuery("form[name=\"expensereport\"]").submit(function() { + if (jQuery(".truploadnewfilenow").is(":hidden")) { + jQuery("input[name=\"sendit\"]").val(""); + } + }); + '; print ' }); '; @@ -2354,33 +2344,23 @@ if ($action == 'create') { $( ".auploadnewfilenow" ).click(function() { jQuery(".truploadnewfilenow").toggle(); jQuery(".trattachnewfilenow").hide(); - if (jQuery(".truploadnewfilenow").is(":hidden")) { - jQuery("input[name=\"sendit\"]").prop("disabled", true); - } else { - jQuery("input[name=\"sendit\"]").prop("disabled", false); - } return false; }); $( ".aattachtodoc" ).click(function() { jQuery(".trattachnewfilenow").toggle(); jQuery(".truploadnewfilenow").hide(); - if (jQuery(".truploadnewfilenow").is(":hidden")) { - jQuery("input[name=\"sendit\"]").prop("disabled", true); - } else { - jQuery("input[name=\"sendit\"]").prop("disabled", false); - } return false; });'."\n"; if (is_array(GETPOST('attachfile', 'array')) && count(GETPOST('attachfile', 'array')) && $action != 'updateline') { print 'jQuery(".trattachnewfilenow").show();'."\n"; } print ' - if (jQuery(".truploadnewfilenow").is(":hidden")) { - jQuery("input[name=\"sendit\"]").prop("disabled", true); - } else { - jQuery("input[name=\"sendit\"]").prop("disabled", false); - } - '; + jQuery("form[name=\"expensereport\"]").submit(function() { + if (jQuery(".truploadnewfilenow").is(":hidden")) { + jQuery("input[name=\"sendit\"]").val(""); + } + }); + '; print ' }); ';