--- /dev/null
+
+<form ng-submit="submitBarcode(args)" role="form" class="form-inline">
+ <div class="input-group">
+
+ <label class="input-group-addon"
+ for="patron-checkout-barcode" >[% l('Patron Barcode') %]</label>
+
+ <input select-me="selectMe" class="form-control"
+ ng-model="args.barcode"
+ placeholder="[% l('Patron Barcode') %]"
+ id="patron-checkout-barcode" type="text"/>
+
+ <input class="btn btn-default" type="submit" value="[% l('Submit') %]"/>
+
+ <!-- do we really need a button?
+ <span class="input-group-btn">
+ <input type="submit" class="btn btn-default" value="[% l('Submit') %]"/>
+ </span>
+ -->
+ </div>
+</form>
+
+<br/>
+<div class="alert alert-warning" ng-show="bcNotFound">
+ [% l('Barcode Not Found: [_1]', '{{bcNotFound}}') %]
+</div>
+
+
</div>
<div class="panel-body">
<div>
- <img src="/xul/server/skin/media/images/portal/retreivepatron.png"/>
- <a target="_self" href="./circ/patron/search">[% l('Find Patrons / Checkout') %]</a>
+ <img src="/xul/server/skin/media/images/portal/forward.png"/>
+ <a target="_self" href="./circ/patron/bcsearch">[% l('Check Out Items') %]</a>
</div>
<div>
<img src="/xul/server/skin/media/images/portal/back.png"/>
<a target="_self" href="./circ/checkin/index">[% l('Check In Items') %]</a>
</div>
+ <div>
+ <img src="/xul/server/skin/media/images/portal/retreivepatron.png"/>
+ <a target="_self" href="./circ/patron/search">[% l('Search For Patron By Name') %]</a>
+ </div>
</div>
</div>
</div>
[% l('Evergreen Documentation') %]
</a>
</div>
+ <div>
+ <img src="/xul/server/skin/media/images/portal/helpdesk.png"/>
+ <a target="_top" href="./admin/workstation/index">
+ [% l('Workstation Administration') %]
+ </a>
+ </div>
</div>
</div>
</div>
resolve : resolver
});
+ $routeProvider.when('/circ/patron/bcsearch', {
+ templateUrl: './circ/patron/t_bcsearch',
+ controller: 'PatronBarcodeSearchCtrl',
+ resolve : resolver
+ });
+
+
$routeProvider.when('/circ/patron/:id/checkout', {
templateUrl: './circ/patron/t_checkout',
controller: 'PatronCheckoutCtrl',
"unable to fetch user "+id+': '+js2JSON(err))
}
);
+ } else {
+
+ // reset with no patron
+ service.resetPatronLists();
+ service.current = null;
+ service.patron_stats = null;
}
}
$scope.patron_stats = function() { return patronSvc.patron_stats }
}])
+.controller('PatronBarcodeSearchCtrl',
+ ['$scope','$location','egAuth','egNet','egEvent','egOrg','egConfirmDialog','egUser','egAppStrings','patronSvc',
+function($scope , $location , egAuth , egNet , egEvent , egOrg , egConfirmDialog , egUser , egAppStrings , patronSvc) {
+ $scope.selectMe = true; // focus text input
+ patronSvc.setDefault(); // clear the default user
+
+ // jump to the patron checkout UI
+ function loadPatron(user_id) {
+ $location.path('/circ/patron/' + user_id + '/checkout');
+ }
+
+ // create an opt-in=yes response for the loaded user
+ function createOptIn(user_id) {
+ egNet.request(
+ 'open-ils.actor',
+ 'open-ils.actor.user.org_unit_opt_in.create',
+ egAuth.token(), user_id).then(function(resp) {
+ if (evt = egEvent.parse(resp)) return alert(evt);
+ loadPatron(user_id);
+ }
+ );
+ }
+
+ $scope.submitBarcode = function(args) {
+ $scope.bcNotFound = null;
+ if (!args.barcode) return;
+
+ // blur so next time it's set to true it will re-apply select()
+ $scope.selectMe = false;
+
+ var user_id;
+
+ // lookup barcode
+ egNet.request(
+ 'open-ils.actor',
+ 'open-ils.actor.get_barcodes',
+ egAuth.token(), egAuth.user().ws_ou(), 'actor', args.barcode)
+
+ .then(function(resp) { // get_barcodes
+
+ if (evt = egEvent.parse(resp)) {
+ alert(evt); // FIXME
+ return;
+ }
+
+ if (!resp || !resp[0]) {
+ $scope.bcNotFound = args.barcode;
+ $scope.selectMe = true;
+ return;
+ }
+
+ // see if an opt-in request is needed
+ user_id = resp[0].id;
+ return egNet.request(
+ 'open-ils.actor',
+ 'open-ils.actor.user.org_unit_opt_in.check',
+ egAuth.token(), user_id);
+
+ }).then(function(optInResp) { // opt_in_check
+
+ if (evt = egEvent.parse(optInResp)) {
+ alert(evt); // FIXME
+ return;
+ }
+
+ if (optInResp == 1) {
+ // opt-in handled or not needed
+ return loadPatron(user_id);
+ }
+
+ // opt-in needed, show the opt-in dialog
+ egUser.get(user_id, {useFields : []})
+
+ .then(function(user) { // retrieve user
+ egConfirmDialog.open(
+ egAppStrings.OPT_IN_DIALOG, '',
+ { org : egOrg.get(egAuth.user().ws_ou()),
+ user : user,
+ ok : function() { createOptIn(user.id()) },
+ cancel : function() {}
+ }
+ );
+ })
+ });
+ }
+}])
+
/**
* Manages patron search