get_header(); BYT_Theme_Utils::breadcrumbs(); get_sidebar('under-header'); global $post, $byt_theme_globals, $tour_date_from, $current_user, $tour_obj, $entity_obj, $default_tour_tabs, $score_out_of_10, $byt_tours_post_type, $byt_theme_of_custom; $enable_reviews = $byt_theme_globals->enable_reviews(); $enable_tours = $byt_theme_globals->enable_tours(); $price_decimal_places = $byt_theme_globals->get_price_decimal_places(); $tour_extra_fields = $byt_theme_globals->get_tour_extra_fields(); $tab_array = $byt_theme_globals->get_tour_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(); $tour_obj = new byt_tour($post); $entity_obj = $tour_obj; $tour_map_code = $tour_obj->get_custom_field('map_code'); $tour_location = $tour_obj->get_location(); $tour_location_title = ''; if ($tour_location) { $tour_location_title = $tour_location->get_title(); } $tour_is_reservation_only = $tour_obj->get_is_reservation_only(); $tour_date_from = date('Y-m-d', strtotime("+0 day", time())); $tour_date_from_year = date('Y', strtotime("+0 day", time())); $tour_date_from_month = date('n', strtotime("+0 day", time())); ?> <script> window.postType = 'tour'; </script>
function get_tour_min_price($tour_id, $date = null) { global $wpdb; $tour_obj = new byt_tour(intval($tour_id)); $tour_id = $tour_obj->get_base_id(); if (!isset($date)) { $date = date('Y-m-d', time()); } $table_name_schedule = BOOKYOURTRAVEL_TOUR_SCHEDULE_TABLE; $sql = "SELECT MIN(schedule.price) \n\t\t\t\tFROM {$table_name_schedule} schedule \n\t\t\t\tWHERE tour_id=%d "; if ($tour_obj->get_type_is_repeated() == 0) { // this tour is a one off and is not repeated. If start date is missed, person cannot participate. $sql .= $wpdb->prepare(" AND start_date > %s ", $date); } else { // daily, weekly, weekdays tours are recurring which means start date is important only in the sense that tour needs to have become valid before we can get min price. } $sql = $wpdb->prepare($sql, $tour_id); $min_price = $wpdb->get_var($sql); if (!$min_price) { $min_price = 0; } $this->sync_tour_min_price($tour_id, $min_price); return $min_price; }
function render_entry_form($booking_id) { global $byt_tours_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_tours_post_type->get_tour_booking($edit); } $tour_date = null; if (isset($_POST['tour_date'])) { $tour_date = wp_kses($_POST['tour_date'], ''); } else { if ($booking_object != null) { $tour_date = $booking_object->tour_date; } } if (isset($tour_date)) { $tour_date = date($this->date_format, strtotime($tour_date)); } $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_adults = 0; if (isset($_POST['total_price_adults'])) { $total_price_adults = floatval(wp_kses($_POST['total_price_adults'], '')); } else { if ($booking_object != null) { $total_price_adults = $booking_object->total_price_adults; } } $total_price_children = 0; if (isset($_POST['total_price_children'])) { $total_price_children = floatval(wp_kses($_POST['total_price_children'], '')); } else { if ($booking_object != null) { $total_price_children = $booking_object->total_price_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; } } $tour_id = 0; if (isset($_GET['tour_id'])) { $tour_id = absint($_GET['tour_id']); } else { if (isset($_POST['tour_id'])) { $tour_id = intval(wp_kses($_POST['tour_id'], '')); } else { if ($booking_object != null) { $tour_id = $booking_object->tour_id; } } } $tour_schedule_id = 0; if (isset($_GET['tour_schedule_id'])) { $tour_schedule_id = absint($_GET['tour_schedule_id']); } else { if (isset($_POST['tour_schedule_id'])) { $tour_schedule_id = intval(wp_kses($_POST['tour_schedule_id'], '')); } else { if ($booking_object != null) { $tour_schedule_id = $booking_object->tour_schedule_id; } } } if ($booking_object) { echo '<h3>' . __('Update Tour Booking Entry', 'bookyourtravel') . '</h3>'; } else { echo '<h3>' . __('Add Tour Booking Entry', 'bookyourtravel') . '</h3>'; } echo '<form id="tour_booking_entry_form" method="post" action="' . esc_url($_SERVER['REQUEST_URI']) . '" style="clear: both;">'; echo wp_nonce_field('tour_booking_entry_form_nonce'); echo '<table cellpadding="3" class="form-table"><tbody>'; $tours_select = '<select id="tour_id" name="tour_id" onchange="tourBookingTourFilterRedirect(' . $edit . ',this.value)">'; $tours_select .= '<option value="">' . __('Select tour', 'bookyourtravel') . '</option>'; $author_id = null; if (!is_super_admin()) { $author_id = get_current_user_id(); } $tour_results = $byt_tours_post_type->list_tours(0, -1, 'title', 'ASC', 0, array(), array(), array(), false, $author_id); if (count($tour_results) > 0 && $tour_results['total'] > 0) { foreach ($tour_results['results'] as $tour_result) { global $post; $post = $tour_result; setup_postdata($post); $tours_select .= '<option value="' . $post->ID . '" ' . ($post->ID == $tour_id ? 'selected' : '') . '>' . $post->post_title . '</option>'; } } $tours_select .= '</select>'; echo '<tr>'; echo ' <th scope="row" valign="top">' . __('Select tour entry', 'bookyourtravel') . '</th>'; echo ' <td>' . $tours_select . '</td>'; echo '</tr>'; $is_price_per_group = 0; if ($tour_id > 0) { $tour_obj = new byt_tour(intval($tour_id)); $is_price_per_group = $tour_obj->get_is_price_per_group(); echo $tour_obj->get_type_name(); $tour_type = __('One-off tour', 'bookyourtravel'); if ($tour_obj->get_type_is_repeated() == 1) { $tour_type = __('Daily tour', 'bookyourtravel'); } else { if ($tour_obj->get_type_is_repeated() == 2) { $tour_type = __('Weekday tour', 'bookyourtravel'); } else { if ($tour_obj->get_type_is_repeated() == 3) { $tour_type = sprintf(__('Tour on %s.</p>', 'bookyourtravel'), $tour_obj->get_type_day_of_week_day()); } } } $tours_schedule_select = '<select id="tour_schedule_id" name="tour_schedule_id" onchange="tourBookingTourScheduleFilterRedirect(' . $edit . ',' . $tour_id . ',this.value)">'; $tours_schedule_select .= '<option value="">' . __('Select tour schedule', 'bookyourtravel') . '</option>'; $author_id = null; if (!is_super_admin()) { $author_id = get_current_user_id(); } $tours_schedule_results = $byt_tours_post_type->list_tour_schedules(null, 0, 'Id', 'ASC', 0, 0, 0, $tour_id, '', $author_id); if (count($tours_schedule_results) > 0 && $tours_schedule_results['total'] > 0) { foreach ($tours_schedule_results['results'] as $tours_schedule_result) { $schedule_date = date('Y-m-d', strtotime($tours_schedule_result->start_date)); $tours_schedule_select .= '<option value="' . $tours_schedule_result->Id . '" ' . ($tours_schedule_result->Id == $tour_schedule_id ? 'selected' : '') . '>' . __('From', 'bookyourtravel') . ' ' . $schedule_date . ' ' . __('Days', 'bookyourtravel') . ' ' . $tours_schedule_result->duration_days . ' ' . __('Price', 'bookyourtravel') . ' ' . $tours_schedule_result->price . ' [' . $tour_type . '] </option>'; } } $tours_schedule_select .= '</select>'; echo '<tr>'; echo ' <th scope="row" valign="top">' . __('Select tour schedule entry', 'bookyourtravel') . '</th>'; echo ' <td>' . $tours_schedule_select . '</td>'; echo '</tr>'; } echo '<tr>'; echo ' <th scope="row" valign="top">' . __('Tour date', 'bookyourtravel') . '</th>'; echo ' <td>'; echo ' <script>'; echo ' window.datepickerTourDateValue = "' . $tour_date . '";'; echo ' </script>'; echo ' <input class="datepicker" type="text" name="datepicker_tour_date" id="datepicker_tour_date" />'; echo ' <input type="hidden" name="tour_date" id="tour_date" />'; 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>'; if (!$is_price_per_group) { echo '<tr>'; echo ' <th scope="row" valign="top">' . __('Total price for adults', 'bookyourtravel') . '</th>'; echo ' <td><input type="text" name="total_price_adults" id="total_price_adults" value="' . $total_price_adults . '" /></td>'; echo '</tr>'; echo '<tr>'; echo ' <th scope="row" valign="top">' . __('Total price for children', 'bookyourtravel') . '</th>'; echo ' <td><input type="text" name="total_price_children" id="total_price_children" value="' . $total_price_children . '" /></td>'; echo '</tr>'; } else { echo '<tr>'; echo ' <th scope="row" valign="top">' . __('Total price for group', 'bookyourtravel') . '</th>'; echo ' <td><input type="text" name="total_price_adults" id="total_price_adults" value="' . $total_price_adults . '" /> <input type="hidden" name="total_price_children" id="total_price_children" value="' . $total_price_children . '" /> </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=tour&page=theme_tour_schedule_booking_admin.php" class="button-secondary">' . __('Cancel', 'bookyourtravel') . '</a> '; 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 ($tour_id > 0 && $tour_schedule_id > 0) { echo '<input class="button-primary" type="submit" name="insert" value="' . __('Add Booking', 'bookyourtravel') . '"/>'; } } echo '</p>'; echo '</form>'; }
<?php global $post, $tour_class, $display_mode, $byt_theme_globals, $byt_tours_post_type, $byt_reviews_post_type; $tour_id = $post->ID; $tour_obj = new byt_tour($post); $base_id = $tour_obj->get_base_id(); $reviews_total = $byt_reviews_post_type->get_reviews_count($base_id); $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(); $tour_image = $tour_obj->get_main_image(); if (empty($tour_image)) { $tour_image = BYT_Theme_Utils::get_file_uri('/images/uploads/img.jpg'); } $is_price_per_group = $tour_obj->get_is_price_per_group(); $score_out_of_10 = 0; if ($reviews_total > 0) { $review_score = $tour_obj->get_custom_field('review_score', false); $score_out_of_10 = round($review_score * 10); } $tour_description_html = BYT_Theme_Utils::strip_tags_and_shorten($tour_obj->get_description(), 100) . '<a href="' . $tour_obj->get_permalink() . '">' . __('More info', 'bookyourtravel') . '</a>'; $current_date = date('Y-m-d', time()); $tour_min_price = $byt_tours_post_type->get_tour_min_price($tour_id, $current_date); $tour_location = $tour_obj->get_location(); $tour_location_title = ''; if ($tour_location) { $tour_location_title = $tour_location->get_title(); } if (empty($display_mode) || $display_mode == 'card') { ?> <!--tour item-->
function render_entry_form() { global $byt_tours_post_type; $tour_id = 0; $schedule_object = null; $tour_obj = null; $is_price_per_group = 0; $tour_type_is_repeated = 0; // on-off tour by default $edit = isset($_GET['edit']) ? absint($_GET['edit']) : ""; if (!empty($edit)) { $schedule_object = $byt_tours_post_type->get_tour_schedule($edit); } if (isset($_POST['tours_select'])) { $tour_id = wp_kses($_POST['tours_select'], ''); } else { if ($schedule_object != null) { $tour_id = $schedule_object->tour_id; } } if ($tour_id) { $tour_obj = new byt_tour(intval($tour_id)); $tour_id = $tour_obj->get_base_id(); $is_price_per_group = $tour_obj->get_is_price_per_group(); $tour_type_is_repeated = $tour_obj->get_type_is_repeated(); } $tours_select = '<select id="tours_select" name="tours_select">'; $tours_select .= '<option value="">' . __('Select tour', 'bookyourtravel') . '</option>'; $author_id = null; if (!is_super_admin()) { $author_id = get_current_user_id(); } $tour_results = $byt_tours_post_type->list_tours(0, -1, 'title', 'ASC', 0, array(), array(), array(), false, $author_id); if (count($tour_results) > 0 && $tour_results['total'] > 0) { foreach ($tour_results['results'] as $tour_result) { global $post; $post = $tour_result; setup_postdata($post); $tours_select .= '<option value="' . $post->ID . '" ' . ($post->ID == $tour_id ? 'selected' : '') . '>' . $post->post_title . '</option>'; } } $tours_select .= '</select>'; $start_date = null; if (isset($_POST['start_date'])) { $start_date = wp_kses($_POST['start_date'], ''); } else { if ($schedule_object != null) { $start_date = $schedule_object->start_date; } } if (isset($start_date)) { $start_date = date($this->date_format, strtotime($start_date)); } $max_people = 0; if (isset($_POST['max_people'])) { $max_people = intval(wp_kses($_POST['max_people'], '0')); } else { if ($schedule_object != null) { $max_people = $schedule_object->max_people; } } $duration_days = 0; if (isset($_POST['duration_days'])) { $duration_days = intval(wp_kses($_POST['duration_days'], '0')); } else { if ($schedule_object != null) { $duration_days = $schedule_object->duration_days; } } $price = 0; if (isset($_POST['price'])) { $price = floatval(wp_kses($_POST['price'], '2')); } else { if ($schedule_object != null) { $price = $schedule_object->price; } } $price_child = 0; if (!$is_price_per_group) { if (isset($_POST['price_child'])) { $price_child = floatval(wp_kses($_POST['price_child'], '2')); } else { if ($schedule_object != null) { $price_child = $schedule_object->price_child; } } } $end_date = null; if (isset($_POST['end_date'])) { $end_date = wp_kses($_POST['end_date'], ''); } else { if ($schedule_object != null) { $end_date = $schedule_object->end_date; } } if (isset($end_date)) { $end_date = date($this->date_format, strtotime($end_date)); } if ($schedule_object) { echo '<h3>' . __('Update Tour Schedule Entry', 'bookyourtravel') . '</h3>'; } else { echo '<h3>' . __('Add Tour Schedule Entry', 'bookyourtravel') . '</h3>'; } echo '<form id="tour_schedule_entry_form" method="post" action="' . esc_url($_SERVER['REQUEST_URI']) . '" style="clear: both;">'; echo wp_nonce_field('tour_schedule_entry_form'); echo '<table cellpadding="3" class="form-table"><tbody>'; echo '<tr>'; echo ' <th scope="row" valign="top">' . __('Select tour', 'bookyourtravel') . '</th>'; echo ' <td>' . $tours_select . '</td>'; echo '</tr>'; echo '<tr>'; echo ' <th scope="row" valign="top">' . __('Max number of people', 'bookyourtravel') . '</th>'; echo ' <td><input type="text" name="max_people" id="max_people" value="' . $max_people . '" /></td>'; echo '</tr>'; echo '<tr>'; echo ' <th scope="row" valign="top">' . __('Duration (days)', 'bookyourtravel') . '</th>'; echo ' <td><input type="text" name="duration_days" id="duration_days" value="' . $duration_days . '" /></td>'; echo '</tr>'; echo '<tr>'; echo ' <th scope="row" valign="top">' . __('Start date', 'bookyourtravel') . '</th>'; echo ' <td>'; echo ' <script>'; echo ' window.datepickerStartDateValue = "' . $start_date . '";'; echo ' </script>'; echo ' <input class="datepicker" type="text" name="datepicker_start_date" id="datepicker_start_date" />'; echo ' <input type="hidden" name="start_date" id="start_date" />'; echo ' </td>'; echo '</tr>'; echo '<tr class="is_repeated" ' . ($tour_type_is_repeated ? '' : 'style="display:none"') . '>'; echo ' <th scope="row" valign="top">' . __('End date', 'bookyourtravel') . '</th>'; echo ' <td>'; echo ' <script>'; echo ' window.datepickerEndDateValue = "' . $end_date . '";'; echo ' </script>'; echo ' <input class="datepicker" type="text" name="datepicker_end_date" id="datepicker_end_date" />'; echo ' <input type="hidden" name="end_date" id="end_date" />'; echo ' </td>'; echo '</tr>'; echo '<tr>'; echo ' <th scope="row" valign="top">' . __('Price', 'bookyourtravel') . ' <span class="per_person" ' . (!$is_price_per_group ? '' : 'style="display:none"') . '>' . __('per adult', 'bookyourtravel') . '</span> <span class="per_group" ' . ($is_price_per_group ? '' : 'style="display:none"') . '>' . __('per group', 'bookyourtravel') . '</span></th>'; echo ' <td><input type="text" name="price" id="price" value="' . $price . '" /></td>'; echo '</tr>'; echo '<tr class="per_person" ' . (!$is_price_per_group ? '' : 'style="display:none"') . '>'; echo ' <th scope="row" valign="top">' . __('Price per child', 'bookyourtravel') . '</th>'; echo ' <td><input type="text" name="price_child" id="price_child" value="' . $price_child . '" /></td>'; echo '</tr>'; echo '</table>'; echo '<p>'; echo '<a href="edit.php?post_type=tour&page=theme_tour_schedule_admin.php" class="button-secondary">' . __('Cancel', 'bookyourtravel') . '</a> '; if ($schedule_object) { echo '<input id="schedule_id" name="schedule_id" value="' . $edit . '" type="hidden" />'; echo '<input class="button-primary" type="submit" name="update" value="' . __('Update Tour Schedule Entry', 'bookyourtravel') . '"/>'; } else { echo '<input class="button-primary" type="submit" name="insert" value="' . __('Add Tour Schedule Entry', 'bookyourtravel') . '"/>'; } echo '</p>'; echo '</form>'; }
function tour_type_is_repeated_ajax_request() { if (isset($_REQUEST)) { $nonce = wp_kses($_REQUEST['nonce'], ''); $tour_id = intval(wp_kses($_REQUEST['tourId'], '')); if (wp_verify_nonce($nonce, 'tour_schedule_entry_form')) { $tour_obj = new byt_tour(intval($tour_id)); $tour_type_is_repeated = $tour_obj->get_type_is_repeated(); echo $tour_type_is_repeated; } } // Always die in functions echoing ajax content die; }