function ct_order_send_email($booking_no, $booking_pincode, $type = 'new', $subject = '', $description = '') { $order = new CT_Hotel_Order($booking_no, $booking_pincode); $order_data = $order->get_order_info(); if (!empty($order_data)) { $post_type = get_post_type($order_data['post_id']); if ('hotel' == $post_type) { return ct_hotel_generate_conf_mail($order, $type); } elseif ('tour' == $post_type) { return ct_tour_generate_conf_mail($order, $type); } } return false; }
function ct_tour_order_render_manage_page() { global $wpdb, $ct_options; if (!empty($_POST['save'])) { ct_tour_order_save_action(); return; } $order_data = array(); $tour_data = array(); $service_data = array(); if ('edit' == $_REQUEST['action']) { if (empty($_REQUEST['order_id'])) { echo "<h2>" . esc_html__("You attempted to edit an item that doesn't exist. Perhaps it was deleted?", "ct") . "</h2>"; return; } $order_id = $_REQUEST['order_id']; $post_table_name = $wpdb->prefix . 'posts'; $order = new CT_Hotel_Order($order_id); $order_data = $order->get_order_info(); $tour_data = $order->get_tours(); $service_data = $order->get_services(); if (empty($order_data)) { echo "<h2>" . esc_html__("You attempted to edit an item that doesn't exist. Perhaps it was deleted?", "ct") . "</h2>"; return; } } $default_order_data = ct_order_default_order_data(); $order_data = array_replace($default_order_data, $order_data); $site_currency_symbol = ct_get_site_currency_symbol(); ?> <div class="wrap"> <?php $page_title = 'edit' == $_REQUEST['action'] ? 'Edit Tour Order<a href="edit.php?post_type=tour&page=tour_orders&action=add" class="add-new-h2">Add New</a>' : 'Add New Tour Order'; ?> <h2><?php echo wp_kses_post($page_title); ?> </h2> <?php if (isset($_REQUEST['updated'])) { echo '<div id="message" class="updated below-h2"><p>Order saved</p></div>'; } ?> <form method="post" id="order-form" onsubmit="return manage_order_validateForm();" data-message="<?php echo esc_attr(esc_html__('Please select a tour', 'citytours')); ?> "> <input type="hidden" name="id" value="<?php echo esc_attr($order_data['id']); ?> "> <div class="row postbox"> <div class="one-half"> <h3><?php echo esc_html__('Order Detail', 'citytours'); ?> </h3> <table class="ct_admin_table ct_order_manage_table"> <tr> <th><?php echo esc_html__('Tour', 'citytours'); ?> </th> <td> <select name="post_id" id="post_id"> <option></option> <?php $args = array('post_type' => 'tour', 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC'); if (!current_user_can('manage_options')) { $args['author'] = get_current_user_id(); } $tour_query = new WP_Query($args); if ($tour_query->have_posts()) { while ($tour_query->have_posts()) { $tour_query->the_post(); $selected = ''; $id = $tour_query->post->ID; if ($order_data['post_id'] == $id) { $selected = ' selected '; } echo '<option ' . esc_attr($selected) . 'value="' . esc_attr($id) . '">' . wp_kses_post(get_the_title($id)) . '</option>'; } } wp_reset_postdata(); ?> </select> </td> </tr> <tr> <th><?php echo esc_html__('Date', 'citytours'); ?> </th> <td><input type="text" name="date_from" id="date" value="<?php echo esc_attr($order_data['date_from']); ?> "></td> </tr> <tr> <th><?php echo esc_html__('Total Adults', 'citytours'); ?> </th> <td><input type="number" name="total_adults" value="<?php echo esc_attr($order_data['total_adults']); ?> "></td> </tr> <tr> <th><?php echo esc_html__('Total Children', 'citytours'); ?> </th> <td><input type="number" name="total_kids" value="<?php echo esc_attr($order_data['total_kids']); ?> "></td> </tr> <tr> <th><?php echo esc_html__('Total Price', 'citytours'); ?> </th> <td><input type="text" name="total_price" value="<?php echo esc_attr($order_data['total_price']); ?> "> <?php echo esc_html($site_currency_symbol); ?> </td> </tr> <?php if (ct_is_multi_currency()) { ?> <tr> <th><?php echo esc_html__('User Currency', 'citytours'); ?> </th> <td> <select name="currency_code"> <?php foreach (array_filter($ct_options['site_currencies']) as $key => $content) { ?> <option value="<?php echo esc_attr($key); ?> " <?php selected($key, $order_data['currency_code']); ?> ><?php echo esc_html($key); ?> </option> <?php } ?> </select> </td> </tr> <tr> <th><?php echo esc_html__('Exchange Rate', 'citytours'); ?> </th> <td><input type="text" name="exchange_rate" value="<?php echo esc_attr($order_data['exchange_rate']); ?> "></td> </tr> <tr> <th><?php echo esc_html__('Total Price in User Currency', 'citytours'); ?> </th> <td><label> <?php if (!empty($order_data['total_price']) && !empty($order_data['exchange_rate'])) { echo esc_html($order_data['total_price'] * $order_data['exchange_rate']) . esc_html(ct_get_currency_symbol($order_data['currency_code'])); } ?> </td> </tr> <?php } ?> <tr> <th><?php echo esc_html__('Deposit Amount', 'citytours'); ?> </th> <td><input type="text" name="deposit_price" value="<?php echo esc_attr($order_data['deposit_price']); ?> "> <?php echo esc_html(ct_get_currency_symbol($order_data['currency_code'])); ?> </td> </tr> <?php if ('add' == $_REQUEST['action'] || !empty($order_data['deposit_price']) && !($order_data['deposit_price'] == 0)) { ?> <tr> <th><?php echo esc_html__('Deposit Paid', 'citytours'); ?> </th> <td> <select name="deposit_paid"> <?php $deposit_paid = array('1' => esc_html__('yes', 'citytours'), '0' => esc_html__('no', 'citytours')); ?> <?php foreach ($deposit_paid as $key => $content) { ?> <option value="<?php echo esc_attr($key); ?> " <?php selected($key, $order_data['deposit_paid']); ?> ><?php echo esc_html($content); ?> </option> <?php } ?> </select> </td> </tr> <?php if (!empty($order_data['deposit_paid'])) { $other_data = unserialize($order_data['other']); if (!empty($other_data['pp_transaction_id'])) { ?> <tr> <th><?php echo esc_html__('Paypal Payment Transaction ID', 'citytours'); ?> </th> <td><label><?php echo esc_html($other_data['pp_transaction_id']); ?> </label></td> </tr> <?php } } ?> <?php } else { ?> <input type="hidden" name="deposit_paid" value="1"> <?php } ?> <tr> <th><?php echo esc_html__('Status', 'citytours'); ?> </th> <td> <select name="status"> <?php $statuses = array('new' => esc_html__('New', 'citytours'), 'confirmed' => esc_html__('Confirmed', 'citytours'), 'cancelled' => esc_html__('Cancelled', 'citytours'), 'pending' => esc_html__('Pending', 'citytours')); if (!isset($order_data['status'])) { $order_data['status'] = 'new'; } ?> <?php foreach ($statuses as $key => $content) { ?> <option value="<?php echo esc_attr($key); ?> " <?php selected($key, $order_data['status']); ?> ><?php echo esc_html($content); ?> </option> <?php } ?> </select> </td> </tr> </table> </div> <div class="one-half"> <h3><?php echo esc_html__('Customer Infomation', 'citytours'); ?> </h3> <table class="ct_admin_table ct_order_manage_table"> <tr> <th><?php echo esc_html__('First Name', 'citytours'); ?> </th> <td><input type="text" name="first_name" value="<?php echo esc_attr($order_data['first_name']); ?> "></td> </tr> <tr> <th><?php echo esc_html__('Last Name', 'citytours'); ?> </th> <td><input type="text" name="last_name" value="<?php echo esc_attr($order_data['last_name']); ?> "></td> </tr> <tr> <th><?php echo esc_html__('Email', 'citytours'); ?> </th> <td><input type="email" name="email" value="<?php echo esc_attr($order_data['email']); ?> "></td> </tr> <tr> <th><?php echo esc_html__('Phone', 'citytours'); ?> </th> <td><input type="text" name="phone" value="<?php echo esc_attr($order_data['phone']); ?> "></td> </tr> <tr> <th><?php echo esc_html__('Street line 1', 'citytours'); ?> </th> <td><input type="text" name="address1" value="<?php echo esc_attr($order_data['address1']); ?> "></td> </tr> <tr> <th><?php echo esc_html__('Street line 2', 'citytours'); ?> </th> <td><input type="text" name="address2" value="<?php echo esc_attr($order_data['address2']); ?> "></td> </tr> <tr> <th><?php echo esc_html__('City', 'citytours'); ?> </th> <td><input type="text" name="city" value="<?php echo esc_attr($order_data['city']); ?> "></td> </tr> <tr> <th><?php echo esc_html__('State', 'citytours'); ?> </th> <td><input type="text" name="state" value="<?php echo esc_attr($order_data['state']); ?> "></td> </tr> <tr> <th><?php echo esc_html__('Postal Code', 'citytours'); ?> </th> <td><input type="text" name="zip" value="<?php echo esc_attr($order_data['zip']); ?> "></td> </tr> <tr> <th><?php echo esc_html__('Country', 'citytours'); ?> </th> <td><input type="text" name="country" value="<?php echo esc_attr($order_data['country']); ?> "></td> </tr> <tr> <th><?php echo esc_html__('Special Requirements', 'citytours'); ?> </th> <td><textarea name="special_requirements"><?php echo esc_textarea(stripslashes($order_data['special_requirements'])); ?> </textarea></td> </tr> <tr> <th><?php echo esc_html__('Booking No', 'citytours'); ?> </th> <td><input type="text" name="booking_no" value="<?php echo esc_attr($order_data['booking_no']); ?> "></td> </tr> <tr> <th><?php echo esc_html__('Pin Code', 'citytours'); ?> </th> <td><input type="text" name="pin_code" value="<?php echo esc_attr($order_data['pin_code']); ?> "></td> </tr> </table> </div> </div> <input type="hidden" name="tour_booking_id" value="<?php echo esc_attr(empty($tour_data) || empty($tour_data['id']) ? '' : $tour_data['id']); ?> "> <div class="row postbox ct-order-services"> <h3><?php echo esc_html__('Order Services Detail', 'citytours'); ?> </h3> <div class="services-wrapper"> <table class="services-table"><tbody class="clone-wrapper"> <tr class="rwmb-field"> <th><?php echo esc_html__('Title', 'citytours'); ?> </th> <th><?php echo esc_html__('Qty', 'citytours'); ?> </th> <th><?php echo esc_html__('Total Price', 'citytours'); ?> </th> <th> </th> </tr> <?php if (empty($service_data)) { ?> <tr class="clone-field"> <td> <input type="hidden" name="service_booking_id[0]" value=""> <select name="service_id[0]" class="service_id_select"> <?php echo ct_get_service_list($order_data['post_id']); ?> </select> </td> <td><input type="text" name="service_qty[0]"></td> <td><input type="text" name="service_price[0]"></td> <td><a href="#" class="rwmb-button button remove-clone" style="display: none;">-</a></td> </tr> <?php } else { ?> <?php foreach ($service_data as $key => $service) { ?> <tr class="clone-field"> <td> <input type="hidden" name="service_booking_id[<?php echo esc_attr($key); ?> ]" value="<?php echo esc_attr($service['id']); ?> "> <select name="service_id[<?php echo esc_attr($key); ?> ]" class="service_id_select"> <?php echo ct_get_service_list($order_data['post_id'], $service['add_service_id']); ?> </select> </td> <td><input type="text" name="service_qty[<?php echo esc_attr($key); ?> ]" value="<?php echo esc_attr($service['qty']); ?> "></td> <td><input type="text" name="service_price[<?php echo esc_attr($key); ?> ]" value="<?php echo esc_attr($service['total_price']); ?> "></td> <td><a href="#" class="rwmb-button button remove-clone">-</a></td> </tr> <?php } ?> <?php } ?> <tr><td colspan="5"><a href="#" class="rwmb-button button-primary add-clone">+</a></td></tr> </tbody></table> </div> </div> <input type="submit" class="button-primary button_save_order" name="save" value="Save order"> <a href="edit.php?post_type=tour&page=tour_orders" class="button-secondary">Cancel</a> <?php wp_nonce_field('ct_manage_orders', 'order_save'); ?> </form> </div> <?php if (!empty($ct_options['vld_credit_card']) && !empty($ct_options['cc_off_charge']) && !empty($order_data['other'])) { $cc_fields = array('cc_type' => 'CREDIT CARD TYPE', 'cc_holder_name' => 'CARD HOLDER NAME', 'cc_number' => 'CARD NUMBER', 'cc_cid' => 'CARD IDENTIFICATION NUMBER', 'cc_exp_year' => 'EXPIRATION YEAR', 'cc_exp_month' => 'EXPIRATION MONTH'); $cc_infos = unserialize($order_data['other']); echo '<style>.cc_table{background:#fff;margin-top:30px;}.cc_table td{padding:10px;}.cc_table,.cc_table tr,.cc_table td{border:1px solid #000; border-collapse: collapse;}</style>'; echo '<div style="clear:both"></div><h3>Credit Card Info</h3><table class="cc_table"><tbody>'; foreach ($cc_fields as $key => $label) { if (!empty($cc_infos[$key])) { echo '<tr><td><label>' . $label . '</label></td><td>' . $cc_infos[$key] . '</td></tr>'; } } echo '</tbody></table>'; } }
<?php if (!isset($_REQUEST['booking_no']) || !isset($_REQUEST['pin_code'])) { do_action('ct_hotel_thankyou_wrong_data'); exit; } global $wpdb, $ct_options; $order = new CT_Hotel_Order($_REQUEST['booking_no'], $_REQUEST['pin_code']); if (!($order_data = $order->get_order_info())) { do_action('ct_hotel_thankyou_wrong_data'); exit; } $deposit_rate = get_post_meta($order_data['post_id'], '_hotel_security_deposit', true); $deposit_rate = empty($deposit_rate) ? 0 : $deposit_rate; if (empty($order_data['deposit_paid'])) { // init payment variables if ($deposit_rate < 100) { $ItemName = sprintf(esc_html__('Deposit(%d%%) for your order %d', 'citytours'), $deposit_rate, $order_data['id']); } else { $ItemName = sprintf(esc_html__('Deposit for your order %d', 'citytours'), $order_data['id']); } $payment_data = array(); $payment_data['item_name'] = $ItemName; $payment_data['item_number'] = $order_data['id']; $payment_data['item_desc'] = esc_html__('Check In', 'citytours') . ' ' . $order_data['date_from'] . ' ' . esc_html__('Check Out', 'citytours') . ' ' . $order_data['date_to']; $payment_data['item_qty'] = 1; $payment_data['item_price'] = $order_data['deposit_price']; $payment_data['item_total_price'] = $payment_data['item_qty'] * $payment_data['item_price']; $payment_data['grand_total'] = $payment_data['item_total_price']; $payment_data['currency'] = strtoupper($order_data['currency_code']); $payment_data['return_url'] = ct_get_current_page_url() . '?booking_no=' . $order_data['booking_no'] . '&pin_code=' . $order_data['pin_code'] . '&payment=success';
function ct_ajax_submit_review() { global $wpdb; $result_json = array('success' => 0, 'result' => '', 'title' => ''); if (!isset($_POST['_wpnonce']) || !wp_verify_nonce($_POST['_wpnonce'], 'post-' . $_POST['post_id'])) { $result_json['success'] = 0; $result_json['result'] = esc_html__('Sorry, your nonce did not verify.', 'citytours'); wp_send_json($result_json); } $fields = array('post_id', 'booking_no', 'pin_code', 'review_text', 'review_rating'); //validation $data = array(); foreach ($fields as $field) { $data[$field] = isset($_POST[$field]) ? sanitize_text_field($_POST[$field]) : ''; } $order = new CT_Hotel_Order($data['booking_no'], $data['pin_code']); if (!($order_data = $order->get_order_info())) { $result_json['success'] = 0; $result_json['result'] = esc_html__('Wrong Booking Number and Pin Code.', 'citytours'); wp_send_json($result_json); } if (!is_array($order_data) || $order_data['status'] == 'cancelled') { $result_json['success'] = 0; $result_json['title'] = esc_html__('Sorry, You cannot leave a rating.', 'citytours'); $result_json['result'] = esc_html__('You cancelled your booking, so cannot leave a rating.', 'citytours'); wp_send_json($result_json); } if (empty($order_data['date_to']) && ct_strtotime($order_data['date_from']) > ct_strtotime(date("Y-m-d")) || ct_strtotime($order_data['date_to']) > ct_strtotime(date("Y-m-d"))) { $result_json['success'] = 0; $result_json['title'] = esc_html__('Sorry, You cannot leave a rating before travel.', 'citytours'); $result_json['result'] = esc_html__('You can leave a review after travel.', 'citytours'); wp_send_json($result_json); } $data['post_id'] = $order_data['post_id']; $data['reviewer_name'] = $order_data['first_name'] . ' ' . $order_data['last_name']; $data['reviewer_email'] = $order_data['email']; $data['reviewer_ip'] = $_SERVER['REMOTE_ADDR']; $data['review_rating_detail'] = serialize($_POST['review_rating_detail']); $data['review_rating'] = array_sum($_POST['review_rating_detail']) / count($_POST['review_rating_detail']); $data['date'] = date('Y-m-d H:i:s'); $data['status'] = 'pending'; if (is_user_logged_in()) { $data['user_id'] = get_current_user_id(); } if (!($review_data = $wpdb->get_row($wpdb->prepare('SELECT * FROM ' . CT_REVIEWS_TABLE . ' WHERE booking_no=%d AND pin_code=%d', $data['booking_no'], $data['pin_code']), ARRAY_A))) { if ($wpdb->insert(CT_REVIEWS_TABLE, $data)) { $result_json['success'] = 1; $result_json['title'] = esc_html__('Thank you! Your review has been submitted successfully.', 'citytours'); $result_json['result'] = esc_html__('Your review has been submitted.', 'citytours'); } else { $result_json['success'] = 0; $result_json['title'] = esc_html__('Sorry, An error occurred while add review.', 'citytours'); $result_json['result'] = esc_html__('Please try again after a while.', 'citytours'); } } else { if ($wpdb->update(CT_REVIEWS_TABLE, $data, array('booking_no' => $data['booking_no'], 'pin_code' => $data['pin_code']))) { $result_json['success'] = 1; $result_json['title'] = esc_html__('Thank you! Your review has been submitted successfully.', 'citytours'); $result_json['result'] = esc_html__('You can change your review anytime.', 'citytours'); ct_review_calculate_rating($data['post_id']); } else { $result_json['success'] = 0; $result_json['title'] = esc_html__('Sorry, An error occurred while add review.', 'citytours'); $result_json['result'] = esc_html__('Please try again after a while.', 'citytours'); } } wp_send_json($result_json); }
<style> .invoice-title h2, .invoice-title h3 {display: inline-block;} .table > tbody > tr > .no-line {border-top: none;} .table > thead > tr > .no-line {border-bottom: none;} .table > tbody > tr > .thick-line {border-top: 2px solid;} </style> <?php wp_head(); ?> </head> <body> <div class="container"> <?php if (!empty($_REQUEST['booking_no']) && !empty($_REQUEST['pin_code'])) { $order = new CT_Hotel_Order($_REQUEST['booking_no'], $_REQUEST['pin_code']); if ($order_info = $order->get_order_info()) { $post_type = get_post_type($order_info['post_id']); $deposit_rate = 0; if ('tour' == $post_type) { $deposit_rate = get_post_meta($order_info['post_id'], '_tour_security_deposit', true); } elseif ('hotel' == $post_type) { $deposit_rate = get_post_meta($order_info['post_id'], '_hotel_security_deposit', true); } ?> <div class="row"> <div class="col-xs-12"> <div class="invoice-title"> <h2><?php echo esc_html__('Invoice', 'citytours');