| 21627 |
kshitij.so |
1 |
var googleProfile;
|
|
|
2 |
|
| 22139 |
amit.gupta |
3 |
|
|
|
4 |
$(document).ajaxComplete(
|
|
|
5 |
function(){
|
| 23026 |
ashik.ali |
6 |
}
|
| 22139 |
amit.gupta |
7 |
);
|
| 21627 |
kshitij.so |
8 |
var startApp = function() {
|
|
|
9 |
gapi.load('auth2', function(){
|
|
|
10 |
// Retrieve the singleton for the GoogleAuth library and set up the client.
|
|
|
11 |
auth2 = gapi.auth2.init({
|
| 22071 |
ashik.ali |
12 |
client_id: googleApiKey,
|
| 21627 |
kshitij.so |
13 |
cookiepolicy: 'single_host_origin',
|
|
|
14 |
// Request scopes in addition to 'profile' and 'email'
|
|
|
15 |
//scope: 'additional_scope'
|
|
|
16 |
});
|
|
|
17 |
attachSignin(document.getElementById('customBtn'));
|
|
|
18 |
});
|
|
|
19 |
};
|
|
|
20 |
|
| 22956 |
ashik.ali |
21 |
function badRequestAlert(response){
|
|
|
22 |
console.log(response.responseText);
|
|
|
23 |
var errorObject = JSON.parse(response.responseText);
|
|
|
24 |
errorObject = errorObject.response;
|
|
|
25 |
alert('Bad Request\n'+
|
|
|
26 |
'rejectedType : '+errorObject.rejectedType+'\n'+
|
|
|
27 |
'rejectedValue : '+errorObject.rejectedValue+'\n'+
|
|
|
28 |
'message : '+errorObject.message);
|
|
|
29 |
}
|
|
|
30 |
|
|
|
31 |
function internalServerErrorAlert(response){
|
|
|
32 |
console.log(response.responseText);
|
|
|
33 |
var errorObject = JSON.parse(response.responseText);
|
|
|
34 |
errorObject = errorObject.response;
|
|
|
35 |
alert('Internal Server Error\n'+
|
|
|
36 |
'rejectedType : '+errorObject.rejectedType+'\n'+
|
|
|
37 |
'rejectedValue : '+errorObject.rejectedValue+'\n'+
|
|
|
38 |
'message : '+errorObject.message);
|
|
|
39 |
}
|
|
|
40 |
|
|
|
41 |
$( document ).ajaxError(function(event, jqxhr, settings, thrownError) {
|
|
|
42 |
//$( ".log" ).text( "Triggered ajaxError handler." );
|
|
|
43 |
if(jqxhr.status == 400){
|
| 22982 |
ashik.ali |
44 |
//$('#error-prompt-model').modal();
|
| 22956 |
ashik.ali |
45 |
badRequestAlert(jqxhr);
|
|
|
46 |
}else{
|
|
|
47 |
internalServerErrorAlert(jqxhr);
|
|
|
48 |
}
|
|
|
49 |
});
|
|
|
50 |
|
| 23026 |
ashik.ali |
51 |
function doGetAjaxRequest(urlString){
|
|
|
52 |
var response;
|
|
|
53 |
doAjaxRequestHandler(urlString, "GET", function(ajaxResponse){
|
|
|
54 |
response = ajaxResponse;
|
|
|
55 |
});
|
|
|
56 |
return response;
|
|
|
57 |
}
|
|
|
58 |
|
|
|
59 |
function doPutAjaxRequest(urlString){
|
|
|
60 |
var response;
|
|
|
61 |
doAjaxRequestHandler(urlString, "PUT", function(ajaxResponse){
|
|
|
62 |
response = ajaxResponse;
|
|
|
63 |
});
|
|
|
64 |
return response;
|
|
|
65 |
}
|
|
|
66 |
|
| 23032 |
ashik.ali |
67 |
function doPutAjaxRequestWithJson(urlString, json){
|
|
|
68 |
var response;
|
|
|
69 |
doAjaxRequestWithJsonHandler(urlString, "PUT", json, function(ajaxResponse){
|
|
|
70 |
response = ajaxResponse;
|
|
|
71 |
});
|
|
|
72 |
return response;
|
|
|
73 |
}
|
| 23026 |
ashik.ali |
74 |
|
| 23032 |
ashik.ali |
75 |
function doAjaxRequestWithJsonHandler(urlString, httpType, json, callback_function){
|
|
|
76 |
$.ajax({
|
|
|
77 |
url: urlString,
|
|
|
78 |
async: false,
|
|
|
79 |
cache: false,
|
|
|
80 |
processData: false,
|
|
|
81 |
data: json,
|
|
|
82 |
contentType:'application/json',
|
|
|
83 |
type: httpType,
|
|
|
84 |
success: function(response) {
|
|
|
85 |
//console.log("response"+JSON.stringify(data));
|
|
|
86 |
callback_function(response);
|
|
|
87 |
}
|
|
|
88 |
});
|
|
|
89 |
}
|
|
|
90 |
|
|
|
91 |
|
| 23026 |
ashik.ali |
92 |
function doAjaxRequestHandler(urlString, httpType, callback_function){
|
| 22982 |
ashik.ali |
93 |
$.ajax({
|
|
|
94 |
url: urlString,
|
|
|
95 |
async: false,
|
| 23026 |
ashik.ali |
96 |
cache: false,
|
| 22982 |
ashik.ali |
97 |
type: httpType,
|
|
|
98 |
success: function(response) {
|
|
|
99 |
//console.log("response"+JSON.stringify(data));
|
|
|
100 |
callback_function(response);
|
|
|
101 |
}
|
|
|
102 |
});
|
|
|
103 |
}
|
|
|
104 |
|
| 23026 |
ashik.ali |
105 |
function doAjaxUploadRequest(urlString, httpType, file){
|
|
|
106 |
var response;
|
|
|
107 |
doAjaxUploadRequestHandler(urlString, httpType, file, function(ajaxResponse){
|
|
|
108 |
response = ajaxResponse;
|
|
|
109 |
});
|
|
|
110 |
return response;
|
|
|
111 |
}
|
|
|
112 |
|
|
|
113 |
function doAjaxUploadRequestHandler(urlString, httpType, file, callback_function){
|
| 22982 |
ashik.ali |
114 |
var formData = new FormData();
|
|
|
115 |
formData.append("file", file);
|
|
|
116 |
$.ajax({
|
|
|
117 |
url: urlString,
|
|
|
118 |
type: httpType,
|
|
|
119 |
data: formData,
|
|
|
120 |
dataType: 'json',
|
| 23026 |
ashik.ali |
121 |
async: false,
|
| 22982 |
ashik.ali |
122 |
cache: false,
|
|
|
123 |
contentType: false,
|
|
|
124 |
enctype: 'multipart/form-data',
|
|
|
125 |
processData: false,
|
|
|
126 |
success: function(response) {
|
|
|
127 |
//console.log("response"+JSON.stringify(data));
|
|
|
128 |
callback_function(response);
|
|
|
129 |
}
|
|
|
130 |
});
|
|
|
131 |
}
|
|
|
132 |
|
|
|
133 |
function uploadDocument(file){
|
|
|
134 |
var url = '/profitmandi-web/document-upload';
|
| 23026 |
ashik.ali |
135 |
var response = doAjaxUploadRequest(url, 'POST', file);
|
| 22982 |
ashik.ali |
136 |
var documentId = response.response.document_id;
|
|
|
137 |
console.log("documentId : "+documentId);
|
|
|
138 |
return documentId;
|
|
|
139 |
}
|
|
|
140 |
|
|
|
141 |
|
| 21627 |
kshitij.so |
142 |
function attachSignin(element) {
|
|
|
143 |
console.log(element.id);
|
|
|
144 |
auth2.attachClickHandler(element, {},
|
|
|
145 |
function(googleUser) {
|
|
|
146 |
googleProfile = googleUser.getBasicProfile();
|
|
|
147 |
console.log(googleProfile.getImageUrl());
|
|
|
148 |
submitUser(googleUser);
|
|
|
149 |
}, function(error) {
|
|
|
150 |
console.log(JSON.stringify(error, undefined, 2));
|
|
|
151 |
});
|
|
|
152 |
}
|
|
|
153 |
|
|
|
154 |
function submitUser(googleUser){
|
|
|
155 |
jQuery.ajax({
|
|
|
156 |
type : "POST",
|
| 22090 |
amit.gupta |
157 |
url : context+"/login",
|
| 22139 |
amit.gupta |
158 |
dataType: 'json',
|
| 21627 |
kshitij.so |
159 |
data: {"token":googleUser.getAuthResponse().id_token},
|
|
|
160 |
success: function(data, textStatus, request){
|
|
|
161 |
console.log(data);
|
|
|
162 |
addProfileInLocalDb();
|
| 22139 |
amit.gupta |
163 |
window.location.href= data.redirectUrl;
|
| 21627 |
kshitij.so |
164 |
}
|
|
|
165 |
});
|
|
|
166 |
}
|
|
|
167 |
|
|
|
168 |
function addProfileInLocalDb(){
|
|
|
169 |
var profile = {'image_url':googleProfile.getImageUrl(),'name':googleProfile.getName()};
|
|
|
170 |
localStorage.setItem("profile",JSON.stringify(profile));
|
|
|
171 |
}
|
|
|
172 |
|
|
|
173 |
|
|
|
174 |
function loadNewGrn(domId){
|
| 23026 |
ashik.ali |
175 |
var response = doGetAjaxRequest(context+"/purchase");
|
|
|
176 |
$('#' + domId).html(response);
|
| 21627 |
kshitij.so |
177 |
}
|
|
|
178 |
|
| 23076 |
ashik.ali |
179 |
function getPurchaseByInvoiceNumber(){
|
|
|
180 |
var airwayBillOrInvoiceNumber = $('#airwayBillOrInvoiceNumberText').val();
|
|
|
181 |
var response = doGetAjaxRequest(context+"/purchaseByInvoiceNumber?airwayBillOrInvoiceNumber="+airwayBillOrInvoiceNumber);
|
|
|
182 |
$('#main-content').html(response);
|
|
|
183 |
}
|
|
|
184 |
|
|
|
185 |
function loadPendingGrn(domId){
|
|
|
186 |
var response = doGetAjaxRequest(context+"/pendingGrn");
|
|
|
187 |
$('#' + domId).html(response);
|
|
|
188 |
}
|
|
|
189 |
|
| 21987 |
kshitij.so |
190 |
function loadGoodInventory(domId, search_text){
|
| 23026 |
ashik.ali |
191 |
var response = doGetAjaxRequest(context+"/getCurrentInventorySnapshot/?searchTerm="+search_text);
|
|
|
192 |
$('#' + domId).html(response);
|
| 21987 |
kshitij.so |
193 |
}
|
|
|
194 |
|
|
|
195 |
function loadCatalog(domId, search_text){
|
| 23026 |
ashik.ali |
196 |
var response = doGetAjaxRequest(context+"/getCatalog/?searchTerm="+search_text);
|
|
|
197 |
$('#' + domId).html(response);
|
| 21987 |
kshitij.so |
198 |
}
|
|
|
199 |
|
| 22523 |
ashik.ali |
200 |
function getInventoryItemAgingByInterval(domId, searchContent){
|
|
|
201 |
jQuery.ajax({
|
|
|
202 |
type : "POST",
|
|
|
203 |
url : context+"/getInventoryItemAgingByInterval?searchContent="+searchContent,
|
|
|
204 |
cache: false,
|
|
|
205 |
contentType: "application/json",
|
|
|
206 |
processData: false,
|
|
|
207 |
async: false,
|
|
|
208 |
data : JSON.stringify([5,15,30,45]),
|
|
|
209 |
success : function(response) {
|
|
|
210 |
$('#' + domId).html(response);
|
| 22956 |
ashik.ali |
211 |
}
|
| 22523 |
ashik.ali |
212 |
});
|
|
|
213 |
}
|
|
|
214 |
|
| 22982 |
ashik.ali |
215 |
function getRetailerDetailsByEmailIdOrMobileNumber(domId, emailIdOrMobileNumber){
|
| 23026 |
ashik.ali |
216 |
var response = doGetAjaxRequest(context+"/retailerDetail/?emailIdOrMobileNumber="+emailIdOrMobileNumber);
|
|
|
217 |
$('#' + domId).html(response);
|
| 22982 |
ashik.ali |
218 |
}
|
|
|
219 |
|
| 22488 |
ashik.ali |
220 |
function downloadAgingReport(){
|
| 22523 |
ashik.ali |
221 |
data = JSON.stringify([5,15,30,45]),
|
| 22488 |
ashik.ali |
222 |
xhttp = new XMLHttpRequest();
|
|
|
223 |
xhttp.onreadystatechange = function() {
|
|
|
224 |
var a;
|
|
|
225 |
if (xhttp.readyState === 4 && xhttp.status === 200) {
|
|
|
226 |
// Trick for making downloadable link
|
|
|
227 |
a = document.createElement('a');
|
|
|
228 |
a.href = window.URL.createObjectURL(xhttp.response);
|
|
|
229 |
// Give filename you wish to download
|
|
|
230 |
a.download = "InventoryItemAging.xlsx";
|
|
|
231 |
a.style.display = 'none';
|
|
|
232 |
document.body.appendChild(a);
|
|
|
233 |
a.click();
|
|
|
234 |
}
|
| 22956 |
ashik.ali |
235 |
if(xhttp.readyState == 4 && xhttp.status === 400){
|
|
|
236 |
badRequestAlert(xhttp.responseText);
|
|
|
237 |
}
|
|
|
238 |
if(xhttp.readyState == 4 && xhttp.status === 500){
|
|
|
239 |
internalServerErrorAlert(xhttp.responseText);
|
|
|
240 |
}
|
| 22488 |
ashik.ali |
241 |
};
|
|
|
242 |
// Post data to URL which handles post request
|
|
|
243 |
xhttp.open("POST", context+"/getInventoryItemAgingByInterval");
|
|
|
244 |
xhttp.setRequestHeader("Content-Type", "application/json");
|
|
|
245 |
// You should set responseType as blob for binary responses
|
|
|
246 |
xhttp.responseType = 'blob';
|
|
|
247 |
xhttp.send(data);
|
|
|
248 |
}
|
|
|
249 |
|
| 22523 |
ashik.ali |
250 |
function downloadItemLedgerReport(){
|
| 23026 |
ashik.ali |
251 |
console.log("downloadItemLedgerReport Button clicked")
|
|
|
252 |
var startEndDateTime = $('input[name="startEndDateTime"]').val().split("-");
|
|
|
253 |
var startDateTime = $.trim(startEndDateTime[0]);
|
|
|
254 |
console.log("startDateTime : "+startDateTime);
|
|
|
255 |
var endDateTime = $.trim(startEndDateTime[1]);
|
|
|
256 |
console.log("endDateTime : "+endDateTime);
|
| 22523 |
ashik.ali |
257 |
//data = JSON.stringify([5,10,15,20,25,30,35,40]),
|
|
|
258 |
xhttp = new XMLHttpRequest();
|
|
|
259 |
xhttp.onreadystatechange = function() {
|
|
|
260 |
var a;
|
|
|
261 |
if (xhttp.readyState === 4 && xhttp.status === 200) {
|
|
|
262 |
// Trick for making downloadable link
|
|
|
263 |
a = document.createElement('a');
|
|
|
264 |
a.href = window.URL.createObjectURL(xhttp.response);
|
|
|
265 |
// Give filename you wish to download
|
|
|
266 |
a.download = "ItemCompleteLedegerReport.xlsx";
|
|
|
267 |
a.style.display = 'none';
|
|
|
268 |
document.body.appendChild(a);
|
|
|
269 |
a.click();
|
|
|
270 |
}
|
| 22956 |
ashik.ali |
271 |
if(xhttp.readyState == 4 && xhttp.status === 400){
|
|
|
272 |
badRequestAlert(xhttp.responseText);
|
|
|
273 |
}
|
|
|
274 |
if(xhttp.readyState == 4 && xhttp.status === 500){
|
|
|
275 |
internalServerErrorAlert(xhttp.responseText);
|
|
|
276 |
}
|
| 22523 |
ashik.ali |
277 |
};
|
|
|
278 |
// Post data to URL which handles post request
|
| 23026 |
ashik.ali |
279 |
xhttp.open("GET", context+"/itemLedger/complete/download?startDateTime="+startDateTime+"&endDateTime="+endDateTime);
|
| 22523 |
ashik.ali |
280 |
//xhttp.setRequestHeader("Content-Type", "application/json");
|
|
|
281 |
// You should set responseType as blob for binary responses
|
|
|
282 |
xhttp.responseType = 'blob';
|
|
|
283 |
xhttp.send(null);
|
|
|
284 |
}
|
|
|
285 |
|
| 23026 |
ashik.ali |
286 |
|
|
|
287 |
function schemesDownload(){
|
|
|
288 |
console.log("downloadItemLedgerReport Button clicked")
|
|
|
289 |
var startEndDateTime = $('input[name="startEndDateTime"]').val().split("-");
|
|
|
290 |
var startDateTime = $.trim(startEndDateTime[0]);
|
|
|
291 |
console.log("startDateTime : "+startDateTime);
|
|
|
292 |
var endDateTime = $.trim(startEndDateTime[1]);
|
|
|
293 |
console.log("endDateTime : "+endDateTime);
|
|
|
294 |
//data = JSON.stringify([5,10,15,20,25,30,35,40]),
|
|
|
295 |
xhttp = new XMLHttpRequest();
|
|
|
296 |
xhttp.onreadystatechange = function() {
|
|
|
297 |
var a;
|
|
|
298 |
if (xhttp.readyState === 4 && xhttp.status === 200) {
|
|
|
299 |
// Trick for making downloadable link
|
|
|
300 |
a = document.createElement('a');
|
|
|
301 |
a.href = window.URL.createObjectURL(xhttp.response);
|
|
|
302 |
// Give filename you wish to download
|
|
|
303 |
a.download = "SchemesReport.xlsx";
|
|
|
304 |
a.style.display = 'none';
|
|
|
305 |
document.body.appendChild(a);
|
|
|
306 |
a.click();
|
|
|
307 |
}
|
|
|
308 |
if(xhttp.readyState == 4 && xhttp.status === 400){
|
|
|
309 |
badRequestAlert(xhttp.responseText);
|
|
|
310 |
}
|
|
|
311 |
if(xhttp.readyState == 4 && xhttp.status === 500){
|
|
|
312 |
internalServerErrorAlert(xhttp.responseText);
|
|
|
313 |
}
|
|
|
314 |
};
|
|
|
315 |
// Post data to URL which handles post request
|
|
|
316 |
xhttp.open("GET", context+"/schemes/download?startDateTime="+startDateTime+"&endDateTime="+endDateTime);
|
|
|
317 |
//xhttp.setRequestHeader("Content-Type", "application/json");
|
|
|
318 |
// You should set responseType as blob for binary responses
|
|
|
319 |
xhttp.responseType = 'blob';
|
|
|
320 |
xhttp.send(null);
|
|
|
321 |
}
|
|
|
322 |
|
| 22523 |
ashik.ali |
323 |
function getItemAgingNextPreviousItems(offset, searchContent){
|
|
|
324 |
|
|
|
325 |
jQuery.ajax({
|
|
|
326 |
type : "POST",
|
|
|
327 |
url : context+"/getInventoryItemAgingByInterval?offset="+offset+"&searchContent="+searchContent,
|
|
|
328 |
cache: false,
|
|
|
329 |
contentType: "application/json",
|
|
|
330 |
processData: false,
|
|
|
331 |
async: false,
|
|
|
332 |
data : JSON.stringify([5,15,30,45]),
|
|
|
333 |
beforeSend: function(){
|
|
|
334 |
//$('#ajax-spinner').show();
|
|
|
335 |
},
|
|
|
336 |
complete: function(){
|
|
|
337 |
//$('#ajax-spinner').hide();
|
|
|
338 |
},
|
|
|
339 |
success : function(response) {
|
|
|
340 |
$('#main-content').html(response);
|
| 22956 |
ashik.ali |
341 |
}
|
| 22523 |
ashik.ali |
342 |
});
|
|
|
343 |
}
|
|
|
344 |
|
|
|
345 |
function getGrnHistoryPreviousItems(start,end,pre,purchase_reference, searchType,startTime,endTime){
|
| 23026 |
ashik.ali |
346 |
var response = doGetAjaxRequest(context+"/getPaginatedGrnHistory/?purchaseReference="+purchase_reference+"&searchType="+searchType
|
| 22523 |
ashik.ali |
347 |
+"&startTime="+startTime
|
| 23026 |
ashik.ali |
348 |
+"&endTime="+endTime+"&offset="+pre);
|
|
|
349 |
|
|
|
350 |
$( "#grn-history-paginated .end" ).text(+end - +10);
|
|
|
351 |
$( "#grn-history-paginated .start" ).text(+start - +10);
|
|
|
352 |
$('#grn-history-table').html(response);
|
|
|
353 |
$("#grn-history-paginated .next").prop('disabled', false);
|
|
|
354 |
if (parseInt(pre)==0)
|
|
|
355 |
{
|
|
|
356 |
$("#grn-history-paginated .previous").prop('disabled', true);
|
|
|
357 |
}
|
| 22523 |
ashik.ali |
358 |
}
|
|
|
359 |
|
| 21987 |
kshitij.so |
360 |
function loadBadInventory(domId, search_text){
|
| 23026 |
ashik.ali |
361 |
var response = doGetAjaxRequest(context+"/getBadInventorySnapshot/?searchTerm="+search_text);
|
|
|
362 |
$('#' + domId).html(response);
|
| 21987 |
kshitij.so |
363 |
}
|
|
|
364 |
|
|
|
365 |
function loadGrnHistory(domId,purchase_reference,searchType, startTime, endTime){
|
| 23026 |
ashik.ali |
366 |
var response = doGetAjaxRequest(context+"/grnHistory/?purchaseReference="+purchase_reference+"&searchType="+searchType
|
|
|
367 |
+"&startTime="+startTime
|
|
|
368 |
+"&endTime="+endTime);
|
|
|
369 |
$('#' + domId).html(response);
|
| 21987 |
kshitij.so |
370 |
}
|
|
|
371 |
|
| 22245 |
ashik.ali |
372 |
|
| 21987 |
kshitij.so |
373 |
function getNextItems(start, end, searchText){
|
|
|
374 |
console.log(start);
|
|
|
375 |
console.log(end);
|
|
|
376 |
console.log(+end + +10);
|
|
|
377 |
console.log(+start + +10);
|
| 23026 |
ashik.ali |
378 |
var response = doGetAjaxRequest(context+"/getPaginatedCurrentInventorySnapshot/?offset="+end+"&searchTerm="+searchText);
|
|
|
379 |
|
|
|
380 |
$( "#good-inventory-paginated .end" ).text(+end + +10);
|
|
|
381 |
$( "#good-inventory-paginated .start" ).text(+start + +10);
|
|
|
382 |
var last = $( "#good-inventory-paginated .end" ).text();
|
|
|
383 |
var temp = $( "#good-inventory-paginated .size" ).text();
|
|
|
384 |
if (parseInt(last) >= parseInt(temp)){
|
|
|
385 |
$("#good-inventory-paginated .next").prop('disabled', true);
|
|
|
386 |
//$( "#good-inventory-paginated .end" ).text(temp);
|
| 21987 |
kshitij.so |
387 |
}
|
| 23026 |
ashik.ali |
388 |
$('#good-inventory-table').html(response);
|
|
|
389 |
$("#good-inventory-paginated .previous").prop('disabled', false);
|
|
|
390 |
|
|
|
391 |
}
|
|
|
392 |
|
| 21987 |
kshitij.so |
393 |
function getPreviousItems(start,end,pre,searchText){
|
| 23026 |
ashik.ali |
394 |
var response = doGetAjaxRequest(context+"/getPaginatedCurrentInventorySnapshot/?offset="+pre+"&searchTerm="+searchText);
|
|
|
395 |
|
|
|
396 |
$( "#good-inventory-paginated .end" ).text(+end - +10);
|
|
|
397 |
$( "#good-inventory-paginated .start" ).text(+start - +10);
|
|
|
398 |
$('#good-inventory-table').html(response);
|
|
|
399 |
$("#good-inventory-paginated .next").prop('disabled', false);
|
|
|
400 |
if (parseInt(pre)==0)
|
|
|
401 |
{
|
|
|
402 |
$("#good-inventory-paginated .previous").prop('disabled', true);
|
|
|
403 |
}
|
|
|
404 |
|
| 21987 |
kshitij.so |
405 |
}
|
|
|
406 |
|
|
|
407 |
function getGrnHistoryNextItems(start, end, purchase_reference, searchType,startTime,endTime){
|
|
|
408 |
console.log(start);
|
|
|
409 |
console.log(end);
|
|
|
410 |
console.log(+end + +10);
|
|
|
411 |
console.log(+start + +10);
|
| 23026 |
ashik.ali |
412 |
var response = doGetAjaxRequest(context+"/getPaginatedGrnHistory/?purchaseReference="+purchase_reference+"&searchType="+searchType
|
| 21987 |
kshitij.so |
413 |
+"&startTime="+startTime
|
| 23026 |
ashik.ali |
414 |
+"&endTime="+endTime+"&offset="+end);
|
|
|
415 |
|
|
|
416 |
$( "#grn-history-paginated .end" ).text(+end + +10);
|
|
|
417 |
$( "#grn-history-paginated .start" ).text(+start + +10);
|
|
|
418 |
var last = $( "#grn-history-paginated .end" ).text();
|
|
|
419 |
var temp = $( "#grn-history-paginated .size" ).text();
|
|
|
420 |
if (parseInt(last) >= parseInt(temp)){
|
|
|
421 |
$("#grn-history-paginated .next").prop('disabled', true);
|
|
|
422 |
//$( "#good-inventory-paginated .end" ).text(temp);
|
| 21987 |
kshitij.so |
423 |
}
|
| 23026 |
ashik.ali |
424 |
$('#grn-history-table').html(response);
|
|
|
425 |
$("#grn-history-paginated .previous").prop('disabled', false);
|
|
|
426 |
|
|
|
427 |
}
|
|
|
428 |
|
| 21987 |
kshitij.so |
429 |
function getGrnHistoryPreviousItems(start,end,pre,purchase_reference, searchType,startTime,endTime){
|
| 23026 |
ashik.ali |
430 |
var response = doGetAjaxRequest(context+"/getPaginatedGrnHistory/?purchaseReference="+purchase_reference+"&searchType="+searchType
|
| 21987 |
kshitij.so |
431 |
+"&startTime="+startTime
|
| 23026 |
ashik.ali |
432 |
+"&endTime="+endTime+"&offset="+pre);
|
|
|
433 |
|
|
|
434 |
$( "#grn-history-paginated .end" ).text(+end - +10);
|
|
|
435 |
$( "#grn-history-paginated .start" ).text(+start - +10);
|
|
|
436 |
$('#grn-history-table').html(response);
|
|
|
437 |
$("#grn-history-paginated .next").prop('disabled', false);
|
|
|
438 |
if (parseInt(pre)==0)
|
|
|
439 |
{
|
|
|
440 |
$("#grn-history-paginated .previous").prop('disabled', true);
|
|
|
441 |
}
|
| 21987 |
kshitij.so |
442 |
}
|
|
|
443 |
|
| 22292 |
ashik.ali |
444 |
function getSaleHistoryNextItems(start, end, invoiceNumber, searchType, startTime, endTime){
|
|
|
445 |
console.log(start);
|
|
|
446 |
console.log(end);
|
|
|
447 |
console.log(+end + +10);
|
|
|
448 |
console.log(+start + +10);
|
| 23026 |
ashik.ali |
449 |
var response = doGetAjaxRequest(context+"/getPaginatedSaleHistory/?invoiceNumber="+invoiceNumber+"&searchType="+searchType
|
| 22292 |
ashik.ali |
450 |
+"&startTime="+startTime
|
| 23026 |
ashik.ali |
451 |
+"&endTime="+endTime+"&offset="+end);
|
|
|
452 |
|
|
|
453 |
$( "#sale-history-paginated .end" ).text(+end + +10);
|
|
|
454 |
$( "#sale-history-paginated .start" ).text(+start + +10);
|
|
|
455 |
var last = $( "#sale-history-paginated .end" ).text();
|
|
|
456 |
var temp = $( "#sale-history-paginated .size" ).text();
|
|
|
457 |
if (parseInt(last) >= parseInt(temp)){
|
|
|
458 |
$("#sale-history-paginated .next").prop('disabled', true);
|
|
|
459 |
//$( "#good-inventory-paginated .end" ).text(temp);
|
| 22292 |
ashik.ali |
460 |
}
|
| 23026 |
ashik.ali |
461 |
$('#sale-history-table').html(response);
|
|
|
462 |
$("#sale-history-paginated .previous").prop('disabled', false);
|
|
|
463 |
|
|
|
464 |
}
|
|
|
465 |
|
| 22292 |
ashik.ali |
466 |
function getSaleHistoryPreviousItems(start, end, pre, invoiceNumber, searchType,startTime,endTime){
|
| 23026 |
ashik.ali |
467 |
|
|
|
468 |
var response = doGetAjaxRequest(context+"/getPaginatedSaleHistory/?invoiceNumber="+invoiceNumber+"&searchType="+searchType
|
| 22292 |
ashik.ali |
469 |
+"&startTime="+startTime
|
| 23026 |
ashik.ali |
470 |
+"&endTime="+endTime+"&offset="+pre);
|
|
|
471 |
|
|
|
472 |
$( "#sale-history-paginated .end" ).text(+end - +10);
|
|
|
473 |
$( "#sale-history-paginated .start" ).text(+start - +10);
|
|
|
474 |
$('#sale-history-table').html(response);
|
|
|
475 |
$("#sale-history-paginated .next").prop('disabled', false);
|
|
|
476 |
if (parseInt(pre)==0)
|
|
|
477 |
{
|
|
|
478 |
$("#sale-history-paginated .previous").prop('disabled', true);
|
|
|
479 |
}
|
|
|
480 |
|
| 22292 |
ashik.ali |
481 |
}
|
|
|
482 |
|
| 22551 |
ashik.ali |
483 |
|
| 22860 |
ashik.ali |
484 |
function getSchemesNextItems(start, end){
|
|
|
485 |
console.log(start);
|
|
|
486 |
console.log(end);
|
|
|
487 |
console.log(+end + +10);
|
|
|
488 |
console.log(+start + +10);
|
| 23026 |
ashik.ali |
489 |
var response = doGetAjaxRequest(context+"/getPaginatedSchemes?offset="+end);
|
|
|
490 |
|
|
|
491 |
$( "#schemes-paginated .end" ).text(+end + +10);
|
|
|
492 |
$( "#schemes-paginated .start" ).text(+start + +10);
|
|
|
493 |
var last = $( "#schemes-paginated .end" ).text();
|
|
|
494 |
var temp = $( "#schemes-paginated .size" ).text();
|
|
|
495 |
if (parseInt(last) >= parseInt(temp)){
|
|
|
496 |
$("#schemes-paginated .next").prop('disabled', true);
|
|
|
497 |
//$( "#good-inventory-paginated .end" ).text(temp);
|
| 22860 |
ashik.ali |
498 |
}
|
| 23026 |
ashik.ali |
499 |
$('#schemes-table').html(response);
|
|
|
500 |
$('#scheme-details-container').html('');
|
|
|
501 |
$("#schemes-paginated .previous").prop('disabled', false);
|
|
|
502 |
|
|
|
503 |
}
|
| 22551 |
ashik.ali |
504 |
|
| 22860 |
ashik.ali |
505 |
|
|
|
506 |
function getSchemesPreviousItems(start, end, pre){
|
| 23026 |
ashik.ali |
507 |
|
|
|
508 |
var response = doGetAjaxRequest(context+"/getPaginatedSchemes/?offset="+pre);
|
|
|
509 |
$( "#schemes-paginated .end" ).text(+end - +10);
|
|
|
510 |
$( "#schemes-paginated .start" ).text(+start - +10);
|
|
|
511 |
$('#schemes-table').html(response);
|
|
|
512 |
$('#scheme-details-container').html('');
|
|
|
513 |
$("#schemes-paginated .next").prop('disabled', false);
|
|
|
514 |
if (parseInt(pre)==0)
|
|
|
515 |
{
|
|
|
516 |
$("#schemes-paginated .previous").prop('disabled', true);
|
|
|
517 |
}
|
|
|
518 |
|
| 22860 |
ashik.ali |
519 |
}
|
|
|
520 |
|
|
|
521 |
|
|
|
522 |
|
| 22551 |
ashik.ali |
523 |
function getWalletHistoryNextItems(start, end, startTime, endTime){
|
|
|
524 |
console.log(start);
|
|
|
525 |
console.log(end);
|
|
|
526 |
console.log(+end + +10);
|
|
|
527 |
console.log(+start + +10);
|
| 23026 |
ashik.ali |
528 |
var response = doGetAjaxRequest(context+"/getPaginatedWalletHistory?startTime="+startTime
|
|
|
529 |
+"&endTime="+endTime+"&offset="+end);
|
|
|
530 |
|
|
|
531 |
$( "#wallet-history-paginated .end" ).text(+end + +10);
|
|
|
532 |
$( "#wallet-history-paginated .start" ).text(+start + +10);
|
|
|
533 |
var last = $( "#wallet-history-paginated .end" ).text();
|
|
|
534 |
var temp = $( "#wallet-history-paginated .size" ).text();
|
|
|
535 |
if (parseInt(last) >= parseInt(temp)){
|
|
|
536 |
$("#wallet-history-paginated .next").prop('disabled', true);
|
|
|
537 |
//$( "#good-inventory-paginated .end" ).text(temp);
|
| 22551 |
ashik.ali |
538 |
}
|
| 23026 |
ashik.ali |
539 |
$('#wallet-history-table').html(response);
|
|
|
540 |
$("#wallet-history-paginated .previous").prop('disabled', false);
|
|
|
541 |
|
|
|
542 |
|
|
|
543 |
}
|
|
|
544 |
|
| 22860 |
ashik.ali |
545 |
function getWalletHistoryPreviousItems(start, end, pre, startTime, endTime){
|
| 23026 |
ashik.ali |
546 |
var response = doGetAjaxRequest(context+"/getPaginatedWalletHistory?startTime="+startTime
|
|
|
547 |
+"&endTime="+endTime+"&offset="+pre);
|
|
|
548 |
|
|
|
549 |
$( "#wallet-history-paginated .end" ).text(+end - +10);
|
|
|
550 |
$( "#wallet-history-paginated .start" ).text(+start - +10);
|
|
|
551 |
$('#wallet-history-table').html(response);
|
|
|
552 |
$("#wallet-history-paginated .next").prop('disabled', false);
|
|
|
553 |
if (parseInt(pre)==0)
|
|
|
554 |
{
|
|
|
555 |
$("#wallet-history-paginated .previous").prop('disabled', true);
|
|
|
556 |
}
|
|
|
557 |
|
| 22551 |
ashik.ali |
558 |
}
|
|
|
559 |
|
| 21987 |
kshitij.so |
560 |
function loadGoodInventorySearchInfo(search_text){
|
|
|
561 |
loadGoodInventory("main-content",search_text);
|
|
|
562 |
}
|
|
|
563 |
|
|
|
564 |
function loadGrnHistorySearchInfo(search_text,searchType,startTime,endTime){
|
|
|
565 |
loadGrnHistory("main-content",search_text,searchType,startTime,endTime);
|
|
|
566 |
}
|
|
|
567 |
|
| 21627 |
kshitij.so |
568 |
function findDuplicateSerialNumbers(value){
|
|
|
569 |
var result = $("#grnImeiInformation :input[value='" + value + "']").length - 1;
|
|
|
570 |
return result;
|
|
|
571 |
}
|
| 21987 |
kshitij.so |
572 |
|
| 23026 |
ashik.ali |
573 |
function loadGrnDetails(purchaseId, domId){
|
|
|
574 |
var response = doGetAjaxRequest(context+"/grnHistoryDetailByPurchaseId/?purchaseId="+purchaseId);
|
|
|
575 |
$('#' + domId).html(response);
|
|
|
576 |
window.dispatchEvent(new Event('resize'));
|
| 21987 |
kshitij.so |
577 |
}
|
|
|
578 |
|
| 23076 |
ashik.ali |
579 |
function loadPendingGrnDetails(orderId, domId){
|
|
|
580 |
var response = doGetAjaxRequest(context+"/pendingGrnDetails/?orderId="+orderId);
|
|
|
581 |
$('#' + domId).html(response);
|
|
|
582 |
|
|
|
583 |
window.dispatchEvent(new Event('resize'));
|
|
|
584 |
}
|
|
|
585 |
|
| 22245 |
ashik.ali |
586 |
function loadSaleDetails(orderId, domId){
|
| 23026 |
ashik.ali |
587 |
|
|
|
588 |
var response = doGetAjaxRequest(context+"/saleDetails?orderId="+orderId);
|
|
|
589 |
$('#' + domId).html(response);
|
| 22860 |
ashik.ali |
590 |
}
|
|
|
591 |
|
|
|
592 |
function loadSchemeDetails(schemeId, domId){
|
| 23026 |
ashik.ali |
593 |
var response = doGetAjaxRequest(context+"/getSchemeById?schemeId="+schemeId);
|
|
|
594 |
$('#' + domId).html(response);
|
|
|
595 |
window.dispatchEvent(new Event('resize'));
|
| 22245 |
ashik.ali |
596 |
}
|
|
|
597 |
|
| 22860 |
ashik.ali |
598 |
function activeScheme(schemeId, offset, domId){
|
| 23026 |
ashik.ali |
599 |
var response = doPutAjaxRequest(context+"/activeSchemeById?schemeId="+schemeId
|
|
|
600 |
+"&offset="+offset);
|
|
|
601 |
$('#' + domId).html(response);
|
|
|
602 |
$('#scheme-details-container').html('');
|
| 22860 |
ashik.ali |
603 |
}
|
|
|
604 |
|
|
|
605 |
function expireScheme(schemeId, offset, domId){
|
| 23026 |
ashik.ali |
606 |
var response = doPutAjaxRequest(context+"/expireSchemeById?schemeId="+schemeId
|
|
|
607 |
+"&offset="+offset);
|
|
|
608 |
$('#' + domId).html(response);
|
|
|
609 |
$('#scheme-details-container').html('');
|
| 22860 |
ashik.ali |
610 |
}
|
|
|
611 |
|
| 21987 |
kshitij.so |
612 |
function getNextCatalogItems(start, end, searchText){
|
|
|
613 |
console.log(start);
|
|
|
614 |
console.log(end);
|
|
|
615 |
console.log(+end + +10);
|
|
|
616 |
console.log(+start + +10);
|
| 23026 |
ashik.ali |
617 |
var response = doGetAjaxRequest(context+"/getPaginatedCatalog/?offset="+end+"&searchTerm="+searchText);
|
|
|
618 |
|
|
|
619 |
$( "#catalog-paginated .end" ).text(+end + +10);
|
|
|
620 |
$( "#catalog-paginated .start" ).text(+start + +10);
|
|
|
621 |
var last = $( "#catalog-paginated .end" ).text();
|
|
|
622 |
var temp = $( "#catalog-paginated .size" ).text();
|
|
|
623 |
if (parseInt(last) >= parseInt(temp)){
|
|
|
624 |
$("#catalog-paginated .next").prop('disabled', true);
|
| 21987 |
kshitij.so |
625 |
}
|
| 23026 |
ashik.ali |
626 |
$('#catalog-table').html(response);
|
|
|
627 |
$("#catalog-paginated .previous").prop('disabled', false);
|
|
|
628 |
|
|
|
629 |
}
|
|
|
630 |
|
| 21987 |
kshitij.so |
631 |
function getPreviousCatalogItems(start,end,pre,searchText){
|
| 23026 |
ashik.ali |
632 |
var response = doGetAjaxRequest(context+"/getPaginatedCatalog/?offset="+pre+"&searchTerm="+searchText);
|
|
|
633 |
|
|
|
634 |
$( "#catalog-paginated .end" ).text(+end - +10);
|
|
|
635 |
$( "#catalog-paginated .start" ).text(+start - +10);
|
|
|
636 |
$('#catalog-table').html(response);
|
|
|
637 |
$("#catalog-paginated .next").prop('disabled', false);
|
|
|
638 |
if (parseInt(pre)==0)
|
|
|
639 |
{
|
|
|
640 |
$("#catalog-paginated .previous").prop('disabled', true);
|
|
|
641 |
}
|
| 21987 |
kshitij.so |
642 |
}
|
|
|
643 |
|
|
|
644 |
function loadCatalogSearchInfo(search_text){
|
|
|
645 |
loadCatalog("main-content",search_text);
|
|
|
646 |
}
|
|
|
647 |
|
|
|
648 |
function addItemInLocalStorage(bagObj){
|
|
|
649 |
if (localStorage.getItem("bag")!=null){
|
|
|
650 |
var bag = JSON.parse(localStorage.getItem("bag"));
|
|
|
651 |
bag[bagObj.itemId] = bagObj
|
|
|
652 |
localStorage.setItem("bag",JSON.stringify(bag));
|
|
|
653 |
bag = localStorage.getItem("bag")
|
|
|
654 |
$("#cart_bar").find('span').text(Object.keys(JSON.parse(bag)).length);
|
|
|
655 |
}
|
|
|
656 |
else{
|
|
|
657 |
var tempObj = {};
|
|
|
658 |
tempObj[bagObj.itemId] = bagObj
|
|
|
659 |
localStorage.setItem("bag",JSON.stringify(tempObj));
|
|
|
660 |
var bag = localStorage.getItem("bag")
|
|
|
661 |
$("#cart_bar").find('span').text(Object.keys(JSON.parse(bag)).length);
|
|
|
662 |
}
|
|
|
663 |
}
|
|
|
664 |
|
|
|
665 |
|
|
|
666 |
function changeQuantityInLocalStorage(itemId, newQuantity){
|
|
|
667 |
var bag = JSON.parse(localStorage.getItem("bag"));
|
|
|
668 |
bag[itemId].quantity = newQuantity;
|
|
|
669 |
localStorage.setItem("bag",JSON.stringify(bag));
|
|
|
670 |
}
|
|
|
671 |
|
|
|
672 |
function removeItemFromLocalStorage(itemId){
|
|
|
673 |
if (localStorage.getItem("bag")!=null){
|
|
|
674 |
var bag = JSON.parse(localStorage.getItem("bag"));
|
|
|
675 |
delete bag[itemId];
|
|
|
676 |
localStorage.setItem("bag",JSON.stringify(bag));
|
|
|
677 |
$("#cart_bar").find('span').text(Object.keys(bag).length);
|
|
|
678 |
}
|
|
|
679 |
}
|
|
|
680 |
|
|
|
681 |
function emptyBag(){
|
| 22095 |
kshitij.so |
682 |
localStorage.setItem("bag",JSON.stringify({}));
|
| 21987 |
kshitij.so |
683 |
$("#cart_bar").find('span').text(0);
|
|
|
684 |
}
|
|
|
685 |
|
|
|
686 |
function loadCart(domId){
|
|
|
687 |
jQuery.ajax({
|
|
|
688 |
type : "POST",
|
|
|
689 |
data: {"cartData":localStorage.getItem("bag")},
|
| 22090 |
amit.gupta |
690 |
url : context+"/cart",
|
| 21987 |
kshitij.so |
691 |
success : function(response) {
|
|
|
692 |
$('#' + domId).html(response);
|
|
|
693 |
}
|
|
|
694 |
});
|
|
|
695 |
}
|
|
|
696 |
|
| 22551 |
ashik.ali |
697 |
function loadWallet(domId, startTime, endTime){
|
| 23026 |
ashik.ali |
698 |
var response = doGetAjaxRequest(context+"/walletDetails?startTime="+startTime
|
|
|
699 |
+"&endTime="+endTime);
|
|
|
700 |
$('#' + domId).html(response);
|
| 22551 |
ashik.ali |
701 |
}
|
|
|
702 |
|
| 21987 |
kshitij.so |
703 |
function checkout(domId){
|
|
|
704 |
jQuery.ajax({
|
| 22095 |
kshitij.so |
705 |
type : "GET",
|
| 21987 |
kshitij.so |
706 |
data: {"cartData":localStorage.getItem("bag")},
|
| 22090 |
amit.gupta |
707 |
url : context+"/validate-cart",
|
| 21987 |
kshitij.so |
708 |
success : function(response) {
|
|
|
709 |
var obj = JSON.parse(response);
|
|
|
710 |
redirectCart(obj.redirectUrl, obj.params, obj.method, "main-content");
|
| 22095 |
kshitij.so |
711 |
$('#main-content').html(response);
|
| 21987 |
kshitij.so |
712 |
}
|
| 22245 |
ashik.ali |
713 |
});
|
| 21987 |
kshitij.so |
714 |
}
|
|
|
715 |
|
| 22860 |
ashik.ali |
716 |
function loadScheme(domId){
|
| 23026 |
ashik.ali |
717 |
var response = doGetAjaxRequest(context+"/createScheme");
|
|
|
718 |
$('#' + domId).html(response);
|
|
|
719 |
}
|
|
|
720 |
|
|
|
721 |
function loadItemLedgerReportDownloadPage(domId){
|
|
|
722 |
var response = doGetAjaxRequest(context+"/itemLedger/downloadPage");
|
|
|
723 |
$('#' + domId).html(response);
|
|
|
724 |
}
|
|
|
725 |
|
|
|
726 |
function loadItemsDescriptionByBrand(domId, brand){
|
|
|
727 |
var response = doGetAjaxRequest(context+"/getItemsByBrand?brand="+brand);
|
|
|
728 |
$('#' + domId).html(response);
|
|
|
729 |
configureItemsDescriptionDropDown();
|
|
|
730 |
}
|
|
|
731 |
|
|
|
732 |
function configureItemsDescriptionDropDown(){
|
|
|
733 |
$(document).ready(function() {
|
|
|
734 |
$('#itemsDescription').multiselect({
|
|
|
735 |
includeSelectAllOption: true,
|
|
|
736 |
maxHeight: 200,
|
|
|
737 |
buttonWidth: '180px',
|
|
|
738 |
numberDisplayed: 1,
|
|
|
739 |
nonSelectedText: 'Items',
|
|
|
740 |
nSelectedText: ' - Items Selected',
|
|
|
741 |
allSelectedText: 'All Items Selected',
|
|
|
742 |
enableFiltering: true
|
|
|
743 |
});
|
| 22860 |
ashik.ali |
744 |
});
|
|
|
745 |
}
|
|
|
746 |
|
| 22982 |
ashik.ali |
747 |
function retailerInfo(domId){
|
| 23026 |
ashik.ali |
748 |
var response = doGetAjaxRequest(context+"/retailerInfo");
|
|
|
749 |
$('#' + domId).html(response);
|
| 22982 |
ashik.ali |
750 |
}
|
|
|
751 |
|
| 21987 |
kshitij.so |
752 |
function redirectCart(url, cartData, method, domId){
|
|
|
753 |
jQuery.ajax({
|
|
|
754 |
type : method,
|
|
|
755 |
data: {"cartData":cartData},
|
|
|
756 |
url : context+url,
|
|
|
757 |
success : function(response) {
|
|
|
758 |
$('#' + domId).html(response);
|
|
|
759 |
window.dispatchEvent(new Event('resize'));
|
|
|
760 |
}
|
|
|
761 |
});
|
|
|
762 |
}
|
|
|
763 |
|
| 22245 |
ashik.ali |
764 |
function saleHistory(domId, invoiceNumber, searchType, startTime, endTime){
|
| 23026 |
ashik.ali |
765 |
var response = doGetAjaxRequest(context+"/saleHistory?invoiceNumber="+invoiceNumber+"&searchType="+searchType
|
|
|
766 |
+"&startTime="+startTime
|
|
|
767 |
+"&endTime="+endTime);
|
|
|
768 |
$('#' + domId).html(response);
|
| 22245 |
ashik.ali |
769 |
}
|
|
|
770 |
|
| 22860 |
ashik.ali |
771 |
function schemes(domId){
|
| 23026 |
ashik.ali |
772 |
var response = doGetAjaxRequest(context+"/getSchemes");
|
|
|
773 |
$('#' + domId).html(response);
|
| 22860 |
ashik.ali |
774 |
}
|
| 22354 |
ashik.ali |
775 |
|
| 23026 |
ashik.ali |
776 |
function loadSchemesDownloadPage(domId){
|
|
|
777 |
var response = doGetAjaxRequest(context+"/schemes/downloadPage");
|
|
|
778 |
$('#' + domId).html(response);
|
|
|
779 |
}
|
| 22860 |
ashik.ali |
780 |
|
| 23026 |
ashik.ali |
781 |
|
| 22354 |
ashik.ali |
782 |
function contactUs(domId){
|
| 23026 |
ashik.ali |
783 |
var response = doGetAjaxRequest(context+"/contactUs");
|
|
|
784 |
$('#' + domId).html(response);
|
| 22354 |
ashik.ali |
785 |
}
|
|
|
786 |
|
|
|
787 |
function writeOldCustomerDetailsByMobileNumber(mobileNumber){
|
| 23026 |
ashik.ali |
788 |
var response = doGetAjaxRequest(context+"/customer/mobileNumber?mobileNumber="+mobileNumber);
|
|
|
789 |
|
|
|
790 |
var customer = response.response;
|
|
|
791 |
$('#firstName').attr('value', customer.firstName);
|
|
|
792 |
$('#lastName').attr('value', customer.lastName);
|
|
|
793 |
$('#email').attr('value', customer.emailId);
|
|
|
794 |
//$('#phone').attr('value', customer.mobileNumber);
|
|
|
795 |
$('#alternatePhone').attr('value', customer.address.phoneNumber);
|
|
|
796 |
$('#line1').attr('value', customer.address.line1);
|
|
|
797 |
$('#line2').attr('value', customer.address.line2);
|
|
|
798 |
$('#landmark').attr('value', customer.address.landmark);
|
|
|
799 |
$('#pinCode').attr('value', customer.address.pinCode);
|
|
|
800 |
$('#city').attr('value', customer.address.city);
|
|
|
801 |
$('#state').attr('value', customer.address.state).prop('selected',true);
|
|
|
802 |
//$('#state').val(customer.address.state).prop('selected', true);
|
|
|
803 |
$('#phone').attr('addressId', customer.address.id);
|
| 22354 |
ashik.ali |
804 |
}
|
|
|
805 |
|
| 22283 |
ashik.ali |
806 |
function saleHistorySearchInfo(search_text, searchType, startTime, endTime){
|
|
|
807 |
saleHistory("main-content", search_text, searchType, startTime, endTime);
|
|
|
808 |
}
|
| 22245 |
ashik.ali |
809 |
|
| 22551 |
ashik.ali |
810 |
function walletHistoryDateSearchSearchInfo(startTime, endTime){
|
|
|
811 |
|
|
|
812 |
}
|
| 22283 |
ashik.ali |
813 |
|
| 22551 |
ashik.ali |
814 |
|
| 23026 |
ashik.ali |
815 |
|
| 21987 |
kshitij.so |
816 |
function validateOrderDetails(){
|
|
|
817 |
var sNumbers = [];
|
|
|
818 |
var error = false;
|
|
|
819 |
$("form#cd input.serialNumber").each(function(){
|
|
|
820 |
var input = $(this).val().trim();
|
| 22245 |
ashik.ali |
821 |
var itemType = $(this).attr("itemType");
|
| 21987 |
kshitij.so |
822 |
$(this).removeClass("border-highlight");
|
| 22245 |
ashik.ali |
823 |
if (sNumbers.indexOf(input) !=-1 || (itemType ==='SERIALIZED' && !input)){
|
| 21987 |
kshitij.so |
824 |
error = true;
|
|
|
825 |
$(this).addClass("border-highlight");
|
|
|
826 |
}
|
|
|
827 |
sNumbers.push(input);
|
|
|
828 |
});
|
|
|
829 |
|
|
|
830 |
$("form#cd input.unitPrice").each(function(){
|
|
|
831 |
var input = $(this).val().trim();
|
|
|
832 |
$(this).removeClass("border-highlight");
|
|
|
833 |
if (!input || parseInt(input)<=0 || isNaN(input)){
|
|
|
834 |
error=true;
|
|
|
835 |
$(this).addClass("border-highlight");
|
|
|
836 |
}
|
|
|
837 |
});
|
|
|
838 |
|
| 22581 |
ashik.ali |
839 |
// checking input discountAmount is not greater than maxDiscountAmount
|
|
|
840 |
$("form#cd input.discountAmount").each(function(){
|
|
|
841 |
var input = $(this).val().trim();
|
|
|
842 |
var mop = $(this).attr("mop");
|
| 22860 |
ashik.ali |
843 |
|
| 22581 |
ashik.ali |
844 |
if(mop){
|
| 22860 |
ashik.ali |
845 |
var maxDiscountPriceRangeString = $(this).attr("placeholder");
|
|
|
846 |
var maxDiscountPrice = 0;
|
|
|
847 |
if(maxDiscountPriceRangeString != undefined && maxDiscountPriceRangeString != ''){
|
|
|
848 |
maxDiscountPrice = maxDiscountPriceRangeString.substring(6);
|
|
|
849 |
}
|
| 22581 |
ashik.ali |
850 |
$(this).removeClass("border-highlight");
|
|
|
851 |
if (!input || parseFloat(input)<0 || isNaN(input)){
|
|
|
852 |
alert("DiscountAmount value can not be lesser than 0 or invalid value");
|
|
|
853 |
error=true;
|
|
|
854 |
$(this).addClass("border-highlight");
|
|
|
855 |
}
|
|
|
856 |
if(parseFloat(input) > maxDiscountPrice){
|
| 22655 |
ashik.ali |
857 |
alert("DiscountAmount [" + parseFloat(input) + "] value can not be greater than the suggested maxDiscountPrice [" + maxDiscountPrice + "]");
|
| 22581 |
ashik.ali |
858 |
error=true;
|
|
|
859 |
$(this).addClass("border-highlight");
|
|
|
860 |
}
|
|
|
861 |
}
|
|
|
862 |
});
|
|
|
863 |
|
| 21987 |
kshitij.so |
864 |
var amount = 0;
|
|
|
865 |
var netPayableAmount = parseFloat($("form#cd input.netPayableAmount").val());
|
|
|
866 |
|
|
|
867 |
|
|
|
868 |
$("form#cd input.amount").each(function(){
|
| 22354 |
ashik.ali |
869 |
if ($(this).val() == ""){
|
| 21987 |
kshitij.so |
870 |
$(this).val(0);
|
|
|
871 |
}
|
|
|
872 |
var tmpAmount = parseFloat($(this).val());
|
|
|
873 |
amount = amount + tmpAmount;
|
|
|
874 |
});
|
|
|
875 |
|
|
|
876 |
console.log(amount);
|
|
|
877 |
console.log(netPayableAmount);
|
|
|
878 |
|
| 22354 |
ashik.ali |
879 |
if (amount != netPayableAmount){
|
|
|
880 |
if(amount < netPayableAmount){
|
|
|
881 |
alert("[" + (netPayableAmount - amount) + "] is more required to complete the payment");
|
|
|
882 |
}else{
|
|
|
883 |
alert("[" + (amount - netPayableAmount) + "] is extra amount, please reduce the amount");
|
|
|
884 |
}
|
|
|
885 |
$("form#cd input.netPayableAmount").each(function(){
|
|
|
886 |
$(this).addClass("border-highlight");
|
|
|
887 |
});
|
| 21987 |
kshitij.so |
888 |
error = true;
|
|
|
889 |
}
|
|
|
890 |
|
|
|
891 |
if (error){
|
|
|
892 |
return false;
|
|
|
893 |
}
|
|
|
894 |
return true;
|
|
|
895 |
|
|
|
896 |
}
|
|
|
897 |
|
| 22860 |
ashik.ali |
898 |
function validateSchemeDetails(){
|
|
|
899 |
console.log("validating Scheme Details...");
|
|
|
900 |
var error = false;
|
|
|
901 |
var name = $("form#create-scheme-form input[name=schemeName]").val();
|
|
|
902 |
console.log("schemeName = " + name);
|
|
|
903 |
$("#schemeName").removeClass("border-highlight");
|
|
|
904 |
if(name = ""){
|
|
|
905 |
alert("Name is required");
|
|
|
906 |
$("#schemeName").addClass("border-highlight");
|
|
|
907 |
error = true;
|
|
|
908 |
return error;
|
|
|
909 |
}
|
|
|
910 |
var schemeType = $("#schemeType option:selected").val();
|
|
|
911 |
console.log("schemeType = " + schemeType);
|
|
|
912 |
$("#schemeType").removeClass("border-highlight");
|
|
|
913 |
if(schemeType = ""){
|
|
|
914 |
alert("Please choose Scheme Type");
|
|
|
915 |
$("#schemeType").addClass("border-highlight");
|
|
|
916 |
error = true;
|
|
|
917 |
return error;
|
|
|
918 |
}
|
|
|
919 |
var amountType = $("#amountType option:selected").val();
|
|
|
920 |
console.log("amountType = " + amountType);
|
|
|
921 |
$("#amountType").removeClass("border-highlight");
|
|
|
922 |
if(amountType = ""){
|
|
|
923 |
alert("Please choose Amount Type");
|
|
|
924 |
$("#amountType").addClass("border-highlight");
|
|
|
925 |
error = true;
|
|
|
926 |
return error;
|
|
|
927 |
}
|
|
|
928 |
var amount = $("form#create-scheme-form input[name=schemeAmount]").val();
|
|
|
929 |
console.log("amount = " + amount);
|
|
|
930 |
$("#schemeAmount").removeClass("border-highlight");
|
|
|
931 |
if (amount == ""){
|
|
|
932 |
$("form#create-scheme-form input[name=schemeAmount]").val(0);
|
|
|
933 |
}else if(amount <= 0){
|
|
|
934 |
alert("Amount should be greater than 0");
|
|
|
935 |
$("#schemeAmount").addClass("border-highlight");
|
|
|
936 |
error = true;
|
|
|
937 |
return error;
|
|
|
938 |
}
|
|
|
939 |
|
|
|
940 |
|
| 23026 |
ashik.ali |
941 |
var startEndDateTime = $("form#create-scheme-form input[name=startEndDateTime]").val().split("-");
|
|
|
942 |
var startDateTimeString = $.trim(startEndDateTime[0]);
|
|
|
943 |
console.log("startDateTimeString : "+startDateTimeString);
|
|
|
944 |
var endDateTimeString = $.trim(startEndDateTime[1]);
|
|
|
945 |
console.log("endDateTimeString : "+endDateTimeString);
|
|
|
946 |
$("#startEndDateTime").removeClass("border-highlight");
|
|
|
947 |
|
|
|
948 |
|
|
|
949 |
if(Date.parse(endDateTimeString) < Date.parse(startDateTimeString)){
|
|
|
950 |
alert("End date Time [" + endDateTimeString + "] can not be greater than equal to Start date Time [" + startDateTimeString + "]");
|
|
|
951 |
$("#startEndDateTime").addClass("border-highlight");
|
| 22860 |
ashik.ali |
952 |
error = true;
|
|
|
953 |
return error;
|
|
|
954 |
}
|
|
|
955 |
|
| 23026 |
ashik.ali |
956 |
//$('#brand-value').text($(this).text());
|
|
|
957 |
$("#brand-value").removeClass("border-highlight");
|
|
|
958 |
if($("#brand-value").text() == "Brands"){
|
|
|
959 |
alert("Please choose Brand");
|
|
|
960 |
$("#brand-value").addClass("border-highlight");
|
| 22860 |
ashik.ali |
961 |
error = true;
|
|
|
962 |
return error;
|
|
|
963 |
}
|
|
|
964 |
|
| 23026 |
ashik.ali |
965 |
$("#itemsDescription").removeClass("border-hightlight");
|
|
|
966 |
var itemIdsString = $("#itemsDescription").val();
|
|
|
967 |
if(itemIdsString == null){
|
|
|
968 |
alert("Please choose items");
|
|
|
969 |
$("#itemsDescription").addClass("border-highlight");
|
|
|
970 |
error = true;
|
|
|
971 |
return error;
|
|
|
972 |
}
|
|
|
973 |
|
| 22860 |
ashik.ali |
974 |
var retailerIdsString = $("#retailerIds").val();
|
|
|
975 |
if(retailerIdsString != undefined){
|
|
|
976 |
var retailerIdsPattern = "^[0-9]{1,10}(?:,[0-9]{1,10})*$";
|
|
|
977 |
if(retailerIdsString.match(retailerIdsPattern) == null){
|
|
|
978 |
alert("Invalid retailerIds["+retailerIdsString+"] pattern");
|
|
|
979 |
$("#retailerIds").addClass("border-highlight");
|
|
|
980 |
error = true;
|
|
|
981 |
return error;
|
|
|
982 |
}
|
|
|
983 |
}
|
|
|
984 |
|
|
|
985 |
console.log("validation scheme error = " + error);
|
|
|
986 |
return error;
|
|
|
987 |
}
|
|
|
988 |
|
| 23026 |
ashik.ali |
989 |
function validateRetailerDetails(){
|
|
|
990 |
console.log("validating Retailer Details...");
|
|
|
991 |
var error = false;
|
|
|
992 |
var retailerName = $("form#update-retailer-details-form input[name=retailerName]").val();
|
|
|
993 |
console.log("retailerName = " + retailerName);
|
|
|
994 |
$("#retailerName").removeClass("border-highlight");
|
|
|
995 |
if(retailerName == ""){
|
|
|
996 |
alert("Retailer Name is required");
|
|
|
997 |
$("#retailerName").addClass("border-highlight");
|
|
|
998 |
error = true;
|
|
|
999 |
return error;
|
|
|
1000 |
}
|
|
|
1001 |
|
| 23108 |
ashik.ali |
1002 |
/*var retailerNumber = $("form#update-retailer-details-form input[name=retailerNumber]").val();
|
| 23026 |
ashik.ali |
1003 |
console.log("retailerNumber = " + retailerNumber);
|
|
|
1004 |
$("#retailerNumber").removeClass("border-highlight");
|
|
|
1005 |
if(retailerNumber == ""){
|
|
|
1006 |
alert("Retailer Number is required");
|
|
|
1007 |
$("#retailerNumber").addClass("border-highlight");
|
|
|
1008 |
error = true;
|
|
|
1009 |
return error;
|
| 23108 |
ashik.ali |
1010 |
}*/
|
| 23026 |
ashik.ali |
1011 |
|
|
|
1012 |
var fileSelector = $('#retailerDocument')[0];
|
|
|
1013 |
if(fileSelector != undefined && fileSelector.files[0] == undefined){
|
|
|
1014 |
alert("Retailer Document is required");
|
|
|
1015 |
error = true;
|
|
|
1016 |
return error;
|
|
|
1017 |
}
|
|
|
1018 |
|
|
|
1019 |
var retailerAddressName = $("form#update-retailer-details-form input[name=retailerAddressName]").val();
|
|
|
1020 |
console.log("retailerAddressName = " + retailerAddressName);
|
|
|
1021 |
$("#retailerAddressName").removeClass("border-highlight");
|
|
|
1022 |
if(retailerAddressName == ""){
|
|
|
1023 |
alert("Retailer Address Name is required");
|
|
|
1024 |
$("#retailerAddressName").addClass("border-highlight");
|
|
|
1025 |
error = true;
|
|
|
1026 |
return error;
|
|
|
1027 |
}
|
|
|
1028 |
|
|
|
1029 |
var retailerAddressLine1 = $("form#update-retailer-details-form input[name=retailerAddressLine1]").val();
|
|
|
1030 |
console.log("retailerAddressLine1 = " + retailerAddressLine1);
|
|
|
1031 |
$("#retailerAddressLine1").removeClass("border-highlight");
|
|
|
1032 |
if(retailerAddressLine1 == ""){
|
|
|
1033 |
alert("Retailer Address Line1 is required");
|
|
|
1034 |
$("#retailerAddressLine1").addClass("border-highlight");
|
|
|
1035 |
error = true;
|
|
|
1036 |
return error;
|
|
|
1037 |
}
|
|
|
1038 |
|
|
|
1039 |
var retailerAddressLine2 = $("form#update-retailer-details-form input[name=retailerAddressLine2]").val();
|
|
|
1040 |
console.log("retailerAddressLine2 = " + retailerAddressLine2);
|
|
|
1041 |
$("#retailerAddressLine2").removeClass("border-highlight");
|
|
|
1042 |
if(retailerAddressLine2 == ""){
|
|
|
1043 |
alert("Retailer Address Line2 is required");
|
|
|
1044 |
$("#retailerAddressLine2").addClass("border-highlight");
|
|
|
1045 |
error = true;
|
|
|
1046 |
return error;
|
|
|
1047 |
}
|
|
|
1048 |
|
|
|
1049 |
var retailerAddressCity = $("form#update-retailer-details-form input[name=retailerAddressCity]").val();
|
|
|
1050 |
console.log("retailerAddressCity = " + retailerAddressCity);
|
|
|
1051 |
$("#retailerAddressCity").removeClass("border-highlight");
|
|
|
1052 |
if(retailerAddressCity == ""){
|
|
|
1053 |
alert("Retailer Address City is required");
|
|
|
1054 |
$("#retailerAddressCity").addClass("border-highlight");
|
|
|
1055 |
error = true;
|
|
|
1056 |
return error;
|
|
|
1057 |
}
|
|
|
1058 |
|
|
|
1059 |
var retailerAddressPinCode = $("form#update-retailer-details-form input[name=retailerAddressPinCode]").val();
|
|
|
1060 |
console.log("retailerAddressPinCode = " + retailerAddressPinCode);
|
|
|
1061 |
$("#retailerAddressPinCode").removeClass("border-highlight");
|
|
|
1062 |
if(retailerAddressPinCode == ""){
|
|
|
1063 |
alert("Retailer Address Pin Code is required");
|
|
|
1064 |
$("#retailerAddressPinCode").addClass("border-highlight");
|
|
|
1065 |
error = true;
|
|
|
1066 |
return error;
|
|
|
1067 |
}
|
|
|
1068 |
|
|
|
1069 |
var retailerAddressState = $("form#update-retailer-details-form input[name=retailerAddressState]").val();
|
|
|
1070 |
console.log("retailerAddressState = " + retailerAddressState);
|
|
|
1071 |
$("#retailerAddressState").removeClass("border-highlight");
|
|
|
1072 |
if(retailerAddressState == ""){
|
|
|
1073 |
alert("Retailer Address State is required");
|
|
|
1074 |
$("#retailerAddressState").addClass("border-highlight");
|
|
|
1075 |
error = true;
|
|
|
1076 |
return error;
|
|
|
1077 |
}
|
|
|
1078 |
|
|
|
1079 |
|
|
|
1080 |
//start from here
|
|
|
1081 |
var shopDetailsSize = $("#shopDetailsSize").attr("size");
|
|
|
1082 |
for(var i = 0; i < shopDetailsSize; i++){
|
|
|
1083 |
var shopName = $("form#update-retailer-details-form input[name=shopName"+i+"]").val();
|
|
|
1084 |
$("form#update-retailer-details-form input[name=shopName"+i+"]").removeClass("border-highlight");
|
|
|
1085 |
if(shopName == ""){
|
|
|
1086 |
alert("Shop Name is required");
|
|
|
1087 |
$("form#update-retailer-details-form input[name=shopName"+i+"]").addClass("border-highlight");
|
|
|
1088 |
error = true;
|
|
|
1089 |
return error;
|
|
|
1090 |
}
|
|
|
1091 |
var fileSelector = $('#retailerShopDocument'+i)[0];
|
|
|
1092 |
if(fileSelector != undefined && fileSelector.files[0] == undefined){
|
|
|
1093 |
alert("Retailer Shop Document is required");
|
|
|
1094 |
error = true;
|
|
|
1095 |
return error;
|
|
|
1096 |
}
|
|
|
1097 |
var shopAddressName = $("form#update-retailer-details-form input[name=shopAddressName"+i+"]").val();
|
|
|
1098 |
$("form#update-retailer-details-form input[name=shopAddressName"+i+"]").removeClass("border-highlight");
|
|
|
1099 |
if(shopAddressName == ""){
|
|
|
1100 |
alert("Shop Address Name is required");
|
|
|
1101 |
$("form#update-retailer-details-form input[name=shopAddressName"+i+"]").addClass("border-highlight");
|
|
|
1102 |
error = true;
|
|
|
1103 |
return error;
|
|
|
1104 |
}
|
|
|
1105 |
var shopAddressLine1 = $("form#update-retailer-details-form input[name=shopAddressLine1"+i+"]").val();
|
|
|
1106 |
$("form#update-retailer-details-form input[name=shopAddressLine1"+i+"]").removeClass("border-highlight");
|
|
|
1107 |
if(shopAddressLine1 == ""){
|
|
|
1108 |
alert("Shop Address Line1 is required");
|
|
|
1109 |
$("form#update-retailer-details-form input[name=shopAddressLine1"+i+"]").addClass("border-highlight");
|
|
|
1110 |
error = true;
|
|
|
1111 |
return error;
|
|
|
1112 |
}
|
|
|
1113 |
var shopAddressLine2 = $("form#update-retailer-details-form input[name=shopAddressLine2"+i+"]").val();
|
|
|
1114 |
$("form#update-retailer-details-form input[name=shopAddressLine2"+i+"]").removeClass("border-highlight");
|
|
|
1115 |
if(shopAddressLine2 == ""){
|
|
|
1116 |
alert("Shop Address Line2 is required");
|
|
|
1117 |
$("form#update-retailer-details-form input[name=shopAddressLine2"+i+"]").addClass("border-highlight");
|
|
|
1118 |
error = true;
|
|
|
1119 |
return error;
|
|
|
1120 |
}
|
|
|
1121 |
var shopAddressCity = $("form#update-retailer-details-form input[name=shopAddressCity"+i+"]").val();
|
|
|
1122 |
$("form#update-retailer-details-form input[name=shopAddressCity"+i+"]").removeClass("border-highlight");
|
|
|
1123 |
if(shopAddressCity == ""){
|
|
|
1124 |
alert("Shop Address City is required");
|
|
|
1125 |
$("form#update-retailer-details-form input[name=shopAddressCity"+i+"]").addClass("border-highlight");
|
|
|
1126 |
error = true;
|
|
|
1127 |
return error;
|
|
|
1128 |
}
|
|
|
1129 |
var shopAddressPinCode = $("form#update-retailer-details-form input[name=shopAddressPinCode"+i+"]").val();
|
|
|
1130 |
$("form#update-retailer-details-form input[name=shopAddressPinCode"+i+"]").removeClass("border-highlight");
|
|
|
1131 |
if(shopAddressPinCode == ""){
|
|
|
1132 |
alert("Shop Address is Pin Code required");
|
|
|
1133 |
$("form#update-retailer-details-form input[name=shopAddressPinCode"+i+"]").addClass("border-highlight");
|
|
|
1134 |
error = true;
|
|
|
1135 |
return error;
|
|
|
1136 |
}
|
|
|
1137 |
var shopAddressState = $("form#update-retailer-details-form input[name=shopAddressState"+i+"]").val();
|
|
|
1138 |
$("form#update-retailer-details-form input[name=shopAddressState"+i+"]").removeClass("border-highlight");
|
|
|
1139 |
if(shopAddressState == ""){
|
|
|
1140 |
alert("Shop Address State is required");
|
|
|
1141 |
$("form#update-retailer-details-form input[name=shopAddressState"+i+"]").addClass("border-highlight");
|
|
|
1142 |
error = true;
|
|
|
1143 |
return error;
|
|
|
1144 |
}
|
|
|
1145 |
}
|
|
|
1146 |
|
|
|
1147 |
console.log("validation retailer details error = " + error);
|
|
|
1148 |
return error;
|
|
|
1149 |
}
|
|
|
1150 |
|
|
|
1151 |
|
|
|
1152 |
function retailerDetailsJson(){
|
|
|
1153 |
console.log("retailerDetailsJson")
|
|
|
1154 |
var retailerDetailsObject = {};
|
| 23105 |
ashik.ali |
1155 |
retailerDetailsObject['emailIdOrMobileNumber'] = $('#retailer-details-search-text').val().trim();
|
| 23026 |
ashik.ali |
1156 |
retailerDetailsObject['name'] = $("form#update-retailer-details-form input[name=retailerName]").val();
|
|
|
1157 |
retailerDetailsObject['number'] = $("form#update-retailer-details-form input[name=retailerNumber]").val();
|
|
|
1158 |
|
|
|
1159 |
var fileSelector = $('#retailerDocument')[0];
|
|
|
1160 |
if(fileSelector != undefined && fileSelector.files[0] != undefined){
|
|
|
1161 |
var documentId = uploadDocument(fileSelector.files[0]);
|
|
|
1162 |
retailerDetailsObject['documentId'] = documentId;
|
|
|
1163 |
}else{
|
|
|
1164 |
retailerDetailsObject['documentId'] = 0;
|
|
|
1165 |
}
|
|
|
1166 |
|
|
|
1167 |
//retailerDetailsObject['file'] = $('#retailerDocument')[0].files[0];
|
|
|
1168 |
var retailerAddressObject = {};
|
|
|
1169 |
retailerAddressObject['name'] = $("form#update-retailer-details-form input[name=retailerAddressName]").val();
|
|
|
1170 |
retailerAddressObject['line1'] = $("form#update-retailer-details-form input[name=retailerAddressLine1]").val();
|
|
|
1171 |
retailerAddressObject['line2'] = $("form#update-retailer-details-form input[name=retailerAddressLine2]").val();
|
|
|
1172 |
retailerAddressObject['city'] = $("form#update-retailer-details-form input[name=retailerAddressCity]").val();
|
|
|
1173 |
retailerAddressObject['pinCode'] = $("form#update-retailer-details-form input[name=retailerAddressPinCode]").val();
|
|
|
1174 |
retailerAddressObject['state'] = $("form#update-retailer-details-form input[name=retailerAddressState]").val();
|
|
|
1175 |
|
|
|
1176 |
retailerDetailsObject['address'] = retailerAddressObject;
|
|
|
1177 |
|
|
|
1178 |
retailerDetailsObject['shops'] = [];
|
|
|
1179 |
var shopDetailsSize = $("#shopDetailsSize").attr("size");
|
|
|
1180 |
|
|
|
1181 |
for(var i = 0; i < shopDetailsSize; i++){
|
|
|
1182 |
var shopObject = {};
|
| 23080 |
ashik.ali |
1183 |
var shopId = $("form#update-retailer-details-form input[name=shopName"+i+"]").attr('shopId');
|
|
|
1184 |
shopObject['shopId'] = shopId;
|
| 23026 |
ashik.ali |
1185 |
shopObject['name'] = $("form#update-retailer-details-form input[name=shopName"+i+"]").val();
|
|
|
1186 |
|
|
|
1187 |
var fileSelector = $('#retailerShopDocument'+i)[0];
|
|
|
1188 |
if(fileSelector != undefined && fileSelector.files[0] != undefined){
|
|
|
1189 |
var documentId = uploadDocument(fileSelector.files[0]);
|
|
|
1190 |
shopObject['documentId'] = documentId;
|
|
|
1191 |
}else{
|
|
|
1192 |
shopObject['documentId'] = 0;
|
|
|
1193 |
}
|
| 23080 |
ashik.ali |
1194 |
var sameAsRetailerAddress = $("form#update-retailer-details-form input[name=sameAsRetailerAddress"+i+"]").val();
|
| 23092 |
ashik.ali |
1195 |
shopObject['sameAsRetailerAddress'] = (sameAsRetailerAddress == 'true');
|
|
|
1196 |
if(shopId == '0' && sameAsRetailerAddress == 'true'){
|
| 23080 |
ashik.ali |
1197 |
shopObject['address'] = null;
|
|
|
1198 |
}else{
|
|
|
1199 |
shopObject['address'] = getShopAddressObject(i);
|
|
|
1200 |
}
|
| 23026 |
ashik.ali |
1201 |
retailerDetailsObject['shops'].push(shopObject);
|
| 23080 |
ashik.ali |
1202 |
|
| 23026 |
ashik.ali |
1203 |
}
|
|
|
1204 |
|
|
|
1205 |
return JSON.stringify(retailerDetailsObject);
|
|
|
1206 |
}
|
|
|
1207 |
|
| 23080 |
ashik.ali |
1208 |
function getShopAddressObject(counter){
|
|
|
1209 |
var shopAddressObject = {};
|
|
|
1210 |
shopAddressObject['name'] = $("form#update-retailer-details-form input[name=shopAddressName"+counter+"]").val();
|
|
|
1211 |
shopAddressObject['line1'] = $("form#update-retailer-details-form input[name=shopAddressLine1"+counter+"]").val();
|
|
|
1212 |
shopAddressObject['line2'] = $("form#update-retailer-details-form input[name=shopAddressLine2"+counter+"]").val();
|
|
|
1213 |
shopAddressObject['city'] = $("form#update-retailer-details-form input[name=shopAddressCity"+counter+"]").val();
|
|
|
1214 |
shopAddressObject['pinCode'] = $("form#update-retailer-details-form input[name=shopAddressPinCode"+counter+"]").val();
|
|
|
1215 |
shopAddressObject['state'] = $("form#update-retailer-details-form input[name=shopAddressState"+counter+"]").val();
|
|
|
1216 |
return shopAddressObject;
|
|
|
1217 |
}
|
|
|
1218 |
|
| 22860 |
ashik.ali |
1219 |
function schemeDetailsJson(){
|
|
|
1220 |
console.log("schemeDetailsJson")
|
|
|
1221 |
var schemeObject = {};
|
|
|
1222 |
schemeObject['name'] = $("form#create-scheme-form input[name=schemeName]").val();
|
|
|
1223 |
schemeObject['description'] = $("form#create-scheme-form input[name=description]").val();
|
|
|
1224 |
schemeObject['type'] = $("#schemeType option:selected").val();
|
|
|
1225 |
schemeObject['amountType'] = $("#amountType option:selected").val();
|
|
|
1226 |
schemeObject['amount'] = $('#schemeAmount').val();
|
| 23026 |
ashik.ali |
1227 |
var startEndDateTime = $("form#create-scheme-form input[name=startEndDateTime]").val().split("-");
|
|
|
1228 |
var startDateTimeString = $.trim(startEndDateTime[0]);
|
|
|
1229 |
console.log("startDateTimeString : "+startDateTimeString);
|
|
|
1230 |
var endDateTimeString = $.trim(startEndDateTime[1]);
|
|
|
1231 |
console.log("endDateTimeString : "+endDateTimeString);
|
|
|
1232 |
|
|
|
1233 |
schemeObject['startDateTimeString'] = startDateTimeString;
|
|
|
1234 |
schemeObject['endDateTimeString'] = endDateTimeString;
|
| 22860 |
ashik.ali |
1235 |
schemeObject['itemIds'] = [];
|
| 23026 |
ashik.ali |
1236 |
var itemIds = $("#itemsDescription").val();
|
|
|
1237 |
//var itemIds = itemIdsString.substring(1, itemIdsString.length - 1).split(",");
|
|
|
1238 |
for(var i = 0; i < itemIds.length; i++){
|
|
|
1239 |
schemeObject['itemIds'].push(parseInt(itemIds[i]));
|
| 22860 |
ashik.ali |
1240 |
}
|
|
|
1241 |
schemeObject['retailerAll'] = $("form#create-scheme-form input[name=retailerAll]").val();
|
|
|
1242 |
if($("#retailerAll").val() == 'true'){
|
|
|
1243 |
schemeObject['retailerIds'] = [];
|
|
|
1244 |
}else{
|
|
|
1245 |
schemeObject['retailerIds'] = []
|
|
|
1246 |
var retailerIds = $("#retailerIds").val().split(",");
|
|
|
1247 |
for(var retailerId of retailerIds){
|
|
|
1248 |
schemeObject['retailerIds'].push(parseInt(retailerId));
|
|
|
1249 |
}
|
|
|
1250 |
}
|
|
|
1251 |
return JSON.stringify(schemeObject);
|
|
|
1252 |
}
|
|
|
1253 |
|
| 22681 |
amit.gupta |
1254 |
function getSerialNumbersFromOrder($el){
|
|
|
1255 |
var $serialNumberElement = $el.find('.serialNumber');
|
| 22860 |
ashik.ali |
1256 |
if($serialNumberElement.val() == ''){
|
|
|
1257 |
return null;
|
|
|
1258 |
}
|
| 22681 |
amit.gupta |
1259 |
var insuranceAmount = parseFloat($el.find('.insuranceAmount').val());
|
|
|
1260 |
if(insuranceAmount > 0){
|
|
|
1261 |
insurance = true;
|
|
|
1262 |
globalInsurace = true;
|
|
|
1263 |
}else{
|
|
|
1264 |
insurance = false;
|
|
|
1265 |
}
|
|
|
1266 |
return {'serialNumber':$serialNumberElement.val(),'insurance':insurance,'amount':insuranceAmount}
|
|
|
1267 |
}
|
|
|
1268 |
|
| 21987 |
kshitij.so |
1269 |
function orderDetailsPayload(){
|
|
|
1270 |
var orderObj = {};
|
|
|
1271 |
var priceQtyArray = [];
|
|
|
1272 |
var customerObj = {};
|
|
|
1273 |
var paymentOption = [];
|
| 22860 |
ashik.ali |
1274 |
var globalInsurance = false;
|
| 21987 |
kshitij.so |
1275 |
|
|
|
1276 |
$("form#cd input.serialNumber").each(function(){
|
|
|
1277 |
var itemId = parseInt($(this).attr("itemId"));
|
| 22860 |
ashik.ali |
1278 |
if (orderObj.hasOwnProperty('fofoOrderItems')){
|
|
|
1279 |
var itemDetails = orderObj['fofoOrderItems'];
|
| 21987 |
kshitij.so |
1280 |
if (itemDetails.hasOwnProperty(itemId)){
|
|
|
1281 |
var serialNumbers = itemDetails[itemId];
|
|
|
1282 |
serialNumbers.push($(this).val());
|
|
|
1283 |
itemDetails[itemId] = serialNumbers;
|
| 22245 |
ashik.ali |
1284 |
}else{
|
| 21987 |
kshitij.so |
1285 |
var serialNumbers = [];
|
|
|
1286 |
serialNumbers.push($(this).val());
|
|
|
1287 |
itemDetails[itemId] = serialNumbers;
|
|
|
1288 |
}
|
| 22245 |
ashik.ali |
1289 |
}else{
|
| 21987 |
kshitij.so |
1290 |
var serialNumbers = [];
|
|
|
1291 |
serialNumbers.push($(this).val());
|
|
|
1292 |
var tmp ={};
|
|
|
1293 |
tmp[itemId] = serialNumbers;
|
| 22860 |
ashik.ali |
1294 |
orderObj['fofoOrderItems'] = tmp;
|
| 21987 |
kshitij.so |
1295 |
}
|
|
|
1296 |
});
|
|
|
1297 |
console.log( JSON.stringify(orderObj));
|
| 22581 |
ashik.ali |
1298 |
$("#order-details").find("tr:not(:first-child)").each(function(index, el){
|
|
|
1299 |
//console.log(el);
|
|
|
1300 |
//console.log(index);
|
| 22681 |
amit.gupta |
1301 |
var $el = $(el);
|
|
|
1302 |
var $unitPriceElement = $el.find('.unitPrice');
|
|
|
1303 |
var $discountAmountElement = $el.find('.discountAmount');
|
| 22581 |
ashik.ali |
1304 |
|
|
|
1305 |
var itemId = parseInt($unitPriceElement.attr("itemId"));
|
|
|
1306 |
var unitPrice = parseFloat($unitPriceElement.val());
|
|
|
1307 |
var qty = parseInt($unitPriceElement.attr("quantity"));
|
|
|
1308 |
var discountAmount = parseFloat($discountAmountElement.val());
|
|
|
1309 |
var mop = $discountAmountElement.attr("mop");
|
|
|
1310 |
var tmpObj = {'itemId':itemId,'sellingPrice':unitPrice,'quantity':qty};
|
|
|
1311 |
tmpObj.discountAmount = discountAmount;
|
| 22860 |
ashik.ali |
1312 |
/*tmpObj['serialNumberDetails'] = [];
|
|
|
1313 |
var found = false;
|
|
|
1314 |
for(var i = 0; i < priceQtyArray.length; i++){
|
|
|
1315 |
if (priceQtyArray[i]["itemId"] == itemId){
|
|
|
1316 |
found = true;
|
|
|
1317 |
break;
|
|
|
1318 |
}
|
|
|
1319 |
}
|
|
|
1320 |
if(!found){
|
|
|
1321 |
priceQtyArray.push(tmpObj);
|
|
|
1322 |
}else{
|
|
|
1323 |
for(var i = 0; i < priceQtyArray.length; i++){
|
|
|
1324 |
if (priceQtyArray[i]["itemId"] == itemId){
|
|
|
1325 |
priceQtyArray[i]["quantity"] = priceQtyArray[i]["quantity"] + 1;
|
|
|
1326 |
break;
|
|
|
1327 |
}
|
|
|
1328 |
}
|
|
|
1329 |
}
|
|
|
1330 |
var serialNumberDetails = getSerialNumbersFromOrder($el);
|
|
|
1331 |
if(serialNumberDetails != null){
|
|
|
1332 |
for(var i = 0; i < priceQtyArray.length; i++){
|
|
|
1333 |
if (priceQtyArray[i]["itemId"] == itemId){
|
|
|
1334 |
priceQtyArray[i]["serialNumberDetails"].push(serialNumberDetails);
|
|
|
1335 |
break;
|
|
|
1336 |
}
|
|
|
1337 |
}
|
|
|
1338 |
}
|
|
|
1339 |
});*/
|
| 22581 |
ashik.ali |
1340 |
|
| 22860 |
ashik.ali |
1341 |
if (orderObj['fofoOrderItems'][itemId] === undefined){
|
|
|
1342 |
tmpObj['serialNumberDetails'] =[];
|
|
|
1343 |
}
|
|
|
1344 |
else{
|
|
|
1345 |
//tmpObj['serialNumbers'] = orderObj['fofoLineItems'][itemId];
|
|
|
1346 |
tmpObj['serialNumberDetails'] = [];
|
|
|
1347 |
}
|
|
|
1348 |
var found = false;
|
|
|
1349 |
for(var i = 0; i < priceQtyArray.length; i++){
|
|
|
1350 |
if (priceQtyArray[i]["itemId"] == itemId){
|
|
|
1351 |
priceQtyArray[i]["quantity"] = priceQtyArray[i]["quantity"] + 1;
|
|
|
1352 |
found = true;
|
|
|
1353 |
break;
|
|
|
1354 |
}
|
|
|
1355 |
}
|
|
|
1356 |
if(!found){
|
|
|
1357 |
priceQtyArray.push(tmpObj);
|
|
|
1358 |
}
|
| 21987 |
kshitij.so |
1359 |
});
|
|
|
1360 |
|
| 22860 |
ashik.ali |
1361 |
|
|
|
1362 |
$("#order-details").find("tr:not(:first-child)").each(function(index,el){
|
|
|
1363 |
//console.log(el);
|
|
|
1364 |
//console.log(index);
|
|
|
1365 |
var $serialNumberElement = $(el).find('.serialNumber');
|
|
|
1366 |
var itemId = parseInt($serialNumberElement.attr("itemId"));
|
|
|
1367 |
var insuranceAmount = parseFloat($(el).find('.insuranceAmount').val());
|
|
|
1368 |
//if (priceQtyArray['fofoLineItems'][itemId] !=undefined){
|
|
|
1369 |
|
|
|
1370 |
//}
|
|
|
1371 |
//console.log($serialNumberElement.val());
|
|
|
1372 |
//console.log(itemId);
|
|
|
1373 |
for(var i = 0; i < priceQtyArray.length; i++){
|
|
|
1374 |
console.log(priceQtyArray[i]["itemId"]);
|
|
|
1375 |
if (priceQtyArray[i]["itemId"] == itemId){
|
|
|
1376 |
if(insuranceAmount > 0){
|
|
|
1377 |
insurance = true;
|
|
|
1378 |
globalInsurance = true;
|
|
|
1379 |
}else{
|
|
|
1380 |
insurance = false;
|
|
|
1381 |
}
|
|
|
1382 |
var serialNumberDetails = {'serialNumber':$serialNumberElement.val(),'insurance':insurance,'amount':insuranceAmount}
|
|
|
1383 |
priceQtyArray[i]['serialNumberDetails'].push(serialNumberDetails);
|
|
|
1384 |
}
|
|
|
1385 |
}
|
|
|
1386 |
});
|
|
|
1387 |
|
| 22245 |
ashik.ali |
1388 |
console.log("priceQtyArray : "+JSON.stringify(priceQtyArray));
|
|
|
1389 |
customerObj['firstName'] = $("form#cd input[name=firstName]").val();
|
|
|
1390 |
customerObj['lastName'] = $("form#cd input[name=lastName]").val();
|
| 21987 |
kshitij.so |
1391 |
customerObj['mobileNumber'] = $("form#cd input[name=phone]").val();
|
|
|
1392 |
customerObj['emailId'] = $("form#cd input[name=email]").val();
|
| 22594 |
ashik.ali |
1393 |
customerObj['dateOfBirth'] = $("form#cd input[name=dateOfBirth]").val();
|
| 21987 |
kshitij.so |
1394 |
var customerAddress = {};
|
| 22245 |
ashik.ali |
1395 |
customerAddress['name'] = $("form#cd input[name=firstName]").val() + " " + $("form#cd input[name=lastName]").val();
|
| 21987 |
kshitij.so |
1396 |
customerAddress['line1'] = $("form#cd input[name=line1]").val();
|
|
|
1397 |
customerAddress['line2'] = $("form#cd input[name=line2]").val();
|
|
|
1398 |
customerAddress['landmark'] = $("form#cd input[name=landmark]").val();
|
|
|
1399 |
customerAddress['city'] = $("form#cd input[name=city]").val();
|
|
|
1400 |
customerAddress['state'] = $('select[name=state] option:selected').val();
|
| 22245 |
ashik.ali |
1401 |
customerAddress['pinCode'] = $("form#cd input[name=pinCode]").val();
|
| 21987 |
kshitij.so |
1402 |
customerAddress['phoneNumber'] = $("form#cd input[name=alternatePhone]").val();
|
|
|
1403 |
customerAddress['country'] = "India";
|
| 22860 |
ashik.ali |
1404 |
customerObj['customerAddressId'] = parseInt($("form#cd input[name=phone]").attr("addressId"));
|
| 21987 |
kshitij.so |
1405 |
customerObj['address'] = customerAddress;
|
|
|
1406 |
console.log( JSON.stringify(customerObj));
|
|
|
1407 |
$("#payment-details input").each(function(){
|
|
|
1408 |
console.log($(this).attr('name'));
|
|
|
1409 |
if ($(this).attr('name') =="" ){
|
|
|
1410 |
return;
|
|
|
1411 |
}
|
|
|
1412 |
var paymentObj = {};
|
|
|
1413 |
paymentObj['type'] = $(this).attr('name');
|
|
|
1414 |
if ($(this).val() == ""){
|
|
|
1415 |
paymentObj['amount'] = 0.0;
|
|
|
1416 |
}
|
|
|
1417 |
else{
|
|
|
1418 |
paymentObj['amount'] = parseFloat($(this).val());
|
|
|
1419 |
}
|
|
|
1420 |
paymentOption.push(paymentObj);
|
|
|
1421 |
});
|
|
|
1422 |
console.log( JSON.stringify(paymentOption));
|
|
|
1423 |
|
|
|
1424 |
var retObj = {};
|
| 22254 |
ashik.ali |
1425 |
var dateOfBirth = $("form#cd input[name=dateOfBirth]").val();
|
| 22860 |
ashik.ali |
1426 |
if(globalInsurance){
|
| 22681 |
amit.gupta |
1427 |
retObj['customerDateOfBirth'] = (dateOfBirth);
|
| 22254 |
ashik.ali |
1428 |
}
|
| 22860 |
ashik.ali |
1429 |
retObj['fofoOrderItems'] = (priceQtyArray);
|
| 21987 |
kshitij.so |
1430 |
retObj['customer'] = (customerObj);
|
|
|
1431 |
retObj['paymentOptions'] = (paymentOption);
|
| 22254 |
ashik.ali |
1432 |
|
| 21987 |
kshitij.so |
1433 |
console.log(retObj);
|
|
|
1434 |
return JSON.stringify(retObj);
|
| 23026 |
ashik.ali |
1435 |
}
|