| Line 102... |
Line 102... |
| 102 |
$(this).closest('tr').find('.insuranceid').val("");
|
102 |
$(this).closest('tr').find('.insuranceid').val("");
|
| 103 |
$(this).closest('tr').find('.insuranceamount').val("0");
|
103 |
$(this).closest('tr').find('.insuranceamount').val("0");
|
| 104 |
}
|
104 |
}
|
| 105 |
calculateTotalAmount();
|
105 |
calculateTotalAmount();
|
| 106 |
});
|
106 |
});
|
| - |
|
107 |
customerInfo = $("div.customerinfo").html();
|
| - |
|
108 |
billingInfo = $("div.billinginfo").html();
|
| 107 |
|
109 |
|
| 108 |
$( "input.phone").change(function() {
|
110 |
$( "input.search-phone").change(function() {
|
| 109 |
console.log("phone blur called");
|
111 |
resetInputs();
|
| 110 |
var mobileNumber = $(this).val();
|
112 |
var mobileNumber = $(this).val();
|
| 111 |
if(mobileNumber.length < 10) {
|
113 |
if(mobileNumber.length < 10) {
|
| 112 |
return;
|
114 |
return;
|
| 113 |
}
|
115 |
}
|
| 114 |
writeOldCustomerDetailsByMobileNumber(mobileNumber);
|
116 |
writeOldCustomerDetailsByMobileNumber(mobileNumber);
|
| 115 |
});
|
117 |
});
|
| 116 |
|
118 |
|
| - |
|
119 |
$('button.new-address-btn').live('click', function() {
|
| - |
|
120 |
$('#newaddressModal').modal({show: true});
|
| - |
|
121 |
});
|
| - |
|
122 |
$('button.btn-add-address').live('click', function(){
|
| - |
|
123 |
var customerAddress = {};
|
| - |
|
124 |
customerAddress['firstName'] = $("#firstName").val();
|
| - |
|
125 |
customerAddress['lastName'] = $("#lastName").val();
|
| - |
|
126 |
customerAddress['line1'] = $("#line1").val();
|
| - |
|
127 |
customerAddress['line2'] = $("#line2").val();
|
| - |
|
128 |
customerAddress['landmark'] = $("#landmark").val();
|
| - |
|
129 |
customerAddress['city'] = $("#city").val();
|
| - |
|
130 |
customerAddress['state'] = $('select[name=state] option:selected').val();
|
| - |
|
131 |
customerAddress['pinCode'] = $("#pinCode").val();
|
| - |
|
132 |
customerAddress['phoneNumber'] = $("#alternatePhone").val();
|
| - |
|
133 |
customerAddress['country'] = "India";
|
| - |
|
134 |
console.log(customerAddress);
|
| - |
|
135 |
var customerId = $('input.phone').data('id');
|
| - |
|
136 |
doPostAjaxRequestWithJsonHandler(`${context}/customer/address/${customerId}`, JSON.stringify(customerAddress), function(response){
|
| - |
|
137 |
$("#address-body").prepend(getAddressTr(response.response));
|
| - |
|
138 |
});
|
| - |
|
139 |
});
|
| - |
|
140 |
|
| 117 |
}
|
141 |
}
|
| 118 |
function validateOrderDetails(){
|
142 |
function validateOrderDetails(){
|
| 119 |
var sNumbers = [];
|
143 |
var sNumbers = [];
|
| 120 |
var error = false;
|
144 |
var error = false;
|
| 121 |
$("form#cd input.serialNumber").each(function(){
|
145 |
$("form#cd input.serialNumber").each(function(){
|
| Line 280... |
Line 304... |
| 280 |
customerObj['lastName'] = $("form#cd input[name=lastName]").val();
|
304 |
customerObj['lastName'] = $("form#cd input[name=lastName]").val();
|
| 281 |
customerObj['mobileNumber'] = $("form#cd input[name=phone]").val();
|
305 |
customerObj['mobileNumber'] = $("form#cd input[name=phone]").val();
|
| 282 |
customerObj['emailId'] = $("form#cd input[name=email]").val();
|
306 |
customerObj['emailId'] = $("form#cd input[name=email]").val();
|
| 283 |
customerObj['gstNumber'] = $("form#cd input[name=gstNumber]").val();
|
307 |
customerObj['gstNumber'] = $("form#cd input[name=gstNumber]").val();
|
| 284 |
// customerObj['dateOfBirth'] = startDate;
|
308 |
// customerObj['dateOfBirth'] = startDate;
|
| 285 |
var customerAddress = {};
|
- |
|
| 286 |
customerAddress['name'] = $("form#cd input[name=firstName]").val() + " " + $("form#cd input[name=lastName]").val();
|
- |
|
| 287 |
customerAddress['line1'] = $("form#cd input[name=line1]").val();
|
- |
|
| 288 |
customerAddress['line2'] = $("form#cd input[name=line2]").val();
|
- |
|
| 289 |
customerAddress['landmark'] = $("form#cd input[name=landmark]").val();
|
- |
|
| 290 |
customerAddress['city'] = $("form#cd input[name=city]").val();
|
- |
|
| 291 |
customerAddress['state'] = $('select[name=state] option:selected').val();
|
- |
|
| 292 |
customerAddress['pinCode'] = $("form#cd input[name=pinCode]").val();
|
- |
|
| 293 |
customerAddress['phoneNumber'] = $("form#cd input[name=alternatePhone]").val();
|
- |
|
| 294 |
customerAddress['country'] = "India";
|
- |
|
| - |
|
309 |
|
| 295 |
customerObj['customerAddressId'] = parseInt($("form#cd input[name=phone]").attr("addressId"));
|
310 |
customerObj['customerAddressId'] = parseInt($("form#cd input[name=phone]").attr("addressId"));
|
| 296 |
customerObj['address'] = customerAddress;
|
311 |
customerObj['address'] = customerAddress;
|
| 297 |
customerObj['gender'] = $("#gender").val();
|
312 |
customerObj['gender'] = $("#gender").val();
|
| 298 |
customerObj['dateOfBirth'] = startDate;
|
313 |
customerObj['dateOfBirth'] = startDate;
|
| 299 |
localStorage.setItem("customerDetails", JSON.stringify(customerObj));
|
314 |
localStorage.setItem("customerDetails", JSON.stringify(customerObj));
|
| Line 322... |
Line 337... |
| 322 |
|
337 |
|
| 323 |
console.log(retObj);
|
338 |
console.log(retObj);
|
| 324 |
return JSON.stringify(retObj);
|
339 |
return JSON.stringify(retObj);
|
| 325 |
}
|
340 |
}
|
| 326 |
|
341 |
|
| - |
|
342 |
function resetInputs() {
|
| - |
|
343 |
$("div.customerinfo").html(customerInfo);
|
| - |
|
344 |
$("div.billinginfo").html(billingInfo).hide();
|
| 327 |
|
345 |
}
|
| 328 |
function writeOldCustomerDetailsByMobileNumber(mobileNumber){
|
346 |
function writeOldCustomerDetailsByMobileNumber(mobileNumber){
|
| 329 |
doAjaxRequestHandler(context+"/customer/mobileNumber?mobileNumber="+mobileNumber, "GET", function(response){
|
347 |
doAjaxRequestHandler(context+"/customer/mobileNumber?mobileNumber="+mobileNumber, "GET", function(response){
|
| 330 |
if(response.response=='') {
|
348 |
if(response.response=='') {
|
| 331 |
return;
|
349 |
return;
|
| 332 |
}
|
350 |
}
|
| 333 |
var customer = response.response;
|
351 |
var customer = response.response;
|
| 334 |
$('#firstName').attr('value', customer.firstName);
|
352 |
$('#firstName').attr('value', customer.firstName);
|
| 335 |
$('#lastName').attr('value', customer.lastName);
|
353 |
$('#lastName').attr('value', customer.lastName);
|
| 336 |
$('#email').attr('value', customer.emailId);
|
354 |
$('#alternatePhone').attr('value', customer.mobileNumber);
|
| 337 |
// $('#phone').attr('value', customer.mobileNumber);
|
355 |
$('input.phone').attr('value', customer.mobileNumber).attr('readonly', true).data("id",customer.customerId);
|
| 338 |
if(customer.address !== null) {
|
- |
|
| 339 |
$('#alternatePhone').val(customer.address.phoneNumber);
|
356 |
$('input.firstName').attr('value', customer.firstName).attr('readonly', true);
|
| 340 |
$('#line1').val(customer.address.line1);
|
- |
|
| 341 |
$('#line2').val(customer.address.line2);
|
- |
|
| 342 |
$('#landmark').val(customer.address.landmark);
|
357 |
$('input.lastName').attr('value', customer.lastName).attr('readonly', true);
|
| 343 |
$('#pinCode').val(customer.address.pinCode);
|
- |
|
| 344 |
$('#city').val(customer.address.city);
|
358 |
if(customer.emailId!=null) {
|
| 345 |
$('#state').val(customer.address.state);
|
- |
|
| 346 |
$('#phone').attr('addressId', customer.address.id);
|
359 |
$('#email').attr('value', customer.emailId).attr('readonly', true);
|
| 347 |
}
|
360 |
}
|
| - |
|
361 |
$("div.billinginfo").show();
|
| - |
|
362 |
trs = [];
|
| 348 |
// $('#state').val(customer.address.state).prop('selected', true);
|
363 |
for(address of customer.addresses) {
|
| - |
|
364 |
trs.push(getAddressTr(address));
|
| - |
|
365 |
}
|
| - |
|
366 |
$("#address-body").html(trs.join(""));
|
| 349 |
});
|
367 |
});
|
| - |
|
368 |
}
|
| - |
|
369 |
function getAddressTr(customAddress) {
|
| - |
|
370 |
var tr = [];
|
| - |
|
371 |
tr.push(`<tr><td>${address.name} ${address.lastName}</td>`);
|
| - |
|
372 |
tr.push(`<td>${address.line1}, ${address.line2}</td>`);
|
| - |
|
373 |
tr.push(`<td>${address.city}</td>`);
|
| - |
|
374 |
tr.push(`<td>${address.state}</td>`);
|
| - |
|
375 |
tr.push(`<td>${address.pinCode}</td>`);
|
| - |
|
376 |
tr.push(`<td>${address.phoneNumber}</td>`);
|
| - |
|
377 |
tr.push(`<td><a href="javascript:void();" data-addressid="${address.id}">Select address</a></td></tr>`);
|
| - |
|
378 |
return tr.join("");
|
| 350 |
}
|
379 |
}
|
| 351 |
|
380 |
|