function trav_tour_get_single_schedule_html($tour_id, $st_id, $schedule) { global $trav_options; // init variables $st_data = trav_tour_get_schedule_type_data($tour_id, $st_id); $st_title = !empty($st_data) && !empty($st_data['title']) ? $st_data['title'] : ''; $st_desc = !empty($st_data) && !empty($st_data['description']) ? $st_data['description'] : ''; $st_time = !empty($st_data) && !empty($st_data['time']) ? $st_data['time'] : ''; $repeated = get_post_meta($tour_id, 'trav_tour_repeated', true); $multi_book = get_post_meta($tour_id, 'trav_tour_multi_book', true); $tour_booking_page = ''; if (!empty($trav_options['tour_booking_page'])) { $tour_booking_page = trav_get_permalink_clang($trav_options['tour_booking_page']); } $location_arr = array(); $location_arr[] = trav_tour_get_city($tour_id); $location_arr[] = trav_tour_get_country($tour_id); $location = implode(', ', $location_arr); $discount = get_post_meta($tour_id, 'trav_tour_hot', true); $discount_rate = get_post_meta($tour_id, 'trav_tour_discount_rate', true); // init variables $def_date = key($schedule); $default_data = $schedule[$def_date]; foreach ($schedule as $key => $value) { if (!empty($value['available_seat'])) { $def_date = $key; $default_data = $value; break; } } $adults = 1; $kids = 0; ?> <div class="intro small-box table-wrapper full-width hidden-table-sms"> <div class="col-sm-4 table-cell features"> <table> <tr><td><label><?php _e('Location', 'trav'); ?> :</label></td><td><?php echo esc_html($location); ?> </td></tr> <?php if (empty($repeated)) { ?> <tr><td><label><?php _e('Tour Date', 'trav'); ?> :</label></td><td><?php echo date('l, F, j, Y', trav_strtotime($default_data['tour_date'])); ?> </td></tr> <?php } ?> <tr><td><label><?php _e('Duration', 'trav'); ?> :</label></td><td><?php echo esc_html($default_data['duration']); ?> </td></tr> <tr><td><label><?php _e('Available Seats', 'trav'); ?> :</label></td><td class="available-seats"><?php echo esc_html($default_data['available_seat']); ?> </td></tr> <?php if (!empty($multi_book)) { ?> <tr><td><label><?php _e('Price Per Adult', 'trav'); ?> :</label></td><td class="adult-price"><?php echo esc_html(trav_get_price_field($default_data['price'])); ?> </td></tr> <?php if (!empty($default_data['child_price']) && (double) $default_data['child_price'] != 0) { ?> <tr><td><label><?php _e('Price Per Child', 'trav'); ?> :</label></td><td class="child-price"><?php echo esc_html(trav_get_price_field($default_data['child_price'])); ?> </td></tr> <?php } ?> <?php } else { ?> <tr><td><label><?php _e('Price', 'trav'); ?> :</label></td><td class="adult-price"><?php echo esc_html(trav_get_price_field($default_data['price'])); ?> </td></tr> <?php } ?> <?php if (!empty($discount) && !empty($discount_rate)) { ?> <tr><td><label><?php _e('Discount', 'trav'); ?> :</label></td><td><?php echo sprintf(__('%d%% Off', 'trav'), $discount_rate); ?> </td></tr> <?php } ?> </table> </div> <div class="col-sm-8 table-cell"> <form method="get" action="<?php echo $tour_booking_page; ?> " class="tour-booking-form"> <input type="hidden" name="tour_id" value="<?php echo esc_attr($tour_id); ?> "> <input type="hidden" name="st_id" value="<?php echo esc_attr($st_id); ?> "> <?php wp_nonce_field('post-' . $tour_id, '_wpnonce', false); ?> <?php if (defined('ICL_LANGUAGE_CODE')) { ?> <input type="hidden" name="lang" value="<?php echo ICL_LANGUAGE_CODE; ?> "> <?php } ?> <?php if (empty($multi_book)) { ?> <input type="hidden" name="adults" value="1"> <?php } ?> <?php if (empty($repeated)) { ?> <input type="hidden" name="tour_date" value="<?php echo $default_data['tour_date']; ?> "> <?php } ?> <div class="detail-section-top row"> <div class="st-details col-md-9 col-sm-8"> <?php if (!empty($st_title)) { ?> <h4 class="box-title"><?php echo wp_kses_post($st_title); ?> </h4> <?php } ?> <?php if (!empty($st_desc)) { ?> <div class="st-description"><?php echo wp_kses_post($st_desc); ?> </div> <?php } ?> <?php if (!empty($st_time)) { ?> <div class="time"><i class="soap-icon-clock yellow-color"></i><span><?php echo wp_kses_post($st_time); ?> </span></div> <?php } ?> </div> <div class="price-details col-md-3 col-sm-4"> <h3 class="price"> <div class="adult-price"><?php echo trav_get_price_field($default_data['price']); ?> </div> <?php if (!empty($multi_book)) { ?> <small><?php _e('per adult', 'trav'); ?> </small> <?php } ?> </h3> <?php if (empty($multi_book) && empty($repeated)) { ?> <button title="book now" class="button btn-small full-width text-center btn-book-now <?php echo empty($default_data['available_seat']) ? 'no-display' : ''; ?> "><?php _e("BOOK NOW", "trav"); ?> </button> <h4 class="sold-out <?php echo empty($default_data['available_seat']) ? '' : 'no-display'; ?> "><?php echo __('Sold Out', 'trav'); ?> </h4> <h4 class="exceed-persons no-display"><?php echo __('Exceed Persons', 'trav'); ?> </h4> <?php } ?> </div> </div> <?php if (!empty($multi_book) || !empty($repeated)) { ?> <div class="detail-section-bottom"> <div class="row"> <?php if (!empty($repeated)) { ?> <div class="col-md-4 col-sm-6"> <label><?php _e('AVAILABLE ON', 'trav'); ?> </label> <div class="selector validation-field"> <select name="tour_date" class="full-width tour-date-select"> <?php foreach ($schedule as $key => $value) { $selected = $key == $def_date ? 'selected' : ''; echo '<option value="' . esc_attr($key) . '" ' . $selected . ' data-max-seat="' . esc_attr($value['available_seat']) . '" data-price="' . esc_attr($value['price']) . '" data-child-price="' . esc_attr($value['child_price']) . '" >' . esc_html(trav_tophptime($key)) . '</option>'; } ?> </select> </div> </div> <?php } else { ?> <div class="price-data no-display" data-max-seat="<?php echo esc_attr($default_data['available_seat']); ?> " data-price="<?php echo esc_attr($default_data['price']); ?> " data-child-price="<?php echo esc_attr($default_data['child_price']); ?> "></div> <?php } ?> <?php if (!empty($multi_book)) { ?> <div class="col-md-2 col-sm-3 col-xs-6"> <label><?php _e('ADULTS', 'trav'); ?> </label> <div class="selector validation-field"> <select name="adults" class="full-width"> <?php for ($i = 1; $i <= 10; $i++) { $selected = $i == $adults ? 'selected' : ''; echo '<option value="' . esc_attr($i) . '" ' . $selected . '>' . esc_html($i) . '</option>'; } ?> </select> </div> </div> <div class="col-md-2 col-sm-3 col-xs-6"> <label><?php _e('KIDS', 'trav'); ?> </label> <div class="selector validation-field"> <select name="kids" class="full-width"> <?php for ($i = 0; $i <= 10; $i++) { $selected = $i == $kids ? 'selected' : ''; echo '<option value="' . esc_attr($i) . '" ' . $selected . '>' . esc_html($i) . '</option>'; } ?> </select> </div> </div> <?php } ?> <div class="col-md-4 pull-right"> <label> <?php _e('Total', 'trav'); ?> : <span class="total-price"> <?php echo trav_get_price_field($default_data['price']); ?> </span> </label> <div class="row"> <div class="col-sm-12"> <button data-animation-duration="1" data-animation-type="bounce" class="btn-book-now full-width icon-check animated bounce <?php echo empty($default_data['available_seat']) ? 'no-display' : ''; ?> " type="submit"><?php _e("BOOK NOW", "trav"); ?> </button> <h4 class="sold-out <?php echo empty($default_data['available_seat']) ? '' : 'no-display'; ?> "><?php echo __('Sold Out', 'trav'); ?> </h4> <h4 class="exceed-persons no-display"><?php echo __('Exceed Persons', 'trav'); ?> </h4> </div> </div> </div> </div> </div> <?php } ?> </form> </div> </div> <?php }
function trav_tour_send_confirmation_email($booking_no, $booking_pincode, $type = 'new', $subject = '', $description = '') { global $wpdb, $logo_url, $trav_options; $booking_data = trav_tour_get_booking_data($booking_no, $booking_pincode); if (!empty($booking_data)) { // server variables $admin_email = get_option('admin_email'); $home_url = esc_url(home_url()); $site_name = $_SERVER['SERVER_NAME']; $logo_url = esc_url($logo_url); $tour_book_conf_url = ''; if (isset($trav_options['tour_booking_confirmation_page']) && !empty($trav_options['tour_booking_confirmation_page'])) { $tour_book_conf_url = trav_get_permalink_clang($trav_options['tour_booking_confirmation_page']); } $booking_data['tour_id'] = trav_tour_clang_id($booking_data['tour_id']); $st_data = trav_tour_get_schedule_type_data($booking_data['tour_id'], $booking_data['st_id']); $schedule_data = trav_tour_get_schedule_data($booking_data); // tour info $tour_name = get_the_title($booking_data['tour_id']); $tour_url = esc_url(trav_get_permalink_clang($booking_data['tour_id'])); $tour_thumbnail = get_the_post_thumbnail($booking_data['tour_id'], 'list-thumb'); $tour_address = get_post_meta($booking_data['tour_id'], 'trav_tour_address', true); $tour_city = trav_tour_get_city($booking_data['tour_id']); $tour_country = trav_tour_get_country($booking_data['tour_id']); $tour_phone = get_post_meta($booking_data['tour_id'], 'trav_tour_phone', true); $tour_email = get_post_meta($booking_data['tour_id'], 'trav_tour_email', true); $tour_duration = ''; if (!empty($schedule_data) && $schedule_data['success'] == 1) { $tour_duration = $schedule_data['schedule_data']['duration']; } $tour_st_title = esc_html(trav_tour_get_schedule_type_title($booking_data['tour_id'], $booking_data['st_id'])); $tour_st_description = esc_html($st_data['description']); $tour_st_time = esc_html($st_data['time']); if (empty($tour_address)) { $tour_address = $tour_city . ' ' . $tour_country; } $tour_date = date('l, F, j, Y', trav_strtotime($booking_data['tour_date'])); // booking info $booking_no = $booking_data['booking_no']; $booking_pincode = $booking_data['pin_code']; $booking_adults = $booking_data['adults']; $booking_kids = $booking_data['kids']; $booking_total_price = esc_html(trav_get_price_field($booking_data['total_price'] * $booking_data['exchange_rate'], $booking_data['currency_code'], 0)); $booking_deposit_price = esc_html($booking_data['deposit_price'] . $booking_data['currency_code']); $booking_deposit_paid = esc_html(empty($booking_data['deposit_paid']) ? 'No' : 'Yes'); $booking_update_url = esc_url(add_query_arg(array('booking_no' => $booking_data['booking_no'], 'pin_code' => $booking_data['pin_code']), $tour_book_conf_url)); // customer info $customer_first_name = $booking_data['first_name']; $customer_last_name = $booking_data['last_name']; $customer_email = $booking_data['email']; $customer_country_code = $booking_data['country_code']; $customer_phone = $booking_data['phone']; $customer_address = $booking_data['address']; $customer_city = $booking_data['city']; $customer_zip = $booking_data['zip']; $customer_country = $booking_data['country']; $customer_special_requirements = $booking_data['special_requirements']; $variables = array('home_url', 'site_name', 'logo_url', 'tour_name', 'tour_url', 'tour_thumbnail', 'tour_country', 'tour_city', 'tour_address', 'tour_phone', 'tour_email', 'tour_date', 'tour_duration', 'tour_st_title', 'tour_st_description', 'tour_st_time', 'booking_no', 'booking_pincode', 'booking_adults', 'booking_kids', 'booking_total_price', 'booking_deposit_price', 'booking_deposit_paid', 'booking_update_url', 'customer_first_name', 'customer_last_name', 'customer_email', 'customer_country_code', 'customer_phone', 'customer_address', 'customer_city', 'customer_zip', 'customer_country', 'customer_special_requirements'); if (empty($subject)) { if ($type == 'new') { $subject = empty($trav_options['tour_confirm_email_subject']) ? 'Booking Confirmation Email Subject' : $trav_options['tour_confirm_email_subject']; } elseif ($type == 'update') { $subject = empty($trav_options['tour_update_email_subject']) ? 'Booking Updated Email Subject' : $trav_options['tour_update_email_subject']; } elseif ($type == 'cancel') { $subject = empty($trav_options['tour_cancel_email_subject']) ? 'Booking Canceled Email Subject' : $trav_options['tour_cancel_email_subject']; } } if (empty($description)) { if ($type == 'new') { $description = empty($trav_options['tour_confirm_email_description']) ? 'Booking Confirmation Email Description' : $trav_options['tour_confirm_email_description']; } elseif ($type == 'update') { $description = empty($trav_options['tour_update_email_description']) ? 'Booking Confirmation Email Description' : $trav_options['tour_update_email_description']; } elseif ($type == 'cancel') { $description = empty($trav_options['tour_cancel_email_description']) ? 'Booking Confirmation Email Description' : $trav_options['tour_cancel_email_description']; } } foreach ($variables as $variable) { $subject = str_replace("[" . $variable . "]", ${$variable}, $subject); $description = str_replace("[" . $variable . "]", ${$variable}, $description); } $mail_sent = trav_send_mail($site_name, $admin_email, $customer_email, $subject, $description); /* mailing function to business owner */ $bowner_address = ''; if (!empty($trav_options['tour_booked_notify_bowner'])) { if ($type == 'new') { $subject = empty($trav_options['tour_bowner_email_subject']) ? 'You received a booking' : $trav_options['tour_bowner_email_subject']; $description = empty($trav_options['tour_bowner_email_description']) ? 'Booking Details' : $trav_options['tour_bowner_email_description']; } elseif ($type == 'update') { $subject = empty($trav_options['tour_update_bowner_email_subject']) ? 'A booking is updated' : $trav_options['tour_update_bowner_email_subject']; $description = empty($trav_options['tour_update_bowner_email_description']) ? 'Booking Details' : $trav_options['tour_update_bowner_email_description']; } elseif ($type == 'cancel') { $subject = empty($trav_options['tour_cancel_bowner_email_subject']) ? 'A booking is canceled' : $trav_options['tour_cancel_bowner_email_subject']; $description = empty($trav_options['tour_cancel_bowner_email_description']) ? 'Booking Details' : $trav_options['tour_cancel_bowner_email_description']; } foreach ($variables as $variable) { $subject = str_replace("[" . $variable . "]", ${$variable}, $subject); $description = str_replace("[" . $variable . "]", ${$variable}, $description); } if (!empty($tour_email)) { $bowner_address = $tour_email; } else { $post_author_id = get_post_field('post_author', $booking_data['tour_id']); $bowner = get_user_by('id', $post_author_id); if (!empty($bowner)) { $bowner_address = $bowner->user_email; } } if (!empty($bowner_address)) { trav_send_mail($site_name, $admin_email, $bowner_address, $subject, $description); } } /* mailing function to admin */ if (!empty($trav_options['tour_booked_notify_admin'])) { if ($bowner_address != $admin_email) { if ($type == 'new') { $subject = empty($trav_options['tour_admin_email_subject']) ? 'You received a booking' : $trav_options['tour_admin_email_subject']; $description = empty($trav_options['tour_admin_email_description']) ? 'Booking Details' : $trav_options['tour_admin_email_description']; } elseif ($type == 'update') { $subject = empty($trav_options['tour_update_admin_email_subject']) ? 'A booking is updated' : $trav_options['tour_update_admin_email_subject']; $description = empty($trav_options['tour_update_admin_email_description']) ? 'Booking Details' : $trav_options['tour_update_admin_email_description']; } elseif ($type == 'cancel') { $subject = empty($trav_options['tour_cancel_admin_email_subject']) ? 'A booking is canceled' : $trav_options['tour_cancel_admin_email_subject']; $description = empty($trav_options['tour_cancel_admin_email_description']) ? 'Booking Details' : $trav_options['tour_cancel_admin_email_description']; } foreach ($variables as $variable) { $subject = str_replace("[" . $variable . "]", ${$variable}, $subject); $description = str_replace("[" . $variable . "]", ${$variable}, $description); } trav_send_mail($site_name, $admin_email, $admin_email, $subject, $description); } } return true; } return false; }
} ?> </dl> <hr /> <?php if (!empty($st_id)) { ?> <h4><?php echo esc_html(trav_tour_get_schedule_type_title($tour_id, $st_id)); ?> </h4> <dl class="term-description"> <?php $st_data = trav_tour_get_schedule_type_data($tour_id, $st_id); if (!empty($st_data)) { $tour_detail_fields = array('description' => __('Description', 'trav'), 'time' => __('Time', 'trav')); foreach ($tour_detail_fields as $field => $label) { ${$field} = empty($st_data["{$field}"]) ? '' : $st_data["{$field}"]; if (!empty(${$field})) { echo sprintf($dt_dd, esc_html($label), esc_html(${$field})); } } } ?> </dl> <?php } }