Exemplo n.º 1
0
 function trav_acc_send_confirmation_email($booking_no, $booking_pincode, $type = 'new', $subject = '', $description = '')
 {
     global $wpdb, $logo_url, $trav_options;
     $booking_data = trav_acc_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);
         $acc_book_conf_url = trav_acc_get_book_conf_url();
         $booking_data['accommodation_id'] = trav_acc_clang_id($booking_data['accommodation_id']);
         $booking_data['room_type_id'] = trav_room_clang_id($booking_data['room_type_id']);
         // accommodation info
         $accommodation_name = get_the_title($booking_data['accommodation_id']);
         $accommodation_url = esc_url(trav_get_permalink_clang($booking_data['accommodation_id']));
         $accommodation_thumbnail = get_the_post_thumbnail($booking_data['accommodation_id'], 'list-thumb');
         $accommodation_address = get_post_meta($booking_data['accommodation_id'], 'trav_accommodation_address', true);
         $accommodation_city = trav_acc_get_city($booking_data['accommodation_id']);
         $accommodation_country = trav_acc_get_country($booking_data['accommodation_id']);
         $accommodation_phone = get_post_meta($booking_data['accommodation_id'], 'trav_accommodation_phone', true);
         $accommodation_email = get_post_meta($booking_data['accommodation_id'], 'trav_accommodation_email', true);
         $accommodation_room_name = esc_html(get_the_title($booking_data['room_type_id']));
         if (empty($accommodation_address)) {
             $accommodation_address = $accommodation_city . ' ' . $accommodation_country;
         }
         $check_in = get_post_meta($booking_data['accommodation_id'], 'trav_accommodation_check_in', true);
         $check_out = get_post_meta($booking_data['accommodation_id'], 'trav_accommodation_check_out', true);
         $check_in_time = empty($check_in) ? $booking_data['date_from'] : $booking_data['date_from'] . ' ' . $check_in;
         $check_out_time = empty($check_out) ? $booking_data['date_to'] : $booking_data['date_to'] . ' ' . $check_out;
         // booking info
         $booking_no = $booking_data['booking_no'];
         $booking_pincode = $booking_data['pin_code'];
         $date_from = new DateTime($booking_data['date_from']);
         $date_to = new DateTime($booking_data['date_to']);
         $number1 = $date_from->format('U');
         $number2 = $date_to->format('U');
         $booking_nights = ($number2 - $number1) / (3600 * 24);
         $booking_checkin_time = date('l, F, j, Y', trav_strtotime($booking_data['date_from']));
         $booking_checkout_time = date('l, F, j, Y', trav_strtotime($booking_data['date_to']));
         $booking_rooms = $booking_data['rooms'];
         $booking_adults = $booking_data['adults'];
         $booking_kids = $booking_data['kids'];
         $booking_room_price = esc_html(trav_get_price_field($booking_data['room_price'] * $booking_data['exchange_rate'], $booking_data['currency_code'], 0));
         $booking_tax = esc_html(trav_get_price_field($booking_data['tax'] * $booking_data['exchange_rate'], $booking_data['currency_code'], 0));
         $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']), $acc_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', 'accommodation_name', 'accommodation_url', 'accommodation_thumbnail', 'accommodation_country', 'accommodation_city', 'accommodation_address', 'accommodation_phone', 'accommodation_email', 'accommodation_room_name', 'booking_no', 'booking_pincode', 'booking_nights', 'booking_checkin_time', 'booking_checkout_time', 'booking_rooms', 'booking_adults', 'booking_kids', 'booking_room_price', 'booking_tax', '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['acc_confirm_email_subject']) ? 'Booking Confirmation Email Subject' : $trav_options['acc_confirm_email_subject'];
             } elseif ($type == 'update') {
                 $subject = empty($trav_options['acc_update_email_subject']) ? 'Booking Updated Email Subject' : $trav_options['acc_update_email_subject'];
             } elseif ($type == 'cancel') {
                 $subject = empty($trav_options['acc_cancel_email_subject']) ? 'Booking Canceled Email Subject' : $trav_options['acc_cancel_email_subject'];
             }
         }
         if (empty($description)) {
             if ($type == 'new') {
                 $description = empty($trav_options['acc_confirm_email_description']) ? 'Booking Confirmation Email Description' : $trav_options['acc_confirm_email_description'];
             } elseif ($type == 'update') {
                 $description = empty($trav_options['acc_update_email_description']) ? 'Booking Confirmation Email Description' : $trav_options['acc_update_email_description'];
             } elseif ($type == 'cancel') {
                 $description = empty($trav_options['acc_cancel_email_description']) ? 'Booking Confirmation Email Description' : $trav_options['acc_cancel_email_description'];
             }
         }
         foreach ($variables as $variable) {
             $subject = str_replace("[" . $variable . "]", ${$variable}, $subject);
             $description = str_replace("[" . $variable . "]", ${$variable}, $description);
         }
         if (!empty($trav_options['acc_confirm_email_ical']) && $type == 'new') {
             $mail_sent = trav_send_ical_event($site_name, $admin_email, $customer_first_name . ' ' . $customer_last_name, $customer_email, $check_in_time, $check_out_time, $subject, $description, $accommodation_address);
         } else {
             $mail_sent = trav_send_mail($site_name, $admin_email, $customer_email, $subject, $description);
         }
         /* mailing function to business owner */
         $bowner_address = '';
         if (!empty($trav_options['acc_booked_notify_bowner'])) {
             if ($type == 'new') {
                 $subject = empty($trav_options['acc_bowner_email_subject']) ? 'You received a booking' : $trav_options['acc_bowner_email_subject'];
                 $description = empty($trav_options['acc_bowner_email_description']) ? 'Booking Details' : $trav_options['acc_bowner_email_description'];
             } elseif ($type == 'update') {
                 $subject = empty($trav_options['acc_update_bowner_email_subject']) ? 'A booking is updated' : $trav_options['acc_update_bowner_email_subject'];
                 $description = empty($trav_options['acc_update_bowner_email_description']) ? 'Booking Details' : $trav_options['acc_update_bowner_email_description'];
             } elseif ($type == 'cancel') {
                 $subject = empty($trav_options['acc_cancel_bowner_email_subject']) ? 'A booking is canceled' : $trav_options['acc_cancel_bowner_email_subject'];
                 $description = empty($trav_options['acc_cancel_bowner_email_description']) ? 'Booking Details' : $trav_options['acc_cancel_bowner_email_description'];
             }
             foreach ($variables as $variable) {
                 $subject = str_replace("[" . $variable . "]", ${$variable}, $subject);
                 $description = str_replace("[" . $variable . "]", ${$variable}, $description);
             }
             if (!empty($accommodation_email)) {
                 $bowner_address = $accommodation_email;
             } else {
                 $post_author_id = get_post_field('post_author', $booking_data['accommodation_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['acc_booked_notify_admin'])) {
             if ($bowner_address != $admin_email) {
                 if ($type == 'new') {
                     $subject = empty($trav_options['acc_admin_email_subject']) ? 'You received a booking' : $trav_options['acc_admin_email_subject'];
                     $description = empty($trav_options['acc_admin_email_description']) ? 'Booking Details' : $trav_options['acc_admin_email_description'];
                 } elseif ($type == 'update') {
                     $subject = empty($trav_options['acc_update_admin_email_subject']) ? 'A booking is updated' : $trav_options['acc_update_admin_email_subject'];
                     $description = empty($trav_options['acc_update_admin_email_description']) ? 'Booking Details' : $trav_options['acc_update_admin_email_description'];
                 } elseif ($type == 'cancel') {
                     $subject = empty($trav_options['acc_cancel_admin_email_subject']) ? 'A booking is canceled' : $trav_options['acc_cancel_admin_email_subject'];
                     $description = empty($trav_options['acc_cancel_admin_email_description']) ? 'Booking Details' : $trav_options['acc_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;
 }
Exemplo n.º 2
0
?>
	</div>
	<div class="col-md-6">
		<h2><?php 
echo __('Recent Activity', 'trav');
?>
</h2>
		<div class="recent-activity">
			<ul>

				<?php 
$recent_activity = get_user_meta($user_id, 'recent_activity', true);
if (!empty($recent_activity)) {
    $recent_activity_array = unserialize($recent_activity);
    foreach ($recent_activity_array as $post_id) {
        $post_id = trav_acc_clang_id($post_id);
        $post_type = get_post_type($post_id);
        if (!in_array($post_type, $available_post_types)) {
            continue;
        }
        if ($post_type == 'accommodation') {
            $_country = get_post_meta($post_id, 'trav_accommodation_country', true);
            if (!empty($_country)) {
                if ($country_obj = get_term_by('id', $_country, 'location')) {
                    $_country = __($country_obj->name, 'trav');
                }
            }
            $_city = get_post_meta($post_id, 'trav_accommodation_city', true);
            if (!empty($_city)) {
                if ($user_info['city_obj'] = get_term_by('id', $_city, 'location')) {
                    $_city = __($user_info['city_obj']->name, 'trav');
Exemplo n.º 3
0
<?php

/*
 * Accommodation List
 */
global $acc_list, $current_view, $before_article, $after_article;
foreach ($acc_list as $acc_id) {
    $acc_id = trav_acc_clang_id($acc_id);
    $avg_price = get_post_meta($acc_id, 'trav_accommodation_avg_price', true);
    $review = get_post_meta($acc_id, 'review', true);
    $review = !empty($review) ? round($review, 1) : 0;
    $brief = get_post_meta($acc_id, 'trav_accommodation_brief', true);
    $discount_rate = get_post_meta($acc_id, 'trav_accommodation_discount_rate', true);
    if (empty($brief)) {
        $brief = apply_filters('the_content', get_post_field('post_content', $acc_id));
        $brief = wp_trim_words($brief, 20, '');
    }
    $loc = get_post_meta($acc_id, 'trav_accommodation_loc', true);
    $rooms = isset($_REQUEST['rooms']) && is_numeric($_REQUEST['rooms']) ? sanitize_text_field($_REQUEST['rooms']) : 1;
    $adults = isset($_REQUEST['adults']) && is_numeric($_REQUEST['adults']) ? sanitize_text_field($_REQUEST['adults']) : 1;
    $kids = isset($_REQUEST['kids']) && is_numeric($_REQUEST['kids']) ? sanitize_text_field($_REQUEST['kids']) : 0;
    $child_ages = isset($_REQUEST['child_ages']) && is_array($_REQUEST['child_ages']) ? $_REQUEST['child_ages'] : array();
    $date_from = isset($_REQUEST['date_from']) ? trav_sanitize_date($_REQUEST['date_from']) : '';
    $date_to = isset($_REQUEST['date_to']) ? trav_sanitize_date($_REQUEST['date_to']) : '';
    if (trav_strtotime($date_from) >= trav_strtotime($date_to)) {
        $date_from = '';
        $date_to = '';
    }
    $query_args = array('adults' => $adults, 'kids' => $kids, 'rooms' => $rooms, 'date_from' => $date_from, 'date_to' => $date_to);
    if (!empty($child_ages)) {
        $query_args['child_ages'] = $child_ages;
Exemplo n.º 4
0
    function trav_get_user_booking_list($user_id, $status = 1, $sortby = 'created', $order = 'desc')
    {
        global $wpdb, $trav_options;
        $sql = '';
        $order = $order == 'desc' ? 'desc' : 'asc';
        $order_by = ' ORDER BY ' . esc_sql($sortby) . ' ' . $order;
        $where = ' WHERE 1=1';
        $where .= ' AND user_id=' . esc_sql($user_id);
        if ($status != -1) {
            $where .= ' AND status=' . esc_sql($status);
        }
        // $sql = $wpdb->prepare( 'SELECT * FROM ' . TRAV_ACCOMMODATION_BOOKINGS_TABLE . $where . $order_by, $user_id );
        $available_modules = trav_get_available_modules();
        $sqls = array();
        if (in_array('accommodation', $available_modules)) {
            $sqls[] = "SELECT 'accommodation' AS post_type, booking_no, pin_code, total_price, created, status, accommodation_id AS post_id, date_from AS event_date, adults, rooms AS tickets FROM " . TRAV_ACCOMMODATION_BOOKINGS_TABLE . $where;
        }
        if (in_array('tour', $available_modules)) {
            $sqls[] = "SELECT 'tour' AS post_type, booking_no, pin_code, total_price, created, status, tour_id AS post_id, tour_date AS event_date, adults, NULL AS tickets FROM " . TRAV_TOUR_BOOKINGS_TABLE . $where;
        }
        $sql = implode(' UNION ALL ', $sqls);
        $sql .= $order_by;
        //return $sql;
        $booking_list = $wpdb->get_results($sql);
        if (empty($booking_list)) {
            return __('You don\'t have any booked trips yet.', 'trav');
        }
        // if empty return false
        $acc_book_conf_url = trav_acc_get_book_conf_url();
        $tour_book_conf_url = trav_tour_get_book_conf_url();
        $html = '';
        foreach ($booking_list as $booking_data) {
            $class = '';
            $label = 'UPCOMMING';
            if ($booking_data->status == 0) {
                $class = ' cancelled';
                $label = 'CANCELLED';
            }
            if ($booking_data->status == 2) {
                $class = ' completed';
                $label = 'COMPLETED';
            }
            // if ( ( $booking_data->status == 1 ) && ( trav_strtotime( $booking_data->event_date ) < trav_strtotime(date('Y-m-d')) ) ) { $class = ' completed'; $label = 'COMPLETED'; }
            $html .= '<div class="booking-info clearfix' . $class . '">';
            $html .= '<div class="date">
							<label class="month">' . date('M', trav_strtotime($booking_data->event_date)) . '</label>
							<label class="date">' . date('d', trav_strtotime($booking_data->event_date)) . '</label>
							<label class="day">' . date('D', trav_strtotime($booking_data->event_date)) . '</label>
						</div>';
            $conf_url = '';
            $icon_class = '';
            if ('accommodation' == $booking_data->post_type) {
                $conf_url = $acc_book_conf_url;
                $icon_class = 'soap-icon-hotel blue-color';
            } elseif ('tour' == $booking_data->post_type) {
                $conf_url = $tour_book_conf_url;
                $icon_class = 'soap-icon-beach yellow-color';
            }
            $url = empty($conf_url) ? '' : add_query_arg(array('booking_no' => $booking_data->booking_no, 'pin_code' => $booking_data->pin_code), $conf_url);
            $html .= '<h4 class="box-title">';
            $html .= '<i class="icon circle ' . $icon_class . '"></i>';
            $html .= '<a href="' . esc_url($url) . '">' . get_the_title(trav_acc_clang_id($booking_data->post_id)) . '</a>';
            $html .= '<small>';
            if ('accommodation' == $booking_data->post_type) {
                $html .= $booking_data->tickets . __('rooms', 'trav') . ' ';
            }
            $html .= $booking_data->adults . __('adults', 'trav') . '</small></h4>';
            $html .= '<button class="btn-mini status">' . __($label, 'trav') . '</button>';
            $html .= '<dl class="info">';
            $html .= '<dt>' . __('booked on', 'trav') . '</dt>';
            $html .= '<dd>' . date('l, M, j, Y', trav_strtotime($booking_data->created)) . '</dd>';
            $html .= '</dl>';
            $html .= '<dl class="info">';
            $html .= '<dt>' . __('BOOKING NO', 'trav') . '</dt><dd>' . $booking_data->booking_no . '</dd>';
            $html .= '<dt>' . __('PIN CODE', 'trav') . '</dt><dd>' . $booking_data->pin_code . '</dd>';
            $html .= '</dl>';
            $html .= '</div>';
        }
        return $html;
    }
<?php

/**
 * Accommodation Booking Confirmation Template
 */
global $wpdb;
global $booking_data, $acc_id, $room_type_id, $deposit_rate, $date_from, $date_to;
if (!isset($_REQUEST['booking_no']) || !isset($_REQUEST['pin_code'])) {
    do_action('trav_acc_conf_wrong_data');
    exit;
}
if (!($booking_data = trav_acc_get_booking_data($_REQUEST['booking_no'], $_REQUEST['pin_code']))) {
    do_action('trav_acc_conf_wrong_data');
    exit;
}
$acc_id = trav_acc_clang_id($booking_data['accommodation_id']);
$room_type_id = trav_room_clang_id($booking_data['room_type_id']);
$deposit_rate = get_post_meta($acc_id, 'trav_accommodation_security_deposit', true);
$deposit_rate = empty($deposit_rate) ? 0 : $deposit_rate;
$date_from = trav_tophptime($booking_data['date_from']);
$date_to = trav_tophptime($booking_data['date_to']);
if (!is_array($booking_data['child_ages'])) {
    $booking_data['child_ages'] = unserialize($booking_data['child_ages']);
}
$query_args = array('date_from' => $date_from, 'date_to' => $date_to, 'rooms' => $booking_data['rooms'], 'adults' => $booking_data['adults'], 'kids' => $booking_data['kids'], 'child_ages' => $booking_data['child_ages'], 'edit_booking_no' => $booking_data['booking_no'], 'pin_code' => $booking_data['pin_code']);
// if deposit is required and it is not paid process payment
if (!empty($deposit_rate) && empty($booking_data['deposit_paid'])) {
    // init payment variables
    $ItemName = '';
    if ($deposit_rate < 100) {
        $ItemName = sprintf(__('Deposit(%d%%) for ', 'trav'), $deposit_rate);