items-provider="gridDataProvider"
persist-key="circ.patron.items_out">
- <eg-grid-action
- handler="print_receipt"
- label="[% l('Print Item Receipt') %]">
- </eg-grid-action>
- <eg-grid-action
- handler="edit_due_date"
- label="[% l('Edit Due Date') %]">
- </eg-grid-action>
- <eg-grid-action
- handler="mark_lost"
- label="[% l('Mark Lost (By Patron)') %]">
- </eg-grid-action>
- <eg-grid-action
- handler="mark_claims_returned"
- label="[% l('Mark Claims Returned') %]">
- </eg-grid-action>
+ <eg-grid-action handler="print_receipt"
+ label="[% l('Print Item Receipt') %]"></eg-grid-action>
+ <eg-grid-action handler="edit_due_date"
+ label="[% l('Edit Due Date') %]"></eg-grid-action>
+ <eg-grid-action handler="mark_lost"
+ label="[% l('Mark Lost (By Patron)') %]"></eg-grid-action>
+ <eg-grid-action handler="mark_claims_returned"
+ label="[% l('Mark Claims Returned') %]"></eg-grid-action>
+ <eg-grid-action handler="mark_claims_never_checked_out"
+ label="[% l('Mark Claims Never Checked Out') %]"></eg-grid-action>
+ <eg-grid-action handler="renew" label="[% l('Renew') %]"></eg-grid-action>
+ <eg-grid-action handler="renew_all" label="[% l('Renew All') %]"></eg-grid-action>
<eg-grid-field label="[% l('Circ ID') %]" path='id'></eg-grid-field>
<eg-grid-field label="[% l('Barcode') %]" path='target_copy.barcode'>
angular.module('egPatronApp').controller('PatronItemsOutCtrl',
['$scope','$q','$routeParams','egCore','egUser','patronSvc',
- 'egGridDataProvider','$modal','egCirc',
+ 'egGridDataProvider','$modal','egCirc','egConfirmDialog',
function($scope, $q, $routeParams, egCore , egUser, patronSvc ,
- egGridDataProvider , $modal , egCirc) {
+ egGridDataProvider , $modal , egCirc , egConfirmDialog) {
$scope.initTab('items_out', $routeParams.id);
var display_lo = Number(
egCore.env.aous['ui.circ.items_out.longoverdue']) || 1;
var display_cr = Number(
- egCore.env.aous['ui.circ.items_out.claimsreturned']) || 1;
+ egCore.env.aous['ui.circ.items_out.claimsreturned']) || 2;
var provider = egGridDataProvider.instance({});
$scope.gridDataProvider = provider;
});
}
+ // Reload the user to pick up changes in items out, fines, etc.
+ // Reload circs since LOST, etc. items may no longer be applicable for display.
+ function reset_page() {
+ patronSvc.refreshPrimary();
+ patronSvc.items_out = [];
+ patronSvc.items_out_ids = [];
+ provider.refresh()
+ }
+
+ function batch_action_with_barcodes(items, action) {
+ if (!items.length) return;
+ var barcodes = items.map(function(circ)
+ { return circ.target_copy().barcode() });
+ action(barcodes).then(reset_page);
+ }
$scope.mark_lost = function(items) {
+ batch_action_with_barcodes(items, egCirc.mark_lost);
+ }
+ $scope.mark_claims_returned = function(items) {
+ batch_action_with_barcodes(items, egCirc.mark_claims_returned_dialog);
+ }
+ $scope.mark_claims_never_checked_out = function(items) {
+ batch_action_with_barcodes(items, egCirc.mark_claims_never_checked_out);
+ }
+
+ $scope.renew = function(items, msg) {
if (!items.length) return;
- var barcodes = items.map(function(circ) {
- return circ.target_copy().barcode()
- });
+ var barcodes = items.map(function(circ)
+ { return circ.target_copy().barcode() });
- egCirc.mark_lost(barcodes)
- .then(function() {
- // reload the user to pick up changes in items out, fines, etc.
- patronSvc.refreshPrimary();
+ if (!msg) msg = egCore.strings.RENEW_ITEMS;
- // reload circs since LOST items may no longer be applicable
- // for display.
- patronSvc.items_out = [];
- patronSvc.items_out_ids = [];
- provider.refresh()
+ return egConfirmDialog.open(msg, barcodes.join(' '), {}).result
+ .then(function() {
+ function do_one() {
+ var bc = barcodes.pop();
+ if (!bc) { reset_page(); return }
+ // finally -> continue even when one fails
+ egCirc.renew({copy_barcode : bc}).finally(do_one);
+ }
+ do_one();
});
}
- $scope.mark_claims_returned = function(items) {
- if (!items.length) return;
-
- var barcodes = items.map(function(circ) {
- return circ.target_copy().barcode()
- });
-
- egCirc.mark_claims_returned_dialog(barcodes)
- .then(function() {
- // reload the user to pick up changes in items out, fines, etc.
- patronSvc.refreshPrimary();
-
- // reload circs since LOST items may no longer be applicable
- // for display.
- patronSvc.items_out = [];
- patronSvc.items_out_ids = [];
- provider.refresh()
+ $scope.renew_all = function() {
+ var circs = patronSvc.items_out.filter(function(circ) {
+ // all others will be rejected at the server
+ return (
+ !circ.stop_fines() ||
+ circ.stop_fines() == 'MAXFINES'
+ );
});
+ $scope.renew(circs, egCore.strings.RENEW_ALL_ITEMS);
}
}]);
$modalInstance.close();
return;
}
+
+ // finally -> continue even when one fails
service.mark_claims_returned(bc, date)
- .then(function(barcode) {
+ .finally(function(barcode) {
if (barcode) deferred.notify(barcode);
mark_one();
});
}).result;
}
+ // serially checks in each barcode with claims_never_checked_out set
+ // returns promise, notified on each barcode, resolved after all
+ // checkins are complete.
+ service.mark_claims_never_checked_out = function(barcodes) {
+ if (!barcodes.length) return;
+
+ var deferred = $q.defer();
+ egConfirmDialog.open(
+ egCore.strings.MARK_NEVER_CHECKED_OUT, '', {barcodes : barcodes}
+
+ ).result.then(function() {
+ function mark_one() {
+ var bc = barcodes.pop();
+
+ if (!bc) { // all done
+ deferred.resolve();
+ return;
+ }
+
+ service.checkin(
+ {claims_never_checked_out : true, copy_barcode : bc})
+ .finally(function() {
+ deferred.notify(bc);
+ mark_one();
+ })
+ }
+ mark_one();
+ });
+
+ return deferred.promise;
+ }
+
service.mark_damaged = function(copy_ids) {
return egConfirmDialog.open(
egCore.strings.MARK_DAMAGED_CONFIRM, '',