From ad954bc342e31a27cdd610592e98572e7c21d3c0 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 25 Jun 2014 11:08:22 -0400 Subject: [PATCH] checkin; backdate post checkin Signed-off-by: Bill Erickson --- .../staff/circ/checkin/t_checkin_table.tt2 | 8 ++- .../staff/circ/share/t_backdate_dialog.tt2 | 24 ++++++++ .../web/js/ui/default/staff/circ/checkin/app.js | 24 ++++++-- .../web/js/ui/default/staff/circ/services/circ.js | 66 ++++++++++++++++++++-- 4 files changed, 112 insertions(+), 10 deletions(-) create mode 100644 Open-ILS/src/templates/staff/circ/share/t_backdate_dialog.tt2 diff --git a/Open-ILS/src/templates/staff/circ/checkin/t_checkin_table.tt2 b/Open-ILS/src/templates/staff/circ/checkin/t_checkin_table.tt2 index 4b9024dc33..79392c1c0e 100644 --- a/Open-ILS/src/templates/staff/circ/checkin/t_checkin_table.tt2 +++ b/Open-ILS/src/templates/staff/circ/checkin/t_checkin_table.tt2 @@ -13,6 +13,10 @@ handler="fetchLastCircPatron" label="[% l('Retrieve Last Patron Who Circulated Item') %]"> + + @@ -34,7 +38,7 @@ path='circ.id'> + path='circ.checkin_time' dateformat='short'> @@ -59,7 +63,7 @@ + path='circ.due_date' dateformat='short' hidden> diff --git a/Open-ILS/src/templates/staff/circ/share/t_backdate_dialog.tt2 b/Open-ILS/src/templates/staff/circ/share/t_backdate_dialog.tt2 new file mode 100644 index 0000000000..034e9091bc --- /dev/null +++ b/Open-ILS/src/templates/staff/circ/share/t_backdate_dialog.tt2 @@ -0,0 +1,24 @@ + + + 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 840ddb5ef3..f40415c7d8 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 @@ -213,10 +213,8 @@ function($scope , $q , $window , $location , egCore , checkinSvc , egGridDataPro var checkin = items[0]; if (!checkin || !checkin.acp) return; - egCore.pcrud.search('circ', - {target_copy : checkin.acp.id()}, - {order_by : {circ : 'xact_start desc' }, limit : 1} - ).then(function(circ) { + egCirc.last_copy_circ(checkin.acp.id()) + .then(function(circ) { if (circ) { // jump to the patron UI (separate app) @@ -230,5 +228,23 @@ function($scope , $q , $window , $location , egCore , checkinSvc , egGridDataPro }); } + $scope.showBackdateDialog = function(items) { + var circ_ids = []; + + angular.forEach(items, function(item) { + if (item.circ) circ_ids.push(item.circ.id()); + }); + + if (circ_ids.length) { + egCirc.backdate_dialog(circ_ids).then(function(result) { + angular.forEach(items, function(item) { + item.circ.checkin_time(result.backdate); + }) + }); + // TODO: support grid row styling + checkinGrid.refresh(); + } + } + }]) diff --git a/Open-ILS/web/js/ui/default/staff/circ/services/circ.js b/Open-ILS/web/js/ui/default/staff/circ/services/circ.js index deab3a53b3..1eaa702754 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/services/circ.js +++ b/Open-ILS/web/js/ui/default/staff/circ/services/circ.js @@ -598,6 +598,13 @@ function($modal , $q , egCore , egAlertDialog , egConfirmDialog) { }); } + service.last_copy_circ = function(copy_id) { + return egCore.pcrud.search('circ', + {target_copy : copy_id}, + {order_by : {circ : 'xact_start desc' }, limit : 1} + ); + } + service.circ_exists_dialog = function(evt, params, options) { return $modal.open({ templateUrl: './circ/share/t_circ_exists_dialog', @@ -614,10 +621,7 @@ function($modal , $q , egCore , egAlertDialog , egConfirmDialog) { resolve : { // fetch the conflicting open circulation openCirc : function() { - return egCore.pcrud.search('circ', - {target_copy : evt.payload.copy.id()}, - {order_by : {circ : 'xact_start desc' }, limit : 1} - ); + return service.last_copy_circ(evt.payload.copy.id()); } } }).result.then( @@ -637,6 +641,60 @@ function($modal , $q , egCore , egAlertDialog , egConfirmDialog) { ); } + service.batch_backdate = function(circ_ids, backdate) { + return egCore.net.request( + 'open-ils.circ', + 'open-ils.circ.post_checkin_backdate.batch', + egCore.auth.token(), circ_ids, backdate); + } + + service.backdate_dialog = function(circ_ids) { + return $modal.open({ + templateUrl: './circ/share/t_backdate_dialog', + controller: + ['$scope','$modalInstance', + function($scope , $modalInstance) { + + var today = new Date(); + $scope.dialog = { + num_circs : circ_ids.length, + num_processed : 0, + backdate : today + } + + $scope.$watch('dialog.backdate', function(newval) { + if (newval && newval > today) + $scope.dialog.backdate = today; + }); + + + $scope.cancel = function() { + $modalInstance.dismiss(); + } + + $scope.ok = function() { + + var bd = $scope.dialog.backdate.toISOString().replace(/T.*/,''); + service.batch_backdate(circ_ids, bd) + .then( + function() { // on complete + $modalInstance.close({backdate : bd}); + }, + null, + function(resp) { // on response + console.debug('backdate returned ' + resp); + if (resp == '1') { + $scope.num_processed++; + } else { + console.error(egCore.evt.parse(resp)); + } + } + ); + } + }] + }).result; + } + // alert when copy location alert_message is set. // This does not affect processing, it only produces a click-through -- 2.11.0