'[% l("Item [_1] needs to be routed to [_2]",
"{{copy.barcode()}}","{{copy.location().name()}}") %]';
s.MARK_DAMAGED_CONFIRM = '[% l("Mark {{num_items}} items as DAMAGED?") %]';
-s.MARK_DISCARD_CONFIRM = '[% l("Mark {{num_items}} items as DISCARD/WEED?") %]';
s.MARK_MISSING_CONFIRM = '[% l("Mark {{num_items}} items as MISSING?") %]';
+s.MARK_DISCARD_CHECKED_OUT = '[% l("Item to mark Discard/Weed is checked out.") %]';
+s.MARK_DISCARD_IN_TRANSIT = '[% l("Item to mark Discard/Weed is in transit.") %]';
+s.MARK_DISCARD_RESTRICT_DELETE = '[% l("Item to mark Discard/Weed is in a status with a copy delete warning.") %]';
+s.MARK_DISCARD_LAST_HOLD_COPY = '[% l("Item with barcode {{barcode}} is the last item to fill a hold.") %]';
+s.MARK_DISCARD_CONTINUE = '[% l("Do you wish to continue?") %]';
s.ABORT_TRANSIT_CONFIRM = '[% l("Cancel {{num_transits}} transits?") %]';
s.ROUTE_TO_HOLDS_SHELF = '[% l("Holds Shelf") %]';
s.ROUTE_TO_CATALOGING = '[% l("Cataloging") %]';
}).result;
}
- service.mark_discard = function(copy_ids) {
- return egConfirmDialog.open(
- egCore.strings.MARK_DISCARD_CONFIRM, '',
- { num_items : copy_ids.length,
- ok : function() {},
- cancel : function() {}
- }
- ).result.then(function() {
- var promises = [];
- angular.forEach(copy_ids, function(copy_id) {
- promises.push(
- egCore.net.request(
- 'open-ils.circ',
- 'open-ils.circ.mark_item_discard',
- egCore.auth.token(), copy_id
- ).then(function(resp) {
- if (evt = egCore.evt.parse(resp)) {
- console.error('mark discard/weed failed: ' + evt);
- }
- })
- );
+ service.mark_discard = function(copy) {
+ if (!copy) return $q.when();
+ // Make sure the copy status is fleshed.
+ if (!isNaN(copy.status)) {
+ service.flesh_copy_status(copy);
+ }
+ var doRefresh = copy.refresh;
+ var arg = {};
+ if (copy.status.id == 1) {
+ egConfimDialog.open(
+ egCore.strings.MARK_DISCARD_CHECKED_OUT,
+ egCore.strings.MARK_DISCARD_CONTINUE,
+ {
+ ok : function() {},
+ cancel :function() {}
+ }
+ ).result.then(function() {
+ arg.handle_checkin = 1;
});
-
- return $q.all(promises);
+ } else if (copy.status.id == 6) {
+ egConfimDialog.open(
+ egCore.strings.MARK_DISCARD_IN_TRANSIT,
+ egCore.strings.MARK_DISCARD_CONTINUE,
+ {
+ ok : function() {},
+ cancel :function() {}
+ }
+ ).result.then(function() {
+ arg.handle_transit = 1;
+ });
+ } else if (copy.status.restrict_copy_delete == "t") {
+ egConfimDialog.open(
+ egCore.strings.MARK_DISCARD_RESTRICT_DELETE,
+ egCore.strings.MARK_DISCARD_CONTINUE,
+ {
+ ok : function() {},
+ cancel :function() {}
+ }
+ ).result.then(function() {
+ arg.handle_copy_delete_warning = 1;
+ });
+ }
+ var result = egCore.net.request(
+ 'open-ils.circ',
+ 'open-ils.circ.mark_item_discard',
+ egCore.auth.token(), copy.id, arg
+ ).then(function(resp) {
+ if (evt = egCore.evt.parse(resp)) {
+ if (evt.textcode == "ITEM_TO_MARK_LAST_HOLD_COPY") {
+ egConfimDialog.open(
+ egCore.strings.MARK_DISCARD_LAST_HOLD_COPY,
+ egCore.strings.MARK_DISCARD_CONTINUE,
+ {
+ barcode : copy.barcode,
+ ok : function() {},
+ cancel :function() {}
+ }
+ ).result.then(function() {
+ arg.handle_last_hold_copy = 1;
+ result = egCore.net.request(
+ 'open-ils.circ',
+ 'open-ils.circ.mark_item_discard',
+ egCore.auth.token(), copy.id, arg
+ ).then(function(resp) {
+ if (evt == egCore.evt.parse(resp)) {
+ console.error('mark discard/weed failed: ' + evt);
+ doRefresh = false;
+ }
+ });
+ });
+ } else {
+ console.error('mark discard/weed failed: ' + evt);
+ doRefresh = false;
+ }
+ }
});
+ if (doRefresh) {
+ egItem.add_barcode_to_list(copy.barcode);
+ }
+ return result;
}
service.mark_missing = function(copy_ids) {