| Line 119... |
Line 119... |
| 119 |
|
119 |
|
| 120 |
$('button.new-address-btn').live('click', function() {
|
120 |
$('button.new-address-btn').live('click', function() {
|
| 121 |
$('#newaddressModal').modal({show: true});
|
121 |
$('#newaddressModal').modal({show: true});
|
| 122 |
});
|
122 |
});
|
| 123 |
|
123 |
|
| - |
|
124 |
$('button.mk_add_email').live('click', function() {
|
| - |
|
125 |
let customerObj = {};
|
| - |
|
126 |
customerObj['customerId'] = customerId;
|
| - |
|
127 |
customerObj['emailId'] = $("#emailId").val();
|
| - |
|
128 |
if(validateEmail(customerObj['emailId'])) {
|
| - |
|
129 |
doPostAjaxRequestWithJsonHandler(`${context}/customer/add-email`, JSON.stringify(customerObj), function(response){
|
| - |
|
130 |
alert("Email added");
|
| - |
|
131 |
$( "input.search-phone").val(customerObj['mobileNumber']).change();
|
| - |
|
132 |
});
|
| - |
|
133 |
} else {
|
| - |
|
134 |
alert("Invalid email id");
|
| - |
|
135 |
}
|
| - |
|
136 |
|
| - |
|
137 |
});
|
| 124 |
$('button.mk_add_customer').live('click', function() {
|
138 |
$('button.mk_add_customer').live('click', function() {
|
| 125 |
customerObj = {}
|
139 |
customerObj = {}
|
| 126 |
if($("input.firstName").val().length==0) {
|
140 |
if($("input.firstName").val().length==0) {
|
| 127 |
alert("First Name is required");
|
141 |
alert("First Name is required");
|
| 128 |
return false;
|
142 |
return false;
|
| 129 |
}
|
143 |
}
|
| 130 |
customerObj['firstName'] = $("input.firstName").val();
|
144 |
customerObj['firstName'] = $("input.firstName").val();
|
| 131 |
customerObj['lastName'] = $("input.lastName").val();
|
145 |
customerObj['lastName'] = $("input.lastName").val();
|
| 132 |
customerObj['emailId'] = $("#emailIds").val();
|
146 |
customerObj['emailId'] = $("#emailId").val();
|
| 133 |
|
147 |
|
| 134 |
console.log(customerObj['emailId']);
|
148 |
console.log(customerObj['emailId']);
|
| 135 |
customerObj['mobileNumber'] = $("input.phone").val();
|
149 |
customerObj['mobileNumber'] = $("input.phone").val();
|
| 136 |
doPostAjaxRequestWithJsonHandler(`${context}/customer/add`, JSON.stringify(customerObj), function(response){
|
150 |
doPostAjaxRequestWithJsonHandler(`${context}/customer/add`, JSON.stringify(customerObj), function(response){
|
| 137 |
alert("Customer added");
|
151 |
alert("Customer added");
|
| Line 381... |
Line 395... |
| 381 |
return;
|
395 |
return;
|
| 382 |
}
|
396 |
}
|
| 383 |
$('input.firstName').attr('value', customer.firstName).attr('readonly', true);
|
397 |
$('input.firstName').attr('value', customer.firstName).attr('readonly', true);
|
| 384 |
$('input.lastName').attr('value', customer.lastName).attr('readonly', true);
|
398 |
$('input.lastName').attr('value', customer.lastName).attr('readonly', true);
|
| 385 |
$('input.phone').attr('value', customer.mobileNumber).attr('readonly', true);
|
399 |
$('input.phone').attr('value', customer.mobileNumber).attr('readonly', true);
|
| 386 |
if(customer.emailId!=null) {
|
400 |
if(customer.emailId!= null && customer.emailId!='') {
|
| 387 |
$('#emailIds').attr('value', customer.emailId).attr('readonly', true);
|
401 |
$('#emailId').attr('value', customer.emailId).attr('readonly', true);
|
| 388 |
console.log('helo');
|
402 |
console.log('helo');
|
| - |
|
403 |
} else {
|
| - |
|
404 |
$('button.mk_add_email').show();
|
| 389 |
}
|
405 |
}
|
| 390 |
$('#firstName').attr('value', customer.firstName);
|
406 |
$('#firstName').attr('value', customer.firstName);
|
| 391 |
$('#lastName').attr('value', customer.lastName);
|
407 |
$('#lastName').attr('value', customer.lastName);
|
| 392 |
$('#alternatePhone').attr('value', customer.mobileNumber);
|
408 |
$('#alternatePhone').attr('value', customer.mobileNumber);
|
| 393 |
customerId = customer.customerId;
|
409 |
customerId = customer.customerId;
|
| Line 416... |
Line 432... |
| 416 |
tr.push(`<td>${address.state}</td>`);
|
432 |
tr.push(`<td>${address.state}</td>`);
|
| 417 |
tr.push(`<td>${address.pinCode}</td>`);
|
433 |
tr.push(`<td>${address.pinCode}</td>`);
|
| 418 |
tr.push(`<td>${address.phoneNumber}</td>`);
|
434 |
tr.push(`<td>${address.phoneNumber}</td>`);
|
| 419 |
tr.push(`<td><a class="select-address" href="javascript:void(0);" data-addressid="${address.id}">Select address</a></td></tr>`);
|
435 |
tr.push(`<td><a class="select-address" href="javascript:void(0);" data-addressid="${address.id}">Select address</a></td></tr>`);
|
| 420 |
return tr.join("");
|
436 |
return tr.join("");
|
| - |
|
437 |
}
|
| - |
|
438 |
function validateEmail(email) {
|
| - |
|
439 |
const re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
| - |
|
440 |
return re.test(String(email).toLowerCase());
|
| 421 |
}
|
441 |
}
|
| 422 |
|
442 |
|