Subversion Repositories SmartDukaan

Rev

Rev 22283 | Rev 22354 | 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
 
84
function loadBadInventory(domId, search_text){
85
	jQuery.ajax({
86
        type : "GET",
22090 amit.gupta 87
        url : context+"/getBadInventorySnapshot/?searchTerm="+search_text,
21987 kshitij.so 88
        success : function(response) {
89
            $('#' + domId).html(response);
90
        }
91
    });  
92
}
93
 
94
function loadGrnHistory(domId,purchase_reference,searchType, startTime, endTime){
95
	jQuery.ajax({
96
        type : "GET",
22090 amit.gupta 97
        url : context+"/grnHistory/?purchaseReference="+purchase_reference+"&searchType="+searchType
21987 kshitij.so 98
        +"&startTime="+startTime
99
        +"&endTime="+endTime,
100
        success : function(response) {
101
            $('#' + domId).html(response);
102
        }
103
    });  
104
}
105
 
22245 ashik.ali 106
 
107
 
22283 ashik.ali 108
 
109
 
21987 kshitij.so 110
function getNextItems(start, end, searchText){
111
	console.log(start);
112
	console.log(end);
113
	console.log(+end + +10);
114
	console.log(+start + +10);
115
	jQuery.ajax({
116
	        type : "GET",
22090 amit.gupta 117
	        url : context+"/getPaginatedCurrentInventorySnapshot/?offset="+end+"&searchTerm="+searchText,
21987 kshitij.so 118
			beforeSend: function(){
119
	        //$('#ajax-spinner').show();
120
	        },
121
	        complete: function(){
122
	        //$('#ajax-spinner').hide();
123
	        },
124
	        success : function(response) {
125
	        	$( "#good-inventory-paginated .end" ).text(+end + +10);
126
	        	$( "#good-inventory-paginated .start" ).text(+start + +10);
127
				var last = $( "#good-inventory-paginated .end" ).text();
128
				var temp = $( "#good-inventory-paginated .size" ).text();
129
				if (parseInt(last) >= parseInt(temp)){
130
					$("#good-inventory-paginated .next").prop('disabled', true);
131
					//$( "#good-inventory-paginated .end" ).text(temp);
132
				}
133
	            $('#good-inventory-table').html(response);
134
	            $("#good-inventory-paginated .previous").prop('disabled', false);
135
	        },
136
			error : function() {
137
				alert("Unable to fetch items");
138
			 },
139
	    });  
140
	}
141
function getPreviousItems(start,end,pre,searchText){
142
	jQuery.ajax({
143
	        type : "GET",
22090 amit.gupta 144
	        url : context+"/getPaginatedCurrentInventorySnapshot/?offset="+pre+"&searchTerm="+searchText,
21987 kshitij.so 145
			beforeSend: function(){
146
	        //$('#ajax-spinner').show();
147
	        },
148
	        complete: function(){
149
	        //$('#ajax-spinner').hide();
150
	        },
151
	        success : function(response) {
152
	        	$( "#good-inventory-paginated .end" ).text(+end - +10);
153
	        	$( "#good-inventory-paginated .start" ).text(+start - +10);
154
	        	$('#good-inventory-table').html(response);
155
	        	$("#good-inventory-paginated .next").prop('disabled', false);
156
				if (parseInt(pre)==0)
157
				{
158
					$("#good-inventory-paginated .previous").prop('disabled', true);
159
				}
160
 
161
	        },
162
			error : function() {
163
				alert("Unable to fetch items");
164
			 },
165
	    });
166
}
167
 
168
function getGrnHistoryNextItems(start, end, purchase_reference, searchType,startTime,endTime){
169
	console.log(start);
170
	console.log(end);
171
	console.log(+end + +10);
172
	console.log(+start + +10);
173
	jQuery.ajax({
174
	        type : "GET",
22090 amit.gupta 175
	        url : context+"/getPaginatedGrnHistory/?purchaseReference="+purchase_reference+"&searchType="+searchType
21987 kshitij.so 176
	        +"&startTime="+startTime
177
	        +"&endTime="+endTime+"&offset="+end,
178
			beforeSend: function(){
179
	        //$('#ajax-spinner').show();
180
	        },
181
	        complete: function(){
182
	        //$('#ajax-spinner').hide();
183
	        },
184
	        success : function(response) {
185
	        	$( "#grn-history-paginated .end" ).text(+end + +10);
186
	        	$( "#grn-history-paginated .start" ).text(+start + +10);
187
				var last = $( "#grn-history-paginated .end" ).text();
188
				var temp = $( "#grn-history-paginated .size" ).text();
189
				if (parseInt(last) >= parseInt(temp)){
190
					$("#grn-history-paginated .next").prop('disabled', true);
191
					//$( "#good-inventory-paginated .end" ).text(temp);
192
				}
193
	            $('#grn-history-table').html(response);
194
	            $("#grn-history-paginated .previous").prop('disabled', false);
195
	        },
196
			error : function() {
197
				alert("Unable to fetch items");
198
			 },
199
	    });  
200
	}
201
function getGrnHistoryPreviousItems(start,end,pre,purchase_reference, searchType,startTime,endTime){
202
	jQuery.ajax({
203
	        type : "GET",
22090 amit.gupta 204
	        url : context+"/getPaginatedGrnHistory/?purchaseReference="+purchase_reference+"&searchType="+searchType
21987 kshitij.so 205
	        +"&startTime="+startTime
206
	        +"&endTime="+endTime+"&offset="+pre,
207
			beforeSend: function(){
208
	        //$('#ajax-spinner').show();
209
	        },
210
	        complete: function(){
211
	        //$('#ajax-spinner').hide();
212
	        },
213
	        success : function(response) {
214
	        	$( "#grn-history-paginated .end" ).text(+end - +10);
215
	        	$( "#grn-history-paginated .start" ).text(+start - +10);
216
	        	$('#grn-history-table').html(response);
217
	        	$("#grn-history-paginated .next").prop('disabled', false);
218
				if (parseInt(pre)==0)
219
				{
220
					$("#grn-history-paginated .previous").prop('disabled', true);
221
				}
222
 
223
	        },
224
			error : function() {
225
				alert("Unable to fetch items");
226
			 },
227
	    });
228
}
229
 
22292 ashik.ali 230
function getSaleHistoryNextItems(start, end, invoiceNumber, searchType, startTime, endTime){
231
	console.log(start);
232
	console.log(end);
233
	console.log(+end + +10);
234
	console.log(+start + +10);
235
	jQuery.ajax({
236
	        type : "GET",
237
	        url : context+"/getPaginatedSaleHistory/?invoiceNumber="+invoiceNumber+"&searchType="+searchType
238
	        +"&startTime="+startTime
239
	        +"&endTime="+endTime+"&offset="+end,
240
			beforeSend: function(){
241
	        //$('#ajax-spinner').show();
242
	        },
243
	        complete: function(){
244
	        //$('#ajax-spinner').hide();
245
	        },
246
	        success : function(response) {
247
	        	$( "#sale-history-paginated .end" ).text(+end + +10);
248
	        	$( "#sale-history-paginated .start" ).text(+start + +10);
249
				var last = $( "#sale-history-paginated .end" ).text();
250
				var temp = $( "#sale-history-paginated .size" ).text();
251
				if (parseInt(last) >= parseInt(temp)){
252
					$("#sale-history-paginated .next").prop('disabled', true);
253
					//$( "#good-inventory-paginated .end" ).text(temp);
254
				}
255
	            $('#sale-history-table').html(response);
256
	            $("#sale-history-paginated .previous").prop('disabled', false);
257
	        },
258
			error : function() {
259
				alert("Unable to fetch items");
260
			 },
261
	    });  
262
	}
263
function getSaleHistoryPreviousItems(start, end, pre, invoiceNumber, searchType,startTime,endTime){
264
	jQuery.ajax({
265
	        type : "GET",
266
	        url : context+"/getPaginatedSaleHistory/?invoiceNumber="+invoiceNumber+"&searchType="+searchType
267
	        +"&startTime="+startTime
268
	        +"&endTime="+endTime+"&offset="+pre,
269
			beforeSend: function(){
270
	        //$('#ajax-spinner').show();
271
	        },
272
	        complete: function(){
273
	        //$('#ajax-spinner').hide();
274
	        },
275
	        success : function(response) {
276
	        	$( "#sale-history-paginated .end" ).text(+end - +10);
277
	        	$( "#sale-history-paginated .start" ).text(+start - +10);
278
	        	$('#sale-history-table').html(response);
279
	        	$("#sale-history-paginated .next").prop('disabled', false);
280
				if (parseInt(pre)==0)
281
				{
282
					$("#sale-history-paginated .previous").prop('disabled', true);
283
				}
284
	        },
285
			error : function() {
286
				alert("Unable to fetch items");
287
			 },
288
	    });
289
}
290
 
21987 kshitij.so 291
function loadGoodInventorySearchInfo(search_text){
292
	loadGoodInventory("main-content",search_text);
293
}
294
 
295
function loadGrnHistorySearchInfo(search_text,searchType,startTime,endTime){
296
	loadGrnHistory("main-content",search_text,searchType,startTime,endTime);
297
}
298
 
21627 kshitij.so 299
function findDuplicateSerialNumbers(value){
300
    var result = $("#grnImeiInformation :input[value='" + value + "']").length - 1;
301
    return result;
302
}
21987 kshitij.so 303
 
304
function loadGrnDetails(purchaseId,domId){
305
	jQuery.ajax({
306
        type : "GET",
22090 amit.gupta 307
        url : context+"/grnHistoryDetailByPurchaseId/?purchaseId="+purchaseId,
21987 kshitij.so 308
        success : function(response) {
309
            $('#' + domId).html(response);
310
            window.dispatchEvent(new Event('resize'));
311
        }
312
    });
313
}
314
 
22245 ashik.ali 315
function loadSaleDetails(orderId, domId){
316
	jQuery.ajax({
317
        type : "GET",
318
        url : context+"/saleDetails?orderId="+orderId,
319
        success : function(response) {
320
            $('#' + domId).html(response);
321
            window.dispatchEvent(new Event('resize'));
322
        }
323
    });
324
}
325
 
21987 kshitij.so 326
function loadPendingGrnDetails(purchaseId,domId){
327
	jQuery.ajax({
22090 amit.gupta 328
		url: context+"/purchase/?airwayBillOrInvoiceNumber="+purchaseId,
21987 kshitij.so 329
		type: 'POST',
330
		async: false,
331
		success: function (data) {
332
			$('#'+domId).html(data);
333
		},
334
		error : function() {
335
			alert("OOPS!!!Failed to do changes.Try Again.",'ERROR');
336
		},
337
		cache: false,
338
		contentType: false,
339
		processData: false
340
	});
341
}
342
 
343
function getNextCatalogItems(start, end, searchText){
344
	console.log(start);
345
	console.log(end);
346
	console.log(+end + +10);
347
	console.log(+start + +10);
348
	jQuery.ajax({
349
	        type : "GET",
22090 amit.gupta 350
	        url : context+"/getPaginatedCatalog/?offset="+end+"&searchTerm="+searchText,
21987 kshitij.so 351
			beforeSend: function(){
352
	        //$('#ajax-spinner').show();
353
	        },
354
	        complete: function(){
355
	        //$('#ajax-spinner').hide();
356
	        },
357
	        success : function(response) {
358
	        	$( "#catalog-paginated .end" ).text(+end + +10);
359
	        	$( "#catalog-paginated .start" ).text(+start + +10);
360
				var last = $( "#catalog-paginated .end" ).text();
361
				var temp = $( "#catalog-paginated .size" ).text();
362
				if (parseInt(last) >= parseInt(temp)){
363
					$("#catalog-paginated .next").prop('disabled', true);
364
				}
365
	            $('#catalog-table').html(response);
366
	            $("#catalog-paginated .previous").prop('disabled', false);
367
	        },
368
			error : function() {
369
				alert("Unable to fetch items");
370
			 },
371
	    });  
372
	}
373
function getPreviousCatalogItems(start,end,pre,searchText){
374
	jQuery.ajax({
375
	        type : "GET",
22090 amit.gupta 376
	        url : context+"/getPaginatedCatalog/?offset="+pre+"&searchTerm="+searchText,
21987 kshitij.so 377
			beforeSend: function(){
378
	        //$('#ajax-spinner').show();
379
	        },
380
	        complete: function(){
381
	        //$('#ajax-spinner').hide();
382
	        },
383
	        success : function(response) {
384
	        	$( "#catalog-paginated .end" ).text(+end - +10);
385
	        	$( "#catalog-paginated .start" ).text(+start - +10);
386
	        	$('#catalog-table').html(response);
387
	        	$("#catalog-paginated .next").prop('disabled', false);
388
				if (parseInt(pre)==0)
389
				{
390
					$("#catalog-paginated .previous").prop('disabled', true);
391
				}
392
 
393
	        },
394
			error : function() {
395
				alert("Unable to fetch items");
396
			 },
397
	    });
398
}
399
 
400
function loadCatalogSearchInfo(search_text){
401
	loadCatalog("main-content",search_text);
402
}
403
 
404
function addItemInLocalStorage(bagObj){
405
	if (localStorage.getItem("bag")!=null){
406
		var bag = JSON.parse(localStorage.getItem("bag"));
407
		bag[bagObj.itemId] = bagObj
408
		localStorage.setItem("bag",JSON.stringify(bag));
409
		bag = localStorage.getItem("bag")
410
		$("#cart_bar").find('span').text(Object.keys(JSON.parse(bag)).length);
411
	}
412
	else{
413
		var tempObj = {};
414
		tempObj[bagObj.itemId] = bagObj
415
		localStorage.setItem("bag",JSON.stringify(tempObj));
416
		var bag = localStorage.getItem("bag")
417
		$("#cart_bar").find('span').text(Object.keys(JSON.parse(bag)).length);
418
	}
419
}
420
 
421
 
422
function changeQuantityInLocalStorage(itemId, newQuantity){
423
	var bag = JSON.parse(localStorage.getItem("bag"));
424
	bag[itemId].quantity = newQuantity;
425
	localStorage.setItem("bag",JSON.stringify(bag));
426
}
427
 
428
function removeItemFromLocalStorage(itemId){
429
	if (localStorage.getItem("bag")!=null){
430
		var bag = JSON.parse(localStorage.getItem("bag"));
431
		delete bag[itemId];
432
		localStorage.setItem("bag",JSON.stringify(bag));
433
		$("#cart_bar").find('span').text(Object.keys(bag).length);
434
	}
435
}
436
 
437
function emptyBag(){
22095 kshitij.so 438
	localStorage.setItem("bag",JSON.stringify({}));
21987 kshitij.so 439
	$("#cart_bar").find('span').text(0);
440
}
441
 
442
function loadCart(domId){
443
	jQuery.ajax({
444
        type : "POST",
445
        data: {"cartData":localStorage.getItem("bag")},
22090 amit.gupta 446
        url : context+"/cart",
21987 kshitij.so 447
        success : function(response) {
448
            $('#' + domId).html(response);
449
        }
450
    });  
451
}
452
 
453
function checkout(domId){
454
	jQuery.ajax({
22095 kshitij.so 455
        type : "GET",
21987 kshitij.so 456
        data: {"cartData":localStorage.getItem("bag")},
22090 amit.gupta 457
        url : context+"/validate-cart",
21987 kshitij.so 458
        success : function(response) {
459
        	var obj = JSON.parse(response);
460
        	redirectCart(obj.redirectUrl, obj.params, obj.method, "main-content");
22095 kshitij.so 461
        	$('#main-content').html(response);
21987 kshitij.so 462
        }
22245 ashik.ali 463
    });
21987 kshitij.so 464
}
465
 
466
function redirectCart(url, cartData, method, domId){
467
	jQuery.ajax({
468
        type : method,
469
        data: {"cartData":cartData},
470
        url : context+url,
471
        success : function(response) {
472
            $('#' + domId).html(response);
473
            window.dispatchEvent(new Event('resize'));
474
        }
475
    });  
476
}
477
 
22245 ashik.ali 478
function saleHistory(domId, invoiceNumber, searchType, startTime, endTime){
479
	jQuery.ajax({
480
        type : "GET",
481
        url : context+"/saleHistory?invoiceNumber="+invoiceNumber+"&searchType="+searchType
482
        +"&startTime="+startTime
483
        +"&endTime="+endTime,
484
        success : function(response) {
485
            $('#' + domId).html(response);
486
        }
487
    });  
488
}
489
 
22283 ashik.ali 490
function saleHistorySearchInfo(search_text, searchType, startTime, endTime){
491
	saleHistory("main-content", search_text, searchType, startTime, endTime);
492
}
22245 ashik.ali 493
 
22283 ashik.ali 494
 
21987 kshitij.so 495
function validateOrderDetails(){
496
	var sNumbers = [];
497
	var error = false;
498
	$("form#cd input.serialNumber").each(function(){
499
		var input = $(this).val().trim();
22245 ashik.ali 500
		var itemType = $(this).attr("itemType");
21987 kshitij.so 501
		$(this).removeClass("border-highlight");
22245 ashik.ali 502
		if (sNumbers.indexOf(input) !=-1 || (itemType ==='SERIALIZED' && !input)){
21987 kshitij.so 503
			error = true;
504
			$(this).addClass("border-highlight");
505
		}
506
		sNumbers.push(input);
507
	});
508
 
509
	$("form#cd input.unitPrice").each(function(){
510
		var input = $(this).val().trim();
511
		$(this).removeClass("border-highlight");
512
		if (!input || parseInt(input)<=0 || isNaN(input)){
513
			error=true;
514
			$(this).addClass("border-highlight");
515
		}
516
	});
517
 
518
	var amount = 0;
519
	var netPayableAmount = parseFloat($("form#cd input.netPayableAmount").val());
520
 
521
 
522
	$("form#cd input.amount").each(function(){
523
		if ($(this).val() ==""){
524
			$(this).val(0);
525
		}
526
		var tmpAmount = parseFloat($(this).val());
527
		amount = amount + tmpAmount;
528
	});
529
 
530
	console.log(amount);
531
	console.log(netPayableAmount);
532
 
533
	if (amount!=netPayableAmount){
534
		alert("Mismatch in amount");
535
		error = true;
536
	}
537
 
538
	if (error){
539
		return false;
540
	}
541
	return true;
542
 
543
}
544
 
545
function orderDetailsPayload(){
546
		var orderObj = {};
547
		var priceQtyArray = [];
548
		var customerObj = {};
549
		var paymentOption = [];
550
 
551
		$("form#cd input.serialNumber").each(function(){
552
			var itemId = parseInt($(this).attr("itemId"));
553
			if (orderObj.hasOwnProperty('fofoLineItems')){
554
				var itemDetails = orderObj['fofoLineItems'];
555
				if (itemDetails.hasOwnProperty(itemId)){
556
					var serialNumbers = itemDetails[itemId];
557
					serialNumbers.push($(this).val());
558
					itemDetails[itemId] = serialNumbers;
22245 ashik.ali 559
				}else{
21987 kshitij.so 560
					var serialNumbers = [];
561
					serialNumbers.push($(this).val());
562
					itemDetails[itemId] = serialNumbers;
563
				}
22245 ashik.ali 564
			}else{
21987 kshitij.so 565
				var serialNumbers = [];
566
				serialNumbers.push($(this).val());
567
				var tmp ={};
568
				tmp[itemId]  = serialNumbers;
569
				orderObj['fofoLineItems'] = tmp;
570
			}
571
		});
572
		console.log( JSON.stringify(orderObj));
573
		$("form#cd input.unitPrice").each(function(){
574
			var itemId = parseInt($(this).attr("itemId"));
575
			var unitPrice = parseFloat($(this).val());
576
			var qty = parseInt($(this).attr("quantity"));
577
			var tmpObj = {'itemId':itemId,'sellingPrice':unitPrice,'quantity':qty};
22245 ashik.ali 578
			if (orderObj['fofoLineItems'][itemId] === undefined){
579
				tmpObj['serialNumberDetails'] =[];
21987 kshitij.so 580
			}
581
			else{
22245 ashik.ali 582
				//tmpObj['serialNumbers'] = orderObj['fofoLineItems'][itemId];
583
				tmpObj['serialNumberDetails'] = [];
21987 kshitij.so 584
			}
22245 ashik.ali 585
			var found = false;
586
			for(var i = 0; i < priceQtyArray.length; i++){			
587
				if (priceQtyArray[i]["itemId"] == itemId){
588
					found = true;
589
					break;
590
				}
591
			}
592
			if(!found){
593
				priceQtyArray.push(tmpObj);
594
			}
21987 kshitij.so 595
		});
596
 
22245 ashik.ali 597
 
22254 ashik.ali 598
		var insurance = false;
599
 
22245 ashik.ali 600
		$("#order-details").find("tr:not(:first-child)").each(function(index,el){
601
			//console.log(el);
602
			//console.log(index);
603
			var $serialNumberElement = $(el).find('.serialNumber');
604
			var itemId = parseInt($serialNumberElement.attr("itemId"));
605
			var insuranceAmount = parseFloat($(el).find('.insuranceAmount').val());
606
			//if (priceQtyArray['fofoLineItems'][itemId] !=undefined){
607
 
608
			//}
609
			//console.log($serialNumberElement.val());
610
			//console.log(itemId);
611
			for(var i = 0; i < priceQtyArray.length; i++){
612
				console.log(priceQtyArray[i]["itemId"]);			
613
				if (priceQtyArray[i]["itemId"] == itemId){
614
					if(insuranceAmount > 0){
615
						insurance = true;
616
					}
617
					var serialNumberDetails = {'serialNumber':$serialNumberElement.val(),'insurance':insurance,'amount':insuranceAmount}
618
					priceQtyArray[i]['serialNumberDetails'].push(serialNumberDetails);
619
				}
620
            }
621
 
622
		});
623
 
624
		console.log("priceQtyArray : "+JSON.stringify(priceQtyArray));
21987 kshitij.so 625
		//customer-details
626
		/*$("#customer-details input").each(function(){
627
			console.log($(this).attr('name'));
628
			customerObj[$(this).attr('name')] = $(this).val();
629
		});*/
630
		//$("input[name=nameGoesHere]").val();
22245 ashik.ali 631
		customerObj['firstName'] = $("form#cd input[name=firstName]").val();
632
		customerObj['lastName'] = $("form#cd input[name=lastName]").val();
21987 kshitij.so 633
		customerObj['mobileNumber'] = $("form#cd input[name=phone]").val(); 
634
		customerObj['emailId'] = $("form#cd input[name=email]").val();
22245 ashik.ali 635
		customerObj['dateOfBirth'] = $("form#cd input[name=dateOfBirth").val();
21987 kshitij.so 636
		var customerAddress = {};
22245 ashik.ali 637
		customerAddress['name'] = $("form#cd input[name=firstName]").val() + " " + $("form#cd input[name=lastName]").val();
21987 kshitij.so 638
		customerAddress['line1'] = $("form#cd input[name=line1]").val();
639
		customerAddress['line2'] = $("form#cd input[name=line2]").val();
640
		customerAddress['landmark'] = $("form#cd input[name=landmark]").val();
641
		customerAddress['city'] = $("form#cd input[name=city]").val();
642
		customerAddress['state'] = $('select[name=state] option:selected').val();
22245 ashik.ali 643
		customerAddress['pinCode'] = $("form#cd input[name=pinCode]").val();
21987 kshitij.so 644
		customerAddress['phoneNumber'] = $("form#cd input[name=alternatePhone]").val();
645
		customerAddress['country'] = "India";
646
		customerObj['address'] = customerAddress; 
647
		console.log( JSON.stringify(customerObj));
648
		$("#payment-details input").each(function(){
649
		console.log($(this).attr('name'));
650
		if ($(this).attr('name') =="" ){
651
			return;
652
		}
653
		var paymentObj = {};
654
		paymentObj['type'] = $(this).attr('name');
655
		if ($(this).val() == ""){
656
			paymentObj['amount'] = 0.0;
657
		}
658
		else{
659
			paymentObj['amount'] = parseFloat($(this).val());
660
		}
661
		paymentOption.push(paymentObj);
662
		});
663
		console.log( JSON.stringify(paymentOption));
664
 
665
		var retObj = {};
22254 ashik.ali 666
		var dateOfBirth = $("form#cd input[name=dateOfBirth]").val();
667
		if(insurance){
668
			retObj['customerDateOfBirth'] = (dateOfBirth)
669
		}
21987 kshitij.so 670
		retObj['fofoLineItems'] = (priceQtyArray);
671
		retObj['customer'] = (customerObj);
672
		retObj['paymentOptions'] =  (paymentOption);
22254 ashik.ali 673
 
21987 kshitij.so 674
		console.log(retObj);
675
		return  JSON.stringify(retObj);
676
}