webstaff: users with negative balance
authorBill Erickson <berickxx@gmail.com>
Mon, 5 Oct 2015 02:05:58 +0000 (22:05 -0400)
committerKathy Lussier <klussier@masslnc.org>
Tue, 2 Feb 2016 19:58:53 +0000 (14:58 -0500)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Open-ILS/src/templates/staff/admin/local/circ/neg_balance_users.tt2 [new file with mode: 0644]
Open-ILS/src/templates/staff/admin/local/t_splash.tt2
Open-ILS/web/js/ui/default/staff/admin/local/circ/neg_balance_users.js [new file with mode: 0644]

diff --git a/Open-ILS/src/templates/staff/admin/local/circ/neg_balance_users.tt2 b/Open-ILS/src/templates/staff/admin/local/circ/neg_balance_users.tt2
new file mode 100644 (file)
index 0000000..73d7ec8
--- /dev/null
@@ -0,0 +1,55 @@
+[%
+  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 %]
index 8aa67de..c55235f 100644 (file)
@@ -22,8 +22,8 @@
     </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>
@@ -42,8 +42,8 @@
     </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>
@@ -62,8 +62,8 @@
     </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">
diff --git a/Open-ILS/web/js/ui/default/staff/admin/local/circ/neg_balance_users.js b/Open-ILS/web/js/ui/default/staff/admin/local/circ/neg_balance_users.js
new file mode 100644 (file)
index 0000000..43fa878
--- /dev/null
@@ -0,0 +1,46 @@
+
+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')
+            });
+        });
+    }
+}])