2 * Shared item services for circulation
5 angular.module('egCoreMod')
7 ['egCore','egOrg','egCirc','$uibModal','$q','$timeout','$window','ngToast','egConfirmDialog','egAlertDialog',
8 function(egCore , egOrg , egCirc , $uibModal , $q , $timeout , $window , ngToast , egConfirmDialog , egAlertDialog ) {
11 copies : [], // copy barcode search results
12 index : 0 // search grid index
18 acp : ['call_number','location','status','floating','circ_modifier',
19 'age_protect','circ_lib','copy_alerts', 'creator', 'editor', 'circ_as_type', 'latest_inventory', 'total_circ_count'],
20 acn : ['record','prefix','suffix','label_class'],
21 bre : ['simple_record','creator','editor'],
22 alci : ['inventory_workstation']
25 // avoid fleshing MARC on the bre
26 // note: don't add simple_record.. not sure why
27 bre : ['id','tcn_value','creator','editor', 'create_date', 'edit_date'],
37 'checkin_workstation',
45 order_by : {combcirc : 'xact_start desc'},
49 //Retrieve separate copy, aacs, and accs information
50 service.getCopy = function(barcode, id) {
52 // handle barcode completion
53 return egCirc.handle_barcode_completion(barcode)
54 .then(function(actual_barcode) {
55 return egCore.pcrud.search(
56 'acp', {barcode : actual_barcode, deleted : 'f'},
57 service.flesh).then(function(copy) {return copy});
61 return egCore.pcrud.retrieve( 'acp', id, service.flesh)
62 .then(function(copy) {return copy});
65 service.getCirc = function(id) {
66 return egCore.pcrud.search('combcirc', { target_copy : id },
67 service.circFlesh).then(function(circ) {return circ});
70 service.getSummary = function(id) {
71 return circ_summary = egCore.net.request(
73 'open-ils.circ.renewal_chain.retrieve_by_circ.summary',
74 egCore.auth.token(), id).then(
75 function(circ_summary) {return circ_summary});
78 //Combine copy, circ, and accs information
79 service.retrieveCopyData = function(barcode, id) {
82 var fetchCopy = function(barcode, id) {
83 return service.getCopy(barcode, id)
84 .then(function(copy) {
89 var fetchCirc = function(copy) {
90 return service.getCirc(copy.id())
91 .then(function(circ) {
96 var fetchSummary = function(circ) {
97 return service.getSummary(circ.id())
98 .then(function(summary) {
99 copyData.circ_summary = summary;
104 return fetchCopy(barcode, id).then(function(res) {
106 if(!res.copy) { return $q.when(); }
107 return fetchCirc(copyData.copy).then(function(res) {
109 return fetchSummary(copyData.circ).then(function() {
120 // resolved with the last received copy
121 service.fetch = function(barcode, id, noListDupes, noPrepend) {
127 return service.retrieveCopyData(barcode, id)
128 .then(function(copyData) {
129 if(!copyData) { return $q.when(); }
130 //Make sure we're getting a completed copyData - no plain acp or circ objects
132 // flesh circ_lib locally
133 copyData.circ.circ_lib(egCore.org.get(copyData.circ.circ_lib()));
139 // use the existing copy if possible
140 flatCopy = service.copies.filter(
141 function(c) {return c.id == copyData.copy.id()})[0];
144 // flesh acn.owning_lib
145 copyData.copy.call_number().owning_lib(egCore.org.get(copyData.copy.call_number().owning_lib()));
148 flatCopy = egCore.idl.toHash(copyData.copy, true);
151 flatCopy._circ = egCore.idl.toHash(copyData.circ, true);
152 flatCopy._circ_summary = egCore.idl.toHash(copyData.circ_summary, true);
153 flatCopy._circ_lib = copyData.circ.circ_lib();
154 flatCopy._duration = copyData.circ.duration();
155 flatCopy._circ_ws = flatCopy._circ_summary.last_renewal_workstation ?
156 flatCopy._circ_summary.last_renewal_workstation :
157 flatCopy._circ_summary.checkout_workstation ?
158 flatCopy._circ_summary.checkout_workstation :
161 flatCopy.index = service.index++;
162 flatCopy.copy_alert_count = copyData.copy.copy_alerts().filter(function(aca) {
163 return !aca.ack_time();
167 service.copies.unshift(flatCopy);
171 //Get in-house use count
172 egCore.pcrud.search('aihu',
173 {item : flatCopy.id}, {}, {idlist : true, atomic : true})
174 .then(function(uses) {
175 flatCopy._inHouseUseCount = uses.length;
176 copyData.copy._inHouseUseCount = uses.length;
179 //Get Monograph Parts
180 egCore.pcrud.search('acpm',
181 {target_copy: flatCopy.id},
182 { flesh : 1, flesh_fields : { acpm : ['part'] } },
184 .then(function(acpm_array) {
185 angular.forEach(acpm_array, function(acpm) {
186 flatCopy.parts = egCore.idl.toHash(acpm.part());
187 copyData.copy.parts = egCore.idl.toHash(acpm.part());
195 copy : copyData.copy,
196 index : flatCopy.index
203 //all_items = selected grid rows, to be updated in place
204 service.updateInventory = function(copy_list, all_items) {
205 if (copy_list.length == 0) return;
206 return egCore.net.request(
208 'open-ils.circ.circulation.update_copy_inventory',
209 egCore.auth.token(), {copy_list: copy_list}
210 ).then(function(res) {
212 if (all_items) angular.forEach(copy_list, function(copy) {
213 angular.forEach(all_items, function(item) {
214 if (copy == item.id) {
215 egCore.pcrud.search('alci', {copy: copy},
216 {flesh: 1, flesh_fields:
217 {alci: ['inventory_workstation']}
218 }).then(function(alci) {
219 //update existing grid rows
221 item["latest_inventory.inventory_date"] = alci.inventory_date();
222 item["latest_inventory.inventory_workstation.name"] =
223 alci.inventory_workstation().name();
234 service.add_copies_to_bucket = function(list, bucket_type) {
235 if (list.length == 0) return;
236 if (!bucket_type) bucket_type = 'copy';
238 return $uibModal.open({
239 templateUrl: './cat/catalog/t_add_to_bucket',
244 ['$scope','$uibModalInstance',
245 function($scope , $uibModalInstance) {
247 $scope.bucket_id = 0;
248 $scope.newBucketName = '';
249 $scope.allBuckets = [];
253 'open-ils.actor.container.retrieve_by_class.authoritative',
254 egCore.auth.token(), egCore.auth.user().id(),
255 bucket_type, 'staff_client'
256 ).then(function(buckets) { $scope.allBuckets = buckets; });
258 $scope.add_to_bucket = function() {
259 var promise = $q.when();
260 angular.forEach(list, function (entry) {
261 var item = bucket_type == 'copy' ? new egCore.idl.ccbi() : new egCore.idl.cbrebi();
262 item.bucket($scope.bucket_id);
263 if (bucket_type == 'copy') item.target_copy(entry);
264 if (bucket_type == 'biblio') item.target_biblio_record_entry(entry);
265 promise = promise.then(function() {
266 return egCore.net.request(
268 'open-ils.actor.container.item.create',
269 egCore.auth.token(), bucket_type, item
273 promise.then(function() {
274 $uibModalInstance.close();
278 $scope.add_to_new_bucket = function() {
279 var bucket = bucket_type == 'copy' ? new egCore.idl.ccb() : new egCore.idl.cbreb();
280 bucket.owner(egCore.auth.user().id());
281 bucket.name($scope.newBucketName);
282 bucket.description('');
283 bucket.btype('staff_client');
285 return egCore.net.request(
287 'open-ils.actor.container.create',
288 egCore.auth.token(), bucket_type, bucket
289 ).then(function(bucket) {
290 $scope.bucket_id = bucket;
291 $scope.add_to_bucket();
295 $scope.cancel = function() {
296 $uibModalInstance.dismiss();
302 service.create_carousel_from_items = function(list) {
303 if (list.length == 0) return;
305 return $uibModal.open({
306 templateUrl: './cat/catalog/t_create_carousel',
311 ['$scope','$uibModalInstance',
312 function($scope , $uibModalInstance) {
314 $scope.carousel_name = '';
316 $scope.create_carousel = function() {
317 return egCore.net.request(
319 'open-ils.actor.carousel.create_carousel_from_items',
320 egCore.auth.token(), $scope.carousel_name, list
321 ).then(function(response) {
323 var evt = egCore.evt.parse(response);
327 ngToast.success(egCore.strings.SUCCESS_CAROUSEL_CREATE);
328 $uibModalInstance.close();
334 $scope.cancel = function() {
335 $uibModalInstance.dismiss();
341 service.make_copies_bookable = function(items) {
343 var copies_by_record = {};
344 var record_list = [];
348 var record_id = item['call_number.record.id'];
349 if (typeof copies_by_record[ record_id ] == 'undefined') {
350 copies_by_record[ record_id ] = [];
351 record_list.push( record_id );
353 copies_by_record[ record_id ].push(item.id);
358 var combined_results = [];
359 angular.forEach(record_list, function(record_id) {
363 'open-ils.booking.resources.create_from_copies',
365 copies_by_record[record_id]
366 ).then(function(results) {
367 if (results && results['brsrc']) {
368 combined_results = combined_results.concat(results['brsrc']);
374 $q.all(promises).then(function() {
375 if (combined_results.length > 0) {
377 template: '<eg-embed-frame url="booking_admin_url" handlers="funcs"></eg-embed-frame>',
382 ['$scope','$location','egCore','$uibModalInstance',
383 function($scope , $location , egCore , $uibModalInstance) {
386 ses : egCore.auth.token(),
387 resultant_brsrc : combined_results.map(function(o) { return o[0]; })
390 var booking_path = '/eg/conify/global/booking/resource';
392 $scope.booking_admin_url =
393 $location.absUrl().replace(/\/eg\/staff\/.*/, booking_path);
400 service.book_copies_now = function(barcode) {
401 location.href = "/eg2/staff/booking/create_reservation/for_resource/" + barcode;
404 service.manage_reservations = function(barcode) {
405 location.href = "/eg2/staff/booking/manage_reservations/by_resource/" + barcode;
408 service.requestItems = function(copy_list,record_list) {
409 if (copy_list.length == 0) return;
411 record_list = record_list.filter(function(v,i,s){ // dedup
412 return s.indexOf(v) == i;
416 return $uibModal.open({
417 templateUrl: './cat/catalog/t_request_items',
421 ['$scope','$uibModalInstance','egUser',
422 function($scope , $uibModalInstance , egUser) {
424 $scope.first_user_fetch = true;
428 copy_list : copy_list,
429 record_list : record_list,
430 pickup_lib: egCore.org.get(egCore.auth.user().ws_ou()),
431 user : egCore.auth.user().id(),
432 honor_user_settings :
433 egCore.hatch.getLocalItem('eg.cat.request_items.honor_user_settings')
436 egUser.get( $scope.hold_data.user ).then(function(u) {
438 $scope.barcode = u.card().barcode();
439 $scope.user_name = egUser.format_name(u);
440 $scope.hold_data.user = u.id();
443 $scope.user_name = '';
445 function user_preferred_pickup_lib(u) {
446 var pickup_lib = u.home_ou();
447 angular.forEach(u.settings(), function (s) {
448 if (s.name() == "opac.default_pickup_location") {
449 pickup_lib = s.value();
452 return egOrg.get(pickup_lib);
454 $scope.$watch('barcode', function (n) {
455 if (!$scope.first_user_fetch) {
456 egUser.getByBarcode(n).then(function(u) {
458 $scope.user_name = egUser.format_name(u);
459 $scope.hold_data.user = u.id();
460 if ($scope.hold_data.honor_user_settings) {
461 $scope.hold_data.pickup_lib = user_preferred_pickup_lib(u);
465 $scope.user_name = '';
466 delete $scope.hold_data.user;
469 $scope.first_user_fetch = false;
471 $scope.$watch('hold_data.honor_user_settings', function (n) {
472 if (n && $scope.user) {
473 $scope.hold_data.pickup_lib = user_preferred_pickup_lib($scope.user);
475 $scope.hold_data.pickup_lib = egCore.org.get(egCore.auth.user().ws_ou());
477 egCore.hatch.setLocalItem('eg.cat.request_items.honor_user_settings',n);
480 $scope.ok = function(h) {
483 hold_type : h.hold_type,
484 pickup_lib: h.pickup_lib.id(),
490 'open-ils.circ.holds.test_and_create.batch.override',
491 egCore.auth.token(), args,
492 h.hold_type == 'T' ? h.record_list : h.copy_list,
493 { 'all' : 1, 'honor_user_settings' : h.honor_user_settings }
495 console.log('request result',r);
496 if (isNaN(r.result)) {
497 if (typeof r.result.desc != 'undefined') {
498 ngToast.danger(r.result.desc);
500 if (typeof r.result.last_event != 'undefined') {
501 ngToast.danger(r.result.last_event.desc);
503 ngToast.danger(egCore.strings.FAILURE_HOLD_REQUEST);
507 ngToast.success(egCore.strings.SUCCESS_HOLD_REQUEST);
511 $uibModalInstance.close();
514 $scope.cancel = function($event) {
515 $uibModalInstance.dismiss();
516 $event.preventDefault();
522 service.attach_to_peer_bib = function(items) {
523 if (items.length == 0) return;
525 egCore.hatch.getItem('eg.cat.marked_conjoined_record').then(function(target_record) {
526 if (!target_record) return;
528 return $uibModal.open({
529 templateUrl: './cat/catalog/t_conjoined_selector',
533 ['$scope','$uibModalInstance',
534 function($scope , $uibModalInstance) {
535 $scope.update = false;
537 $scope.peer_type = null;
538 $scope.peer_type_list = [];
540 get_peer_types = function() {
542 return $q.when(egCore.env.bpt.list);
544 return egCore.pcrud.retrieveAll('bpt', null, {atomic : true})
545 .then(function(list) {
546 egCore.env.absorbList(list, 'bpt');
551 get_peer_types().then(function(list){
552 $scope.peer_type_list = list;
555 $scope.ok = function(type) {
558 angular.forEach(items, function (cp) {
559 var n = new egCore.idl.bpbcm();
561 n.peer_record(target_record);
562 n.target_copy(cp.id);
564 promises.push(egCore.pcrud.create(n).then(function(){service.add_barcode_to_list(cp.barcode)}));
567 return $q.all(promises).then(function(){$uibModalInstance.close()});
570 $scope.cancel = function($event) {
571 $uibModalInstance.dismiss();
572 $event.preventDefault();
579 service.selectedHoldingsCopyDelete = function (items) {
580 if (items.length == 0) return;
582 var copy_objects = [];
583 egCore.pcrud.search('acp',
584 {deleted : 'f', id : items.map(function(el){return el.id;}) },
585 { flesh : 1, flesh_fields : { acp : ['call_number'] } }
589 var perCnCopies = {};
599 var cn_id = cp.call_number().id();
600 if (!cnHash[cn_id]) {
601 cnHash[cn_id] = cp.call_number();
602 perCnCopies[cn_id] = [cp];
604 perCnCopies[cn_id].push(cp);
606 cp.call_number(cn_id); // prevent loops in JSON-ification
610 angular.forEach(perCnCopies, function (v, k) {
615 angular.forEach(cnHash, function (v, k) {
619 if (cnList.length == 0) return;
623 egConfirmDialog.open(
624 egCore.strings.CONFIRM_DELETE_COPIES_VOLUMES,
625 egCore.strings.CONFIRM_DELETE_COPIES_VOLUMES_MESSAGE,
626 {copies : cp_count, volumes : cn_count}
627 ).result.then(function() {
630 'open-ils.cat.asset.volume.fleshed.batch.update',
631 egCore.auth.token(), cnList, 1, flags
632 ).then(function(resp){
633 var evt = egCore.evt.parse(resp);
635 egConfirmDialog.open(
636 egCore.strings.OVERRIDE_DELETE_ITEMS_FROM_CATALOG_TITLE,
637 egCore.strings.OVERRIDE_DELETE_ITEMS_FROM_CATALOG_BODY,
638 {'evt_desc': evt.desc}
639 ).result.then(function() {
642 'open-ils.cat.asset.volume.fleshed.batch.update.override',
643 egCore.auth.token(), cnList, 1,
644 { events: ['TITLE_LAST_COPY', 'COPY_DELETE_WARNING'] }
646 angular.forEach(items, function(cp){service.add_barcode_to_list(cp.barcode)});
650 angular.forEach(items, function(cp){service.add_barcode_to_list(cp.barcode)});
657 copy_objects.push(copy);
661 service.checkin = function (items) {
662 // Recursive function that creates a promise for each item. Once the dialog
663 // window for a given item is closed the next promise is started and a
664 // new dialog is opened.
665 // This keeps multiple popups from hitting the screen at once.
666 (function checkinLoop(i) {
667 if (i < items.length) new Promise((resolve, reject) => {
668 egCirc.checkin({copy_barcode: items[i].barcode})
670 service.add_barcode_to_list(items[i].barcode);
673 }).then(checkinLoop.bind(null, i+1));
677 service.renew = function (items) {
678 angular.forEach(items, function (cp) {
679 egCirc.renew({copy_barcode:cp.barcode}).then(
680 function() { service.add_barcode_to_list(cp.barcode) }
685 service.cancel_transit = function (items) {
686 angular.forEach(items, function(cp) {
687 egCirc.find_copy_transit(null, {copy_barcode:cp.barcode})
688 .then(function(t) { return egCirc.abort_transit(t.id()) })
689 .then(function() { return service.add_barcode_to_list(cp.barcode) });
693 service.selectedHoldingsDamaged = function (items) {
694 angular.forEach(items, function(cp) {
696 egCirc.mark_damaged({
705 service.selectedHoldingsDiscard = function (items) {
706 egCirc.mark_discard(items.map(function(el){return {id : el.id, barcode : el.barcode};})).then(function(){
707 angular.forEach(items, function(cp){service.add_barcode_to_list(cp.barcode)});
711 service.selectedHoldingsMissing = function (items) {
712 return egCirc.mark_missing(
713 items.map(function(el){return {id : el.id, barcode : el.barcode};})
714 ).then(function(modified){
715 var promise = $q.when();
716 angular.forEach(modified, function(barcode){
717 promise = promise.then(function() {
718 return service.add_barcode_to_list(barcode, true);
725 service.gatherSelectedRecordIds = function (items) {
730 if (rid_list.indexOf(item['call_number.record.id']) == -1)
731 rid_list.push(item['call_number.record.id'])
737 service.gatherSelectedVolumeIds = function (items,rid) {
742 if (rid && item['call_number.record.id'] != rid) return;
743 if (cn_id_list.indexOf(item['call_number.id']) == -1)
744 cn_id_list.push(item['call_number.id'])
750 service.gatherSelectedHoldingsIds = function (items,rid) {
755 if (rid && item['call_number.record.id'] != rid) return;
756 cp_id_list.push(item.id)
762 service.spawnHoldingsAdd = function (items,use_vols,use_copies){
763 angular.forEach(service.gatherSelectedRecordIds(items), function (r) {
765 if (use_copies) { // just a copy on existing volumes
766 angular.forEach(service.gatherSelectedVolumeIds(items,r), function (v) {
767 raw.push( {callnumber : v} );
769 } else if (use_vols) {
771 service.gatherSelectedHoldingsIds(items,r),
773 angular.forEach(items, function(item) {
775 // owning_lib may be fleshed.
776 var owner = item['call_number.owning_lib.id']
777 || item['call_number.owning_lib'];
778 raw.push({owner : owner});
785 if (raw.length == 0) raw.push({});
789 'open-ils.actor.anon_cache.set_value',
790 null, 'edit-these-copies', {
796 ).then(function(key) {
798 var tab = (hide_vols === true) ? 'attrs' : 'holdings';
799 var url = '/eg2/staff/cat/volcopy/' + tab + '/session/ ' + key;
800 $timeout(function() { $window.open(url, '_blank') });
802 alert('Could not create anonymous cache key!');
808 service.spawnHoldingsEdit = function (items,hide_vols,hide_copies){
810 angular.forEach(items, function(i){
814 // provide record_id iff one record is selected.
815 // 0 disables record summary
816 var record_ids = service.gatherSelectedRecordIds(items);
817 var record_id = record_ids.length === 1 ? record_ids[0] : 0;
820 'open-ils.actor.anon_cache.set_value',
824 record_id: record_id,
827 hide_vols : hide_vols,
828 hide_copies : hide_copies
829 }).then(function(key) {
831 var tab = (hide_vols === true) ? 'attrs' : 'holdings';
832 var url = '/eg2/staff/cat/volcopy/' + tab + '/session/ ' + key;
833 $timeout(function() { $window.open(url, '_blank') });
835 alert('Could not create anonymous cache key!');
840 service.replaceBarcodes = function(items) {
841 angular.forEach(items, function (cp) {
843 templateUrl: './cat/share/t_replace_barcode',
847 ['$scope','$uibModalInstance',
848 function($scope , $uibModalInstance) {
849 $scope.isModal = true;
850 $scope.focusBarcode = false;
851 $scope.focusBarcode2 = true;
852 $scope.barcode1 = cp.barcode;
854 $scope.updateBarcode = function() {
855 $scope.copyNotFound = false;
856 $scope.updateOK = false;
858 egCore.pcrud.search('acp',
859 {deleted : 'f', barcode : $scope.barcode1})
860 .then(function(copy) {
863 $scope.focusBarcode = true;
864 $scope.copyNotFound = true;
868 egCore.pcrud.search('acp',
869 {deleted : 'f', barcode : $scope.barcode2})
870 .then(function(newBarcodeCopy) {
872 if (newBarcodeCopy) {
873 $scope.duplicateBarcode = true;
877 $scope.copyId = copy.id();
881 'open-ils.cat.update_copy_barcode',
882 egCore.auth.token(), $scope.copyId, $scope.barcode2
883 ).then(function(resp) {
884 var evt = egCore.evt.parse(resp);
886 console.log('toast 0 here 2', evt);
888 $scope.updateOK = true;
889 $scope.focusBarcode = true;
890 $scope.focusBarcode2 = false;
891 service.add_barcode_to_list($scope.barcode2);
892 $uibModalInstance.close();
898 console.log('toast 1 here 2',E);
900 console.log('toast 2 here 2',E);
904 $scope.cancel = function($event) {
905 $uibModalInstance.dismiss();
906 $event.preventDefault();
914 // this "transfers" selected copies to a new owning library,
915 // auto-creating volumes and deleting unused volumes as required.
916 service.changeItemOwningLib = function(items) {
917 var xfer_target = egCore.hatch.getLocalItem('eg.cat.transfer_target_lib');
918 if (!xfer_target || !items.length) {
921 var vols_to_move = {};
922 var copies_to_move = {};
923 angular.forEach(items, function(item) {
924 if (item['call_number.owning_lib'] != xfer_target) {
925 if (item['call_number.id'] in vols_to_move) {
926 copies_to_move[item['call_number.id']].push(item.id);
928 vols_to_move[item['call_number.id']] = {
929 label : item['call_number.label'],
930 label_class : item['call_number.label_class'],
931 record : item['call_number.record.id'],
932 prefix : item['call_number.prefix.id'],
933 suffix : item['call_number.suffix.id']
935 copies_to_move[item['call_number.id']] = new Array;
936 copies_to_move[item['call_number.id']].push(item.id);
942 angular.forEach(vols_to_move, function(vol, vol_id) {
943 promises.push(egCore.net.request(
945 'open-ils.cat.call_number.find_or_create',
953 ).then(function(resp) {
954 var evt = egCore.evt.parse(resp);
956 return egCore.net.request(
958 'open-ils.cat.transfer_copies_to_volume',
961 copies_to_move[vol_id]
969 angular.forEach(items, function(cp){service.add_barcode_to_list(cp.barcode)});
974 service.transferItems = function (items){
975 var xfer_target = egCore.hatch.getLocalItem('eg.cat.transfer_target_vol');
976 var copy_ids = service.gatherSelectedHoldingsIds(items);
977 if (xfer_target && copy_ids.length > 0) {
980 'open-ils.cat.transfer_copies_to_volume',
985 function(resp) { // oncomplete
986 var evt = egCore.evt.parse(resp);
988 egConfirmDialog.open(
989 egCore.strings.OVERRIDE_TRANSFER_COPIES_TO_MARKED_VOLUME_TITLE,
990 egCore.strings.OVERRIDE_TRANSFER_COPIES_TO_MARKED_VOLUME_BODY,
992 ).result.then(function() {
995 'open-ils.cat.transfer_copies_to_volume.override',
999 { events: ['TITLE_LAST_COPY', 'COPY_DELETE_WARNING'] }
1001 }).then(function() {
1002 angular.forEach(items, function(cp){service.add_barcode_to_list(cp.barcode)});
1005 angular.forEach(items, function(cp){service.add_barcode_to_list(cp.barcode)});
1015 service.mark_missing_pieces = function(copy,outer_scope) {
1016 var b = copy.barcode();
1017 var t = egCore.idl.toHash(copy.call_number()).record.title;
1018 egConfirmDialog.open(
1019 egCore.strings.CONFIRM_MARK_MISSING_TITLE,
1020 egCore.strings.CONFIRM_MARK_MISSING_BODY,
1021 { barcode : b, title : t }
1022 ).result.then(function() {
1024 // kick off mark missing
1025 return egCore.net.request(
1027 'open-ils.circ.mark_item_missing_pieces',
1028 egCore.auth.token(), copy.id()
1031 }).then(function(resp) {
1032 var evt = egCore.evt.parse(resp); // should always produce event
1034 if (evt.textcode == 'ACTION_CIRCULATION_NOT_FOUND') {
1035 return egAlertDialog.open(
1036 egCore.strings.CIRC_NOT_FOUND, {barcode : copy.barcode()});
1039 var payload = evt.payload;
1041 // TODO: open copy editor inline? new tab?
1043 // print the missing pieces slip
1044 var promise = $q.when();
1046 // wait for completion, since it may spawn a confirm dialog
1047 promise = egCore.print.print({
1048 context : 'receipt',
1049 content_type : 'text/html',
1050 content : payload.slip.template_output().data()
1054 if (payload.letter) {
1055 outer_scope.letter = payload.letter.template_output().data();
1058 // apply patron penalty
1060 promise.then(function() {
1061 egCirc.create_penalty(payload.circ.usr())
1068 service.print_spine_labels = function(copy_ids){
1071 'open-ils.actor.anon_cache.set_value',
1072 null, 'print-labels-these-copies', {
1075 ).then(function(key) {
1077 var url = egCore.env.basePath + 'cat/printlabels/' + key;
1078 $timeout(function() { $window.open(url, '_blank') });
1080 alert('Could not create anonymous cache key!');
1085 service.show_in_catalog = function(copy_list){
1086 angular.forEach(copy_list, function(copy){
1087 window.open('/eg2/staff/catalog/record/'+copy['call_number.record.id'], '_blank')
1093 .filter('string_pick', function() { return function(i){ return arguments[i] || ''; }; })