$user_info = trav_get_current_user_info(); ?> <h1 class="no-margin skin-color"><?php printf(__('Hi %s, Welcome to %s', 'trav'), $user_info['display_name'], get_bloginfo('name')); ?> </h1> <br /> <div class="row block"> <div class="col-md-6 notifications"> <h2><?php printf(__('What\'s New On %s', 'trav'), get_bloginfo('name')); ?> </h2> <?php $list_size = 8; $available_post_types = trav_get_available_modules(); $available_post_types[] = 'post'; $args = array('posts_per_page' => $list_size, 'orderby' => 'date', 'order' => 'desc', 'post_status' => 'publish', 'post_type' => $available_post_types); $the_query = new WP_Query($args); if ($the_query->have_posts()) { while ($the_query->have_posts()) { $the_query->the_post(); $post_type = get_post_type(get_the_id()); ?> <a href="<?php the_permalink(); ?> "> <div class="icon-box style1 fourty-space"> <?php if ($post_type == 'accommodation') {
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; }