LP#1685929 - Extract itemSvc from item module to core
[working/Evergreen.git] / Open-ILS / web / js / ui / default / staff / circ / checkin / app.js
index 5428f16..e3bf69a 100644 (file)
@@ -34,14 +34,14 @@ angular.module('egCheckinApp', ['ngRoute', 'ui.bootstrap',
  * Manages checkin
  */
 .controller('CheckinCtrl',
-       ['$scope','$q','$window','$location','egCore','checkinSvc','egGridDataProvider','egCirc',
-function($scope , $q , $window , $location , egCore , checkinSvc , egGridDataProvider , egCirc)  {
+       ['$scope','$q','$window','$location', '$timeout','egCore','checkinSvc','egGridDataProvider','egCirc', 'egItem',
+function($scope , $q , $window , $location , $timeout , egCore , checkinSvc , egGridDataProvider , egCirc, itemSvc)  {
 
     $scope.focusMe = true;
     $scope.checkins = checkinSvc.checkins;
     var today = new Date();
     $scope.checkinArgs = {backdate : today}
-    $scope.using_hatch = egCore.hatch.usingHatch();
+    $scope.using_hatch_printer = egCore.hatch.usePrinting();
     $scope.modifiers = {};
     $scope.fine_total = 0;
     $scope.is_capture = $location.path().match(/capture$/);
@@ -58,6 +58,14 @@ function($scope , $q , $window , $location , egCore , checkinSvc , egGridDataPro
         suppress_popups = set['ui.circ.suppress_checkin_popups'];
     });
 
+    $scope.sort_money = function (a,b) {
+        var ma = parseFloat(a);
+        var mb = parseFloat(b);
+        if (ma < mb) return -1;
+        if (ma > mb) return 1;
+        return 0
+    }
+
     // checkin & hold capture modifiers
     var modifiers = [
         'void_overdues', 
@@ -318,5 +326,53 @@ function($scope , $q , $window , $location , egCore , checkinSvc , egGridDataPro
         });
     }
 
+    $scope.add_copies_to_bucket = function(items){
+        var itemsIds = [];
+        angular.forEach(items, function(cp){
+            itemsIds.push(cp.acp.id());
+        });
+
+        itemSvc.add_copies_to_bucket(itemsIds);
+    }
+
+    $scope.showBibHolds = function(items){
+        var recordIds = [];
+        angular.forEach(items, function(i){
+            recordIds.push(i.acn.record());
+        });
+        angular.forEach(recordIds, function (r) {
+            var url = egCore.env.basePath + 'cat/catalog/record/' + r + '/holds';
+            $timeout(function() { $window.open(url, '_blank') });
+        });
+    }
+
+    $scope.showLastCircs = function(items){
+        var itemIds = [];
+        angular.forEach(items, function(cp){
+            itemIds.push(cp.acp.id());
+        });
+        angular.forEach(itemIds, function (id) {
+            var url = egCore.env.basePath + 'cat/item/' + id + '/circs';
+            $timeout(function() { $window.open(url, '_blank') });
+        });
+    }
+
+    $scope.selectedHoldingsVolCopyEdit = function (items) {
+        var itemObjs = [];
+        angular.forEach(items, function(i){
+            var h = egCore.idl.toHash(i);
+            h['call_number.record.id'] = h.record.doc_id;
+            itemObjs.push(h);
+        });
+        itemSvc.spawnHoldingsEdit(itemObjs,false,false);
+    }
+
+    $scope.show_mark_missing_pieces = function(items){
+        angular.forEach(items, function(i){
+            i.acp.call_number(i.acn);
+            i.acp.call_number().record(i.record);
+            itemSvc.mark_missing_pieces(i.acp);
+        });
+    }
 }])