From 4b590c32062fa57cf255a22ff1f085fdc0fb29d3 Mon Sep 17 00:00:00 2001 From: Dan Briem Date: Sat, 30 May 2020 19:27:39 -0400 Subject: [PATCH] LP#1880028 Backdate Checkins Until Logout Option - Adds a checkbox option to store the backdate as a session item and only loads the backdate on the checkin screen (backdate ignored on the hold capture screen) - Adjusts existing $watch to enable/disable the checkbox and store/remove session backdate when appropriate - Adjusts is_backdate() to not consider null or undefined dates as backdates so the visible alert is accurate - Adjusts "today" comparison to use a time of 00:00:00 so that when the Clear button is used and clears the time the Today button won't cause a backdate just because it's an earlier time on the same date Signed-off-by: Dan Briem Signed-off-by: rfrasur Signed-off-by: Dawn Dale Signed-off-by: Jason Boyer --- .../staff/circ/checkin/t_checkin.tt2 | 20 ++++++++-- .../js/ui/default/staff/circ/checkin/app.js | 39 ++++++++++++++----- 2 files changed, 47 insertions(+), 12 deletions(-) diff --git a/Open-ILS/src/templates/staff/circ/checkin/t_checkin.tt2 b/Open-ILS/src/templates/staff/circ/checkin/t_checkin.tt2 index 417f26aeb4..6e505decf3 100644 --- a/Open-ILS/src/templates/staff/circ/checkin/t_checkin.tt2 +++ b/Open-ILS/src/templates/staff/circ/checkin/t_checkin.tt2 @@ -9,9 +9,14 @@
-
- [% l('Backdated Check In [_1]', - '{{checkinArgs.backdate | date:$root.egDateFormat}}') %] +
+
+ [% l('Backdated Check In [_1]', + '{{checkinArgs.backdate | date:$root.egDateFormat}}') %] +
+
+ [% l('Use Effective Date Until Logout') %] +
[% l('Ignore Pre-Cataloged Items') %] @@ -88,6 +93,15 @@
+
+
+
+ +
+
diff --git a/Open-ILS/web/js/ui/default/staff/circ/checkin/app.js b/Open-ILS/web/js/ui/default/staff/circ/checkin/app.js index eb360c9ff7..5c8992241e 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/checkin/app.js +++ b/Open-ILS/web/js/ui/default/staff/circ/checkin/app.js @@ -39,7 +39,7 @@ function($scope , $q , $window , $location , $timeout , egCore , checkinSvc , eg $scope.focusMe = true; $scope.checkins = checkinSvc.checkins; - var today = new Date(); + var today = new Date(new Date().setHours(0,0,0,0)); $scope.checkinArgs = {backdate : today} $scope.modifiers = {}; $scope.fine_total = 0; @@ -90,6 +90,26 @@ function($scope , $q , $window , $location , $timeout , egCore , checkinSvc , eg modifiers.push('noop'); // AKA suppress holds and transits modifiers.push('auto_print_holds_transits'); modifiers.push('do_inventory_update'); + + // backdate is possible so load options + $scope.backdate = {date: egCore.hatch.getSessionItem('eg.circ.checkin.backdate')}; + $scope.backdate.untilLogout = !!$scope.backdate.date; + if ($scope.backdate.untilLogout) + $scope.checkinArgs.backdate = new Date($scope.backdate.date); + + // watch backdate to enable/disable the sticky option + // and ensure the backdate is not in the future + // note: input type=date max=foo not yet supported anywhere + $scope.$watch('checkinArgs.backdate', function(newval) { + if (!newval || newval.getTime() == today.getTime()) { + $scope.backdate.untilLogout = false; + egCore.hatch.removeSessionItem('eg.circ.checkin.backdate'); + } else if (newval > today) { + $scope.checkinArgs.backdate = today; + } else if ($scope.backdate.untilLogout) { + egCore.hatch.setSessionItem('eg.circ.checkin.backdate', newval); + } + }); } // set modifiers from stored preferences @@ -116,16 +136,17 @@ function($scope , $q , $window , $location , $timeout , egCore , checkinSvc , eg } } - - // ensure the backdate is not in the future - // note: input type=date max=foo not yet supported anywhere - $scope.$watch('checkinArgs.backdate', function(newval) { - if (newval && newval > today) - $scope.checkinArgs.backdate = today; - }); + $scope.onUntilLogoutChange = function() { + if ($scope.backdate.untilLogout) + egCore.hatch.setSessionItem('eg.circ.checkin.backdate', + $scope.checkinArgs.backdate + ); + else + egCore.hatch.removeSessionItem('eg.circ.checkin.backdate'); + }; $scope.is_backdate = function() { - return $scope.checkinArgs.backdate < today; + return $scope.checkinArgs.backdate && $scope.checkinArgs.backdate < today; } var checkinGrid = $scope.gridControls = {}; -- 2.43.2