| 21627 |
kshitij.so |
1 |
var context = "/profitmandi-fofo";
|
|
|
2 |
$(function() {
|
|
|
3 |
$(".new_grn").live('click', function() {
|
|
|
4 |
loadNewGrn("main-content");
|
|
|
5 |
});
|
|
|
6 |
|
|
|
7 |
$("#purchase-reference-submit").live('submit', function(){
|
|
|
8 |
var formData = new FormData($(this)[0]);
|
|
|
9 |
|
|
|
10 |
jQuery.ajax({
|
|
|
11 |
url: context+"/purchase",
|
|
|
12 |
type: 'POST',
|
|
|
13 |
data: formData,
|
|
|
14 |
async: false,
|
|
|
15 |
success: function (data) {
|
|
|
16 |
$('#main-content').html(data);
|
|
|
17 |
},
|
|
|
18 |
error : function() {
|
|
|
19 |
alert("OOPS!!!Failed to do changes.Try Again.",'ERROR');
|
|
|
20 |
},
|
|
|
21 |
cache: false,
|
|
|
22 |
contentType: false,
|
|
|
23 |
processData: false
|
|
|
24 |
});
|
|
|
25 |
return false;
|
|
|
26 |
});
|
|
|
27 |
|
|
|
28 |
$("td.startGrn").live('click', function() {
|
|
|
29 |
var invoiceNumber = $(this).attr('invoiceNumber');
|
|
|
30 |
var quantity = $(this).attr('quantity');
|
|
|
31 |
var displayName = $(this).attr('displayName');
|
|
|
32 |
var itemId = $(this).attr('itemId');
|
|
|
33 |
console.log(quantity);
|
|
|
34 |
$(".modal-body .grnInvoiceNumber>span").text(invoiceNumber);
|
|
|
35 |
$(".modal-body .grnProductInfo>span").text(displayName);
|
|
|
36 |
$("#invoiceNumber").val(invoiceNumber);
|
|
|
37 |
$("#itemId").val(itemId);
|
|
|
38 |
$( "#grnImeiInformation" ).empty();
|
|
|
39 |
var qty = parseInt(quantity);
|
|
|
40 |
var divCode = '<div class="row">CONTENT</div><p></p>';
|
|
|
41 |
var innerDiv = '<div class="col-sm-3">'+
|
|
|
42 |
'<div class="input-group">'+
|
|
|
43 |
'<input type="text" class="form-control">'+
|
|
|
44 |
'</div>'+
|
|
|
45 |
'</div>';
|
|
|
46 |
while(qty!=0){
|
|
|
47 |
var divText = "";
|
|
|
48 |
if (qty < 4){
|
|
|
49 |
var cp = qty;
|
|
|
50 |
for (var i=0;i<cp;i++ ){
|
|
|
51 |
divText = divText + innerDiv;
|
|
|
52 |
qty = qty - 1;
|
|
|
53 |
}
|
|
|
54 |
}
|
|
|
55 |
else{
|
|
|
56 |
for(var i=0;i<4;i++){
|
|
|
57 |
divText = divText + innerDiv;
|
|
|
58 |
qty = qty - 1;
|
|
|
59 |
}
|
|
|
60 |
}
|
|
|
61 |
divText = divCode.replace("CONTENT",divText);
|
|
|
62 |
$("#grnImeiInformation")
|
|
|
63 |
.append(divText)
|
|
|
64 |
}
|
|
|
65 |
});
|
|
|
66 |
|
|
|
67 |
$("#grnSubmit").live('click', function(){
|
|
|
68 |
var imeis = [];
|
|
|
69 |
var error = false;
|
|
|
70 |
var errorText = "";
|
|
|
71 |
$("#grnImeiInformation :input").each(function(){
|
|
|
72 |
var input = $(this).val().trim();
|
|
|
73 |
if (imeis.indexOf(input) !=-1 || !input){
|
|
|
74 |
error = true;
|
|
|
75 |
if (!input){
|
|
|
76 |
$(this).addClass("border-highlight");
|
|
|
77 |
}
|
|
|
78 |
}
|
|
|
79 |
imeis.push(input);
|
|
|
80 |
});
|
|
|
81 |
if (error){
|
|
|
82 |
return false;
|
|
|
83 |
}
|
|
|
84 |
var invoiceNumber = $("#invoiceNumber").val();
|
|
|
85 |
var itemId = $("#itemId").val();
|
|
|
86 |
var postData = JSON.stringify({"itemId":parseInt(itemId),"invoiceNumber":invoiceNumber,"serialNumbers":imeis});
|
|
|
87 |
jQuery.ajax({
|
|
|
88 |
url: context+"/scanSerialized",
|
|
|
89 |
type: 'POST',
|
|
|
90 |
data: postData,
|
|
|
91 |
contentType:'application/json',
|
|
|
92 |
async: false,
|
|
|
93 |
success: function (data) {
|
|
|
94 |
$('#main-content').html(data);
|
|
|
95 |
},
|
|
|
96 |
error : function() {
|
|
|
97 |
alert("OOPS!!!Failed to do changes.Try Again.",'ERROR');
|
|
|
98 |
},
|
|
|
99 |
cache: false,
|
|
|
100 |
processData: false
|
|
|
101 |
});
|
|
|
102 |
return false;
|
|
|
103 |
});
|
|
|
104 |
|
|
|
105 |
$("#grnImeiInformation :input").live('change paste keyup mouseup', function() {
|
|
|
106 |
if ($(this).val().trim() != "") {
|
|
|
107 |
console.log('The text box really changed this time');
|
|
|
108 |
$('#grnImeiInformation :input').removeClass("border-highlight");
|
|
|
109 |
if(findDuplicateSerialNumbers( $(this).val().trim()) > 0){
|
|
|
110 |
var inputs = $("#grnImeiInformation :input[value="+$(this).val().trim()+"]");
|
|
|
111 |
if(inputs.length > 1){
|
|
|
112 |
inputs.each(function(){$(this).addClass("border-highlight")});
|
|
|
113 |
}
|
|
|
114 |
}
|
|
|
115 |
}
|
|
|
116 |
});
|
|
|
117 |
|
|
|
118 |
|
|
|
119 |
|
|
|
120 |
});
|