<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>
--- /dev/null
+<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>
+
<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>
* 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;
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
});
}
+ 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;
loadCurrentCirc(true);
break;
+ case 'circ_list':
+ loadCircHistory();
+ break;
+
case 'holds':
loadHolds()
loadTransits();
}
);
+
if ($scope.recordId)
loadRecord();
}
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'],
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;
},
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']}});
}
}