[% ELSIF field == 'post_code' %]
<input type="text" ng-blur="post_code_changed(patron.[% path %])"
class="form-control" ng-model="[% model %]"/>
+ [% ELSIF field == 'barcode' %]
+ <input type="text" ng-blur="barcode_changed(patron.card.barcode)"
+ class="form-control" ng-model="[% model %]"/>
[% ELSE %]
<input type="[% input_type %]"
class="form-control" ng-model="[% model %]"/>
[% IF field == 'barcode' %]
- <button class="btn btn-default">[% l('Replace Barcode') %]</button>
+ <button class="btn btn-default"
+ ng-click="replace_card()">[% l('Replace Barcode') %]</button>
<button class="btn btn-default"
ng-click="cards_dialog()">[% l('See All') %]</button>
function PatronRegCtrl($scope, $routeParams,
$q, $modal, egCore, patronSvc, patronRegSvc) {
-
$scope.clone_id = $routeParams.clone_id;
$scope.stage_username = $routeParams.stage_username;
$scope.patron_id =
});
}
+ var new_card_id = -1;
+ $scope.replace_card = function() {
+ $scope.patron.card.active = false;
+ $scope.patron.card.ischanged = true;
+ var new_card = egCore.idl.toHash(new egCore.idl.ac());
+ new_card.id = new_card_id--;
+ new_card.isnew = true;
+ new_card.active = true;
+ new_card._primary = true;
+ $scope.patron.card = new_card;
+ $scope.patron.cards.push(new_card);
+ }
+
+ $scope.barcode_changed = function(bc) {
+ if (!bc) return;
+ egCore.net.request(
+ 'open-ils.actor',
+ 'open-ils.actor.barcode.exists',
+ egCore.auth.token(), bc
+ ).then(function(resp) {
+ if (resp == '1') {
+ console.log('duplicate barcode detected: ' + bc);
+ // DUPLICATE CARD
+ } else {
+ // No dupe -- A-OK
+ }
+ });
+ }
+
$scope.cards_dialog = function() {
$modal.open({
templateUrl: './circ/patron/t_patron_cards_dialog',