--- /dev/null
+[%
+ WRAPPER "staff/base.tt2";
+ ctx.page_title = l("Users with Negative Balances");
+ ctx.page_app = "egAdminCirc";
+ ctx.page_ctrl = 'NegBalances';
+%]
+
+[% BLOCK APP_JS %]
+<script src="[% ctx.media_prefix %]/js/ui/default/staff/services/grid.js"></script>
+<script src="[% ctx.media_prefix %]/js/ui/default/staff/services/ui.js"></script>
+<script src="[% ctx.media_prefix %]/js/ui/default/staff/admin/local/circ/neg_balance_users.js"></script>
+<link rel="stylesheet" href="[% ctx.base_path %]/staff/css/admin.css" />
+[% END %]
+
+<div class="container-fluid" style="text-align:center">
+ <div class="alert alert-info alert-less-pad strong-text-2">
+ [% l('Patrons with Negative Balances') %]
+ </div>
+</div>
+
+<div class="row">
+ <div class="col-md-4">
+ <div class="form-group">
+ <label>[% l('Patron Library') %]</label>
+ <eg-org-selector onchange="org_changed"
+ selected="context_org"></eg-org-selector>
+ </div>
+ </div>
+</div>
+
+<eg-grid
+ id-field="usr_id"
+ features="-sort,-multisort"
+ items-provider="grid_provider"
+ grid-controls="grid_controls"
+ persist-key="admin.local.circ.neg_balance_users">
+
+ <eg-grid-action handler="get_user"
+ label="[% l('Retrieve Patron') %]"></eg-grid-action>
+
+ <eg-grid-field label="[% l('Barred') %]" path='usr.barred'></eg-grid-field>
+ <eg-grid-field label="[% l('Date of Birth') %]" path='usr.dob'></eg-grid-field>
+ <eg-grid-field label="[% l('Last Name') %]" path='usr.family_name'></eg-grid-field>
+ <eg-grid-field label="[% l('First Name') %]" path='usr.first_given_name'></eg-grid-field>
+ <eg-grid-field label="[% l('Middle Name') %]" path='usr.second_given_name'></eg-grid-field>
+ <eg-grid-field label="[% l('Balance Owed') %]" path='balance_owed'></eg-grid-field>
+ <eg-grid-field label="[% l('Last Billing Activity') %]"
+ path='last_billing_activity' datatype='timestamp'></eg-grid-field>
+
+ <eg-grid-field path='usr.*' parent-idl-class="au" hidden></eg-grid-field>
+</eg-grid>
+
+
+
+[% END %]
</div>
<div class="col-md-4">
<span class="glyphicon glyphicon-pencil"></span>
- <a target="_self" href="./admin/local/actor/search_filter_group">
- [% l('Search Filter Groups') %]
+ <a target="_self" href="./admin/local/circ/neg_balance_users">
+ [% l('Patrons with Negative Balances') %]
</a>
</div>
</div>
</div>
<div class="col-md-4">
<span class="glyphicon glyphicon-pencil"></span>
- <a target="_self" href="./admin/local/config/standing_penalty">
- [% l('Standing Penalties') %]
+ <a target="_self" href="./admin/local/actor/search_filter_group">
+ [% l('Search Filter Groups') %]
</a>
</div>
</div>
</div>
<div class="col-md-4">
<span class="glyphicon glyphicon-pencil"></span>
- <a target="_self" href="./admin/local/asset/stat_cat_editor">
- [% l('Statistical Categories Editor') %]
+ <a target="_self" href="./admin/local/config/standing_penalty">
+ [% l('Standing Penalties') %]
</a>
</div>
</div>
[% l('Field Documentation') %]
</a>
</div>
+ <div class="col-md-4">
+ <span class="glyphicon glyphicon-pencil"></span>
+ <a target="_self" href="./admin/local/asset/stat_cat_editor">
+ [% l('Statistical Categories Editor') %]
+ </a>
+ </div>
</div>
<div class="row new-entry">
<div class="col-md-4">
--- /dev/null
+
+angular.module('egAdminCirc',
+ ['ngRoute','ui.bootstrap','egCoreMod','egUiMod','egGridMod'])
+
+.controller('NegBalances',
+ ['$scope','$q','$timeout','$location','$window','egCore','egGridDataProvider',
+function($scope , $q , $timeout , $location , $window , egCore , egGridDataProvider) {
+
+ egCore.startup.go(); // standalone mode requires manual startup
+
+ $scope.grid_provider = egGridDataProvider.instance({});
+
+ // API does not currenlty support paging, so it's all or none.
+ $scope.grid_provider.get = function(offset, count) {
+ if (!$scope.context_org) return $q.when();
+
+ var deferred = $q.defer();
+
+ egCore.net.request(
+ 'open-ils.actor',
+ 'open-ils.actor.users.negative_balance',
+ egCore.auth.token(), $scope.context_org.id())
+ .then(deferred.resolve, null, deferred.notify);
+
+ return deferred.promise;
+ }
+
+ $scope.org_changed = function(org) {
+ $scope.context_org = org; // hmm, why necessary.
+ $scope.grid_provider.refresh();
+ }
+
+ // NOTE: Chrome only allows one tab/window to open per user
+ // action. Only the first patron will be displayed.
+ $scope.get_user = function(selected) {
+ if (!selected.length) return;
+ angular.forEach(selected, function(data) {
+ $timeout(function() {
+ var url = $location.absUrl().replace(
+ /admin\/local\/.*/,
+ 'circ/patron/' + data.usr.id() + '/checkout');
+ $window.open(url, '_blank')
+ });
+ });
+ }
+}])