| 27187 |
amit.gupta |
1 |
var customerId;
|
| 24440 |
amit.gupta |
2 |
function formLoaded() {
|
| 27187 |
amit.gupta |
3 |
$("form#cd input").each(function(){
|
| 22245 |
ashik.ali |
4 |
$(this).attr('autocomplete', 'off');
|
|
|
5 |
});
|
| 27187 |
amit.gupta |
6 |
$('form#cd').validate({
|
|
|
7 |
rules:{
|
|
|
8 |
name:{
|
|
|
9 |
required:true
|
|
|
10 |
},
|
|
|
11 |
email:{
|
|
|
12 |
required:true,
|
|
|
13 |
email:true
|
|
|
14 |
},
|
|
|
15 |
line1:{
|
|
|
16 |
required:true
|
|
|
17 |
},
|
|
|
18 |
state:{
|
|
|
19 |
required:true
|
|
|
20 |
},
|
|
|
21 |
city:{
|
|
|
22 |
required:true
|
|
|
23 |
},
|
|
|
24 |
pincode:{
|
|
|
25 |
required:true,
|
|
|
26 |
digits:true,
|
|
|
27 |
minlength: 6,
|
|
|
28 |
maxlength: 6,
|
|
|
29 |
},
|
|
|
30 |
phone:{
|
|
|
31 |
required:true,
|
|
|
32 |
minlength:10,
|
|
|
33 |
maxlength:10,
|
|
|
34 |
digits:true
|
|
|
35 |
},
|
|
|
36 |
},
|
|
|
37 |
messages:{
|
|
|
38 |
name:{
|
|
|
39 |
required:"Required"
|
|
|
40 |
},
|
|
|
41 |
line1:{
|
|
|
42 |
required:"Required"
|
|
|
43 |
},
|
|
|
44 |
state:{
|
|
|
45 |
required: "State required"
|
|
|
46 |
},
|
|
|
47 |
city:{
|
|
|
48 |
required: "City required"
|
|
|
49 |
},
|
|
|
50 |
email:{
|
|
|
51 |
require: "Required"
|
|
|
52 |
},
|
|
|
53 |
pincode:{
|
|
|
54 |
required: "Required",
|
|
|
55 |
digits:"Invalid pin"
|
|
|
56 |
},
|
|
|
57 |
phone:{
|
|
|
58 |
required: "Required",
|
|
|
59 |
digits:"Invalid number",
|
|
|
60 |
minlength:"Number should be of 10 digits"
|
|
|
61 |
}
|
|
|
62 |
},
|
|
|
63 |
submitHandler: function (form, event) {
|
|
|
64 |
event.preventDefault();
|
|
|
65 |
var payload = orderDetailsPayload();
|
|
|
66 |
if(!validateOrderDetails()){
|
|
|
67 |
alert("Please fix highlighted errors");
|
|
|
68 |
return false;
|
|
|
69 |
}
|
|
|
70 |
doPostAjaxRequestWithJsonHandler(context+"/create-order", payload, function(response){
|
|
|
71 |
emptyBag();
|
|
|
72 |
$('#main-content').html(response);
|
| 23353 |
ashik.ali |
73 |
});
|
| 27187 |
amit.gupta |
74 |
return false; // required to block normal submit since you used
|
|
|
75 |
// ajax
|
|
|
76 |
}
|
|
|
77 |
});
|
|
|
78 |
|
|
|
79 |
$("input.unitPrice").on('change', function() {
|
|
|
80 |
var $element = $(this);
|
|
|
81 |
var unitPrice = parseFloat($element.val());
|
|
|
82 |
if(!isNaN(unitPrice)) {
|
|
|
83 |
var itemType = parseFloat($(this).closest('tr').find('.serialNumber').attr("itemType"));
|
|
|
84 |
var mopPrice = parseFloat($(this).attr('mopPrice'));
|
|
|
85 |
var dp = parseFloat($(this).attr('dp'));
|
|
|
86 |
var mrp = parseFloat($(this).attr('mrp'));
|
|
|
87 |
if(mrp != 0 && unitPrice > mrp) {
|
|
|
88 |
alert("Selling Price should not be greater than MRP");
|
|
|
89 |
$element.addClass("border-highlight");
|
|
|
90 |
} else if(!accessoriesDeals && unitPrice < mopPrice){
|
|
|
91 |
alert("Selling Price must be greater than equal to MOP");
|
|
|
92 |
$element.addClass("border-highlight");
|
|
|
93 |
}else if(itemType=='SERIALIZED' && unitPrice < mopPrice){
|
|
|
94 |
alert("Selling Price must be greater than equal to MOP");
|
|
|
95 |
$element.addClass("border-highlight");
|
|
|
96 |
}else if(itemType=='NON_SERIALIZED' && unitPrice < dp){
|
|
|
97 |
alert("Selling Price must be greater than equal to DP");
|
|
|
98 |
$element.addClass("border-highlight");
|
|
|
99 |
}else{
|
|
|
100 |
$element.removeClass("border-highlight");
|
|
|
101 |
}
|
|
|
102 |
// Clear insurance values if price changes
|
|
|
103 |
$(this).closest('tr').find('.insuranceid').val("");
|
|
|
104 |
$(this).closest('tr').find('.insuranceamount').val("0");
|
|
|
105 |
}
|
|
|
106 |
calculateTotalAmount();
|
|
|
107 |
});
|
|
|
108 |
customerInfo = $("div.customerinfo").html();
|
|
|
109 |
billingInfo = $("div.billinginfo").html();
|
|
|
110 |
|
|
|
111 |
$( "input.search-phone").change(function() {
|
|
|
112 |
resetInputs();
|
| 22354 |
ashik.ali |
113 |
var mobileNumber = $(this).val();
|
| 27187 |
amit.gupta |
114 |
if(mobileNumber.length < 10) {
|
| 23405 |
amit.gupta |
115 |
return;
|
|
|
116 |
}
|
| 22354 |
ashik.ali |
117 |
writeOldCustomerDetailsByMobileNumber(mobileNumber);
|
|
|
118 |
});
|
| 27187 |
amit.gupta |
119 |
|
|
|
120 |
$('button.new-address-btn').live('click', function() {
|
|
|
121 |
$('#newaddressModal').modal({show: true});
|
|
|
122 |
});
|
|
|
123 |
|
| 27693 |
amit.gupta |
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 |
});
|
| 27187 |
amit.gupta |
138 |
$('button.mk_add_customer').live('click', function() {
|
|
|
139 |
customerObj = {}
|
|
|
140 |
if($("input.firstName").val().length==0) {
|
|
|
141 |
alert("First Name is required");
|
|
|
142 |
return false;
|
|
|
143 |
}
|
|
|
144 |
customerObj['firstName'] = $("input.firstName").val();
|
|
|
145 |
customerObj['lastName'] = $("input.lastName").val();
|
| 27693 |
amit.gupta |
146 |
customerObj['emailId'] = $("#emailId").val();
|
| 27688 |
tejbeer |
147 |
|
| 27682 |
tejbeer |
148 |
console.log(customerObj['emailId']);
|
| 27187 |
amit.gupta |
149 |
customerObj['mobileNumber'] = $("input.phone").val();
|
|
|
150 |
doPostAjaxRequestWithJsonHandler(`${context}/customer/add`, JSON.stringify(customerObj), function(response){
|
|
|
151 |
alert("Customer added");
|
| 27694 |
amit.gupta |
152 |
$( "input.search-phone").change();
|
| 27187 |
amit.gupta |
153 |
});
|
|
|
154 |
|
|
|
155 |
|
|
|
156 |
});
|
|
|
157 |
$('a.select-address').live('click', function() {
|
|
|
158 |
$(this).closest('table').data("addressselected", "true").find('td').css("font-weight", "normal");
|
|
|
159 |
$(this).closest('tr').find('td').css("font-weight", "bold");
|
|
|
160 |
selectedAddressId = $(this).data("addressid");
|
|
|
161 |
});
|
|
|
162 |
$('button.btn-add-address').live('click', function(){
|
|
|
163 |
var customerAddress = {};
|
|
|
164 |
customerAddress['name'] = $("#firstName").val();
|
|
|
165 |
customerAddress['lastName'] = $("#lastName").val();
|
|
|
166 |
customerAddress['line1'] = $("#line1").val();
|
|
|
167 |
customerAddress['line2'] = $("#line2").val();
|
|
|
168 |
customerAddress['landmark'] = $("#landmark").val();
|
|
|
169 |
customerAddress['city'] = $("#city").val();
|
|
|
170 |
customerAddress['state'] = $('select[name=state] option:selected').val();
|
|
|
171 |
customerAddress['pinCode'] = $("#pinCode").val();
|
|
|
172 |
customerAddress['phoneNumber'] = $("#alternatePhone").val();
|
|
|
173 |
customerAddress['country'] = "India";
|
|
|
174 |
console.log(customerAddress);
|
|
|
175 |
doPostAjaxRequestWithJsonHandler(`${context}/customer/address?customerId=${customerId}`, JSON.stringify(customerAddress), function(response){
|
|
|
176 |
$("#address-body").prepend(getAddressTr(response.response));
|
|
|
177 |
$('#newaddressModal').modal('toggle');
|
|
|
178 |
$("#address-body").find('a.select-address').click();
|
|
|
179 |
});
|
|
|
180 |
});
|
|
|
181 |
|
| 24440 |
amit.gupta |
182 |
}
|
| 27187 |
amit.gupta |
183 |
function validateOrderDetails(){
|
| 23343 |
ashik.ali |
184 |
var sNumbers = [];
|
|
|
185 |
var error = false;
|
| 27187 |
amit.gupta |
186 |
$("form#cd input.serialNumber").each(function(){
|
| 23343 |
ashik.ali |
187 |
var input = $(this).val().trim();
|
| 27187 |
amit.gupta |
188 |
var itemType = $(this).attr("itemType");
|
| 23343 |
ashik.ali |
189 |
$(this).removeClass("border-highlight");
|
| 27187 |
amit.gupta |
190 |
if (sNumbers.indexOf(input) !=-1 || (itemType ==='SERIALIZED' && !input)){
|
| 23343 |
ashik.ali |
191 |
error = true;
|
|
|
192 |
$(this).addClass("border-highlight");
|
|
|
193 |
}
|
| 27187 |
amit.gupta |
194 |
sNumbers.push(input);
|
| 23343 |
ashik.ali |
195 |
});
|
| 27187 |
amit.gupta |
196 |
|
|
|
197 |
$("form#cd input.unitPrice").each(function(){
|
|
|
198 |
var input = $(this).val().trim();
|
|
|
199 |
$(this).removeClass("border-highlight");
|
|
|
200 |
if (!input || parseInt(input)<=0 || isNaN(input)){
|
|
|
201 |
error=true;
|
|
|
202 |
$(this).addClass("border-highlight");
|
|
|
203 |
}
|
|
|
204 |
});
|
|
|
205 |
|
| 23370 |
ashik.ali |
206 |
var gstNumber = $("form#cd input[name=gstNumber]").val();
|
|
|
207 |
$("form#cd input[name=gstNumber]").removeClass("border-highlight");
|
| 27187 |
amit.gupta |
208 |
if(gstNumber.length > 0 && gstNumber.length != 15){
|
| 23370 |
ashik.ali |
209 |
alert("Please provide valid gstNumber");
|
|
|
210 |
error = true;
|
|
|
211 |
$("form#cd input[name=gstNumber]").addClass("border-highlight");
|
|
|
212 |
}
|
| 27187 |
amit.gupta |
213 |
|
| 23343 |
ashik.ali |
214 |
var amount = 0;
|
|
|
215 |
var netPayableAmount = parseFloat($("form#cd input.netPayableAmount").val());
|
| 27187 |
amit.gupta |
216 |
$("form#cd input.amount").each(function(){
|
|
|
217 |
if ($(this).val() == ""){
|
| 23343 |
ashik.ali |
218 |
$(this).val(0);
|
|
|
219 |
}
|
|
|
220 |
var tmpAmount = parseFloat($(this).val());
|
|
|
221 |
amount = amount + tmpAmount;
|
|
|
222 |
});
|
| 27187 |
amit.gupta |
223 |
|
| 23343 |
ashik.ali |
224 |
console.log(amount);
|
|
|
225 |
console.log(netPayableAmount);
|
| 27187 |
amit.gupta |
226 |
|
|
|
227 |
if (amount != netPayableAmount){
|
|
|
228 |
if(amount < netPayableAmount){
|
|
|
229 |
alert("[" + (netPayableAmount - amount) + "] is more required to complete the payment");
|
|
|
230 |
}else{
|
|
|
231 |
alert("[" + (amount - netPayableAmount) + "] is extra amount, please reduce the amount");
|
| 23343 |
ashik.ali |
232 |
}
|
| 27187 |
amit.gupta |
233 |
$("form#cd input.netPayableAmount").each(function(){
|
| 23343 |
ashik.ali |
234 |
$(this).addClass("border-highlight");
|
|
|
235 |
});
|
|
|
236 |
error = true;
|
|
|
237 |
}
|
| 27187 |
amit.gupta |
238 |
|
|
|
239 |
if (error){
|
| 23343 |
ashik.ali |
240 |
return false;
|
|
|
241 |
}
|
|
|
242 |
return true;
|
| 27187 |
amit.gupta |
243 |
|
| 23347 |
ashik.ali |
244 |
}
|
|
|
245 |
|
| 27187 |
amit.gupta |
246 |
|
|
|
247 |
function getSerialNumbersFromOrder($el){
|
| 23347 |
ashik.ali |
248 |
var $serialNumberElement = $el.find('.serialNumber');
|
| 27187 |
amit.gupta |
249 |
if($serialNumberElement.val() == ''){
|
| 23347 |
ashik.ali |
250 |
return null;
|
|
|
251 |
}
|
| 24440 |
amit.gupta |
252 |
var insuranceAmount = parseFloat($el.find('.insuranceamount').val());
|
| 27187 |
amit.gupta |
253 |
if(insuranceAmount > 0){
|
| 23347 |
ashik.ali |
254 |
insurance = true;
|
|
|
255 |
globalInsurace = true;
|
| 27187 |
amit.gupta |
256 |
}else{
|
| 23347 |
ashik.ali |
257 |
insurance = false;
|
|
|
258 |
}
|
| 27187 |
amit.gupta |
259 |
return {'serialNumber':$serialNumberElement.val(),'insurance':insurance,'amount':insuranceAmount}
|
| 23347 |
ashik.ali |
260 |
}
|
|
|
261 |
|
| 27187 |
amit.gupta |
262 |
function orderDetailsPayload(){
|
| 23419 |
ashik.ali |
263 |
var orderObj = {};
|
|
|
264 |
var priceQtyArray = [];
|
|
|
265 |
var customerObj = {};
|
|
|
266 |
var paymentOptionIdAmount = [];
|
|
|
267 |
var globalInsurance = false;
|
| 27187 |
amit.gupta |
268 |
|
|
|
269 |
$("form#cd input.serialNumber").each(function(){
|
| 23419 |
ashik.ali |
270 |
var itemId = parseInt($(this).attr("itemId"));
|
| 27187 |
amit.gupta |
271 |
if (orderObj.hasOwnProperty('fofoOrderItems')){
|
| 23419 |
ashik.ali |
272 |
var itemDetails = orderObj['fofoOrderItems'];
|
| 27187 |
amit.gupta |
273 |
if (itemDetails.hasOwnProperty(itemId)){
|
| 23419 |
ashik.ali |
274 |
var serialNumbers = itemDetails[itemId];
|
|
|
275 |
serialNumbers.push($(this).val());
|
|
|
276 |
itemDetails[itemId] = serialNumbers;
|
| 27187 |
amit.gupta |
277 |
}else{
|
| 23347 |
ashik.ali |
278 |
var serialNumbers = [];
|
|
|
279 |
serialNumbers.push($(this).val());
|
| 23419 |
ashik.ali |
280 |
itemDetails[itemId] = serialNumbers;
|
| 23347 |
ashik.ali |
281 |
}
|
| 27187 |
amit.gupta |
282 |
}else{
|
| 23419 |
ashik.ali |
283 |
var serialNumbers = [];
|
|
|
284 |
serialNumbers.push($(this).val());
|
| 27187 |
amit.gupta |
285 |
var tmp ={};
|
|
|
286 |
tmp[itemId] = serialNumbers;
|
| 23419 |
ashik.ali |
287 |
orderObj['fofoOrderItems'] = tmp;
|
|
|
288 |
}
|
|
|
289 |
});
|
| 27187 |
amit.gupta |
290 |
console.log( JSON.stringify(orderObj));
|
|
|
291 |
$("#order-items").find("tr:not(:first-child)").each(function(index, el){
|
|
|
292 |
// console.log(el);
|
|
|
293 |
// console.log(index);
|
|
|
294 |
var $el = $(el);
|
|
|
295 |
var $unitPriceElement = $el.find('.unitPrice');
|
|
|
296 |
|
|
|
297 |
var itemId = parseInt($unitPriceElement.attr("itemId"));
|
|
|
298 |
var unitPrice = parseFloat($unitPriceElement.val());
|
|
|
299 |
var qty = parseInt($unitPriceElement.attr("quantity"));
|
|
|
300 |
var tmpObj = {'itemId':itemId,'sellingPrice':unitPrice,'quantity':qty};
|
| 23873 |
amit.gupta |
301 |
|
| 27187 |
amit.gupta |
302 |
if (orderObj['fofoOrderItems'][itemId] === undefined){
|
|
|
303 |
tmpObj['serialNumberDetails'] =[];
|
|
|
304 |
}else{
|
|
|
305 |
// tmpObj['serialNumbers'] = orderObj['fofoLineItems'][itemId];
|
|
|
306 |
tmpObj['serialNumberDetails'] = [];
|
|
|
307 |
}
|
|
|
308 |
var found = false;
|
|
|
309 |
for(var i = 0; i < priceQtyArray.length; i++){
|
|
|
310 |
if (priceQtyArray[i]["itemId"] == itemId){
|
|
|
311 |
priceQtyArray[i]["quantity"] = priceQtyArray[i]["quantity"] + 1;
|
|
|
312 |
found = true;
|
|
|
313 |
break;
|
|
|
314 |
}
|
|
|
315 |
}
|
|
|
316 |
if(!found){
|
|
|
317 |
priceQtyArray.push(tmpObj);
|
|
|
318 |
}
|
|
|
319 |
});
|
|
|
320 |
|
|
|
321 |
$("#order-items").find("tr:not(:first-child)").each(function(index,el){
|
| 24440 |
amit.gupta |
322 |
// console.log(el);
|
|
|
323 |
// console.log(index);
|
| 23419 |
ashik.ali |
324 |
var $serialNumberElement = $(el).find('.serialNumber');
|
|
|
325 |
var itemId = parseInt($serialNumberElement.attr("itemId"));
|
| 24440 |
amit.gupta |
326 |
var insuranceEle = $(el).find('.insuranceamount');
|
|
|
327 |
var insuranceAmount = 0;
|
| 27187 |
amit.gupta |
328 |
if(insuranceEle.length > 0) {
|
| 24440 |
amit.gupta |
329 |
insuranceAmount = parseFloat(insuranceEle.val());
|
|
|
330 |
}
|
|
|
331 |
var insuranceId = "";
|
| 27187 |
amit.gupta |
332 |
if(insuranceAmount > 0) {
|
| 24440 |
amit.gupta |
333 |
insuranceId = $(el).find('.insuranceid').val();
|
|
|
334 |
}
|
| 27187 |
amit.gupta |
335 |
var ram = $(el).find('.ram').val();
|
|
|
336 |
var memory = $(el).find('.memory').val();
|
|
|
337 |
var mfgdate = $(el).find('.mfgdate').val();
|
|
|
338 |
var serialNumberDetails = {'serialNumber':$serialNumberElement.val(),'insurance':insuranceId,'amount':insuranceAmount,
|
|
|
339 |
'ram' :ram, 'memory' : memory, 'mfgDate':mfgdate};
|
| 24440 |
amit.gupta |
340 |
priceQtyArray[index]['serialNumberDetails'].push(serialNumberDetails);
|
| 27187 |
amit.gupta |
341 |
|
| 23419 |
ashik.ali |
342 |
});
|
| 27187 |
amit.gupta |
343 |
|
| 23419 |
ashik.ali |
344 |
customerObj['gstNumber'] = $("form#cd input[name=gstNumber]").val();
|
| 27187 |
amit.gupta |
345 |
if(customerId==undefined) {
|
|
|
346 |
alert("Please choose customer");
|
|
|
347 |
return false;
|
|
|
348 |
}
|
|
|
349 |
if($("#customer-address").data("addressselected")=="true") {
|
|
|
350 |
alert("Please select address");
|
|
|
351 |
return false;
|
|
|
352 |
}
|
|
|
353 |
customerObj['customerId'] = customerId;
|
|
|
354 |
customerObj['customerAddressId'] = selectedAddressId;
|
| 24440 |
amit.gupta |
355 |
customerObj['gender'] = $("#gender").val();
|
|
|
356 |
customerObj['dateOfBirth'] = startDate;
|
| 27187 |
amit.gupta |
357 |
|
|
|
358 |
|
|
|
359 |
var paymentOptionSize = parseInt($('#payment-option-id-amount-container').attr("paymentOptionSize"));
|
| 24440 |
amit.gupta |
360 |
// console.log("paymentOptionSize = "+paymentOptionSize);
|
| 27187 |
amit.gupta |
361 |
for(var index = 0; index < paymentOptionSize; index++){
|
| 23419 |
ashik.ali |
362 |
var paymentOptionAmount = 0.0;
|
| 27187 |
amit.gupta |
363 |
if($('#paymentOptionIdAmount'+index).val() != ""){
|
|
|
364 |
paymentOptionAmount = parseFloat($('#paymentOptionIdAmount'+index).val());
|
| 23367 |
ashik.ali |
365 |
}
|
| 27187 |
amit.gupta |
366 |
var paymentOptionId = $('#paymentOptionIdAmount'+index).attr("paymentOptionId");
|
| 23419 |
ashik.ali |
367 |
var paymentOptionIdAmountObject = {};
|
|
|
368 |
paymentOptionIdAmountObject['paymentOptionId'] = paymentOptionId;
|
|
|
369 |
paymentOptionIdAmountObject['amount'] = paymentOptionAmount;
|
|
|
370 |
paymentOptionIdAmount.push(paymentOptionIdAmountObject);
|
|
|
371 |
}
|
|
|
372 |
var retObj = {};
|
|
|
373 |
retObj['fofoOrderItems'] = (priceQtyArray);
|
|
|
374 |
retObj['customer'] = (customerObj);
|
| 27187 |
amit.gupta |
375 |
retObj['paymentOptions'] = (paymentOptionIdAmount);
|
| 23419 |
ashik.ali |
376 |
|
|
|
377 |
console.log(retObj);
|
| 27187 |
amit.gupta |
378 |
return JSON.stringify(retObj);
|
| 23347 |
ashik.ali |
379 |
}
|
|
|
380 |
|
| 27187 |
amit.gupta |
381 |
function resetInputs() {
|
|
|
382 |
$("div.customerinfo").html(customerInfo);
|
|
|
383 |
$("div.billinginfo").html(billingInfo).hide();
|
|
|
384 |
}
|
|
|
385 |
function writeOldCustomerDetailsByMobileNumber(mobileNumber){
|
|
|
386 |
doAjaxRequestHandler(context+"/customer/mobileNumber?mobileNumber="+mobileNumber, "GET", function(response){
|
|
|
387 |
if(response.response=='') {
|
| 24087 |
amit.gupta |
388 |
return;
|
|
|
389 |
}
|
| 23353 |
ashik.ali |
390 |
var customer = response.response;
|
| 27187 |
amit.gupta |
391 |
if(customer==null) {
|
|
|
392 |
$('input.phone').attr('value', mobileNumber).attr('readonly', true);
|
|
|
393 |
$('button.mk_add_customer').show();
|
|
|
394 |
|
|
|
395 |
return;
|
|
|
396 |
}
|
|
|
397 |
$('input.firstName').attr('value', customer.firstName).attr('readonly', true);
|
|
|
398 |
$('input.lastName').attr('value', customer.lastName).attr('readonly', true);
|
|
|
399 |
$('input.phone').attr('value', customer.mobileNumber).attr('readonly', true);
|
| 27693 |
amit.gupta |
400 |
if(customer.emailId!= null && customer.emailId!='') {
|
|
|
401 |
$('#emailId').attr('value', customer.emailId).attr('readonly', true);
|
| 27682 |
tejbeer |
402 |
console.log('helo');
|
| 27693 |
amit.gupta |
403 |
} else {
|
|
|
404 |
$('button.mk_add_email').show();
|
| 27187 |
amit.gupta |
405 |
}
|
| 26804 |
amit.gupta |
406 |
$('#firstName').attr('value', customer.firstName);
|
|
|
407 |
$('#lastName').attr('value', customer.lastName);
|
| 27187 |
amit.gupta |
408 |
$('#alternatePhone').attr('value', customer.mobileNumber);
|
|
|
409 |
customerId = customer.customerId;
|
|
|
410 |
$("div.billinginfo").show();
|
|
|
411 |
trs = [];
|
|
|
412 |
if(customer.addresses != null) {
|
|
|
413 |
for(address of customer.addresses) {
|
|
|
414 |
if(typeof pendingPO !="undefined") {
|
|
|
415 |
if(pendingPO.customerAddressId==address.id) {
|
|
|
416 |
trs.push(getAddressTr(address));
|
|
|
417 |
}
|
|
|
418 |
} else {
|
|
|
419 |
trs.push(getAddressTr(address));
|
|
|
420 |
}
|
|
|
421 |
}
|
|
|
422 |
}
|
|
|
423 |
$("#address-body").html(trs.join(""));
|
|
|
424 |
|
| 23353 |
ashik.ali |
425 |
});
|
| 27187 |
amit.gupta |
426 |
}
|
|
|
427 |
function getAddressTr(address) {
|
|
|
428 |
var tr = [];
|
|
|
429 |
tr.push(`<tr><td>${address.name} ${address.lastName}</td>`);
|
|
|
430 |
tr.push(`<td>${address.line1}, ${address.line2}</td>`);
|
|
|
431 |
tr.push(`<td>${address.city}</td>`);
|
|
|
432 |
tr.push(`<td>${address.state}</td>`);
|
|
|
433 |
tr.push(`<td>${address.pinCode}</td>`);
|
|
|
434 |
tr.push(`<td>${address.phoneNumber}</td>`);
|
|
|
435 |
tr.push(`<td><a class="select-address" href="javascript:void(0);" data-addressid="${address.id}">Select address</a></td></tr>`);
|
|
|
436 |
return tr.join("");
|
| 27693 |
amit.gupta |
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());
|
| 23343 |
ashik.ali |
441 |
}
|