get_sidebar('under-header');
global $post, $current_user, $accommodation_obj, $entity_obj, $score_out_of_10, $default_accommodation_tabs, $byt_accommodations_post_type, $byt_theme_of_custom;
$enable_reviews = $byt_theme_globals->enable_reviews();
$enable_accommodations = $byt_theme_globals->enable_accommodations();
$accommodation_extra_fields = $byt_theme_globals->get_accommodation_extra_fields();
$location_extra_fields = $byt_theme_globals->get_location_extra_fields();
$tab_array = $byt_theme_globals->get_accommodation_tabs();
$price_decimal_places = $byt_theme_globals->get_price_decimal_places();
$default_currency_symbol = $byt_theme_globals->get_default_currency_symbol();
$show_currency_symbol_after = $byt_theme_globals->show_currency_symbol_after();
if (have_posts()) {
    the_post();
    $accommodation_obj = new byt_accommodation($post);
    $entity_obj = $accommodation_obj;
    $accommodation_id = $accommodation_obj->get_id();
    $base_accommodation_id = $accommodation_obj->get_base_id();
    $accommodation_location = $accommodation_obj->get_location();
    $is_self_catered = $accommodation_obj->get_is_self_catered();
    $accommodation_latitude = $accommodation_obj->get_custom_field('latitude');
    $accommodation_longitude = $accommodation_obj->get_custom_field('longitude');
    $accommodation_count_children_stay_free = $accommodation_obj->get_count_children_stay_free();
    $accommodation_is_price_per_person = $accommodation_obj->get_is_price_per_person();
    $accommodation_is_reservation_only = $accommodation_obj->get_is_reservation_only();
    $total_price_label = __('Total price', 'bookyourtravel');
    if ($accommodation_is_price_per_person && $accommodation_count_children_stay_free > 0) {
        $total_price_label = sprintf(__('Total price (first %d children stay free)', 'bookyourtravel'), $accommodation_count_children_stay_free);
    }
    $max_count = $max_child_count = 0;
    if ($is_self_catered) {
        $max_count = $accommodation_obj->get_custom_field('max_count');
        $max_count = isset($max_count) ? intval($max_count) : 5;
 function render_entry_form()
 {
     global $byt_accommodations_post_type, $byt_room_types_post_type;
     $accommodation_id = 0;
     $is_self_catered = 0;
     $vacancy_object = null;
     $accommodation_obj = null;
     $is_price_per_person = 0;
     $edit = isset($_GET['edit']) ? absint($_GET['edit']) : "";
     if (!empty($edit)) {
         $vacancy_object = $byt_accommodations_post_type->get_accommodation_vacancy($edit);
     }
     if (isset($_POST['accommodations_select'])) {
         $accommodation_id = wp_kses($_POST['accommodations_select'], '');
     } else {
         if ($vacancy_object) {
             $accommodation_id = $vacancy_object->accommodation_id;
         }
     }
     if ($accommodation_id) {
         $accommodation_obj = new byt_accommodation(intval($accommodation_id));
         $accommodation_id = $accommodation_obj->get_base_id();
         $is_self_catered = $accommodation_obj->get_is_self_catered();
         $is_price_per_person = $accommodation_obj->get_is_price_per_person();
     }
     $room_type_id = 0;
     if (isset($_POST['room_types_select'])) {
         $room_type_id = wp_kses($_POST['room_types_select'], '');
     } else {
         if ($vacancy_object) {
             $room_type_id = $vacancy_object->room_type_id;
         }
     }
     if (!empty($room_type_id)) {
         $room_type_id = BYT_Theme_Utils::get_default_language_post_id($room_type_id, 'room_type');
     }
     $accommodations_select = '<select id="accommodations_select" name="accommodations_select">';
     $accommodations_select .= '<option value="">' . __('Select accommodation', 'bookyourtravel') . '</option>';
     $author_id = null;
     if (!is_super_admin()) {
         $author_id = get_current_user_id();
     }
     $accommodation_results = $byt_accommodations_post_type->list_accommodations(0, -1, 'title', 'ASC', 0, array(), array(), array(), false, null, $author_id);
     if (count($accommodation_results) > 0 && $accommodation_results['total'] > 0) {
         foreach ($accommodation_results['results'] as $accommodation_result) {
             global $post;
             $post = $accommodation_result;
             setup_postdata($post);
             $accommodations_select .= '<option value="' . $post->ID . '" ' . ($post->ID == $accommodation_id ? 'selected' : '') . '>' . $post->post_title . '</option>';
         }
     }
     $accommodations_select .= '</select>';
     $room_types_select = '';
     if (!$is_self_catered) {
         $room_types_select = '<select class="normal" id="room_types_select" name="room_types_select">';
         $room_types_select .= '<option value="">' . __('Select room type', 'bookyourtravel') . '</option>';
         if ($accommodation_obj) {
             $room_type_ids = $accommodation_obj->get_room_types();
             if ($room_type_ids && count($room_type_ids) > 0) {
                 for ($i = 0; $i < count($room_type_ids); $i++) {
                     $temp_id = $room_type_ids[$i];
                     $room_type_obj = new byt_room_type(intval($temp_id));
                     $room_types_select .= '<option value="' . $temp_id . '" ' . ($temp_id == $room_type_id ? 'selected' : '') . '>' . $room_type_obj->get_title() . '</option>';
                 }
             }
         }
         $room_types_select .= '</select>';
     }
     wp_reset_postdata();
     $date_from = null;
     if (isset($_POST['date_from'])) {
         $date_from = wp_kses($_POST['date_from'], '');
     } else {
         if ($vacancy_object) {
             $date_from = $vacancy_object->start_date;
         }
     }
     if (isset($date_from)) {
         $date_from = date($this->date_format, strtotime($date_from));
     }
     $date_to = null;
     if (isset($_POST['date_to'])) {
         $date_to = wp_kses($_POST['date_to'], '');
     } else {
         if ($vacancy_object) {
             $date_to = $vacancy_object->end_date;
         }
     }
     if (isset($date_to)) {
         $date_to = date($this->date_format, strtotime($date_to));
     }
     $room_count = 1;
     if (isset($_POST['room_count'])) {
         $room_count = intval(wp_kses($_POST['room_count'], ''));
     } else {
         if ($vacancy_object && isset($vacancy_object->room_count)) {
             $room_count = $vacancy_object->room_count;
         }
     }
     if ($room_count == 0) {
         $room_count = 1;
     }
     $price_per_day = 0;
     if (isset($_POST['price_per_day'])) {
         $price_per_day = floatval(wp_kses($_POST['price_per_day'], ''));
     } else {
         if ($vacancy_object) {
             $price_per_day = $vacancy_object->price_per_day;
         }
     }
     $price_per_day_child = 0;
     if (isset($_POST['price_per_day_child'])) {
         $price_per_day_child = floatval(wp_kses($_POST['price_per_day_child'], ''));
     } else {
         if ($vacancy_object) {
             $price_per_day_child = $vacancy_object->price_per_day_child;
         }
     }
     $season_name = '';
     if (isset($_POST['season_name'])) {
         $season_name = stripslashes(wp_kses($_POST['season_name'], ''));
     } else {
         if ($vacancy_object) {
             $season_name = stripslashes($vacancy_object->season_name);
         }
     }
     if ($vacancy_object) {
         echo '<h3>' . __('Update Vacancy', 'bookyourtravel') . '</h3>';
     } else {
         echo '<h3>' . __('Add Vacancy', 'bookyourtravel') . '</h3>';
     }
     echo '<form id="accommodation_vacancy_form" method="post" action="' . esc_url($_SERVER['REQUEST_URI']) . '" style="clear: both;">';
     echo wp_nonce_field('accommodation_vacancy_nonce');
     echo '<table cellpadding="3" class="form-table"><tbody>';
     echo '<tr>';
     echo '	<th scope="row" valign="top">' . __('Season name', 'bookyourtravel') . '</th>';
     echo '	<td><input type="text" name="season_name" id="season_name" value="' . $season_name . '" /></td>';
     echo '</tr>';
     echo '<tr>';
     echo '	<th scope="row" valign="top">' . __('Select accommodation', 'bookyourtravel') . '</th>';
     echo '	<td>' . $accommodations_select . '</td>';
     echo '</tr>';
     if (!$is_self_catered) {
         echo '<tr id="room_types_row">';
         echo '	<th scope="row" valign="top">' . __('Select room type', 'bookyourtravel') . '</th>';
         echo '	<td>' . $room_types_select . '</td>';
         echo '</tr>';
         echo '<tr id="room_count_row">';
         echo '	<th scope="row" valign="top">' . __('Number of rooms', 'bookyourtravel') . '</th>';
         echo '	<td><input type="text" name="room_count" id="room_count" value="' . $room_count . '" /></td>';
         echo '</tr>';
     }
     echo '<tr>';
     echo '	<th scope="row" valign="top">' . __('Date from', 'bookyourtravel') . '</th>';
     echo '	<td>';
     echo '		<script>';
     echo '			window.datepickerDateFromValue = "' . $date_from . '";';
     echo '  	</script>';
     echo '  	<input class="datepicker" type="text" name="datepicker_date_from" id="datepicker_date_from" />';
     echo '		<input type="hidden" name="date_from" id="date_from" />';
     echo '	</td>';
     echo '</tr>';
     echo '<tr>';
     echo '	<th scope="row" valign="top">' . __('Date to', 'bookyourtravel') . '</th>';
     echo '	<td>';
     echo '		<script>';
     echo '			window.datepickerDateToValue = "' . $date_to . '";';
     echo '  	</script>';
     echo '  	<input class="datepicker" type="text" name="datepicker_date_to" id="datepicker_date_to" />';
     echo '		<input type="hidden" name="date_to" id="date_to" />';
     echo '	</td>';
     echo '</tr>';
     echo '<tr>';
     echo '	<th scope="row" valign="top">' . __('Price per day', 'bookyourtravel') . ' <span class="per_person" ' . ($is_price_per_person ? '' : 'style="display:none"') . '>' . __('(adult)', 'bookyourtravel') . '</span></th>';
     echo '	<td><input type="text" name="price_per_day" id="price_per_day" value="' . $price_per_day . '" /></td>';
     echo '</tr>';
     echo '<tr class="per_person" ' . ($is_price_per_person ? '' : 'style="display:none"') . '>';
     echo '	<th scope="row" valign="top">' . __('Price per day (child)', 'bookyourtravel') . '</th>';
     echo '	<td><input type="text" name="price_per_day_child" id="price_per_day_child" value="' . $price_per_day_child . '" /></td>';
     echo '</tr>';
     echo '</table>';
     echo '<p>';
     echo '<a href="edit.php?post_type=accommodation&page=theme_accommodation_vacancy_admin.php" class="button-secondary">' . __('Cancel', 'bookyourtravel') . '</a>&nbsp;';
     if ($vacancy_object) {
         echo '<input id="vacancy_id" name="vacancy_id" value="' . $edit . '" type="hidden" />';
         echo '<input class="button-primary" type="submit" name="update" value="' . __('Update Vacancy', 'bookyourtravel') . '"/>';
     } else {
         echo '<input class="button-primary" type="submit" name="insert" value="' . __('Add Vacancy', 'bookyourtravel') . '"/>';
     }
     echo '</p>';
     echo '</form>';
 }