<div class="alert alert-danger" ng-if="copyNotFound">
[% l('Item Not Found') %]
</div>
+ <div class="alert alert-danger" ng-if="duplicateBarcode">
+ [% l('Duplicate Barcode') %]
+ </div>
<div class="alert alert-success" ng-if="updateOK">
<span>[% l('Item Updated') %]</span>
<span class="horiz-pad" ng-if="copyId">
$scope.updateBarcode = function() {
$scope.copyNotFound = false;
+ $scope.duplicateBarcode = false;
$scope.updateOK = false;
- egCore.pcrud.search('acp',
+ egCore.pcrud.search('acp',
{deleted : 'f', barcode : $scope.barcode1})
.then(function(copy) {
return;
}
- $scope.copyId = copy.id();
- copy.barcode($scope.barcode2);
+ egCore.pcrud.search('acp',
+ {deleted : 'f', barcode : $scope.barcode2})
+ .then(function(newBarcodeCopy) {
- egCore.pcrud.update(copy).then(function(stat) {
- $scope.updateOK = stat;
- $scope.focusBarcode = true;
+ if (newBarcodeCopy) {
+ $scope.duplicateBarcode = true;
+ return;
+ }
+
+ $scope.copyId = copy.id();
+ copy.barcode($scope.barcode2);
+
+ egCore.pcrud.update(copy).then(function(stat) {
+ $scope.updateOK = stat;
+ $scope.focusBarcode = true;
+ });
});
});
}