| 23343 |
ashik.ali |
1 |
var grnhistory= grnhistory || {};
|
|
|
2 |
grnhistory.searchText = "";
|
|
|
3 |
grnhistory.searchType = "";
|
|
|
4 |
grnhistory.startTime = "0";
|
|
|
5 |
grnhistory.endTime = "0";
|
|
|
6 |
|
|
|
7 |
$(function() {
|
|
|
8 |
$(".new_grn").live('click', function() {
|
|
|
9 |
loadNewGrn("main-content");
|
|
|
10 |
});
|
|
|
11 |
|
|
|
12 |
$(".grn_history").live('click', function() {
|
|
|
13 |
loadGrnHistory("main-content","","","0","0");
|
|
|
14 |
});
|
|
|
15 |
|
|
|
16 |
$(".pending_grn").live('click', function() {
|
|
|
17 |
loadPendingGrn("main-content", "", "", "0", "0");
|
|
|
18 |
});
|
|
|
19 |
|
|
|
20 |
$("td.startGrnSerialized").live('click', function() {
|
|
|
21 |
var invoiceNumber = $(this).attr('invoiceNumber');
|
|
|
22 |
var quantity = $(this).attr('quantity');
|
|
|
23 |
var displayName = $(this).attr('displayName');
|
|
|
24 |
var itemId = $(this).attr('itemId');
|
|
|
25 |
console.log(quantity);
|
|
|
26 |
$(".modal-body .grnInvoiceNumber>span").text(invoiceNumber);
|
|
|
27 |
$(".modal-body .grnProductInfo>span").text(displayName);
|
|
|
28 |
$("#scanModel .invoiceNumber").val(invoiceNumber);
|
|
|
29 |
$("#scanModel .itemId").val(itemId);
|
|
|
30 |
$( "#grnImeiInformation" ).empty();
|
|
|
31 |
var qty = parseInt(quantity);
|
|
|
32 |
var divCode = '<div class="row">CONTENT</div><p></p>';
|
|
|
33 |
var innerDiv = '<div class="col-sm-3">'+
|
|
|
34 |
'<div class="input-group">'+
|
|
|
35 |
'<input type="text" class="form-control">'+
|
|
|
36 |
'</div>'+
|
|
|
37 |
'</div>';
|
|
|
38 |
while(qty!=0){
|
|
|
39 |
var divText = "";
|
|
|
40 |
if (qty < 4){
|
|
|
41 |
var cp = qty;
|
|
|
42 |
for (var i=0;i<cp;i++ ){
|
|
|
43 |
divText = divText + innerDiv;
|
|
|
44 |
qty = qty - 1;
|
|
|
45 |
}
|
|
|
46 |
}
|
|
|
47 |
else{
|
|
|
48 |
for(var i=0;i<4;i++){
|
|
|
49 |
divText = divText + innerDiv;
|
|
|
50 |
qty = qty - 1;
|
|
|
51 |
}
|
|
|
52 |
}
|
|
|
53 |
divText = divCode.replace("CONTENT",divText);
|
|
|
54 |
$("#grnImeiInformation")
|
|
|
55 |
.append(divText)
|
|
|
56 |
}
|
|
|
57 |
});
|
|
|
58 |
|
|
|
59 |
$("td.startGrnNonSerialized").live('click', function() {
|
|
|
60 |
var invoiceNumber = $(this).attr('invoiceNumber');
|
|
|
61 |
var quantity = $(this).attr('quantity');
|
|
|
62 |
var displayName = $(this).attr('displayName');
|
|
|
63 |
var itemId = $(this).attr('itemId');
|
|
|
64 |
console.log(quantity);
|
|
|
65 |
$("#scanNonSerializedModel .modal-body .grnInvoiceNumber>span").text(invoiceNumber);
|
|
|
66 |
$("#scanNonSerializedModel .modal-body .grnProductInfo>span").text(displayName);
|
|
|
67 |
$("#scanNonSerializedModel .invoiceNumber").val(invoiceNumber);
|
|
|
68 |
$("#scanNonSerializedModel .itemId").val(itemId);
|
|
|
69 |
$( "#grnImeiInformation" ).empty();
|
|
|
70 |
var qty = parseInt(quantity);
|
|
|
71 |
var divCode = '<div class="row">CONTENT</div><p></p>';
|
|
|
72 |
var innerDiv = '<div class="col-sm-3">'+
|
|
|
73 |
'<div class="input-group">'+
|
|
|
74 |
'<input type="text" class="form-control">'+
|
|
|
75 |
'</div>'+
|
|
|
76 |
'</div>';
|
|
|
77 |
while(qty!=0){
|
|
|
78 |
var divText = "";
|
|
|
79 |
if (qty < 4){
|
|
|
80 |
var cp = qty;
|
|
|
81 |
for (var i=0;i<cp;i++ ){
|
|
|
82 |
divText = divText + innerDiv;
|
|
|
83 |
qty = qty - 1;
|
|
|
84 |
}
|
|
|
85 |
}
|
|
|
86 |
else{
|
|
|
87 |
for(var i=0;i<4;i++){
|
|
|
88 |
divText = divText + innerDiv;
|
|
|
89 |
qty = qty - 1;
|
|
|
90 |
}
|
|
|
91 |
}
|
|
|
92 |
divText = divCode.replace("CONTENT",divText);
|
|
|
93 |
$("#grnImeiInformation")
|
|
|
94 |
.append(divText)
|
|
|
95 |
}
|
|
|
96 |
});
|
|
|
97 |
|
|
|
98 |
$("#grnSubmitSerialized").live('click', function(){
|
|
|
99 |
var imeis = [];
|
|
|
100 |
var error = false;
|
|
|
101 |
var errorText = "";
|
|
|
102 |
$("#grnImeiInformation :input").each(function(){
|
|
|
103 |
var input = $(this).val().trim();
|
|
|
104 |
if (imeis.indexOf(input) !=-1 || !input){
|
|
|
105 |
error = true;
|
|
|
106 |
if (!input){
|
|
|
107 |
$(this).addClass("border-highlight");
|
|
|
108 |
}
|
|
|
109 |
}
|
|
|
110 |
imeis.push(input);
|
|
|
111 |
|
|
|
112 |
});
|
|
|
113 |
if (error){
|
|
|
114 |
return false;
|
|
|
115 |
}
|
|
|
116 |
var invoiceNumber = $("#scanModel .invoiceNumber").val();
|
|
|
117 |
var itemId = $("#scanModel .itemId").val();
|
|
|
118 |
var postData = JSON.stringify({"itemId":parseInt(itemId),"invoiceNumber":invoiceNumber,"serialNumbers":imeis});
|
| 23500 |
ashik.ali |
119 |
doPostAjaxRequestWithJsonHandler(context+"/scanSerialized", postData, function(response){
|
|
|
120 |
alert("Purchase booked successfully");
|
|
|
121 |
$('#scanModel').modal('hide');
|
|
|
122 |
$("#scanModel").on("hidden.bs.modal", function () {
|
|
|
123 |
$("#purchase-reference-submit-button").click();
|
|
|
124 |
});
|
| 23343 |
ashik.ali |
125 |
});
|
|
|
126 |
return false;
|
|
|
127 |
});
|
|
|
128 |
|
|
|
129 |
$("#grnNonSerializedSubmit").live('click', function(){
|
|
|
130 |
var error = false;
|
|
|
131 |
var errorText = "";
|
|
|
132 |
if (error){
|
|
|
133 |
return false;
|
|
|
134 |
}
|
|
|
135 |
var invoiceNumber = $("#scanNonSerializedModel .invoiceNumber").val();
|
|
|
136 |
var itemId = $("#scanNonSerializedModel .itemId").val();
|
|
|
137 |
var quantity = $("#scanNonSerializedModel .quantity").val();
|
|
|
138 |
var postData = JSON.stringify({"itemId":parseInt(itemId),"invoiceNumber":invoiceNumber,"quantity":parseInt(quantity)});
|
| 23500 |
ashik.ali |
139 |
doPostAjaxRequestWithJsonHandler(context+"/scanNonSerialized", postData, function(response){
|
|
|
140 |
alert("Purchase booked successfully");
|
|
|
141 |
$('#scanNonSerializedModel').modal('hide');
|
|
|
142 |
$("#scanNonSerializedModel").on("hidden.bs.modal", function () {
|
|
|
143 |
$("#purchase-reference-submit-button").click();
|
|
|
144 |
});
|
| 23343 |
ashik.ali |
145 |
});
|
|
|
146 |
return false;
|
|
|
147 |
});
|
|
|
148 |
|
|
|
149 |
$("#grnImeiInformation :input").live('change paste keyup mouseup', function() {
|
|
|
150 |
if ($(this).val().trim() != "") {
|
|
|
151 |
console.log('The text box really changed this time');
|
|
|
152 |
$('#grnImeiInformation :input').removeClass("border-highlight");
|
|
|
153 |
if(findDuplicateSerialNumbers( $(this).val().trim()) > 0){
|
|
|
154 |
var inputs = $("#grnImeiInformation :input[value="+$(this).val().trim()+"]");
|
|
|
155 |
if(inputs.length > 1){
|
|
|
156 |
inputs.each(function(){$(this).addClass("border-highlight")});
|
|
|
157 |
}
|
|
|
158 |
}
|
|
|
159 |
}
|
|
|
160 |
});
|
|
|
161 |
|
|
|
162 |
|
|
|
163 |
$("#grnImeiInformation :input").live('paste', function() {
|
|
|
164 |
if ($(this).val().trim() != "") {
|
|
|
165 |
console.log('paste event');
|
|
|
166 |
$(this).next("input .form-control").focus();
|
|
|
167 |
}
|
|
|
168 |
});
|
|
|
169 |
|
|
|
170 |
$("#airwayBillOrInvoiceNumberText").live("keyup", function(e) {
|
|
|
171 |
var keyCode = e.keyCode || e.which;
|
|
|
172 |
if(keyCode == 13){
|
|
|
173 |
$("#purchase-reference-submit-button").click();
|
|
|
174 |
}
|
|
|
175 |
});
|
|
|
176 |
|
|
|
177 |
$("#grn-history-search-button").live('click', function() {
|
|
|
178 |
grnhistory.searchText = $("#grn-history-search-text").val();
|
|
|
179 |
grnhistory.searchType = "purchaseReference";
|
|
|
180 |
grnhistory.startTime = "0";
|
|
|
181 |
grnhistory.endTime = "0";
|
|
|
182 |
if (typeof (grnhistory.searchText) == "undefined" || !grnhistory.searchText){
|
|
|
183 |
grnhistory.searchText = "";
|
|
|
184 |
}
|
|
|
185 |
loadGrnHistorySearchInfo(grnhistory.searchText,grnhistory.searchType,grnhistory.startTime,grnhistory.endTime);
|
|
|
186 |
});
|
|
|
187 |
|
|
|
188 |
$("#grn-history-search-text").live("keyup", function(e) {
|
|
|
189 |
var keyCode = e.keyCode || e.which;
|
|
|
190 |
if(keyCode == 13){
|
|
|
191 |
$("#grn-history-search-button").click();
|
|
|
192 |
}
|
|
|
193 |
});
|
|
|
194 |
|
|
|
195 |
$("#grn-history-paginated .next").live('click', function() {
|
| 23629 |
ashik.ali |
196 |
var params = {};
|
|
|
197 |
params['purchaseReference'] = grnhistory.searchText;
|
|
|
198 |
params['searchType'] = grnhistory.searchType;
|
|
|
199 |
params['startTime'] = grnhistory.startTime;
|
|
|
200 |
params['endTime'] = grnhistory.endTime;
|
|
|
201 |
loadPaginatedNextItems('/getPaginatedGrnHistory', params, 'grn-history-paginated', 'grn-history-table', null);
|
|
|
202 |
$(this).blur();
|
| 23343 |
ashik.ali |
203 |
|
|
|
204 |
});
|
|
|
205 |
|
|
|
206 |
$("#grn-history-paginated .previous").live('click', function() {
|
| 23629 |
ashik.ali |
207 |
var params = {};
|
|
|
208 |
params['purchaseReference'] = grnhistory.searchText;
|
|
|
209 |
params['searchType'] = grnhistory.searchType;
|
|
|
210 |
params['startTime'] = grnhistory.startTime;
|
|
|
211 |
params['endTime'] = grnhistory.endTime;
|
|
|
212 |
loadPaginatedPreviousItems('/getPaginatedGrnHistory', params, 'grn-history-paginated', 'grn-history-table', null);
|
|
|
213 |
$(this).blur();
|
|
|
214 |
|
| 23343 |
ashik.ali |
215 |
});
|
|
|
216 |
|
|
|
217 |
$("#grn-history-date-button").live('click', function() {
|
|
|
218 |
var dateRange = $('#reportrange span').text();
|
|
|
219 |
grnhistory.startTime = new Date(dateRange.split("-")[0]).getTime();
|
|
|
220 |
grnhistory.endTime = new Date(dateRange.split("-")[1]).getTime();
|
|
|
221 |
grnhistory.searchType = "dateFilter";
|
|
|
222 |
grnhistory.searchText = "";
|
|
|
223 |
loadGrnHistorySearchInfo(grnhistory.searchText,grnhistory.searchType,grnhistory.startTime,grnhistory.endTime);
|
|
|
224 |
});
|
|
|
225 |
|
|
|
226 |
$(".grn-details").live('click',function(){
|
|
|
227 |
var purchaseId = $(this).attr('data');
|
|
|
228 |
console.log(purchaseId);
|
|
|
229 |
loadGrnDetails(purchaseId,"grn-details-container");
|
|
|
230 |
});
|
|
|
231 |
|
|
|
232 |
$(".pending-grn-details").live('click',function(){
|
|
|
233 |
console.log("pending-grn-details clicked");
|
|
|
234 |
var orderId = $(this).attr('data');
|
|
|
235 |
console.log("orderId : "+orderId);
|
|
|
236 |
loadPendingGrnDetails(orderId, "pending-grn-details-container");
|
|
|
237 |
});
|
|
|
238 |
|
|
|
239 |
$(".pending-grn").live('click',function(){
|
|
|
240 |
var purchaseReference = $(this).attr('data');
|
|
|
241 |
console.log(purchaseReference);
|
|
|
242 |
loadPendingGrnDetails(purchaseReference,"main-content");
|
|
|
243 |
});
|
|
|
244 |
|
|
|
245 |
});
|
|
|
246 |
|
|
|
247 |
|
|
|
248 |
function loadNewGrn(domId){
|
|
|
249 |
//var response = doGetAjaxRequest(context+"/purchase");
|
| 23500 |
ashik.ali |
250 |
doGetAjaxRequestHandler(context+"/purchase", function(response){
|
| 23343 |
ashik.ali |
251 |
$('#' + domId).html(response);
|
|
|
252 |
});
|
|
|
253 |
|
|
|
254 |
}
|
|
|
255 |
|
|
|
256 |
function getPurchaseByInvoiceNumber(){
|
|
|
257 |
var airwayBillOrInvoiceNumber = $('#airwayBillOrInvoiceNumberText').val();
|
| 23500 |
ashik.ali |
258 |
doGetAjaxRequestHandler(context+"/purchaseByInvoiceNumber?airwayBillOrInvoiceNumber="+airwayBillOrInvoiceNumber, function(response){
|
| 23343 |
ashik.ali |
259 |
$('#main-content').html(response);
|
|
|
260 |
});
|
|
|
261 |
}
|
|
|
262 |
|
|
|
263 |
function loadPendingGrn(domId){
|
| 23500 |
ashik.ali |
264 |
doGetAjaxRequestHandler(context+"/pendingGrn", function(response){
|
| 23343 |
ashik.ali |
265 |
$('#' + domId).html(response);
|
|
|
266 |
});
|
|
|
267 |
}
|
|
|
268 |
|
|
|
269 |
function loadGrnHistory(domId,purchase_reference,searchType, startTime, endTime){
|
| 23500 |
ashik.ali |
270 |
doGetAjaxRequestHandler(context+"/grnHistory/?purchaseReference="+purchase_reference+"&searchType="+searchType
|
| 23343 |
ashik.ali |
271 |
+"&startTime="+startTime
|
| 23500 |
ashik.ali |
272 |
+"&endTime="+endTime, function(response){
|
| 23343 |
ashik.ali |
273 |
$('#' + domId).html(response);
|
|
|
274 |
});
|
|
|
275 |
}
|
|
|
276 |
|
|
|
277 |
function loadGrnHistorySearchInfo(search_text,searchType,startTime,endTime){
|
|
|
278 |
loadGrnHistory("main-content",search_text,searchType,startTime,endTime);
|
|
|
279 |
}
|
|
|
280 |
|
|
|
281 |
function findDuplicateSerialNumbers(value){
|
|
|
282 |
var result = $("#grnImeiInformation :input[value='" + value + "']").length - 1;
|
|
|
283 |
return result;
|
|
|
284 |
}
|
|
|
285 |
|
|
|
286 |
function loadGrnDetails(purchaseId, domId){
|
| 23500 |
ashik.ali |
287 |
doGetAjaxRequestHandler(context+"/grnHistoryDetailByPurchaseId/?purchaseId="+purchaseId, function(response){
|
| 23343 |
ashik.ali |
288 |
$('#' + domId).html(response);
|
|
|
289 |
window.dispatchEvent(new Event('resize'));
|
|
|
290 |
});
|
|
|
291 |
}
|
|
|
292 |
|
|
|
293 |
function loadPendingGrnDetails(orderId, domId){
|
| 23500 |
ashik.ali |
294 |
doGetAjaxRequestHandler(context+"/pendingGrnDetails/?orderId="+orderId, function(response){
|
| 23343 |
ashik.ali |
295 |
$('#' + domId).html(response);
|
|
|
296 |
window.dispatchEvent(new Event('resize'));
|
|
|
297 |
});
|
|
|
298 |
|
|
|
299 |
}
|