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 egCore.startup.go(); // standalone mode requires manual startup
11 $scope.grid_provider = egGridDataProvider.instance({});
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();
17 var deferred = $q.defer();
21 'open-ils.actor.users.negative_balance',
22 egCore.auth.token(), $scope.context_org.id())
23 .then(deferred.resolve, null, function(blob) {
24 // Give the grid a top-level identifier field
25 blob.usr_id = blob.usr.id();
29 return deferred.promise;
32 $scope.org_changed = function(org) {
33 $scope.context_org = org; // hmm, why necessary.
34 $scope.grid_provider.refresh();
37 // NOTE: Chrome only allows one tab/window to open per user
38 // action. Only the first patron will be displayed.
39 $scope.get_user = function(selected) {
40 if (!selected.length) return;
41 angular.forEach(selected, function(data) {
43 var url = $location.absUrl().replace(
45 'circ/patron/' + data.usr.id() + '/checkout');
46 $window.open(url, '_blank')