input->cookie; $cookie_step = $cookie->get("vbo_reportwidget_{$report_name}_step", 'weekend', 'string'); $vbo_app = VikBooking::getVboApplication(); $vbo_app->loadDatePicker(); // lang vars for JS JText::script('VBOSEVLOWOCC'); JText::script('VBOSEVMEDOCC'); JText::script('VBOSEVHIGHOCC'); JText::script('VBOSEVLOWINDAYS'); JText::script('VBOSEVMEDINDAYS'); JText::script('VBOSEVHIGHINDAYS'); // get occupancy_ranking report instance $report = VikBooking::getReportInstance($report_name)->loadChartsAssets(); // website date format $df = $report->getDateFormat(); // get the next festivities $fests = VikBooking::getFestivitiesInstance(); if ($fests->shouldCheckFestivities()) { $fests->storeNextFestivities(); } $next_fests = $fests->loadFestDates(); // calculate the next from/to date $is_fest = null; // find next interval by default when page loads, unless there's a festivity if ($cookie_step == 'month') { // this month $nowinfo = getdate(); $ts_from = mktime(0, 0, 0, $nowinfo['mon'], 1, $nowinfo['year']); $ts_to = mktime(23, 59, 59, $nowinfo['mon'], date('t', $nowinfo[0]), $nowinfo['year']); $period_name = JText::translate('VBPVIEWRESTRICTIONSTWO'); } elseif ($cookie_step == 'week') { // this week $ts_from = time(); $ts_to = strtotime("+1 week", $ts_from); $period_name = JText::translate('VBOWEEK'); } else { // next weekend by default $ts_from = strtotime("next friday"); $ts_to = strtotime("next saturday"); if ($ts_to < $ts_from) { $ts_to = strtotime("+1 week", $ts_to); } $period_name = JText::translate('VBONEXTWEEKND'); } if (count($next_fests)) { // we start from the next fest only if within 15 days $festlim = strtotime("+15 days", time()); foreach ($next_fests as $next_fest) { if ($festlim >= $next_fest['festinfo'][0]->next_ts) { $is_fest = $next_fest['festinfo'][0]->next_ts; $ts_from = $next_fest['festinfo'][0]->from_ts; $ts_to = $next_fest['festinfo'][0]->to_ts; $period_name = $next_fest['festinfo'][0]->trans_name; } // we check only the very next festivity break; } } // obtain data from the report $rparams = array( 'fromdate' => date($df, $ts_from), 'todate' => date($df, $ts_to), 'period' => 'full', 'krsort' => 'occupancy', 'krorder' => 'DESC', 'idroom' => $room_ids, ); $report->injectParams($rparams); $report_cols = $report->getColumnsValues(); $report_values = $report->getReportValues(1); $report_chart = null; $report_chart_metas = array(); $chart_meta_data = array( 'keys' => array( 'occupancy', 'tot_bookings', 'nights_booked', ), ); $error = ''; $in_days = $report->countDaysTo($ts_from); $in_days_to = $report->countDaysTo($ts_to); $in_days_avg = $report->countAverageDays($in_days, $in_days_to); if (!count($report_values)) { $error = strlen($report->getError()) ? $report->getError() : JText::translate('VBNOTRACKINGS'); } else { // get doughnut chart for the occupancy $report_chart = $report->getChart(array( 'type' => 'doughnut', 'depth' => 1, 'keys' => array('occupancy'), )); $all_chart_metas = $report->getChartMetaData(null, $chart_meta_data); if (count($all_chart_metas)) { // merge all positions into one array foreach ($all_chart_metas as $pos_metas) { $report_chart_metas = array_merge($report_chart_metas, $pos_metas); } } } $promo_factors = VikBooking::getPromotionFactors(); $promo_factors = $promo_factors === false ? array() : $promo_factors; $current_occupancy = count($report_values) ? $report_values['occupancy']['value'] : 0; $current_in_days = $in_days > 0 ? $in_days : $in_days_avg; ?>