1 angular.module('egItemMissingPieces',
2 ['ngRoute', 'ui.bootstrap', 'egCoreMod','egUiMod'])
4 .controller('MissingPiecesCtrl',
5 ['$scope','$q','$window','$location','egCore','egConfirmDialog','egAlertDialog','egCirc','egItem',
6 function($scope, $q, $window, $location, egCore, egConfirmDialog, egAlertDialog, egCirc, itemSvc) {
8 $scope.selectMe = true; // focus text input
11 function get_copy(barcode) {
13 return egCore.net.request(
15 'open-ils.actor.get_barcodes',
16 egCore.auth.token(), egCore.auth.user().ws_ou(),
19 .then(function(resp) { // get_barcodes
21 if (evt = egCore.evt.parse(resp)) {
22 console.error(evt.toString());
26 if (!resp || !resp[0]) {
27 $scope.bcNotFound = barcode;
28 $scope.selectMe = true;
32 return egCore.pcrud.search('acp', {id : resp[0].id}, {
35 acp : ['call_number'],
37 bre : ['simple_record']
40 // avoid fleshing MARC on the bre
41 // note: don't add simple_record.. not sure why
48 function mark_missing_pieces(copy) {
49 itemSvc.mark_missing_pieces(copy);
52 $scope.print_letter = function() {
55 content_type : 'text/plain',
56 content : $scope.letter
60 // find the item by barcode, then proceed w/ missing pieces
61 $scope.submitBarcode = function(args) {
63 $scope.bcNotFound = null;
64 if (!args.barcode) return;
66 $scope.selectMe = false;
69 get_copy(args.barcode).then(mark_missing_pieces);