<div class="row col-md-offset-3 col-md-6 pad-vert">
<div ng-show="logged_in && active_tab != 'session'" class="alert alert-danger">
<h2>[% l('Warning') %]</h2>
- [% l('You are currently logged in while attempting to use the offline interface. If use of this interface is intended, or if you were redirected here due to an internet or server outage, please use the Log Out action in the above-right menu and then select Offline Circulation from the Circulation menu') %]
+ [% l('You are about to enter offline mode. If you proceed, you will be logged out.') %]
+ <br/>
+ <br/>
+ <button class="btn btn-danger" ng-click="logout()">[% l('Proceed') %]</button>
</div>
</div>
[% l('Due Date:') %]
</div>
<div class="col-md-4">
- <eg-date-input id="co_duedate" ng-model="shared.due_date" min-date="minDate"></eg-date-input>
+ <eg-date-input id="co_duedate" ng-model="shared.due_date" out-of-range="shared.outOfRange" min-date="minDate"></eg-date-input>
</div>
<div class="col-md-3">
<select class="form-control" ng-model="shared.due_date_offset" ng-change="resetDueDate()">
[% l('Due Date:') %]
</div>
<div class="col-md-4">
- <eg-date-input ng-model="shared.due_date" min-date="minDate"></eg-date-input>
+ <eg-date-input ng-model="shared.due_date" out-of-range="shared.outOfRange" min-date="minDate"></eg-date-input>
</div>
<div class="col-md-3">
<select class="form-control" ng-model="shared.due_date_offset" ng-change="resetDueDate()">
[% l('Checkin Date:') %]
</div>
<div class="col-md-6">
- <eg-date-input ng-model="checkin.backdate" min-date="minDate"></eg-date-input>
+ <eg-date-input ng-model="checkin.backdate"></eg-date-input>
</div>
</div>
])
.controller('OfflineCtrl',
- ['$q','$scope','$location','$rootScope','egCore','egLovefield','$routeParams','$timeout','$http','ngToast','egConfirmDialog',
- function($q , $scope , $location , $rootScope , egCore , egLovefield , $routeParams , $timeout , $http , ngToast , egConfirmDialog) {
+ ['$q','$scope','$window','$location','$rootScope','egCore','egLovefield','$routeParams','$timeout','$http','ngToast','egConfirmDialog',
+ function($q , $scope , $window , $location , $rootScope , egCore , egLovefield , $routeParams , $timeout , $http , ngToast , egConfirmDialog) {
$scope.active_tab = $routeParams.tab || 'checkout';
- $scope.minDate = new Date();
+ var today = new Date();
+ today.setHours(0);
+ today.setMinutes(0);
+ today.setSeconds(0);
+ today.setMilliseconds(0);
+
+ $scope.minDate = today;
$scope.blocked_patron = null;
$scope.bad_barcode = null;
$scope.barcode_type = 'barcode';
$scope.focusMe = true;
- $scope.shared = { due_date : null, due_date_offset : '' };
+ $scope.shared = { outOfRange : false, due_date : null, due_date_offset : '' };
$scope.workstation_obj = null;
$scope.workstation = '';
$scope.workstation_owner = '';
}
$scope.save = function () {
+ var promises = [$q.when()];
angular.forEach($scope.all_xact, function (x) {
- egLovefield.addOfflineXact(x);
+ promises.push(egLovefield.addOfflineXact(x));
});
var prints = [$q.when()];
});
}
- return $q.all(prints).finally(function() {
+ return $q.all(promises.concat(prints)).finally(function() {
if (prints.length > 1) $scope.printed = true;
$scope.all_xact = [];
$scope.xact_page = { checkin:[], checkout:[], renew:[], in_house_use:[] };
$rootScope.save_offline_xacts = function () { return $scope.save() };
$rootScope.active_tab = function (t) { $scope.active_tab = t };
+ $scope.logout = function () {
+ egCore.auth.logout();
+ $window.location.href = location.href;
+ }
+
$scope.clear_pending = function (skip_confirm) {
if (skip_confirm) {
return egLovefield.destroyPendingOfflineXacts().then(function () {
}
$scope.notEnough = function (xtype) {
+
if (xtype == 'checkout') {
+ if ($scope.shared.outOfRange) return true;
if (
$scope.checkout.patron_barcode &&
($scope.shared.due_date || $scope.shared.due_date_offset) &&
}
if (xtype == 'renew') {
+ if ($scope.shared.outOfRange) return true;
if (
$scope.renew.barcode &&
($scope.shared.due_date || $scope.shared.due_date_offset)
egWorkLog , $timeout , egLovefield , $rootScope) {
$scope.rs = $rootScope;
- patronRegSvc.org = $scope.workstation_obj.owning_lib;
+ if ($scope.workstation_obj) patronRegSvc.org = $scope.workstation_obj.owning_lib;
$scope.offline = true;
$scope.page_data_loaded = false;
ngModel : '=',
ngChange : '=',
ngBlur : '=',
- minDate : '=',
- maxDate : '=',
+ minDate : '=?',
+ maxDate : '=?',
ngDisabled : '=',
ngRequired : '=',
hideDatePicker : '=',
- dateFormat : '=?'
+ dateFormat : '=?',
+ outOfRange : '=?'
},
require: 'ngModel',
templateUrl: './share/t_datetime',
$scope.options = {
minDate : $scope.minDate,
maxDate : $scope.maxDate
+ };
+
+ var maxDateObj = $scope.maxDate ? new Date($scope.maxDate) : null;
+ var minDateObj = $scope.minDate ? new Date($scope.minDate) : null;
+
+ if ($scope.outOfRange !== undefined && (maxDateObj || minDateObj)) {
+ $scope.$watch('ngModel', function (n,o) {
+ if (n && n != o) {
+ var bad = false;
+ var newdate = new Date(n);
+ if (maxDateObj && newdate.getTime() > maxDateObj.getTime()) bad = true;
+ if (minDateObj && newdate.getTime() < minDateObj.getTime()) bad = true;
+ $scope.outOfRange = bad;
+ }
+ });
}
}],
link : function(scope, elm, attrs) {