]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/web/js/ui/default/staff/admin/local/circ/neg_balance_users.js
webstaff: users with negative balance
[Evergreen.git] / Open-ILS / web / js / ui / default / staff / admin / local / circ / neg_balance_users.js
1
2 angular.module('egAdminCirc',
3     ['ngRoute','ui.bootstrap','egCoreMod','egUiMod','egGridMod'])
4
5 .controller('NegBalances',
6        ['$scope','$q','$timeout','$location','$window','egCore','egGridDataProvider',
7 function($scope , $q , $timeout , $location , $window , egCore , egGridDataProvider) {
8
9     egCore.startup.go(); // standalone mode requires manual startup
10
11     $scope.grid_provider = egGridDataProvider.instance({});
12
13     // API does not currenlty support paging, so it's all or none.
14     $scope.grid_provider.get = function(offset, count) {
15         if (!$scope.context_org) return $q.when();
16
17         var deferred = $q.defer();
18
19         egCore.net.request(
20             'open-ils.actor',
21             'open-ils.actor.users.negative_balance',
22             egCore.auth.token(), $scope.context_org.id())
23         .then(deferred.resolve, null, deferred.notify);
24
25         return deferred.promise;
26     }
27
28     $scope.org_changed = function(org) {
29         $scope.context_org = org; // hmm, why necessary.
30         $scope.grid_provider.refresh();
31     }
32
33     // NOTE: Chrome only allows one tab/window to open per user
34     // action.  Only the first patron will be displayed.
35     $scope.get_user = function(selected) {
36         if (!selected.length) return;
37         angular.forEach(selected, function(data) {
38             $timeout(function() {
39                 var url = $location.absUrl().replace(
40                     /admin\/local\/.*/,
41                     'circ/patron/' + data.usr.id() + '/checkout');
42                 $window.open(url, '_blank')
43             });
44         });
45     }
46 }])