item circ history (last few circs)
authorBill Erickson <berick@esilibrary.com>
Mon, 9 Jun 2014 17:09:29 +0000 (13:09 -0400)
committerBill Erickson <berick@esilibrary.com>
Mon, 9 Jun 2014 17:09:29 +0000 (13:09 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/templates/staff/cat/item/index.tt2
Open-ILS/src/templates/staff/cat/item/t_circ_list_pane.tt2 [new file with mode: 0644]
Open-ILS/src/templates/staff/cat/item/t_view.tt2
Open-ILS/web/js/ui/default/staff/cat/item/app.js
Open-ILS/web/js/ui/default/staff/cat/services/record.js
Open-ILS/web/js/ui/default/staff/circ/services/billing.js

index 61f063d..62664af 100644 (file)
@@ -11,6 +11,7 @@
 <script src="[% ctx.media_prefix %]/js/ui/default/staff/services/file.js"></script>
 <script src="[% ctx.media_prefix %]/js/ui/default/staff/cat/item/app.js"></script>
 <script src="[% ctx.media_prefix %]/js/ui/default/staff/cat/services/record.js"></script>
+<script src="[% ctx.media_prefix %]/js/ui/default/staff/circ/services/billing.js"></script>
 [% END %]
 
 <style>
diff --git a/Open-ILS/src/templates/staff/cat/item/t_circ_list_pane.tt2 b/Open-ILS/src/templates/staff/cat/item/t_circ_list_pane.tt2
new file mode 100644 (file)
index 0000000..94abc3f
--- /dev/null
@@ -0,0 +1,46 @@
+<div class="row" ng-repeat="circ in circ_list">
+  
+  <div class="flex-row">
+    <div class="flex-cell well">
+      <a href="./circ/patron/{{circ.usr().id()}}/checkout" target="_self">
+        [% l('[_1], [_2] [_3] : [_4]', 
+          '{{circ.usr().family_name()}}'
+          '{{circ.usr().first_given_name()}}'
+          '{{circ.usr().second_given_name()}}'
+          '{{circ.usr().card().barcode()}}') %]
+      </a>
+      <span class="pad-horiz">[% l('Circulation ID: [_1]', '{{circ.id()}}') %]</span>
+    </div>
+    <div>
+      <button class="btn btn-default" ng-click="addBilling(circ)">
+        [% l('Add Billing') %]
+      </button>
+    </div>
+  </div>
+  <div class="flex-row">
+    <div class="flex-cell">[% l('Check Out Date') %]</div>
+    <div class="flex-cell well">{{circ.xact_start() | date:'short'}}</div>
+    <div class="flex-cell">[% l('Due Date') %]</div>
+    <div class="flex-cell well">{{circ.due_date() | date:'short'}}</div>
+    <div class="flex-cell">[% l('Stop Fines Time') %]</div>
+    <div class="flex-cell well">{{circ.stop_fines_time() | date:'short'}}</div>
+    <div class="flex-cell">[% l('Checkin Time') %]</div>
+    <div class="flex-cell well">{{circ.checkin_time() | date:'short'}}</div>
+  </div>
+  <div class="flex-row">
+    <div class="flex-cell">[% l('Check Out Library') %]</div>
+    <div class="flex-cell well">{{circ.circ_lib().shortname()}}</div>
+    <div class="flex-cell">[% l('Renewal?') %]</div>
+    <div class="flex-cell well">{{
+      circ.phone_renewal() == 't' ||
+      circ.desk_renewal() == 't' ||
+      circ.opac_renewal() == 't'
+    }}</div>
+    <div class="flex-cell">[% l('Stop Fines Reason') %]</div>
+    <div class="flex-cell well">{{circ.stop_fines()}}</div>
+    <div class="flex-cell">[% l('Check In Library') %]</div>
+    <div class="flex-cell well">{{circ.checkin_lib().shortname()}}</div>
+  </div>
+  <hr/>
+</div>
+
index e449591..bbe2993 100644 (file)
@@ -9,7 +9,10 @@
     <a href="./cat/item/{{copy.id()}}">[% l('Quick Summary') %]</a>
   </li>
   <li ng-class="{active : tab == 'circs'}">
-    <a href="./cat/item/{{copy.id()}}/circs">[% l('Circulation History') %]</a>
+    <a href="./cat/item/{{copy.id()}}/circs">[% l('Recent Circ History') %]</a>
+  </li>
+  <li ng-class="{active : tab == 'circ_list'}">
+    <a href="./cat/item/{{copy.id()}}/circ_list">[% l('Circ History List') %]</a>
   </li>
   <li ng-class="{active : tab == 'holds'}">
     <a href="./cat/item/{{copy.id()}}/holds">[% l('Holds / Transit') %]</a>
index 2ac0b09..9ed3ac1 100644 (file)
@@ -199,12 +199,16 @@ function($scope , $q , $location , $timeout , egCore , egGridDataProvider , item
  * Detail view -- shows one copy
  */
 .controller('ViewCtrl', 
-       ['$scope','$q','$location','$routeParams','egCore','itemSvc',
-function($scope , $q, $location , $routeParams , egCore , itemSvc) {
+       ['$scope','$q','$location','$routeParams','egCore','itemSvc','egBilling',
+function($scope , $q , $location , $routeParams , egCore , itemSvc , egBilling) {
     var copyId = $routeParams.id;
     $scope.tab = $routeParams.tab || 'summary';
     $scope.context.page = 'detail';
 
+    // use the cached record info
+    if (itemSvc.copy)
+        $scope.summaryRecord = itemSvc.copy.call_number().record();
+
     function loadCopy(barcode) {
         $scope.context.itemNotFound = false;
 
@@ -248,7 +252,7 @@ function($scope , $q, $location , $routeParams , egCore , itemSvc) {
             copyId = copy.id();
             $scope.copy = copy;
             $scope.recordId = copy.call_number().record().id();
-            $scope.summaryRecord = copy.call_number().record();
+            $scope.summaryRecord = itemSvc.copy.call_number().record();
             $scope.args.barcode = '';
 
             // locally flesh org units
@@ -329,6 +333,73 @@ function($scope , $q, $location , $routeParams , egCore , itemSvc) {
         });
     }
 
+    var maxHistory;
+    function fetchMaxCircHistory() {
+        if (maxHistory) return $q.when(maxHistory);
+        return egCore.org.settings(
+            'circ.item_checkout_history.max')
+        .then(function(set) {
+            maxHistory = set['circ.item_checkout_history.max'] || 4;
+            return maxHistory;
+        });
+    }
+
+    $scope.addBilling = function(circ) {
+        egBilling.showBillDialog({
+            xact_id : circ.id(),
+            patron : circ.usr()
+        });
+    }
+
+    function loadCircHistory() {
+        $scope.circ_list = [];
+
+        var copy_org = 
+            itemSvc.copy.call_number().id() == -1 ?
+            itemSvc.copy.circ_lib().id() :
+            itemSvc.copy.call_number().owning_lib().id()
+
+        // there is an extra layer of permissibility over circ
+        // history views
+        egCore.perm.hasPermAt('VIEW_COPY_CHECKOUT_HISTORY', true)
+        .then(function(orgIds) {
+
+            if (orgIds.indexOf(copy_org) == -1) {
+                console.log('User is not allowed to view circ history');
+                return $q.when(0);
+            }
+
+            return fetchMaxCircHistory();
+
+        }).then(function(count) {
+
+            egCore.pcrud.search('circ', 
+                {target_copy : copyId},
+                {   flesh : 2,
+                    flesh_fields : {
+                        circ : [
+                            'usr',
+                            'workstation',                                         
+                            'checkin_workstation',                                 
+                            'recurring_fine_rule'   
+                        ],
+                        au : ['card']
+                    },
+                    order_by : {circ : 'xact_start desc'}, 
+                    limit :  count
+                }
+
+            ).then(null, null, function(circ) {
+
+                // flesh circ_lib locally
+                circ.circ_lib(egCore.org.get(circ.circ_lib()));
+                circ.checkin_lib(egCore.org.get(circ.checkin_lib()));
+                $scope.circ_list.push(circ);
+            });
+        });
+    }
+
+
     function loadCircCounts() {
 
         delete $scope.circ_counts;
@@ -420,6 +491,10 @@ function($scope , $q, $location , $routeParams , egCore , itemSvc) {
                 loadCurrentCirc(true);
                 break;
 
+            case 'circ_list':
+                loadCircHistory();
+                break;
+
             case 'holds':
                 loadHolds()
                 loadTransits();
index 0dbc251..c6bc882 100644 (file)
@@ -92,6 +92,7 @@ angular.module('egCoreMod')
                     }
                 );
 
+
                 if ($scope.recordId) 
                     loadRecord();
             }
index 57fe012..9a2efb6 100644 (file)
@@ -6,14 +6,14 @@
 angular.module('egCoreMod')
 
 .factory('egBilling', 
-       ['$modal','$q','egCore','egUser',
-function($modal , $q , egCore , egUser) {
+       ['$modal','$q','egCore',
+function($modal , $q , egCore) {
 
     var service = {};
 
     // fetch a fleshed money.billable_xact
     service.fetchXact = function(xact_id) {
-        return egCore.pcrud.retrieve('mbt', {
+        return egCore.pcrud.retrieve('mbt', xact_id, {
             flesh : 5,
             flesh_fields : {
                 mbt : ['summary','circulation','grocery','reservation'],
@@ -119,6 +119,8 @@ function($modal , $q , egCore , egUser) {
             function($scope , $modalInstance , $timeout , billingTypes , xact , patron) {
                 console.debug('billing patron ' + patron.id());
                 $scope.focus = true;
+                if (xact && xact._isfieldmapper)
+                    xact = egCore.idl.toHash(xact);
                 $scope.xact = xact;
                 $scope.patron = patron;
                 $scope.billingTypes = billingTypes;
@@ -150,7 +152,9 @@ function($modal , $q , egCore , egUser) {
                 },
 
                 patron : function() {
-                    return $q.when(args.patron) || egUser.get(args.patron_id);
+                    if (args.patron) return $q.when(args.patron);
+                    return  egCore.pcrud.retrieve('au', args.patron_id,
+                        {flesh : 1, flesh_fields : {au : ['card']}});
                 }
 
             }