function get_cruise_min_price($cruise_id, $cabin_type_id = 0, $date = null) { global $wpdb; $cruise_obj = new byt_cruise(intval($cruise_id)); $cruise_id = $cruise_obj->get_base_id(); if ($cabin_type_id > 0) { $cabin_type_obj = new byt_cabin_type(intval($cabin_type_id)); $cabin_type_id = $cabin_type_obj->get_base_id(); } if (!isset($date)) { $date = date('Y-m-d', time()); } $table_name_schedule = BOOKYOURTRAVEL_CRUISE_SCHEDULE_TABLE; $sql = "SELECT MIN(schedule.price) \r\n\t\t\t\tFROM {$table_name_schedule} schedule \r\n\t\t\t\tWHERE cruise_id=%d "; if ($cabin_type_id > 0) { $sql .= $wpdb->prepare(" AND cabin_type_id=%d ", $cabin_type_id); } if ($cruise_obj->get_type_is_repeated() == 0) { // this cruise 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 cruises are recurring which means start date is important only in the sense that cruise needs to have become valid before we can get min price. } $sql = $wpdb->prepare($sql, $cruise_id); $min_price = $wpdb->get_var($sql); if (!$min_price) { $min_price = 0; } if ($cabin_type_id == 0) { $this->sync_cruise_min_price($cruise_id, $min_price); } return $min_price; }
function render_entry_form($booking_id) { global $byt_cruises_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_cruises_post_type->get_cruise_booking($edit); } $cruise_date = null; if (isset($_POST['cruise_date'])) { $cruise_date = wp_kses($_POST['cruise_date'], ''); } else { if ($booking_object != null) { $cruise_date = $booking_object->cruise_date; } } if (isset($cruise_date)) { $cruise_date = date($this->date_format, strtotime($cruise_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; } } $cruise_id = 0; $cabin_type_id = 0; if ($booking_object != null) { $cruise_id = $booking_object->cruise_id; $cabin_type_id = $booking_object->cabin_type_id; } $cruise_id = 0; if (isset($_GET['cruise_id'])) { $cruise_id = absint($_GET['cruise_id']); } else { if (isset($_POST['tour_id'])) { $cruise_id = intval(wp_kses($_POST['cruise_id'], '')); } else { if ($booking_object != null) { $cruise_id = $booking_object->cruise_id; } } } $cabin_type_id = 0; if (isset($_GET['cabin_type_id'])) { $cabin_type_id = absint($_GET['cabin_type_id']); } else { if (isset($_POST['tour_id'])) { $cabin_type_id = intval(wp_kses($_POST['cabin_type_id'], '')); } else { if ($booking_object != null) { $cabin_type_id = $booking_object->cabin_type_id; } } } $cruise_schedule_id = 0; if (isset($_GET['cruise_schedule_id'])) { $cruise_schedule_id = absint($_GET['cruise_schedule_id']); } else { if (isset($_POST['cruise_schedule_id'])) { $cruise_schedule_id = intval(wp_kses($_POST['cruise_schedule_id'], '')); } else { if ($booking_object != null) { $cruise_schedule_id = $booking_object->cruise_schedule_id; } } } if ($booking_object) { echo '<h3>' . __('Update Cruise Booking Entry', 'bookyourtravel') . '</h3>'; } else { echo '<h3>' . __('Add Cruise Booking Entry', 'bookyourtravel') . '</h3>'; } echo '<form id="cruise_booking_entry_form" method="post" action="' . esc_url($_SERVER['REQUEST_URI']) . '" style="clear: both;">'; echo wp_nonce_field('cruise_booking_entry_form_nonce'); echo '<table cellpadding="3" class="form-table"><tbody>'; $cruises_select = '<select id="cruise_id" name="cruise_id" onchange="cruiseBookingCruiseFilterRedirect(' . $edit . ',this.value)">'; $cruises_select .= '<option value="">' . __('Select cruise', 'bookyourtravel') . '</option>'; $author_id = null; if (!is_super_admin()) { $author_id = get_current_user_id(); } $cruise_results = $byt_cruises_post_type->list_cruises(0, -1, 'title', 'ASC', 0, array(), array(), array(), false, $author_id); if (count($cruise_results) > 0 && $cruise_results['total'] > 0) { foreach ($cruise_results['results'] as $cruise_result) { global $post; $post = $cruise_result; setup_postdata($post); $cruises_select .= '<option value="' . $post->ID . '" ' . ($post->ID == $cruise_id ? 'selected' : '') . '>' . $post->post_title . '</option>'; } } $cruises_select .= '</select>'; echo '<tr>'; echo ' <th scope="row" valign="top">' . __('Select cruise entry', 'bookyourtravel') . '</th>'; echo ' <td>' . $cruises_select . '</td>'; echo '</tr>'; $is_price_per_person = 0; if ($cruise_id > 0) { $cruise_obj = new byt_cruise(intval($cruise_id)); $cabin_types_select = '<select id="cabin_type_id" name="cabin_type_id" onchange="cruiseBookingCabinTypeFilterRedirect(' . $edit . ',' . $cruise_id . ',this.value)">'; $cabin_types_select .= '<option value="">' . __('Select cabin type type', 'bookyourtravel') . '</option>'; if ($cruise_obj) { $cabin_type_ids = $cruise_obj->get_cabin_types(); if ($cabin_type_ids && count($cabin_type_ids) > 0) { for ($i = 0; $i < count($cabin_type_ids); $i++) { $temp_id = $cabin_type_ids[$i]; $cabin_type_obj = new byt_cabin_type(intval($temp_id)); $cabin_types_select .= '<option value="' . $temp_id . '" ' . ($temp_id == $cabin_type_id ? 'selected' : '') . '>' . $cabin_type_obj->get_title() . '</option>'; } } } $cabin_types_select .= '</select>'; echo '<tr>'; echo ' <th scope="row" valign="top">' . __('Select cabin type entry', 'bookyourtravel') . '</th>'; echo ' <td>' . $cabin_types_select . '</td>'; echo '</tr>'; $is_price_per_person = $cruise_obj->get_is_price_per_person(); $cruise_type = __('One-off cruise', 'bookyourtravel'); if ($cruise_obj->get_type_is_repeated() == 1) { $cruise_type = __('Daily cruise', 'bookyourtravel'); } else { if ($cruise_obj->get_type_is_repeated() == 2) { $cruise_type = __('Weekday cruise', 'bookyourtravel'); } else { if ($cruise_obj->get_type_is_repeated() == 3) { $cruise_type = sprintf(__('Cruise on %s.</p>', 'bookyourtravel'), $cruise_obj->get_type_day_of_week_day()); } } } if ($cabin_type_id > 0) { $cruises_schedule_select = '<select id="cruise_schedule_id" name="cruise_schedule_id" onchange="cruiseBookingCruiseScheduleFilterRedirect(' . $edit . ',' . $cruise_id . ',' . $cabin_type_id . ',this.value)">'; $cruises_schedule_select .= '<option value="">' . __('Select cruise schedule', 'bookyourtravel') . '</option>'; $author_id = null; if (!is_super_admin()) { $author_id = get_current_user_id(); } $cruises_schedule_results = $byt_cruises_post_type->list_cruise_schedules(null, 0, 'Id', 'ASC', 0, 0, 0, $cruise_id, $cabin_type_id, $author_id); if (count($cruises_schedule_results) > 0 && $cruises_schedule_results['total'] > 0) { foreach ($cruises_schedule_results['results'] as $cruises_schedule_result) { $schedule_date = date($this->date_format, strtotime($cruises_schedule_result->start_date)); $cruises_schedule_select .= '<option value="' . $cruises_schedule_result->Id . '" ' . ($cruises_schedule_result->Id == $cruise_schedule_id ? 'selected' : '') . '>' . __('From', 'bookyourtravel') . ' ' . $schedule_date . ' ' . __('Days', 'bookyourtravel') . ' ' . $cruises_schedule_result->duration_days . ' ' . __('Price', 'bookyourtravel') . ' ' . $cruises_schedule_result->price . ' [' . $cruise_type . '] </option>'; } } $cruises_schedule_select .= '</select>'; echo '<tr>'; echo ' <th scope="row" valign="top">' . __('Select cruise schedule entry', 'bookyourtravel') . '</th>'; echo ' <td>' . $cruises_schedule_select . '</td>'; echo '</tr>'; } } echo '<tr>'; echo ' <th scope="row" valign="top">' . __('Cruise date', 'bookyourtravel') . '</th>'; echo ' <td>'; echo ' <script>'; echo ' window.datepickerCruiseDateValue = "' . $cruise_date . '";'; echo ' </script>'; echo ' <input class="datepicker" type="text" name="datepicker_cruise_date" id="datepicker_cruise_date" />'; echo ' <input type="hidden" name="cruise_date" id="cruise_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_person) { 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 cabin', '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=cruise&page=theme_cruise_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 ($cruise_id > 0 && $cabin_type_id > 0 && $cruise_schedule_id > 0) { echo '<input class="button-primary" type="submit" name="insert" value="' . __('Add Booking', 'bookyourtravel') . '"/>'; } } echo '</p>'; echo '</form>'; }
function render_entry_form() { global $byt_cruises_post_type; $cruise_id = 0; $cabin_type_id = 0; $schedule_object = null; $cruise_obj = null; $cabin_type_obj = null; $is_price_per_person = 0; $cruise_type_is_repeated = 0; // on-off cruise by default $edit = isset($_GET['edit']) ? absint($_GET['edit']) : ""; if (!empty($edit)) { $schedule_object = $byt_cruises_post_type->get_cruise_schedule($edit); } if (isset($_POST['cruises_select'])) { $cruise_id = wp_kses($_POST['cruises_select'], ''); } else { if ($schedule_object != null) { $cruise_id = $schedule_object->cruise_id; } } if ($cruise_id) { $cruise_obj = new byt_cruise(intval($cruise_id)); $cruise_id = $cruise_obj->get_base_id(); $cruise_type_is_repeated = $cruise_obj->get_type_is_repeated(); $is_price_per_person = $cruise_obj->get_is_price_per_person(); } if (isset($_POST['cabin_types_select'])) { $cabin_type_id = wp_kses($_POST['cabin_types_select'], ''); } else { if ($schedule_object) { $cabin_type_id = $schedule_object->cabin_type_id; } } if (!empty($cabin_type_id)) { $cabin_type_id = BYT_Theme_Utils::get_default_language_post_id($cabin_type_id, 'cabin_type'); } $cruises_select = '<select id="cruises_select" name="cruises_select">'; $cruises_select .= '<option value="">' . __('Select cruise', 'bookyourtravel') . '</option>'; $author_id = null; if (!is_super_admin()) { $author_id = get_current_user_id(); } $cruise_results = $byt_cruises_post_type->list_cruises(0, -1, 'title', 'ASC', 0, array(), array(), array(), false, $author_id); if (count($cruise_results) > 0 && $cruise_results['total'] > 0) { foreach ($cruise_results['results'] as $cruise_result) { global $post; $post = $cruise_result; setup_postdata($post); $cruises_select .= '<option value="' . $post->ID . '" ' . ($post->ID == $cruise_id ? 'selected' : '') . '>' . $post->post_title . '</option>'; } } $cruises_select .= '</select>'; $cabin_types_select = '<select class="normal" id="cabin_types_select" name="cabin_types_select">'; $cabin_types_select .= '<option value="">' . __('Select cabin type', 'bookyourtravel') . '</option>'; if ($cruise_obj) { $cabin_type_ids = $cruise_obj->get_cabin_types(); if ($cabin_type_ids && count($cabin_type_ids) > 0) { for ($i = 0; $i < count($cabin_type_ids); $i++) { $temp_id = $cabin_type_ids[$i]; $cabin_type_obj = new byt_cabin_type(intval($temp_id)); $cabin_types_select .= '<option value="' . $temp_id . '" ' . ($temp_id == $cabin_type_id ? 'selected' : '') . '>' . $cabin_type_obj->get_title() . '</option>'; } } } $cabin_types_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)); } $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; } } $cabin_count = 1; if (isset($_POST['cabin_count'])) { $cabin_count = intval(wp_kses($_POST['cabin_count'], '1')); } else { if ($schedule_object && isset($schedule_object->cabin_count)) { $cabin_count = $schedule_object->cabin_count; } } if ($cabin_count == 0) { $cabin_count = 1; } $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_person) { 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 Cruise Schedule Entry', 'bookyourtravel') . '</h3>'; } else { echo '<h3>' . __('Add Cruise Schedule Entry', 'bookyourtravel') . '</h3>'; } echo '<form id="cruise_schedule_entry_form" method="post" action="' . esc_url($_SERVER['REQUEST_URI']) . '" style="clear: both;">'; echo wp_nonce_field('cruise_schedule_entry_form'); echo '<table cellpadding="3" class="form-table"><tbody>'; echo '<tr>'; echo ' <th scope="row" valign="top">' . __('Select cruise', 'bookyourtravel') . '</th>'; echo ' <td>' . $cruises_select . '</td>'; echo '</tr>'; echo '<tr>'; echo ' <th scope="row" valign="top">' . __('Select cabin type', 'bookyourtravel') . '</th>'; echo ' <td>' . $cabin_types_select . '</td>'; echo '</tr>'; echo '<tr id="cabin_count">'; echo ' <th scope="row" valign="top">' . __('Number of cabins available', 'bookyourtravel') . '</th>'; echo ' <td><input type="text" name="cabin_count" id="cabin_count" value="' . $cabin_count . '" /></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" ' . ($cruise_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_person ? '' : 'style="display:none"') . '>' . __('per adult', 'bookyourtravel') . '</span> <span class="per_person" ' . (!$is_price_per_person ? '' : 'style="display:none"') . '>' . __('per cabin', '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_person ? '' : '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=cruise&page=theme_cruise_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 Cruise Schedule Entry', 'bookyourtravel') . '"/>'; } else { echo '<input class="button-primary" type="submit" name="insert" value="' . __('Add Cruise Schedule Entry', 'bookyourtravel') . '"/>'; } echo '</p>'; echo '</form>'; }
<?php get_header(); BYT_Theme_Utils::breadcrumbs(); get_sidebar('under-header'); global $post, $byt_theme_globals, $current_user, $cruise_obj, $entity_obj, $default_cruise_tabs, $score_out_of_10, $byt_cruises_post_type, $byt_theme_of_custom; $enable_reviews = $byt_theme_globals->enable_reviews(); $enable_cruises = $byt_theme_globals->enable_cruises(); $cruise_extra_fields = $byt_theme_globals->get_cruise_extra_fields(); $tab_array = $byt_theme_globals->get_cruise_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(); $cruise_obj = new byt_cruise($post); $cruise_id = $cruise_obj->get_id(); $entity_obj = $cruise_obj; $cruise_date_from = date('Y-m-d', strtotime("+0 day", time())); $cruise_date_from_year = date('Y', strtotime("+0 day", time())); $cruise_date_from_month = date('n', strtotime("+0 day", time())); $cruise_is_reservation_only = $cruise_obj->get_is_reservation_only(); $cruise_locations = $cruise_obj->get_locations(); ?> <script> window.postType = 'cruise'; </script> <?php if ($enable_reviews) { get_template_part('includes/parts/review', 'form'); }
function cruise_list_cabin_types_ajax_request() { if (isset($_REQUEST)) { $nonce = wp_kses($_REQUEST['nonce'], ''); $cruise_id = intval(wp_kses($_REQUEST['cruiseId'], '')); if (wp_verify_nonce($nonce, 'cruise_schedule_entry_form')) { $cruise_obj = new byt_cruise($cruise_id); $cabin_types = array(); $cabin_type_ids = $cruise_obj->get_cabin_types(); if ($cruise_obj && $cabin_type_ids && count($cabin_type_ids) > 0) { for ($i = 0; $i < count($cabin_type_ids); $i++) { $temp_id = $cabin_type_ids[$i]; $cabin_type_obj = new byt_cabin_type(intval($temp_id)); $cabin_type_temp = new stdClass(); $cabin_type_temp->name = $cabin_type_obj->get_title(); $cabin_type_temp->id = $temp_id; $cabin_types[] = $cabin_type_temp; } } echo json_encode($cabin_types); } } // Always die in functions echoing ajax content die; }
<?php global $post, $cruise_class, $display_mode, $byt_theme_globals, $byt_cruises_post_type, $byt_reviews_post_type; $cruise_id = $post->ID; $cruise_obj = new byt_cruise($post); $base_id = $cruise_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(); $is_price_per_person = $cruise_obj->get_is_price_per_person(); $cruise_image = $cruise_obj->get_main_image(); if (empty($cruise_image)) { $cruise_image = BYT_Theme_Utils::get_file_uri('/images/uploads/img.jpg'); } $score_out_of_10 = 0; if ($reviews_total > 0) { $review_score = $cruise_obj->get_custom_field('review_score', false); $score_out_of_10 = round($review_score * 10); } $cruise_description_html = BYT_Theme_Utils::strip_tags_and_shorten($cruise_obj->get_description(), 100) . '<a href="' . $cruise_obj->get_permalink() . '">' . __('More info', 'bookyourtravel') . '</a>'; $current_date = date('Y-m-d', time()); $cruise_min_price = $byt_cruises_post_type->get_cruise_min_price($cruise_id, 0, $current_date); if (empty($display_mode) || $display_mode == 'card') { ?> <!--cruise item--> <article class="cruise_item <?php echo $cruise_class; ?> "> <div>