(function($) { function minisiteCalWidget(el, params) { var now = new Date(); var thismonth = now.getMonth(); var thisyear = now.getFullYear(); var thisDay = now.getDate(); var thisiso2 = 'it'; var elId = el.attr('id'); var thisinput = ''; var thiscallback = ''; var thisDayStart = ''; var thisOthMonths = false; var opts = { month: thismonth, year: thisyear, dayStart: thisDayStart, siteIso2: thisiso2, inputId: thisinput, callBack: thiscallback, othMonths: thisOthMonths }; $.extend(opts, params); // Restrizioni giorni ABS var restrPeriods = new Array(); var hasRestrictions = false; var sD = opts.dayStart.substr(6,2); var sM = opts.dayStart.substr(4,2); var sY = opts.dayStart.substr(0,4); var sJD = new Date(sY,sM,sD); var sMkTJD = parseInt((sJD.getTime()/1000),10); var mJD = new Date(opts.year,opts.month,1); var mLJD = new Date(opts.year,opts.month+1,0); var checkJD = (sJD >= mJD) ? sJD : mJD ; if(typeof portal_restrictions != 'undefined'){ if(typeof portal_restrictions[params.cityId] != 'undefined'){ if(typeof portal_restrictions[params.cityId][params.strType] != 'undefined'){ $.each(portal_restrictions[params.cityId][params.strType],function(i){ var startBound = new Date(parseInt(this['fromMkTime'],10)*1000); var endBound = new Date(parseInt(this['toMkTime'],10)*1000); if((checkJD >= startBound || mLJD >= startBound) && checkJD <= endBound) { if(opts.inputId=='checkout' || opts.inputId=='checkoutM') { // Se ci sono delle restrizioni per il checkout aggiunto il MinStay if(sMkTJD >= this['fromMkTime'] && sMkTJD <= this['toMkTime']){ if(!opts.othMonths){ selMinStay = this['minstay']-1; sDateWithMinStay = sJD; sDateWithMinStay.setDate(sDateWithMinStay.getDate()+selMinStay); opts.dayStart = String(sDateWithMinStay.getFullYear())+minsiteCalendarGetData(sDateWithMinStay.getMonth())+minsiteCalendarGetData(sDateWithMinStay.getDate()); } } } restrPeriods.push(this); hasRestrictions = true; //return false; } }); } } } // console.log(hasRestrictions); // Fine Restrizioni ABS if(opts.siteIso2 == 'en') opts.siteIso2 = ''; //console.log($.datepicker.regional[opts.siteIso2]); // Traduzioni gestite da file esterno ABS_calWidgetStrings.js if(typeof window.ABS_calWidgetStrings != 'undefined' && typeof window.ABS_calWidgetStrings[opts.siteIso2] != 'undefined'){ var monthNames = window.ABS_calWidgetStrings[opts.siteIso2]['monthNames']; var dayNames = window.ABS_calWidgetStrings[opts.siteIso2]['dayNamesShort']; } else { var monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; var dayNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; } month = i = parseInt(opts.month); year = parseInt(opts.year); var m = 0; var table = '
' + dayNames[d] + ' | '; } table += ''+(prev_days-firstDay+j+1)+' | '); } else { table += (''+ (prev_days-firstDay+j+1) +' | '); } } else if ((j>=firstDay+getDaysInMonth(month,year))) { // Giorni mese successivo i = i+1; nextYearTd = (month+2 > 12) ? year+1 :year; nextMounthTd = (month+2 > 12) ? month+2-12 : month+2; thisSquareDate = new Date(nextYearTd,minsiteCalendarGetData(nextMounthTd)-1,minsiteCalendarGetData(i)); /******************************************************* Controllo data restrictions */ if(hasRestrictions){ thisSquareDateWeekDay = thisSquareDate.getDay(); thisSquareMkTime = parseInt((thisSquareDate.getTime()/1000),10); $.each(restrPeriods,function(i,v){ if(thisSquareMkTime >= v['fromMkTime'] && thisSquareMkTime <= v['toMkTime']){ if(typeof v['days'][thisSquareDateWeekDay][checkType] != 'undefined' && v['days'][thisSquareDateWeekDay][checkType] == 0){ activeClass = ''; onClickBehavior = ''; disabledClassAppend='-disabled'; } return false; } }); } /******************************************************* */ var nsD = opts.dayStart.substr(6,2); var nsM = opts.dayStart.substr(4,2); var nsY = opts.dayStart.substr(0,4); var nsJD = new Date(nsY,nsM,nsD); if(thisSquareDate > nsJD){ table += (''+ i +' | '); } else { table += (''+ i +' | '); } } else if( (String(year)+String(minsiteCalendarGetData(mounth2))+String(minsiteCalendarGetData(j-firstDay+1))==String(now.getFullYear())+String(minsiteCalendarGetData(getMounth))+String(minsiteCalendarGetData(thisDay))) && ( ( opts.dayStart != '' && (String(year)+String(mounth2)+minsiteCalendarGetData(j-firstDay+1) > parseInt(opts.dayStart)) ) || ( opts.dayStart == '' && (String(year)+String(mounth2)+minsiteCalendarGetData(j-firstDay+1) > String(now.getFullYear())+String(minsiteCalendarGetData(getMounth))+String(minsiteCalendarGetData(thisDay))) ) ) ) { // Giorni mese corrente /******************************************************* Controllo data restrictions */ if(hasRestrictions){ thisSquareDate = new Date(year,month,minsiteCalendarGetData(j-firstDay+1)); thisSquareDateWeekDay = thisSquareDate.getDay(); thisSquareMkTime = parseInt((thisSquareDate.getTime()/1000),10); $.each(restrPeriods,function(i,v){ if(thisSquareMkTime >= v['fromMkTime'] && thisSquareMkTime <= v['toMkTime']){ if(typeof v['days'][thisSquareDateWeekDay][checkType] != 'undefined' && v['days'][thisSquareDateWeekDay][checkType] == 0){ activeClass = ''; onClickBehavior = ''; disabledClassAppend='-disabled'; } return false; } }); } /******************************************************* */ table += (''+(j-firstDay+1)+' | '); } else if( opts.dayStart != '' && (String(year)+String(mounth2)+minsiteCalendarGetData(j-firstDay+1) > parseInt(opts.dayStart)) ) { /******************************************************* Controllo data restrictions */ if(hasRestrictions){ thisSquareDate = new Date(year,month,minsiteCalendarGetData(j-firstDay+1)); thisSquareDateWeekDay = thisSquareDate.getDay(); thisSquareMkTime = parseInt((thisSquareDate.getTime()/1000),10); $.each(restrPeriods,function(i,v){ if(thisSquareMkTime >= v['fromMkTime'] && thisSquareMkTime <= v['toMkTime']){ if(typeof v['days'][thisSquareDateWeekDay][checkType] != 'undefined' && v['days'][thisSquareDateWeekDay][checkType] == 0){ activeClass = ''; onClickBehavior = ''; disabledClassAppend='-disabled'; } return false; } }); } /******************************************************* */ table += (''+(j-firstDay+1)+' | '); } else if( // Giorni precedenti alla data di inizio opts.dayStart != '' && (String(year)+String(mounth2)+minsiteCalendarGetData(j-firstDay+1) <= parseInt(opts.dayStart)) ) { table += (''+(j-firstDay+1)+' | '); } else { /******************************************************* Controllo data restrictions */ if(hasRestrictions){ thisSquareDate = new Date(year,month,minsiteCalendarGetData(j-firstDay+1)); thisSquareDateWeekDay = thisSquareDate.getDay(); thisSquareMkTime = parseInt((thisSquareDate.getTime()/1000),10); $.each(restrPeriods,function(i,v){ if(thisSquareMkTime >= v['fromMkTime'] && thisSquareMkTime <= v['toMkTime']){ if(typeof v['days'][thisSquareDateWeekDay][checkType] != 'undefined' && v['days'][thisSquareDateWeekDay][checkType] == 0){ activeClass = ''; onClickBehavior = ''; disabledClassAppend='-disabled'; } return false; } }); } /******************************************************* */ table += (''+(j-firstDay+1)+' | '); } if (j%7==6) table += (''); } if(elId=='cal1'){ table += ('
---|