patron stat cats
authorBill Erickson <berick@esilibrary.com>
Wed, 11 Jun 2014 13:53:59 +0000 (09:53 -0400)
committerBill Erickson <berick@esilibrary.com>
Wed, 11 Jun 2014 13:53:59 +0000 (09:53 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/templates/staff/circ/patron/index.tt2
Open-ILS/src/templates/staff/circ/patron/t_stat_cats.tt2 [new file with mode: 0644]
Open-ILS/src/templates/staff/circ/patron/t_summary.tt2
Open-ILS/web/js/ui/default/staff/circ/patron/app.js

index f2272dd..01bdabf 100644 (file)
@@ -118,6 +118,11 @@ angular.module('egCoreMod').run(['egStrings', function(s) {
             </a>
           </li>
           <li>
+            <a href="./circ/patron/{{patron().id()}}/stat_cats">
+              [% l('Statistical Categories') %]
+            </a>
+          </li>
+          <li>
             <a href="./circ/patron/{{patron().id()}}/group">
               [% l('Group Member Details') %]
             </a>
diff --git a/Open-ILS/src/templates/staff/circ/patron/t_stat_cats.tt2 b/Open-ILS/src/templates/staff/circ/patron/t_stat_cats.tt2
new file mode 100644 (file)
index 0000000..21eb217
--- /dev/null
@@ -0,0 +1,19 @@
+<div class="row pad-vert" ng-repeat="map in patron().stat_cat_entries()">
+  <div class="col-md-12 well" style="margin-left:12px">
+    <div class="row">
+      <div class="col-md-7">
+        <span class="strong-text">{{map.stat_cat().name()}}</span>
+        <span class="pad-horiz">{{map.stat_cat_entry()}}</span>
+      </div>
+      <div class="col-md-5">
+        <div class="pull-right">
+          <span class="pad-horiz alert alert-warning" 
+            ng-if="map.stat_cat().opac_visible() == 't'">[% l('Patron Visible') %]</span>
+          <span class="pad-horiz alert alert-info" 
+            ng-if="map.stat_cat().opac_visible() == 'f'">[% l('Staff Only') %]</span>
+          <span>[% l('@ [_1]', '{{map.stat_cat().owner().shortname()}}') %]</span>
+        </div>
+      </div>
+    </div>
+  </div>
+</div>
index cbbc366..186e8fa 100644 (file)
       <div class="col-md-5">[% l('Email') %]</div>
       <div class="col-md-7">{{patron().email()}}</div>
     </div>
-
+    <div class="row" ng-repeat="map in summary_stat_cats()">
+      <div class="col-md-5">{{map.stat_cat().name()}}</div>
+      <div class="col-md-7">{{map.stat_cat_entry()}}</div>
+    </div>
   </div>
 
   <div class="row" ng-repeat="addr in patron().addresses()">
index e1c8c0a..809301b 100644 (file)
@@ -21,25 +21,37 @@ angular.module('egPatronApp', ['ngRoute', 'ui.bootstrap',
         // note: only load settings here needed by all tabs; load tab-
         // specific settings from within their respective controllers
         egCore.env.classLoaders.aous = function() {
-            return egCore.org.settings(
-            [
+            return egCore.org.settings([
                 'circ.obscure_dob',
                 'ui.circ.show_billing_tab_on_bills',
                 'circ.patron_expires_soon_warning'
             ]).then(function(settings) { egCore.env.aous = settings });
         }
 
+        egCore.env.classLoaders.actsc = function() {
+            return egCore.pcrud.search('actsc', 
+                {owner : egCore.org.ancestors(
+                    egCore.auth.user().ws_ou(), true)},
+                {}, {atomic : true}
+            ).then(function(cats) {
+                egCore.env.absorbList(cats, 'actsc');
+            });
+        }
+
         egCore.env.loadClasses.push('aous');
+        egCore.env.loadClasses.push('actsc');
 
         // app-globally modify the default flesh fields for 
-        // fleshed user retrieval
-        egUser.defaultFleshFields = egUser.defaultFleshFields.concat([
-            'profile',
-            'net_access_level',
-            'ident_type',
-            'ident_type2',
-            'cards'
-        ]);
+        // fleshed user retrieval.
+        if (egUser.defaultFleshFields.indexOf('profile') == -1) {
+            egUser.defaultFleshFields = egUser.defaultFleshFields.concat([
+                'profile',
+                'net_access_level',
+                'ident_type',
+                'ident_type2',
+                'cards'
+            ]);
+        }
 
         return egCore.startup.go()
     }]};
@@ -136,6 +148,12 @@ angular.module('egPatronApp', ['ngRoute', 'ui.bootstrap',
         resolve : resolver
     });
 
+    $routeProvider.when('/circ/patron/:id/stat_cats', {
+        templateUrl: './circ/patron/t_stat_cats',
+        controller: 'PatronStatCatsCtrl',
+        resolve : resolver
+    });
+
     $routeProvider.otherwise({redirectTo : '/circ/patron/search'});
 })
 
@@ -232,6 +250,7 @@ function($q , $timeout , $location , egCore,  egUser , $locale) {
     service.localFlesh = function(user) {
         if (typeof user.home_ou() != 'object')
             user.home_ou(egCore.org.get(user.home_ou()));
+
         angular.forEach(
             user.standing_penalties(),
             function(penalty) {
@@ -239,6 +258,19 @@ function($q , $timeout , $location , egCore,  egUser , $locale) {
                     penalty.org_unit(egCore.org.get(penalty.org_unit()));
             }
         );
+
+        service.summary_stat_cats = [];
+
+        // stat_cat_entries == stat_cat_entry_user_map
+        angular.forEach(user.stat_cat_entries(), function(map) {
+            // flesh the stat cat
+            map.stat_cat(egCore.env.actsc.map[map.stat_cat()]);
+            // flesh the owner
+            map.stat_cat().owner(egCore.org.get(map.stat_cat().owner()));
+
+            if (map.stat_cat().usr_summary() == 't')
+                service.summary_stat_cats.push(map);
+        });
     }
 
     // resolves to true if the patron account has expired or will
@@ -427,6 +459,7 @@ function($scope,  $q,  $location , $filter,  egCore,  egUser,  patronSvc) {
 
     $scope.patron = function() { return patronSvc.current }
     $scope.patron_stats = function() { return patronSvc.patron_stats }
+    $scope.summary_stat_cats = function() { return patronSvc.summary_stat_cats }
 }])
 
 .controller('PatronBarcodeSearchCtrl',
@@ -1237,3 +1270,11 @@ function($scope,  $routeParams , $q , $location , egCore ,
     $scope.moveToAnotherGroup = function(selected) { moveToGroup(selected) };
 }])
 
+.controller('PatronStatCatsCtrl',
+       ['$scope','$routeParams','$q','egCore','patronSvc',
+function($scope,  $routeParams , $q , egCore , patronSvc) {
+    $scope.initTab('other', $routeParams.id);
+    // nothing to do.  Stat cats are already fleshed and patron is
+    // already accessible from the scope.
+}])
+