Subversion Repositories SmartDukaan

Rev

Rev 23347 | Rev 23367 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 23347 Rev 23353
Line 67... Line 67...
67
			var payload = orderDetailsPayload();
67
			var payload = orderDetailsPayload();
68
			if(!validateOrderDetails()){
68
			if(!validateOrderDetails()){
69
				alert("Please fix highlighted errors");
69
				alert("Please fix highlighted errors");
70
				return false;
70
				return false;
71
			}
71
			}
72
             $.ajax({
-
 
73
                 type: "POST",
-
 
74
                 url: "create-order",
-
 
75
                 data: payload,
-
 
76
                 contentType:'application/json',
72
			doAjaxRequestWithJsonHandler(context+"/create-order", "POST", payload, function(response){
77
				async: false,
-
 
78
				success: function (data) {
-
 
79
					emptyBag();
73
				emptyBag();
80
					$('#main-content').html(data);
74
				$('#main-content').html(response);
81
				},
75
			});
82
				cache: false,
-
 
83
				processData: false
-
 
84
             });
-
 
85
             return false; // required to block normal submit since you used ajax
76
            return false; // required to block normal submit since you used ajax
86
         }
77
         }
87
	});
78
	});
88
    
79
    
89
	$("input.unitPrice").blur(function() {
80
	$("input.unitPrice").blur(function() {
90
		console.log("unitPrice blur called");
81
		console.log("unitPrice blur called");
Line 99... Line 90...
99
			$element.removeClass("border-highlight")
90
			$element.removeClass("border-highlight")
100
			if(unitPrice == mopPrice){
91
			if(unitPrice == mopPrice){
101
				$("input.discountAmount").removeAttr("readonly");
92
				$("input.discountAmount").removeAttr("readonly");
102
			}
93
			}
103
			if(unitPrice != ''){
94
			if(unitPrice != ''){
104
			    $.ajax({
-
 
105
			         type: "GET",
-
 
106
			         url: "insurancePrices?price="+unitPrice,
95
				doAjaxRequestHandler(context+"/insurancePrices?price="+unitPrice, "GET", function(response){
107
			         //data: payload,
-
 
108
			         //contentType:'application/json',
-
 
109
					async: false,
-
 
110
					success: function (data) {
-
 
111
						console.log("response : "+JSON.stringify(data));
96
					console.log("response : "+JSON.stringify(response));
112
						var insurancePriceMap = data.response;
97
					var insurancePriceMap = response.response;
113
						for(key in insurancePriceMap){
98
					for(key in insurancePriceMap){
114
							var dealerPrice = insurancePriceMap[key].dealerPrice;
99
						var dealerPrice = insurancePriceMap[key].dealerPrice;
115
							var sellingPrice = insurancePriceMap[key].sellingPrice;
100
						var sellingPrice = insurancePriceMap[key].sellingPrice;
116
							$element.closest('tr').find('.insuranceAmount').attr("placeholder", dealerPrice + "-" + sellingPrice);
101
						$element.closest('tr').find('.insuranceAmount').attr("placeholder", dealerPrice + "-" + sellingPrice);
117
							break;
102
						break;
118
						}
-
 
119
					},
103
					}
120
					error : function() {
-
 
121
						alert("OOPS!!!Failed to do changes.Try Again.",'ERROR');
-
 
122
					},
104
				});
123
					cache: false,
-
 
124
					processData: false
-
 
125
			    });
-
 
126
		    }
105
		    }
127
		}
106
		}
128
	}).focus(function(){
107
	}).focus(function(){
129
		console.log("unitPrice focus called");
108
		console.log("unitPrice focus called");
130
		var $element = $(this);
109
		var $element = $(this);
Line 381... Line 360...
381
		customerAddress['phoneNumber'] = $("form#cd input[name=alternatePhone]").val();
360
		customerAddress['phoneNumber'] = $("form#cd input[name=alternatePhone]").val();
382
		customerAddress['country'] = "India";
361
		customerAddress['country'] = "India";
383
		customerObj['customerAddressId'] = parseInt($("form#cd input[name=phone]").attr("addressId"));
362
		customerObj['customerAddressId'] = parseInt($("form#cd input[name=phone]").attr("addressId"));
384
		customerObj['address'] = customerAddress; 
363
		customerObj['address'] = customerAddress; 
385
		console.log( JSON.stringify(customerObj));
364
		console.log( JSON.stringify(customerObj));
-
 
365
		
386
		$("#payment-details input").each(function(){
366
		$("#payment-details input").each(function(){
387
		console.log($(this).attr('name'));
367
			console.log($(this).attr('name'));
388
		if ($(this).attr('name') =="" ){
368
			if ($(this).attr('name') == "" ){
389
			return;
369
				return;
390
		}
370
			}
391
		var paymentObj = {};
371
			var paymentObj = {};
392
		paymentObj['type'] = $(this).attr('name');
372
			paymentObj['type'] = $(this).attr('name');
393
		if ($(this).val() == ""){
373
			if ($(this).val() == ""){
394
			paymentObj['amount'] = 0.0;
374
				paymentObj['amount'] = 0.0;
395
		}
-
 
396
		else{
375
			}else{
397
			paymentObj['amount'] = parseFloat($(this).val());
376
				paymentObj['amount'] = parseFloat($(this).val());
398
		}
377
			}
399
		paymentOption.push(paymentObj);
378
			paymentOption.push(paymentObj);
400
		});
379
		});
401
		console.log( JSON.stringify(paymentOption));
380
		console.log( JSON.stringify(paymentOption));
402
		
381
		
403
		var retObj = {};
382
		var retObj = {};
404
		var dateOfBirth = $("form#cd input[name=dateOfBirth]").val();
383
		var dateOfBirth = $("form#cd input[name=dateOfBirth]").val();
Line 413... Line 392...
413
		return  JSON.stringify(retObj);
392
		return  JSON.stringify(retObj);
414
}
393
}
415
 
394
 
416
 
395
 
417
function writeOldCustomerDetailsByMobileNumber(mobileNumber){
396
function writeOldCustomerDetailsByMobileNumber(mobileNumber){
418
	var response = doGetAjaxRequest(context+"/customer/mobileNumber?mobileNumber="+mobileNumber);
397
	doAjaxRequestHandler(context+"/customer/mobileNumber?mobileNumber="+mobileNumber, "GET", function(response){
419
	
-
 
420
	var customer = response.response;
398
		var customer = response.response;
421
    $('#firstName').attr('value', customer.firstName);
399
	    $('#firstName').attr('value', customer.firstName);
422
    $('#lastName').attr('value', customer.lastName);
400
	    $('#lastName').attr('value', customer.lastName);
423
    $('#email').attr('value', customer.emailId);
401
	    $('#email').attr('value', customer.emailId);
424
    //$('#phone').attr('value', customer.mobileNumber);
402
	    //$('#phone').attr('value', customer.mobileNumber);
425
    $('#alternatePhone').attr('value', customer.address.phoneNumber);
403
	    $('#alternatePhone').attr('value', customer.address.phoneNumber);
426
    $('#line1').attr('value', customer.address.line1);
404
	    $('#line1').attr('value', customer.address.line1);
427
    $('#line2').attr('value', customer.address.line2);
405
	    $('#line2').attr('value', customer.address.line2);
428
    $('#landmark').attr('value', customer.address.landmark);
406
	    $('#landmark').attr('value', customer.address.landmark);
429
    $('#pinCode').attr('value', customer.address.pinCode);
407
	    $('#pinCode').attr('value', customer.address.pinCode);
430
    $('#city').attr('value', customer.address.city);
408
	    $('#city').attr('value', customer.address.city);
431
    $('#state').attr('value', customer.address.state).prop('selected',true);
409
	    $('#state').attr('value', customer.address.state).prop('selected',true);
432
    //$('#state').val(customer.address.state).prop('selected', true);
410
	    //$('#state').val(customer.address.state).prop('selected', true);
433
    $('#phone').attr('addressId', customer.address.id);
411
	    $('#phone').attr('addressId', customer.address.id);
-
 
412
	});
434
}
413
}
435
414