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>';
 }
$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;
        $max_child_count = $accommodation_obj->get_custom_field('max_child_count');
        $max_child_count = isset($max_child_count) ? intval($max_child_count) : 5;
 function render_entry_form($booking_id)
 {
     global $byt_accommodations_post_type, $byt_room_types_post_type;
     $booking_object = null;
     $edit = isset($_GET['edit']) ? absint($_GET['edit']) : 0;
     if ($booking_id > 0) {
         $edit = $booking_id;
     }
     if (!empty($edit)) {
         $booking_object = $byt_accommodations_post_type->get_accommodation_booking($edit);
     }
     $date_from = null;
     if (isset($_POST['date_from'])) {
         $date_from = wp_kses($_POST['date_from'], '');
     } else {
         if ($booking_object != null) {
             $date_from = $booking_object->date_from;
         }
     }
     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 ($booking_object != null) {
             $date_to = $booking_object->date_to;
         }
     }
     if (isset($date_to)) {
         $date_to = date($this->date_format, strtotime($date_to));
     }
     $first_name = '';
     if (isset($_POST['first_name'])) {
         $first_name = wp_kses($_POST['first_name'], '');
     } else {
         if ($booking_object != null) {
             $first_name = $booking_object->first_name;
         }
     }
     $last_name = '';
     if (isset($_POST['last_name'])) {
         $last_name = wp_kses($_POST['last_name'], '');
     } else {
         if ($booking_object != null) {
             $last_name = $booking_object->last_name;
         }
     }
     $email = '';
     if (isset($_POST['email'])) {
         $email = wp_kses($_POST['email'], '');
     } else {
         if ($booking_object != null) {
             $email = $booking_object->email;
         }
     }
     $phone = '';
     if (isset($_POST['phone'])) {
         $phone = wp_kses($_POST['phone'], '');
     } else {
         if ($booking_object != null) {
             $phone = $booking_object->phone;
         }
     }
     $address = '';
     if (isset($_POST['address'])) {
         $address = wp_kses($_POST['address'], '');
     } else {
         if ($booking_object != null) {
             $address = $booking_object->address;
         }
     }
     $town = '';
     if (isset($_POST['town'])) {
         $town = wp_kses($_POST['town'], '');
     } else {
         if ($booking_object != null) {
             $town = $booking_object->town;
         }
     }
     $zip = '';
     if (isset($_POST['zip'])) {
         $zip = wp_kses($_POST['zip'], '');
     } else {
         if ($booking_object != null) {
             $zip = $booking_object->zip;
         }
     }
     $country = '';
     if (isset($_POST['country'])) {
         $country = wp_kses($_POST['country'], '');
     } else {
         if ($booking_object != null) {
             $country = $booking_object->country;
         }
     }
     $special_requirements = '';
     if (isset($_POST['special_requirements'])) {
         $special_requirements = wp_kses($_POST['special_requirements'], '');
     } else {
         if ($booking_object != null) {
             $special_requirements = $booking_object->special_requirements;
         }
     }
     $adults = 0;
     if (isset($_POST['adults'])) {
         $adults = intval(wp_kses($_POST['adults'], ''));
     } else {
         if ($booking_object != null) {
             $adults = $booking_object->adults;
         }
     }
     $children = 0;
     if (isset($_POST['children'])) {
         $children = intval(wp_kses($_POST['children'], ''));
     } else {
         if ($booking_object != null) {
             $children = $booking_object->children;
         }
     }
     $total_price = 0;
     if (isset($_POST['total_price'])) {
         $total_price = floatval(wp_kses($_POST['total_price'], ''));
     } else {
         if ($booking_object != null) {
             $total_price = $booking_object->total_price;
         }
     }
     $room_count = 0;
     if (isset($_POST['room_count'])) {
         $room_count = intval(wp_kses($_POST['room_count'], ''));
     } else {
         if ($booking_object != null) {
             $room_count = $booking_object->room_count;
         }
     }
     $accommodation_id = 0;
     if (isset($_GET['accommodation_id'])) {
         $accommodation_id = absint($_GET['accommodation_id']);
     } else {
         if (isset($_POST['accommodation_id'])) {
             $accommodation_id = intval(wp_kses($_POST['accommodation_id'], ''));
         } else {
             if ($booking_object != null) {
                 $accommodation_id = $booking_object->accommodation_id;
             }
         }
     }
     $room_type_id = 0;
     if (isset($_GET['room_type_id'])) {
         $room_type_id = absint($_GET['room_type_id']);
     } else {
         if (isset($_POST['room_type_id'])) {
             $room_type_id = intval(wp_kses($_POST['room_type_id'], ''));
         } else {
             if ($booking_object != null) {
                 $room_type_id = $booking_object->room_type_id;
             }
         }
     }
     if ($booking_object) {
         echo '<h3>' . __('Update Accommodation Booking', 'bookyourtravel') . '</h3>';
     } else {
         echo '<h3>' . __('Add Accommodation Booking', 'bookyourtravel') . '</h3>';
     }
     echo '<form id="accommodation_booking_form" method="post" action="' . esc_url($_SERVER['REQUEST_URI']) . '" style="clear: both;">';
     echo wp_nonce_field('accommodation_booking_nonce');
     echo '<table cellpadding="3" class="form-table"><tbody>';
     $accommodations_select = '<select id="accommodation_id" name="accommodation_id" onchange="accommodationBookingAccommodationFilterRedirect(' . $edit . ',this.value)">';
     $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) {
             $accommodations_select .= '<option value="' . $accommodation_result->ID . '" ' . ($accommodation_result->ID == $accommodation_id ? 'selected' : '') . '>' . $accommodation_result->post_title . '</option>';
         }
     }
     $accommodations_select .= '</select>';
     echo '<tr>';
     echo '	<th scope="row" valign="top">' . __('Select accommodation enry', 'bookyourtravel') . '</th>';
     echo '	<td>' . $accommodations_select . '</td>';
     echo '</tr>';
     if ($accommodation_id > 0) {
         $accommodation_obj = new byt_accommodation((int) $accommodation_id);
         $is_self_catered = $accommodation_obj->get_is_self_catered();
         if (!$is_self_catered) {
             $room_types_select = '<select id="room_type_id" name="room_type_id">';
             $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>';
             echo '<tr>';
             echo '	<th scope="row" valign="top">' . __('Select room type entry', 'bookyourtravel') . '</th>';
             echo '	<td>' . $room_types_select . '</td>';
             echo '</tr>';
         }
     }
     echo '<tr>';
     echo '	<th scope="row" valign="top">' . __('Date from', 'bookyourtravel') . '</th>';
     echo '	<td>';
     echo '		<script>';
     echo '			window.datepickerDateFromValue = "' . (isset($date_from) ? $date_from : null) . '";';
     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 = "' . (isset($date_to) ? $date_to : null) . '";';
     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">' . __('First name', 'bookyourtravel') . '</th>';
     echo '	<td><input type="text" name="first_name" id="first_name" value="' . $first_name . '" /></td>';
     echo '</tr>';
     echo '<tr>';
     echo '	<th scope="row" valign="top">' . __('Last name', 'bookyourtravel') . '</th>';
     echo '	<td><input type="text" name="last_name" id="last_name" value="' . $last_name . '" /></td>';
     echo '</tr>';
     echo '<tr>';
     echo '	<th scope="row" valign="top">' . __('Email', 'bookyourtravel') . '</th>';
     echo '	<td><input type="text" name="email" id="email" value="' . $email . '" /></td>';
     echo '</tr>';
     echo '<tr>';
     echo '	<th scope="row" valign="top">' . __('Phone', 'bookyourtravel') . '</th>';
     echo '	<td><input type="text" name="phone" id="phone" value="' . $phone . '" /></td>';
     echo '</tr>';
     echo '<tr>';
     echo '	<th scope="row" valign="top">' . __('Address', 'bookyourtravel') . '</th>';
     echo '	<td><input type="text" name="address" id="address" value="' . $address . '" /></td>';
     echo '</tr>';
     echo '<tr>';
     echo '	<th scope="row" valign="top">' . __('Town', 'bookyourtravel') . '</th>';
     echo '	<td><input type="text" name="town" id="town" value="' . $town . '" /></td>';
     echo '</tr>';
     echo '<tr>';
     echo '	<th scope="row" valign="top">' . __('Zip', 'bookyourtravel') . '</th>';
     echo '	<td><input type="text" name="zip" id="zip" value="' . $zip . '" /></td>';
     echo '</tr>';
     echo '<tr>';
     echo '	<th scope="row" valign="top">' . __('Country', 'bookyourtravel') . '</th>';
     echo '	<td><input type="text" name="country" id="country" value="' . $country . '" /></td>';
     echo '</tr>';
     echo '<tr>';
     echo '	<th scope="row" valign="top">' . __('Special requirements', 'bookyourtravel') . '</th>';
     echo '	<td><textarea type="text" name="special_requirements" id="special_requirements" rows="5" cols="50">' . $special_requirements . '</textarea></td>';
     echo '</tr>';
     echo '<tr>';
     echo '	<th scope="row" valign="top">' . __('Number of adults', 'bookyourtravel') . '</th>';
     echo '	<td><input type="text" name="adults" id="adults" value="' . $adults . '" /></td>';
     echo '</tr>';
     echo '<tr>';
     echo '	<th scope="row" valign="top">' . __('Number of children', 'bookyourtravel') . '</th>';
     echo '	<td><input type="text" name="children" id="children" value="' . $children . '" /></td>';
     echo '</tr>';
     echo '<tr>';
     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">' . __('Total price', 'bookyourtravel') . '</th>';
     echo '	<td><input type="text" name="total_price" id="total_price" value="' . $total_price . '" /></td>';
     echo '</tr>';
     echo '</table>';
     echo '<p>';
     echo '<a href="edit.php?post_type=accommodation&page=theme_accommodation_booking_admin.php" class="button-secondary">' . __('Cancel', 'bookyourtravel') . '</a>&nbsp;';
     if ($booking_object) {
         echo '<input id="booking_id" name="booking_id" value="' . $edit . '" type="hidden" />';
         echo '<input class="button-primary" type="submit" name="update" value="' . __('Update Booking', 'bookyourtravel') . '"/>';
     } else {
         if ($accommodation_id > 0) {
             echo '<input class="button-primary" type="submit" name="insert" value="' . __('Add Booking', 'bookyourtravel') . '"/>';
         }
     }
     echo '</p>';
     echo '</form>';
 }