';
$bookings = array();
$normFromValue = strtotime("-1 day", $startDate);
$normToValue = date("Y-m-d", strtotime("+".$maxday."days", $startDate));
$unconfirmedBookings = 'state = \'confirmed\'';
if(get_option ('abc_unconfirmed') == 1){
$unconfirmedBookings = '(state = \'confirmed\' OR state = \'open\')';
}
$bookingQuery = $wpdb->get_results('SELECT * FROM '.$wpdb->prefix.'abc_bookings
WHERE '.$unconfirmedBookings.'
AND ( (start <= \''.$normFromValue.'\' AND end >=\''.$normToValue.'\')
OR (start >= \''.$normFromValue.'\' AND end <= \''.$normToValue.'\')
OR (start >= \''.$normFromValue.'\' AND start <= \''.$normToValue.'\')
OR (start <= \''.$normFromValue.'\' AND end >= \''.$normToValue.'\')
OR (end <= \''.$normFromValue.'\' AND end >= \''.$normToValue.'\')
OR (end >= \''.$normFromValue.'\' AND end <= \''.$normToValue.'\')
)', ARRAY_A);
foreach($bookingQuery as $bookingRow){
$bookings[$bookingRow["calendar_id"]][] = $bookingRow; // Getting all confirmed bookings for the current month
}
$maxAvailability = array();
$maxAvailabilityQuery = $wpdb->get_results('SELECT calendar_id, count(calendar_id) as availability FROM '.$wpdb->prefix.'abc_rooms GROUP BY calendar_id ORDER BY calendar_id', ARRAY_A);
foreach($maxAvailabilityQuery as $maxAvailabilityRow){
$maxAvailability[$maxAvailabilityRow["calendar_id"]] = $maxAvailabilityRow["availability"]; // Getting max availabilities per calendar
}
$er = $wpdb->get_results('SELECT * FROM '.$wpdb->prefix.'abc_calendars ORDER BY name', ARRAY_A);
foreach($er as $row) { // Creating rows for table
$partlyBooked = intval($row["partlyBooked"]);
$output .= '
';
if ($row["infoPage"] == 0){
$output .= esc_html($row["name"]).'