| Line 128... |
Line 128... |
| 128 |
var itemId = parseInt($(this).attr("itemId"));
|
128 |
var itemId = parseInt($(this).attr("itemId"));
|
| 129 |
itemIds.push(itemId);
|
129 |
itemIds.push(itemId);
|
| 130 |
});
|
130 |
});
|
| 131 |
console.log(itemIds);
|
131 |
console.log(itemIds);
|
| 132 |
calculateTotalAmount();
|
132 |
calculateTotalAmount();
|
| 133 |
checkPrebookingOrdersByCustomerMobileNumber(mobileNumber, itemIds);
|
- |
|
| 134 |
});
|
133 |
});
|
| 135 |
|
134 |
|
| 136 |
});
|
135 |
});
|
| 137 |
|
136 |
|
| 138 |
|
137 |
|
| Line 190... |
Line 189... |
| 190 |
alert("Please provide valid gstNumber");
|
189 |
alert("Please provide valid gstNumber");
|
| 191 |
error = true;
|
190 |
error = true;
|
| 192 |
$("form#cd input[name=gstNumber]").addClass("border-highlight");
|
191 |
$("form#cd input[name=gstNumber]").addClass("border-highlight");
|
| 193 |
}
|
192 |
}
|
| 194 |
|
193 |
|
| 195 |
/*if(localStorage.getItem('otpVerified') == null || localStorage.getItem('otpVerified') == "false"){
|
- |
|
| 196 |
alert("Please verify prebooking orders otp");
|
- |
|
| 197 |
error = true;
|
- |
|
| 198 |
}*/
|
- |
|
| 199 |
|
- |
|
| 200 |
var amount = 0;
|
194 |
var amount = 0;
|
| 201 |
var netPayableAmount = parseFloat($("form#cd input.netPayableAmount").val());
|
195 |
var netPayableAmount = parseFloat($("form#cd input.netPayableAmount").val());
|
| 202 |
var totalAdvanceAmount = parseFloat($("form#cd input.totalAdvanceAmount").val());
|
196 |
var totalAdvanceAmount = parseFloat($("form#cd input.totalAdvanceAmount").val());
|
| 203 |
|
197 |
|
| 204 |
netPayableAmount = netPayableAmount - totalAdvanceAmount;
|
198 |
netPayableAmount = netPayableAmount - totalAdvanceAmount;
|
| Line 288... |
Line 282... |
| 288 |
var itemId = parseInt($unitPriceElement.attr("itemId"));
|
282 |
var itemId = parseInt($unitPriceElement.attr("itemId"));
|
| 289 |
var unitPrice = parseFloat($unitPriceElement.val());
|
283 |
var unitPrice = parseFloat($unitPriceElement.val());
|
| 290 |
var qty = parseInt($unitPriceElement.attr("quantity"));
|
284 |
var qty = parseInt($unitPriceElement.attr("quantity"));
|
| 291 |
var discountAmount = parseFloat($discountAmountElement.val());
|
285 |
var discountAmount = parseFloat($discountAmountElement.val());
|
| 292 |
var mop = $discountAmountElement.attr("mop");
|
286 |
var mop = $discountAmountElement.attr("mop");
|
| 293 |
var prebookingOrder = false;
|
- |
|
| 294 |
$('.prebooking-order-details').each(function(){
|
- |
|
| 295 |
if($(this).find('.useAdvanceAmount').is(':checked')){
|
- |
|
| 296 |
var prebookingOrderItemId = parseInt($(this).find('.prebooking-item-id').text());
|
- |
|
| 297 |
if(prebookingOrderItemId == itemId){
|
- |
|
| 298 |
prebookingOrder = true;
|
- |
|
| 299 |
}
|
- |
|
| 300 |
}
|
- |
|
| 301 |
});
|
- |
|
| 302 |
|
- |
|
| 303 |
var tmpObj = {'itemId':itemId,'sellingPrice':unitPrice,'quantity':qty, 'prebookingOrder':prebookingOrder};
|
287 |
var tmpObj = {'itemId':itemId,'sellingPrice':unitPrice,'quantity':qty};
|
| 304 |
tmpObj.discountAmount = discountAmount;
|
288 |
tmpObj.discountAmount = discountAmount;
|
| 305 |
|
289 |
|
| 306 |
if (orderObj['fofoOrderItems'][itemId] === undefined){
|
290 |
if (orderObj['fofoOrderItems'][itemId] === undefined){
|
| 307 |
tmpObj['serialNumberDetails'] =[];
|
291 |
tmpObj['serialNumberDetails'] =[];
|
| 308 |
}else{
|
292 |
}else{
|
| Line 400... |
Line 384... |
| 400 |
}
|
384 |
}
|
| 401 |
|
385 |
|
| 402 |
|
386 |
|
| 403 |
function writeOldCustomerDetailsByMobileNumber(mobileNumber){
|
387 |
function writeOldCustomerDetailsByMobileNumber(mobileNumber){
|
| 404 |
doAjaxRequestHandler(context+"/customer/mobileNumber?mobileNumber="+mobileNumber, "GET", function(response){
|
388 |
doAjaxRequestHandler(context+"/customer/mobileNumber?mobileNumber="+mobileNumber, "GET", function(response){
|
| - |
|
389 |
if(response.response=='') {
|
| - |
|
390 |
return;
|
| - |
|
391 |
}
|
| 405 |
var customer = response.response;
|
392 |
var customer = response.response;
|
| 406 |
$('#firstName').attr('value', customer.firstName);
|
393 |
$('#firstName').attr('value', customer.firstName);
|
| 407 |
$('#lastName').attr('value', customer.lastName);
|
394 |
$('#lastName').attr('value', customer.lastName);
|
| 408 |
$('#email').attr('value', customer.emailId);
|
395 |
$('#email').attr('value', customer.emailId);
|
| 409 |
//$('#phone').attr('value', customer.mobileNumber);
|
396 |
//$('#phone').attr('value', customer.mobileNumber);
|
| Line 417... |
Line 404... |
| 417 |
$('#state').attr('value', customer.address.state).prop('selected',true);
|
404 |
$('#state').attr('value', customer.address.state).prop('selected',true);
|
| 418 |
$('#phone').attr('addressId', customer.address.id);
|
405 |
$('#phone').attr('addressId', customer.address.id);
|
| 419 |
}
|
406 |
}
|
| 420 |
//$('#state').val(customer.address.state).prop('selected', true);
|
407 |
//$('#state').val(customer.address.state).prop('selected', true);
|
| 421 |
});
|
408 |
});
|
| 422 |
}
|
- |
|
| 423 |
|
- |
|
| 424 |
$(document).on('change', '.prebooking-order-details', function(){
|
- |
|
| 425 |
|
- |
|
| 426 |
var itemIdQuantityMap = {};
|
- |
|
| 427 |
$("#order-details").find("tr:not(:first-child)").each(function(index, el){
|
- |
|
| 428 |
//console.log(el);
|
- |
|
| 429 |
//console.log(index);
|
- |
|
| 430 |
var $el = $(el);
|
- |
|
| 431 |
var $unitPriceElement = $el.find('.unitPrice');
|
- |
|
| 432 |
|
- |
|
| 433 |
var itemId = parseInt($unitPriceElement.attr("itemId"));
|
- |
|
| 434 |
var qty = parseInt($unitPriceElement.attr("quantity"));
|
- |
|
| 435 |
if(itemIdQuantityMap[itemId] == null){
|
- |
|
| 436 |
itemIdQuantityMap[itemId] = qty;
|
- |
|
| 437 |
}else{
|
- |
|
| 438 |
itemIdQuantityMap[itemId] = itemIdQuantityMap[itemId] + qty;
|
- |
|
| 439 |
}
|
- |
|
| 440 |
|
- |
|
| 441 |
});
|
- |
|
| 442 |
|
- |
|
| 443 |
console.log(itemIdQuantityMap);
|
- |
|
| 444 |
|
- |
|
| 445 |
console.log("use advance amount clicked");
|
- |
|
| 446 |
if ($('.useAdvanceAmount').is(':checked')) {
|
- |
|
| 447 |
//$(this).val('true');
|
- |
|
| 448 |
if(localStorage.getItem('otpVerified') != null && localStorage.getItem("otpVerified") == true){
|
- |
|
| 449 |
$('#customer-otp-details').html('');
|
- |
|
| 450 |
}else{
|
- |
|
| 451 |
var customerOtpDetailsDiv='<div class="row">'
|
- |
|
| 452 |
+'<div class="col-lg-2 form-group">'
|
- |
|
| 453 |
+'<button class="btn btn-primary" id="generate-otp-button" onclick="generateOtp()" type="button">Generate Otp</button>'
|
- |
|
| 454 |
+'</div>'
|
- |
|
| 455 |
+'<div class="col-lg-2 form-group">'
|
- |
|
| 456 |
+'<input placeholder = "OTP" id="otpValue" name="otpValue" type="text" class="form-control input-sm">'
|
- |
|
| 457 |
+'</div>'
|
- |
|
| 458 |
+'<div class="col-lg-2 form-group">'
|
- |
|
| 459 |
+'<button class="btn btn-primary" id="validate-otp-button" onclick="validateOtp()" type="button">Validate Otp</button>'
|
- |
|
| 460 |
+'</div>';
|
- |
|
| 461 |
+'</div>';
|
- |
|
| 462 |
$('#customer-otp-details').html(customerOtpDetailsDiv);
|
- |
|
| 463 |
}
|
- |
|
| 464 |
}else{
|
- |
|
| 465 |
//$(this).val('false');
|
- |
|
| 466 |
$('#customer-otp-details').html('');
|
- |
|
| 467 |
}
|
- |
|
| 468 |
if($(this).find('.useAdvanceAmount').is(':checked')){
|
- |
|
| 469 |
$(this).find('.useAdvanceAmount').val('true');
|
- |
|
| 470 |
var advanceAmount = $(this).find('.prebooking-advance-amount').text();
|
- |
|
| 471 |
console.log("- advanceAmount : "+advanceAmount);
|
- |
|
| 472 |
var quantity = $(this).find('.prebooking-available-quantity').text();
|
- |
|
| 473 |
console.log("available quantity : "+quantity);
|
- |
|
| 474 |
var itemId = parseInt($(this).find('.prebooking-item-id').text());
|
- |
|
| 475 |
console.log("itemId : "+itemId);
|
- |
|
| 476 |
var prebookingAmount = 0.0;
|
- |
|
| 477 |
if(itemIdQuantityMap[itemId] < parseInt(quantity)){
|
- |
|
| 478 |
prebookingAmount = parseFloat(advanceAmount) * parseFloat(itemIdQuantityMap[itemId]);
|
- |
|
| 479 |
}else{
|
- |
|
| 480 |
prebookingAmount = parseFloat(advanceAmount) * parseFloat(quantity);
|
- |
|
| 481 |
}
|
- |
|
| 482 |
console.log("prebookingAmount : "+prebookingAmount);
|
- |
|
| 483 |
|
- |
|
| 484 |
|
- |
|
| 485 |
//calculateTotalAmount();
|
- |
|
| 486 |
//var netPayableAmount = $('#cd').find('input.netPayableAmount').val();
|
- |
|
| 487 |
//console.log("netPayableAmount : "+netPayableAmount);
|
- |
|
| 488 |
//$('#cd').find('input.netPayableAmount').val(parseFloat(netPayableAmount) - prebookingAmount);
|
- |
|
| 489 |
$('#cd').find('input.totalAdvanceAmount').val(prebookingAmount);
|
- |
|
| 490 |
}else if(!$(this).find('.useAdvanceAmount').is(':checked')){
|
- |
|
| 491 |
$(this).find('.useAdvanceAmount').val('false');
|
- |
|
| 492 |
var advanceAmount = $(this).find('.prebooking-advance-amount').text();
|
- |
|
| 493 |
console.log("+ advanceAmount : "+advanceAmount);
|
- |
|
| 494 |
var quantity = $(this).find('.prebooking-available-quantity').text();
|
- |
|
| 495 |
console.log("available quantity : "+quantity);
|
- |
|
| 496 |
var itemId = parseInt($(this).find('.prebooking-item-id').text());
|
- |
|
| 497 |
console.log("itemId : "+itemId);
|
- |
|
| 498 |
var prebookingAmount = 0.0;
|
- |
|
| 499 |
if(itemIdQuantityMap[itemId] < parseInt(quantity)){
|
- |
|
| 500 |
prebookingAmount = parseFloat(advanceAmount) * parseFloat(itemIdQuantityMap[itemId]);
|
- |
|
| 501 |
console.log("used quantity : "+itemIdQuantityMap[itemId]);
|
- |
|
| 502 |
}else{
|
- |
|
| 503 |
prebookingAmount = parseFloat(advanceAmount) * parseFloat(quantity);
|
- |
|
| 504 |
console.log("used quantity : "+quantity);
|
- |
|
| 505 |
}
|
- |
|
| 506 |
console.log("prebookingAmount : "+prebookingAmount);
|
- |
|
| 507 |
//calculateTotalAmount();
|
- |
|
| 508 |
//var netPayableAmount = $('#cd').find('input.netPayableAmount').val();
|
- |
|
| 509 |
//console.log("netPayableAmount : "+netPayableAmount);
|
- |
|
| 510 |
//$('#cd').find('input.netPayableAmount').val(parseFloat(netPayableAmount) + prebookingAmount);
|
- |
|
| 511 |
var totalAdvanceAmount = $('#cd').find('input.totalAdvanceAmount').val();
|
- |
|
| 512 |
$('#cd').find('input.totalAdvanceAmount').val(parseFloat(totalAdvanceAmount) - prebookingAmount);
|
- |
|
| 513 |
}
|
- |
|
| 514 |
});
|
- |
|
| 515 |
|
- |
|
| 516 |
/*$(document).on('change', '.useAdvanceAmount', function() {
|
- |
|
| 517 |
if($(this).is(':checked')){
|
- |
|
| 518 |
$(this).val('true');
|
- |
|
| 519 |
}else{
|
- |
|
| 520 |
$(this).val('false');
|
- |
|
| 521 |
}
|
- |
|
| 522 |
});*/
|
- |
|
| 523 |
|
- |
|
| 524 |
function generateOtp(){
|
- |
|
| 525 |
console.log("generate Otp button clicked")
|
- |
|
| 526 |
var itemIdQuantityMap = {};
|
- |
|
| 527 |
$("#order-details").find("tr:not(:first-child)").each(function(index, el){
|
- |
|
| 528 |
//console.log(el);
|
- |
|
| 529 |
//console.log(index);
|
- |
|
| 530 |
var $el = $(el);
|
- |
|
| 531 |
var $unitPriceElement = $el.find('.unitPrice');
|
- |
|
| 532 |
|
- |
|
| 533 |
var itemId = parseInt($unitPriceElement.attr("itemId"));
|
- |
|
| 534 |
var qty = parseInt($unitPriceElement.attr("quantity"));
|
- |
|
| 535 |
if(itemIdQuantityMap[itemId] == null){
|
- |
|
| 536 |
itemIdQuantityMap[itemId] = qty;
|
- |
|
| 537 |
}else{
|
- |
|
| 538 |
itemIdQuantityMap[itemId] = itemIdQuantityMap[itemId] + qty;
|
- |
|
| 539 |
}
|
- |
|
| 540 |
|
- |
|
| 541 |
});
|
- |
|
| 542 |
|
- |
|
| 543 |
//console.log(itemIdQuantityMap);
|
- |
|
| 544 |
var itemIdAdvanceAmountMap = {};
|
- |
|
| 545 |
$('.prebooking-order-details').each(function(){
|
- |
|
| 546 |
if($(this).find('.useAdvanceAmount').is(':checked')){
|
- |
|
| 547 |
var advanceAmount = $(this).find('.prebooking-advance-amount').text();
|
- |
|
| 548 |
//console.log("- advanceAmount : "+advanceAmount);
|
- |
|
| 549 |
var quantity = $(this).find('.prebooking-available-quantity').text();
|
- |
|
| 550 |
//console.log("available quantity : "+quantity);
|
- |
|
| 551 |
var itemId = parseInt($(this).find('.prebooking-item-id').text());
|
- |
|
| 552 |
//console.log("itemId : "+itemId);
|
- |
|
| 553 |
var prebookingAmount = 0.0;
|
- |
|
| 554 |
if(itemIdQuantityMap[itemId] < parseInt(quantity)){
|
- |
|
| 555 |
prebookingAmount = parseFloat(advanceAmount) * parseFloat(itemIdQuantityMap[itemId]);
|
- |
|
| 556 |
}else{
|
- |
|
| 557 |
prebookingAmount = parseFloat(advanceAmount) * parseFloat(quantity);
|
- |
|
| 558 |
}
|
- |
|
| 559 |
itemIdAdvanceAmountMap[itemId] = prebookingAmount;
|
- |
|
| 560 |
}
|
- |
|
| 561 |
});
|
- |
|
| 562 |
console.log(itemIdAdvanceAmountMap);
|
- |
|
| 563 |
var mobileNumber = $("form#cd input[name=phone]").val();
|
- |
|
| 564 |
var emailId = $("form#cd input[name=email]").val();
|
- |
|
| 565 |
var url = context+'/generateOtp?customerMobileNumber='+mobileNumber+'&customerEmailId='+emailId;
|
- |
|
| 566 |
doAjaxRequestWithJsonHandler(url, "POST", JSON.stringify(itemIdAdvanceAmountMap), function(response){
|
- |
|
| 567 |
console.log("generate Otp response : "+JSON.stringify(response));
|
- |
|
| 568 |
alert("OTP has been generated successfully, Please verify OTP for further process");
|
- |
|
| 569 |
var otpId = parseInt(response.response);
|
- |
|
| 570 |
localStorage.setItem("otpId", otpId);
|
- |
|
| 571 |
localStorage.setItem("otpVerified", false);
|
- |
|
| 572 |
});
|
- |
|
| 573 |
}
|
- |
|
| 574 |
|
- |
|
| 575 |
function validateOtp(){
|
- |
|
| 576 |
console.log("validateOtp button click");
|
- |
|
| 577 |
var mobileNumber = $("form#cd input[name=phone]").val();
|
- |
|
| 578 |
var emailId = $("form#cd input[name=email]").val();
|
- |
|
| 579 |
var otpId = parseInt(localStorage.getItem('otpId'));
|
- |
|
| 580 |
var otpValue = $('#otpValue').val();
|
- |
|
| 581 |
if(otpId == null || otpValue == ""){
|
- |
|
| 582 |
alert("Please enter otpValue");
|
- |
|
| 583 |
}else{
|
- |
|
| 584 |
var url = context+'/validateOtp?customerMobileNumber='+mobileNumber+'&customerEmailId='+emailId+'&otpId='+otpId+'&otpValue='+otpValue;
|
- |
|
| 585 |
doAjaxRequestHandler(url, "GET", function(response){
|
- |
|
| 586 |
alert(response.response);
|
- |
|
| 587 |
localStorage.removeItem("otpId");
|
- |
|
| 588 |
$('#customer-otp-details').html('');
|
- |
|
| 589 |
//$('#generate-otp-button').prop("disabled", true);
|
- |
|
| 590 |
//$('#otpValue').prop("disabled", true);
|
- |
|
| 591 |
//$('#validate-otp-button').prop("disabled", true);
|
- |
|
| 592 |
localStorage.setItem("otpVerified", true);
|
- |
|
| 593 |
});
|
- |
|
| 594 |
}
|
- |
|
| 595 |
}
|
- |
|
| 596 |
|
- |
|
| 597 |
|
- |
|
| 598 |
function checkPrebookingOrdersByCustomerMobileNumber(mobileNumber, itemIds){
|
- |
|
| 599 |
//window.dispatchEvent(new Event('resize'));
|
- |
|
| 600 |
|
- |
|
| 601 |
doAjaxRequestWithJsonHandler(context+"/getPrebookingOrdersByCustomerMobileNumber?customerMobileNumber="+mobileNumber, "POST", JSON.stringify(itemIds), function(response){
|
- |
|
| 602 |
$('#prebooking-order-details').html(response);
|
- |
|
| 603 |
});
|
- |
|
| 604 |
}
|
409 |
}
|
| 605 |
|
410 |
|