]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/web/js/ui/default/staff/cat/item/missing_pieces.js
LP2042879 Shelving Location Groups Admin accessibility
[working/Evergreen.git] / Open-ILS / web / js / ui / default / staff / cat / item / missing_pieces.js
1 angular.module('egItemMissingPieces',
2     ['ngRoute', 'ui.bootstrap', 'egCoreMod','egUiMod'])
3
4 .controller('MissingPiecesCtrl',
5        ['$scope','$q','$window','$location','egCore','egConfirmDialog','egAlertDialog','egCirc','egItem',
6 function($scope, $q, $window, $location, egCore, egConfirmDialog, egAlertDialog, egCirc, itemSvc) {
7     
8     $scope.selectMe = true; // focus text input
9     $scope.args = {};
10
11     function get_copy(barcode) {
12
13         return egCore.net.request(
14             'open-ils.actor',
15             'open-ils.actor.get_barcodes',
16             egCore.auth.token(), egCore.auth.user().ws_ou(), 
17             'asset', barcode)
18
19         .then(function(resp) { // get_barcodes
20
21             if (evt = egCore.evt.parse(resp)) {
22                 console.error(evt.toString());
23                 return $q.reject();
24             }
25
26             if (!resp || !resp[0]) {
27                 $scope.bcNotFound = barcode;
28                 $scope.selectMe = true;
29                 return $q.reject();
30             }
31
32             return egCore.pcrud.search('acp', {id : resp[0].id}, {
33                 flesh : 3, 
34                 flesh_fields : {
35                     acp : ['call_number'],
36                     acn : ['record'],
37                     bre : ['simple_record']
38                 },
39                 select : { 
40                     // avoid fleshing MARC on the bre
41                     // note: don't add simple_record.. not sure why
42                     bre : ['id']
43                 } 
44             })
45         })
46     }
47
48     function mark_missing_pieces(copy) {
49         itemSvc.mark_missing_pieces(copy,$scope);
50     }
51
52     $scope.print_letter = function() {
53         egCore.print.print({
54             context : 'mail',
55             content_type : 'text/plain',
56             content : $scope.letter
57         });
58     }
59
60     // find the item by barcode, then proceed w/ missing pieces
61     $scope.submitBarcode = function(args) {
62
63         $scope.bcNotFound = null;
64         if (!args.barcode) return;
65
66         $scope.selectMe = false;
67         $scope.letter = null;
68
69         get_copy(args.barcode).then(function(c){ return mark_missing_pieces(c,$scope) });
70     }
71
72 }])
73