| Server IP : 103.234.187.230 / Your IP : 216.73.216.216 Web Server : Apache System : Linux lserver42043-ind.megavelocity.net 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/b2bzend/public/js/ |
Upload File : |
/**
* @author : Ranvir Singh
* @Created : 01 Sep 2016
* @Updated : 02 Nov 2016
* This file is used for all insurance functions
*/
$(function() {
$.validator.setDefaults({
/*OBSERVATION (1): note the options used for "ignore"*/
ignore: ':not(select:hidden, input:visible, textarea:visible)',
/*...other options omitted to focus on the OP...*/
});
$("#getquote").validate({
ignore: '*:not([name])',
// debug: true,
highlight: function (error, element) {
var name = $(element).attr("name");
$("input[name=" + name + "]").removeClass('error');
},
ignore: [],
rules :{
traveldestination : {required : true },
trip_start_date : {
required : true,
// date : { format : "dd-mm-yy" }
},
trip_end_date : {
required : true,
// date : { format : "dd-mm-yy" }
},
// age_band_0_40 : {required : true, number : true },
// age_band_41_60 : {required : true, number : true },
// age_band_61_70 : {required : true, number : true },
suminsured : {required : true },
travellers : {required : true, min : 1 },
noofdays : {required : true, max : 180, min : 1 },
} ,
messages : {
traveldestination : "Please select destination",
trip_start_date : { required : "Please fill trip start date" },
trip_end_date : { required : "Please fill trip end date" },
// age_band_0_40 : {"required" : "Please fill travellers whose age 0-40", "number" : "Please enter number only" },
// age_band_41_60 : {"required" : "Please fill travellers whose age 41-60", "number" : "Please enter number only" } ,
// age_band_61_70 : {"required" : "Please fill travellers whose age 61-70", "number" : "Please enter number only" } ,
suminsured : "Please select sum insured amount",
travellers : "Please fill travellers",
noofdays : {required : "Please fill Trip Duration", max : "Trip Duration Can't be more than 180 Days" , min : "Trip Duration Can't be less than 1 Day"},
}
});
$("#traveldestination").change(function(){
var destination = this.value;
var combobox = $('#suminsured');
combobox.find('option').remove();
if(destination == 'Asia_Excluding_Japan') {
combobox.append($("<option/>").attr("value", "25000").text("$ 25,000"));
}
else {
combobox.append($("<option/>").attr("value", "100000").text("$ 1,00,000"));
}
});
var selector = function (dateStr) {
var d1 = $('#trip_start_date').val();
var d2 = $('#trip_end_date').val();
var days = 0;
if (d1 && d2 && d1!='__/__/____' && d2 != '__/__/____' ) {
var mdy = d1.split('/');
if(mdy[0] > 0){
var monthSelection=mdy[0]-1;
}else{
var monthSelection=mdy[0];
}
var d1=new Date(mdy[2],parseInt(monthSelection),mdy[1]);
var mdy2 = d2.split('/');
if(mdy2[0] > 0){
var monthSelection2=mdy2[0]-1;
}else{
var monthSelection2=mdy2[0];
}
var d2=new Date( mdy2[2],parseInt(monthSelection2),mdy2[1]);
var days=Math.floor(( Date.parse(d2) - Date.parse(d1) ) / 86400000);
if(days > 0){
var days=days;
}else{
var days=0;
}
$('#noofdays').val(days+1);
}
}
// $('#trip_start_date').datetimepicker({
// timepicker: false,
// datepicker:true,
// mask:true,
// formatDate:'m/d/Y',
// format:'m/d/Y',
// minDate:0,//yesterday is minimum date(for today use 0 or -1970/01/01)
// maxDate:($("#trip_end_date").val()!='' && $('#trip_start_date').val()!='__/__/____')?$("#trip_end_date").val():false,
// defaultViewDate : {year:2000, month:0, day:1},
// onChangeDateTime:selector,
// onShow:function(ct){
// this.setOptions({
// maxDate:($("#trip_end_date").val()!='' && $('#trip_end_date').val()!='__/__/____')?$("#trip_end_date").val():false,
// });
// },
// });
// $('#trip_end_date').datetimepicker({
// timepicker: false,
// datepicker:true,
// mask:true,
// minDate:($('#trip_start_date').val()!='' && $('#trip_start_date').val()!='__/__/____')?$('#trip_start_date').val():false,
// formatDate:'m/d/Y',
// format:'m/d/Y',
// onChangeDateTime:selector,
// onShow:function(ct){
// this.setOptions({
// minDate:($('#trip_start_date').val()!='' && $('#trip_start_date').val()!='__/__/____')?$('#trip_start_date').val():false,
// });
// }
// });
$(".input-group-addon").click(function(){
$(this).parent().children(".datePickerOnly").focus();
});
$('#trip_start_date').datepicker({
defaultDate: "0",
changeMonth: true,
changeYear: true,
numberOfMonths: 1,
minDate: curr_date,
dateFormat: "dd-mm-yy",
maxDate: 89,
onSelect: function(selectedDate) {
var fromvalue = $("#trip_start_date").val();
var tovalue = $("#trip_end_date").val();
if (fromvalue != '') {
$.ajax({
type: "POST",
url: baseUrl + "/insurance/index/check-dates",
async: true,
data: "fromvalue=" + fromvalue + "&tovalue=" + tovalue,
success: function(msg) {
var t = msg.split(":");
$("#noofdays").val(t[0]);
$("#trip_end_date").val(t[1]);
}
});
}
var currDate = curr_date;
var currDateFormatted = changeFormat(currDate,'d-m-y');
var dateFormatted = changeFormat(fromvalue,'d-m-y');
var maxDate = getdate(currDateFormatted, 730);
var toDate = getdate(dateFormatted, 179);
var toNextDate = getdate(dateFormatted, 1);
var ftoNextDate = changeFormat(toNextDate,'m/d/y');
$('#trip_end_date').datepicker('option', { minDate: ftoNextDate, maxDate: new Date(toDate) });
}
});
$('#trip_end_date').datepicker({
defaultDate: "0",
changeMonth: true,
changeYear: true,
numberOfMonths: 1,
//minDate: $("#checkCurrentData").val(),
dateFormat: "dd-mm-yy",
minDate: curr_date,
// maxDate: 90,
onSelect: function(selectedDate) {
var tripType = $("#tripType").val();
var fromvalue = $("#trip_start_date").val();
var tovalue = $("#trip_end_date").val();
if (fromvalue != '') {
$.ajax({
type: "POST",
url: baseUrl + "/insurance/index/check-dates",
async: true,
data: "fromvalue=" + fromvalue + "&tripType=" + tripType + "&tovalue=" + tovalue,
success: function(msg) {
var t = msg.split(":");
$("#noofdays").val(t[0]);
$("#trip_end_date").val(t[1]);
}
});
}
}
});
$('#noofdays').change(function(){
var fromvalue = $("#trip_start_date").val();
var noofdays = $("#noofdays").val();
if (fromvalue != '') {
$.ajax({
type: "POST",
url: baseUrl + "/insurance/index/check-dates-new",
async: true,
data: "fromvalue=" + fromvalue + "&noofdays=" + noofdays ,
success: function(msg) {
var t = msg.split(":");
$("#noofdays").val(t[0]);
$("#trip_end_date").val(t[1]);
}
});
}
});
$("#select_si_optional").change(function(){
showLoader("span_change_si");
var si = this.value;
var combobox = $('#suminsured');
combobox.find('option').remove();
combobox.append($("<option/>").attr("value", si).text("$ "+si));
$('#view_quote').trigger('click');
});
}); // jQuery ends here
function changeFormat(date,format) {
if(format == 'd-m-y') {
var arrDates = date.split("-");
return arrDates[1]+'/'+arrDates[0]+'/'+arrDates[2];
}
if(format == 'm/d/y') {
var arrDates = date.split("/");
return arrDates[1]+'-'+arrDates[0]+'-'+arrDates[2];
}
return date;
}
function getdate(fromDate, noOfDays) {
var tt = fromDate;
var date = new Date(tt);
var newdate = new Date(date);
newdate.setDate(newdate.getDate() + noOfDays);
var dd = newdate.getDate();
var mm = newdate.getMonth() + 1;
var y = newdate.getFullYear();
var someFormattedDate = mm + '/' + dd + '/' + y;
return someFormattedDate;
}
function get_total()
{
var value1 = ($("#age_band_0_40").val()) ? $("#age_band_0_40").val() : 0;
var value2 = ($("#age_band_41_60").val()) ? $("#age_band_41_60").val() : 0;
var value3 = ($("#age_band_61_70").val()) ? $("#age_band_61_70").val() : 0;
var totlmember = parseInt(value1)+parseInt(value2)+parseInt(value3);
if(totlmember > 0) {
$("#total_members").html(totlmember);
$("#travellers").val(totlmember);
}
else {
$("#total_members").html("0");
$("#travellers").val(totlmember);
}
}
function change_traveller(en)
{
var total = $(en).val();
$(".ageband_div").hide();
for(var i=1; i<=total; i++){
$("#ageband_div"+i).show();
}
}
function submitme()
{
$("#getquote").submit();
}
function changeTripEndDate(days) {
if(days < 0){
days=0;
$("#noofdays").val(0);
}
var newFormatedDate='';
var todate = $("#trip_start_date").val();
if($("#trip_start_date").val()!='' && $('#trip_start_date').val()!='__/__/____'){
var mdy = todate.split('/');
if(mdy[0] > 0){
var monthSelection=mdy[0]-1;
}else{
var monthSelection=mdy[0];
}
//alert(mdy[2]+','+monthSelection+','+mdy[1]+','+monthSelection);
var todate=new Date(mdy[2],parseInt(monthSelection),mdy[1]);
//alert(todate);
var d =todate;
d.setDate(d.getDate() + parseInt(days));
var date = d.getDate();
var month = d.getMonth()+1;
var year = d.getFullYear();
if (month < 10)
month = "0" + month;
if (date < 10)
date = "0" + date;
var newFormatedDate = month + '/' + date + '/' + year;
$("#trip_end_date").val(newFormatedDate);
}
}
function showPopupDialog(en)
{
$("#myModa1insuranceDetail").modal("show");
$("#div_popupdata_insurance").html('<div align="center"><img src="'+ baseUrl +'/public/assets/images/loading.gif" alt="Loading..." /></div>'); // show loader
var key = $(en).attr('tabindex');
var premium = $("#prm_"+key).val();
var planname = $("#planname").val();
$.ajax({
type: "POST",
url: baseUrl + "/insurance/index/popupdata",
async: true,
data: "key="+key+ "&premium="+ premium+ "&planname="+ planname,
success: function(data) {
$("#div_popupdata_insurance").html(data);
}
});
}
function validate_insurer_form()
{
var insurer = $("input[name='insurer']:checked").val();
if(!insurer) {
alert("Please choose any Insurer Company.");
return false;
}
}
function validate_date(inputText)
{
// Extract the string into month, date and year
var pdate = inputText.split('/');
var dd = parseInt(pdate[0]);
var mm = parseInt(pdate[1]);
var yy = parseInt(pdate[2]);
// Create list of days of a month [assume there is no leap year by default]
var ListofDays = [31,28,31,30,31,30,31,31,30,31,30,31];
if (mm==1 || mm>2)
{
if (dd>ListofDays[mm-1])
{
return false;
}
}
if (mm==2)
{
var lyear = false;
if ( (!(yy % 4) && yy % 100) || !(yy % 400))
{
lyear = true;
}
if ((lyear==false) && (dd>=29))
{
return false;
}
if ((lyear==true) && (dd>29))
{
return false;
}
}
return true;
} // validate_date
function showLoader(id)
{
$("#"+id).html('<img src="'+ baseUrl +'/public/assets/images/loading.gif" alt="Loading..." width="20" />');
}
function hideLoader(id)
{
$("#"+id).html('');
}