<div>
-<div class="row ">
+<script>window.duplicate_barcode_string = "[% l('Duplicate Barcode') %]";</script>
+<div class="row">
<div class="col-md-1"></div>
<div class="col-md-6">
<h2 class="center-block">[% l('Replace Item Barcode') %]</h2>
<div class="form-group">
<label for="barcode2">[% l('Enter New Barcode for Item') %]</label>
<input type="text" class="form-control" id="barcode2" select-me="focusBarcode2"
- ng-model="barcode2"
+ ng-model="barcode2" ng-change="checkCurrentBarcode()"
required placeholder="[% l('New Barcode...') %]">
+ <div class="label label-danger" ng-if="duplicate_barcode">{{duplicate_barcode_string}}</div>
</div>
- <button type="submit" class="btn btn-default">[% l('Submit') %]</button>
+ <button type="submit" class="btn btn-default" ng-disabled="duplicate_barcode">[% l('Submit') %]</button>
<button ng-if="isModal" class="btn btn-warning" ng-click="cancel($event)">[% l('Cancel') %]</button>
</form>
</div>
controller:
['$scope','$uibModalInstance',
function($scope , $uibModalInstance) {
+ $scope.duplicate_barcode = false;
$scope.isModal = true;
$scope.focusBarcode = false;
$scope.focusBarcode2 = true;
$scope.barcode1 = cp.barcode();
+ // check input to see if it's a duplicate barcode
+ $scope.checkCurrentBarcode = function() {
+ if (!$scope.duplicate_barcode_string) {
+ $scope.duplicate_barcode_string = window.duplicate_barcode_string;
+ }
+ var searchParams = {
+ deleted : 'f',
+ 'barcode' : $scope.barcode2,
+ id : { '!=' : $scope.copyId }
+ };
+ egCore.pcrud.search('acp', searchParams).then(function (res) {
+ $scope.duplicate_barcode = res;
+ });
+ }
+
$scope.updateBarcode = function() {
$scope.copyNotFound = false;
$scope.updateOK = false;