Subversion Repositories SmartDukaan

Rev

Rev 22681 | Rev 22956 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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