2 angular.module('egAdminCirc',
3 ['ngRoute','ui.bootstrap','egCoreMod','egUiMod','egGridMod'])
5 .controller('NegBalances',
6 ['$scope','$q','$timeout','$location','$window','egCore','egGridDataProvider',
7 function($scope , $q , $timeout , $location , $window , egCore , egGridDataProvider) {
9 $scope.grid_provider = egGridDataProvider.instance({});
11 // API does not currenlty support paging, so it's all or none.
12 $scope.grid_provider.get = function(offset, count) {
13 if (!$scope.context_org) return $q.when();
15 var deferred = $q.defer();
19 'open-ils.actor.users.negative_balance',
20 egCore.auth.token(), $scope.context_org.id())
21 .then(deferred.resolve, null, function(blob) {
22 // Give the grid a top-level identifier field
23 blob.usr_id = blob.usr.id();
27 return deferred.promise;
30 $scope.org_changed = function(org) {
31 $scope.grid_provider.refresh();
34 $scope.disable_org = function(org_id) {
35 if (!org_id) return true;
36 return egCore.org.get(org_id).ou_type().can_have_users() != 't';
39 // NOTE: Chrome only allows one tab/window to open per user
40 // action. Only the first patron will be displayed.
41 $scope.get_user = function(selected) {
42 if (!selected.length) return;
43 angular.forEach(selected, function(data) {
45 var url = $location.absUrl().replace(
47 'circ/patron/' + data.usr.id() + '/checkout');
48 $window.open(url, '_blank')
53 $scope.grid_controls = {
54 activateItem : function(selected) {
55 // activateItem returns a single row.
56 $scope.get_user([selected])