| 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 |
|
| 21640 |
kshitij.so |
28 |
$("td.startGrnSerialized").live('click', function() {
|
| 21627 |
kshitij.so |
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);
|
| 21640 |
kshitij.so |
36 |
$("#scanModel .invoiceNumber").val(invoiceNumber);
|
|
|
37 |
$("#scanModel .itemId").val(itemId);
|
| 21627 |
kshitij.so |
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 |
|
| 21640 |
kshitij.so |
67 |
$("td.startGrnNonSerialized").live('click', function() {
|
|
|
68 |
var invoiceNumber = $(this).attr('invoiceNumber');
|
|
|
69 |
var quantity = $(this).attr('quantity');
|
|
|
70 |
var displayName = $(this).attr('displayName');
|
|
|
71 |
var itemId = $(this).attr('itemId');
|
|
|
72 |
console.log(quantity);
|
|
|
73 |
$("#scanNonSerializedModel .modal-body .grnInvoiceNumber>span").text(invoiceNumber);
|
|
|
74 |
$("#scanNonSerializedModel .modal-body .grnProductInfo>span").text(displayName);
|
|
|
75 |
$("#scanNonSerializedModel .invoiceNumber").val(invoiceNumber);
|
|
|
76 |
$("#scanNonSerializedModel .itemId").val(itemId);
|
|
|
77 |
$( "#grnImeiInformation" ).empty();
|
|
|
78 |
var qty = parseInt(quantity);
|
|
|
79 |
var divCode = '<div class="row">CONTENT</div><p></p>';
|
|
|
80 |
var innerDiv = '<div class="col-sm-3">'+
|
|
|
81 |
'<div class="input-group">'+
|
|
|
82 |
'<input type="text" class="form-control">'+
|
|
|
83 |
'</div>'+
|
|
|
84 |
'</div>';
|
|
|
85 |
while(qty!=0){
|
|
|
86 |
var divText = "";
|
|
|
87 |
if (qty < 4){
|
|
|
88 |
var cp = qty;
|
|
|
89 |
for (var i=0;i<cp;i++ ){
|
|
|
90 |
divText = divText + innerDiv;
|
|
|
91 |
qty = qty - 1;
|
|
|
92 |
}
|
|
|
93 |
}
|
|
|
94 |
else{
|
|
|
95 |
for(var i=0;i<4;i++){
|
|
|
96 |
divText = divText + innerDiv;
|
|
|
97 |
qty = qty - 1;
|
|
|
98 |
}
|
|
|
99 |
}
|
|
|
100 |
divText = divCode.replace("CONTENT",divText);
|
|
|
101 |
$("#grnImeiInformation")
|
|
|
102 |
.append(divText)
|
|
|
103 |
}
|
|
|
104 |
});
|
|
|
105 |
|
|
|
106 |
$("#grnSubmitSerialized").live('click', function(){
|
| 21627 |
kshitij.so |
107 |
var imeis = [];
|
|
|
108 |
var error = false;
|
|
|
109 |
var errorText = "";
|
|
|
110 |
$("#grnImeiInformation :input").each(function(){
|
|
|
111 |
var input = $(this).val().trim();
|
|
|
112 |
if (imeis.indexOf(input) !=-1 || !input){
|
|
|
113 |
error = true;
|
|
|
114 |
if (!input){
|
|
|
115 |
$(this).addClass("border-highlight");
|
|
|
116 |
}
|
|
|
117 |
}
|
|
|
118 |
imeis.push(input);
|
|
|
119 |
});
|
|
|
120 |
if (error){
|
|
|
121 |
return false;
|
|
|
122 |
}
|
| 21640 |
kshitij.so |
123 |
var invoiceNumber = $("#scanModel .invoiceNumber").val();
|
|
|
124 |
var itemId = $("#scanModel .itemId").val();
|
| 21627 |
kshitij.so |
125 |
var postData = JSON.stringify({"itemId":parseInt(itemId),"invoiceNumber":invoiceNumber,"serialNumbers":imeis});
|
|
|
126 |
jQuery.ajax({
|
|
|
127 |
url: context+"/scanSerialized",
|
|
|
128 |
type: 'POST',
|
|
|
129 |
data: postData,
|
|
|
130 |
contentType:'application/json',
|
|
|
131 |
async: false,
|
|
|
132 |
success: function (data) {
|
| 21640 |
kshitij.so |
133 |
alert("Purchase booked successfully");
|
|
|
134 |
$('#scanModel').modal('hide');
|
|
|
135 |
$("#scanModel").on("hidden.bs.modal", function () {
|
|
|
136 |
$("#purchase-reference-submit").submit();
|
|
|
137 |
});
|
| 21627 |
kshitij.so |
138 |
},
|
|
|
139 |
error : function() {
|
|
|
140 |
alert("OOPS!!!Failed to do changes.Try Again.",'ERROR');
|
|
|
141 |
},
|
|
|
142 |
cache: false,
|
|
|
143 |
processData: false
|
|
|
144 |
});
|
|
|
145 |
return false;
|
|
|
146 |
});
|
| 21640 |
kshitij.so |
147 |
|
|
|
148 |
$("#grnNonSerializedSubmit").live('click', function(){
|
|
|
149 |
var error = false;
|
|
|
150 |
var errorText = "";
|
|
|
151 |
if (error){
|
|
|
152 |
return false;
|
|
|
153 |
}
|
|
|
154 |
var invoiceNumber = $("#scanNonSerializedModel .invoiceNumber").val();
|
|
|
155 |
var itemId = $("#scanNonSerializedModel .itemId").val();
|
|
|
156 |
var quantity = $("#scanNonSerializedModel .quantity").val();
|
|
|
157 |
var postData = JSON.stringify({"itemId":parseInt(itemId),"invoiceNumber":invoiceNumber,"quantity":parseInt(quantity)});
|
|
|
158 |
jQuery.ajax({
|
|
|
159 |
url: context+"/scanNonSerialized",
|
|
|
160 |
type: 'POST',
|
|
|
161 |
data: postData,
|
|
|
162 |
contentType:'application/json',
|
|
|
163 |
async: false,
|
|
|
164 |
success: function (data) {
|
|
|
165 |
alert("Purchase booked successfully");
|
|
|
166 |
$('#scanNonSerializedModel').modal('hide');
|
|
|
167 |
$("#scanNonSerializedModel").on("hidden.bs.modal", function () {
|
|
|
168 |
$("#purchase-reference-submit").submit();
|
|
|
169 |
});
|
|
|
170 |
},
|
|
|
171 |
error : function() {
|
|
|
172 |
alert("OOPS!!!Failed to do changes.Try Again.",'ERROR');
|
|
|
173 |
},
|
|
|
174 |
cache: false,
|
|
|
175 |
processData: false
|
|
|
176 |
});
|
|
|
177 |
return false;
|
|
|
178 |
});
|
| 21627 |
kshitij.so |
179 |
|
| 21640 |
kshitij.so |
180 |
|
|
|
181 |
|
| 21627 |
kshitij.so |
182 |
$("#grnImeiInformation :input").live('change paste keyup mouseup', function() {
|
|
|
183 |
if ($(this).val().trim() != "") {
|
|
|
184 |
console.log('The text box really changed this time');
|
|
|
185 |
$('#grnImeiInformation :input').removeClass("border-highlight");
|
|
|
186 |
if(findDuplicateSerialNumbers( $(this).val().trim()) > 0){
|
|
|
187 |
var inputs = $("#grnImeiInformation :input[value="+$(this).val().trim()+"]");
|
|
|
188 |
if(inputs.length > 1){
|
|
|
189 |
inputs.each(function(){$(this).addClass("border-highlight")});
|
|
|
190 |
}
|
|
|
191 |
}
|
|
|
192 |
}
|
|
|
193 |
});
|
|
|
194 |
|
|
|
195 |
|
|
|
196 |
|
|
|
197 |
});
|