diff --git a/resources/js/src/table/change.ts b/resources/js/src/table/change.ts index 83cb9a754b..63b8950171 100644 --- a/resources/js/src/table/change.ts +++ b/resources/js/src/table/change.ts @@ -426,6 +426,11 @@ function verificationsAfterFieldChange (urlField, multiEdit, theType) { $thisInput.removeAttr('min'); $thisInput.removeAttr('max'); // @todo: put back attributes if corresponding function is deselected + + if ($thisFunction.val() === 'NOW') { + $thisInput.attr('min', 0); + $thisInput.attr('max', $thisInput.parent().attr('data-decimals')); + } } if ($thisInput.data('rulesadded') === null && ! functionSelected) { diff --git a/resources/js/src/table/select.ts b/resources/js/src/table/select.ts index daa2cf6020..496d2db598 100644 --- a/resources/js/src/table/select.ts +++ b/resources/js/src/table/select.ts @@ -306,7 +306,7 @@ AJAX.registerOnload('table/select.js', function () { // Get the operator. const operator = ($(this).val() as string); - const $targetField = $(this).closest('tr').find('[name*="criteriaValues"]') + const $targetField = $(this).closest('tr').find('[name*="criteriaValues"]'); $targetField.prop('disabled', opIsUnary(operator)); $targetField.siblings('.ui-datepicker-trigger').eq(0).toggle(!opIsUnary(operator)); diff --git a/src/InsertEdit.php b/src/InsertEdit.php index 259e4158a4..a126f92462 100644 --- a/src/InsertEdit.php +++ b/src/InsertEdit.php @@ -24,6 +24,7 @@ use function htmlspecialchars; use function implode; use function in_array; use function is_array; +use function is_numeric; use function is_string; use function json_encode; use function max; @@ -44,7 +45,7 @@ use const PASSWORD_DEFAULT; class InsertEdit { - private const FUNC_OPTIONAL_PARAM = ['RAND', 'UNIX_TIMESTAMP']; + private const FUNC_OPTIONAL_PARAM = ['NOW', 'RAND', 'UNIX_TIMESTAMP']; private const FUNC_NO_PARAM = [ 'CONNECTION_ID', @@ -1132,6 +1133,13 @@ class InsertEdit . $this->dbi->quoteString($editField->salt) . ')'; } + if ( + $editField->function === 'NOW' + && (is_numeric($editField->value) && $editField->value >= 0 && $editField->value <= 6) + ) { + return $editField->function . '(' . (int) $editField->value . ')'; + } + return $editField->function . '(' . $this->dbi->quoteString($editField->value) . ')'; }