/* create an array of days which need to be disabled */ var disabledDays =["2-16-2024","2-17-2024","2-18-2024","2-19-2024","2-20-2024","2-21-2024","2-22-2024","2-23-2024","2-24-2024","2-25-2024","2-26-2024","2-27-2024","2-28-2024","2-29-2024","3-1-2024","3-2-2024","3-3-2024","3-4-2024","3-5-2024","3-6-2024","3-7-2024","3-8-2024","3-9-2024","3-10-2024","3-11-2024","3-12-2024","3-13-2024","3-14-2024","3-15-2024","3-16-2024","3-17-2024","3-18-2024","3-19-2024","3-20-2024","3-21-2024","3-22-2024","3-23-2024","3-24-2024","3-25-2024","3-26-2024","3-27-2024","3-28-2024","3-29-2024","3-30-2024","3-31-2024","4-1-2024","4-2-2024","4-3-2024","4-4-2024","4-5-2024","4-6-2024","4-7-2024","4-8-2024","4-9-2024","4-10-2024","4-11-2024","4-12-2024","4-13-2024","4-14-2024","4-15-2024","4-16-2024","4-17-2024","4-18-2024","4-19-2024","4-20-2024","4-21-2024","4-22-2024","4-23-2024","4-24-2024","4-25-2024","4-26-2024","4-27-2024","4-28-2024","4-29-2024","4-30-2024","5-1-2024","5-2-2024","5-3-2024","5-4-2024","5-5-2024","5-6-2024","5-7-2024","5-8-2024","5-9-2024","5-10-2024","5-11-2024","5-12-2024","5-13-2024","12-27-2024","12-28-2024","12-29-2024","12-30-2024","12-31-2024","1-1-2025",]; function ifDisabled(date) { var m = date.getMonth(); var d = date.getDate(); var y = date.getFullYear(); for (i = 0; i < disabledDays.length; i++) { if($.inArray((m+1) + '-' + d + '-' + y,disabledDays) != -1 || new Date() > date) { return [false]; } } return [true]; } function checkDisabled(date) { return ifDisabled(date); } jQuery(document).ready(function(){ var today = new Date(); var d = today.getDate(); var m = today.getMonth(); var y = today.getFullYear(); jQuery('#depart').datepicker({ /* minDate: 2023-05-15, maxDate: 2025-05-01, minDate: new Date(2023, 05-1, 15), maxDate: new Date(2025, 05-1, 01),*/ minDate: 0, dateFormat: 'dd/mm/yy', constrainInput: true, numberOfMonths: 1, changeMonth: true, changeYear: true, beforeShowDay: checkDisabled }); //////////////// jQuery('#departv').datepicker({ /* minDate: 2023-05-15, maxDate: 2025-05-01, */ minDate: new Date(2023, 05-1, 15), maxDate: new Date(2025, 05-1, 01), dateFormat: 'dd/mm/yy', constrainInput: true, numberOfMonths: 1, changeMonth: true, changeYear: true, beforeShowDay: checkDisabled }); jQuery('#retourv').datepicker({ /* minDate: 2023-05-15, maxDate: 2025-05-01, */ minDate: new Date(2023, 05-1, 15), maxDate: new Date(2025, 05-1, 01), dateFormat: 'dd/mm/yy', constrainInput: true, numberOfMonths: 1, changeMonth: true, changeYear: true, beforeShowDay: checkDisabled }); //////////////// //////////////// jQuery('#retour').datepicker({ /* minDate: 2023-05-15, maxDate: 2025-05-01, */ minDate: new Date(2023, 05-1, 15), maxDate: new Date(2025, 05-1, 01), dateFormat: 'dd/mm/yy', constrainInput: true, numberOfMonths: 1, changeMonth: true, changeYear: true, beforeShowDay: checkDisabled }); }); //////////////// function controledate(input,vol) { if(vol=='h') var formv=document.hotel; if(vol=='v') var formv=document.vols; //alert(vol+'/'+input); var datb = new Date(); var datb=formv.depart.value; var datf = new Date(); var datf=formv.retour.value; //var dat=formv.depart.value; function addDaysToDate(old_date, delta_days) { // Date plus quelques jours var split_date = old_date.split('/'); // Les mois vont de 0 a 11 donc on enleve 1, cast avec *1 var new_date = new Date(split_date[2], split_date[1]*1 - 1, split_date[0]*1 + delta_days); var new_day = new_date.getDate(); new_day = ((new_day < 10) ? '0' : '') + new_day; // ajoute un z�ro devant pour la forme var new_month = new_date.getMonth() + 1; new_month = ((new_month < 10) ? '0' : '') + new_month; // ajoute un z�ro devant pour la forme var new_year = new_date.getYear(); new_year = ((new_year < 200) ? 1900 : 0) + new_year; // necessaire car IE et FF retourne pas la meme chose var new_date_text = new_day + '/' + new_month + '/' + new_year; return new_date_text; } ///////compare 2date///////// function ConvNum(tabDeDate) { for (i=0; i < tabDeDate.length; i++) tabDeDate[i] = (tabDeDate[i].charAt(0)=='0')?tabDeDate[i].charAt(1):tabDeDate[i]; return tabDeDate; } ///// function compare_Dates(valeur_date1, valeur_date2) { var tabDate1 = valeur_date1.split('/'); tabDate1 = ConvNum(tabDate1); var datTest_Date1 = new Date(parseInt(tabDate1[2]), parseInt(tabDate1[1])-1, parseInt(tabDate1[0])); var tabDate2 = valeur_date2.split('/'); tabDate2 = ConvNum(tabDate2); var datTest_Date2 = new Date(parseInt(tabDate2[2]), parseInt(tabDate2[1])-1, parseInt(tabDate2[0])); // return (datTest_Date2-datTest_Date1==0)?"0":(datTest_Date2-datTest_Date1<0)?"-1":"1"; var rest = datTest_Date2-datTest_Date1; return rest } //////////////////////////// var rest = compare_Dates(formv.depart.value, formv.retour.value); /////si la date de debut changer//// var minDate=new Date(2023, 05-1, 15); var maxDate=new Date(2025, 05-1, 01); var yyyy='2025'; var mm='05'; var dd='01'; /////////// var yyyym='2023'; var mmm='05'; var ddm='15'; ///////// maxDate=dd+'/'+mm+'/'+yyyy; minDate=ddm+'/'+mmm+'/'+yyyym; if(vol=='h') var formv=document.hotel; if(vol=='v') var formv=document.vols; if(input=='d') { if((formv.retour.value=='') || (rest<=0)) { date_finale = addDaysToDate(datb, 1); date_dub = addDaysToDate(datb, 0); var restd = compare_Dates(datb, maxDate); if(restd>0) { formv.retour.value=date_finale; } if(restd==0) { formv.retour.value=datb; formv.depart.value=addDaysToDate(datb, -1); } if(restd<0) { formv.depart.value=date_dub; formv.retour.value=datb; } } } /////si la date de fin changer//// if(input=='f') { if((formv.depart.value=='') || (rest<=0)) { date_dubut = addDaysToDate(datf, -1); date_fin = addDaysToDate(datf, 0); var restf = compare_Dates(minDate, datf); if(restf>0) formv.depart.value=date_dubut; if(restf==0) { formv.depart.value=datf; formv.retour.value=date_fin; if(rest==0) formv.retour.value=addDaysToDate(datf, 1) } if(restf<0) { formv.depart.value=datf; formv.retour.value=addDaysToDate(datf, 1); } } } ////////////////////////////// if(formv.depart.value==formv.retour.value){formv.depart.value='';formv.retour.value='';} }