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>'; }
function column_TourType($item) { $tour_obj = new byt_tour($item->tour_id); return $tour_obj->get_type_name(); }