.controller('PatronItemsOutCtrl',
['$scope','$q','$routeParams','$timeout','egCore','egUser','patronSvc',
'$location','egGridDataProvider','$uibModal','egCirc','egConfirmDialog',
- 'egBilling','$window','egBibDisplay',
+ 'egProgressDialog','egBilling','$window','egBibDisplay',
function($scope , $q , $routeParams , $timeout , egCore , egUser , patronSvc ,
$location , egGridDataProvider , $uibModal , egCirc , egConfirmDialog ,
- egBilling , $window , egBibDisplay) {
+ egProgressDialog , egBilling , $window , egBibDisplay) {
// list of noncatatloged circulations. Define before initTab to
// avoid any possibility of race condition, since they are loaded
// list of alt circs (lost, etc.) and/or check-in with fines circs
$scope.alt_list = [];
+
+ egCore.org.settings([
+ 'ui.circ.suppress_checkin_popups' // add other settings as needed
+ ]).then(function(set) {
+ $scope.suppress_popups = set['ui.circ.suppress_checkin_popups'];
+ });
// these are fetched during startup (i.e. .configure())
// By default, show lost/lo/cr items in the alt list
// noncat_list always involves instantiating a new grid.
}
+ $scope.colorizeItemsOutList = {
+ apply: function(item) {
+ var duedate = item.due_date();
+ if (duedate && duedate < new Date().toISOString()) {
+ return 'overdue-row';
+ }
+ }
+ }
+
// Reload the user to pick up changes in items out, fines, etc.
// Reload circs since the contents of the main vs. alt list may
// have changed.
var deferred = $q.defer();
var rendered = 0;
+ egProgressDialog.open();
+
// fetch the lot of circs and stream the results back via notify
egCore.pcrud.search('circ', {id : id_list},
{ flesh : 4,
flesh_fields : {
circ : ['target_copy', 'workstation', 'checkin_workstation'],
- acp : ['call_number', 'holds_count', 'status', 'circ_lib'],
+ acp : ['call_number', 'holds_count', 'status', 'circ_lib', 'location', 'floating', 'age_protect', 'parts'],
+ acpm : ['part'],
acn : ['record', 'owning_lib', 'prefix', 'suffix'],
bre : ['wide_display_entry']
},
// we need an order-by to support paging
order_by : {circ : ['xact_start']}
- }).then(deferred.resolve, null, function(circ) {
+ }).then(null, null, function(circ) {
circ.circ_lib(egCore.org.get(circ.circ_lib())); // local fleshing
// Translate bib display field JSON blobs to JS.
isbn : function() {return circ.target_copy().dummy_isbn()}
})
}
+ circ._parts = circ.target_copy().parts().map(function(part) {
+ return part.label()
+ }).join(',');
+
+ patronSvc.items_out.push(circ);
+
+ }).then(function() {
+
+ var circIds = patronSvc.items_out.map(function(circ) { return circ.id() });
+
+ egCore.net.request(
+ 'open-ils.actor',
+ 'open-ils.actor.user.itemsout.notices',
+ egCore.auth.token(), circIds
+
+ ).then(deferred.resolve, null, function(notice) {
- // call open-ils to get overdue notice count and Last notice date
-
- egCore.net.request(
- 'open-ils.actor',
- 'open-ils.actor.user.itemsout.notices',
- egCore.auth.token(), circ.id(), $scope.patron_id)
- .then(function(notice){
- if (notice.numNotices){
- circ.action_trigger_event_count = notice.numNotices;
- circ.action_trigger_latest_event_date = notice.lastDt;
- }
- patronSvc.items_out.push(circ);
- });
-
- if (rendered++ >= offset && rendered <= count){ deferred.notify(circ) };
+ var circ = patronSvc.items_out.filter(
+ function(circ) {return circ.id() == notice.circ_id})[0];
+
+ if (notice.numNotices) {
+ circ.action_trigger_event_count = notice.numNotices;
+ circ.action_trigger_latest_event_date = notice.lastDt;
+ }
+
+ if (rendered++ >= offset && rendered <= count) {
+ egProgressDialog.close();
+ deferred.notify(circ);
+ };
+ });
});
return deferred.promise;
// Fire off the due-date updater for each circ.
// When all is done, close the dialog
$scope.ok = function(args) {
- // toISOString gives us Zulu time, so
- // adjust for that before truncating to date
- var adjust_date = new Date( $scope.args.due_date );
- adjust_date.setMinutes(
- $scope.args.due_date.getMinutes() - adjust_date.getTimezoneOffset()
- );
- var due = adjust_date.toISOString().replace(/T.*/,'');
+ var due = $scope.args.due_date.toISOString();
console.debug("applying due date of " + due);
+ egProgressDialog.open();
- var promises = [];
+ var promise = $q.when();
angular.forEach(items, function(circ) {
- promises.push(
- egCore.net.request(
+ promise = promise.then(function() {
+ return egCore.net.request(
'open-ils.circ',
'open-ils.circ.circulation.due_date.update',
egCore.auth.token(), circ.id(), due
// date from the modified circulation.
circ.due_date(new_circ.due_date());
})
- );
+ });
});
- $q.all(promises).then(function() {
+ promise.finally(function() {
+ egProgressDialog.close();
$uibModalInstance.close();
provider.refresh();
});
money_summary : patronSvc.patron_stats.fines,
expire_date : cusr.expire_date(),
alias : cusr.alias(),
- has_email : Boolean(patronSvc.current.email() && patronSvc.current.email().match(/.*@.*/).length),
- has_phone : Boolean(cusr.day_phone() || cusr.evening_phone() || cusr.other_phone())
+ has_email : Boolean(patronSvc.current.email() && patronSvc.current.email().match(/.*@.*/)),
+ has_phone : Boolean(cusr.day_phone() || cusr.evening_phone() || cusr.other_phone()),
+ juvenile : cusr.juvenile()
};
return egCore.print.print({
});
}
+ function batch_action_with_flat_copies(items, action) {
+ if (!items.length) return;
+ var copies = items.map(function(circ)
+ { return egCore.idl.toHash(circ.target_copy()) });
+ action(copies).then(reset_page);
+ }
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_damaged = function(items) {
+ if (items.length == 0) return;
+
+ angular.forEach(items, function(circ) {
+ egCirc.mark_damaged({
+ id: circ.target_copy().id(),
+ barcode: circ.target_copy().barcode(),
+ circ_lib: circ.target_copy().circ_lib().id()
+ }).then(() => $timeout(reset_page,1000)) // reset after each, because rejecting one stops the $q.all() chain
+ });
+ }
+ $scope.mark_missing = function(items) {
+ batch_action_with_flat_copies(items, egCirc.mark_missing);
+ }
$scope.mark_lost = function(items) {
batch_action_with_barcodes(items, egCirc.mark_lost);
}
$scope.show_triggered_events = function(items) {
var focus = items.length == 1;
angular.forEach(items, function(item) {
- var url = egCore.env.basePath +
- '/cat/item/' +
- item.target_copy().id() +
- '/triggered_events';
+ var url = '/eg2/staff/circ/item/event-log/' +
+ item.target_copy().id();
$timeout(function() { var x = $window.open(url, '_blank'); if (focus) x.focus() });
+
});
}
return egConfirmDialog.open(msg, barcodes.join(' '), {}).result
.then(function() {
+ window.oils_cancel_batch = false;
+ window.oils_inside_batch = true;
+ function batch_cleanup() {
+ if (window.oils_inside_batch && window.oils_op_change_within_batch) {
+ window.oils_op_change_undo_func();
+ }
+ window.oils_inside_batch = false;
+ window.oils_op_change_within_batch = false;
+ reset_page();
+ }
function do_one() {
var bc = barcodes.pop();
- if (!bc) { reset_page(); return }
+ if (!bc) {
+ batch_cleanup();
+ return;
+ }
+ if (window.oils_op_change_within_batch) {
+ window.oils_op_change_toast_func();
+ }
// finally -> continue even when one fails
- egCirc.renew({copy_barcode : bc}).finally(do_one);
+ egCirc.renew({copy_barcode : bc}).finally(function() {
+ if (!window.oils_cancel_batch) {
+ do_one();
+ } else {
+ console.log('batch cancelled');
+ batch_cleanup();
+ return;
+ }
+ });
}
do_one();
});
controller : [
'$scope','$uibModalInstance',
function($scope , $uibModalInstance) {
+ var now = new Date();
+ $scope.outOfRange = false;
+ $scope.minDate = new Date(now);
$scope.args = {
barcodes : barcodes,
- date : new Date()
+ date : new Date(now)
}
$scope.cancel = function() {$uibModalInstance.dismiss()}
if (!items.length) return;
var copies = items.map(function(circ) { return circ.target_copy() });
var barcodes = copies.map(function(copy) { return copy.barcode() });
-
- return egConfirmDialog.open(
- egCore.strings.CHECK_IN_CONFIRM, barcodes.join(' '), {
-
- }).result.then(function() {
- var copy;
- function do_one() {
- if (copy = copies.pop()) {
- // Checkin expects a barcode, but will pass other
- // parameters too. Passing the copy ID allows
- // for the checkin of deleted copies on the server.
- egCirc.checkin(
- {copy_barcode: copy.barcode(), copy_id: copy.id()})
- .finally(do_one);
- } else {
- reset_page();
- }
+
+ var copy;
+ function do_one() {
+ if (copy = copies.pop()) {
+ // Checkin expects a barcode, but will pass other
+ // parameters too. Passing the copy ID allows
+ // for the checkin of deleted copies on the server.
+ egCirc.checkin(
+ {copy_barcode: copy.barcode(), copy_id: copy.id()},
+ {suppress_popups: $scope.suppress_popups})
+ .finally(do_one);
+ } else {
+ reset_page();
}
- do_one(); // kick it off
- });
+ }
+ if ($scope.suppress_popups) {
+ do_one();
+ } else {
+ return egConfirmDialog.open(
+ egCore.strings.CHECK_IN_CONFIRM, barcodes.join(' '), {
+
+ }).result.then(function() {
+ do_one(); // kick it off
+ });
+ }
}
$scope.add_billing = function(items) {