function event_date($atts) { global $post; extract(shortcode_atts(array('id' => ''), $atts)); if (empty($id)) { $id = $post->ID; } $event = new TC_Event($id); return $event->get_event_date(); }
function event($atts) { ob_start(); global $tc; extract(shortcode_atts(array('id' => false, 'event_table_class' => 'event_tickets tickera', 'ticket_type_title' => __('Ticket Type', 'tc'), 'price_title' => __('Price', 'tc'), 'cart_title' => __('Cart', 'tc'), 'soldout_message' => __('Tickets are sold out.', 'tc'), 'quantity_title' => __('Qty.', 'tc'), 'quantity' => false, 'type' => 'cart', 'title' => __('Add to Cart', 'tc'), 'wrapper' => ''), $atts)); $event = new TC_Event($id); $event_tickets = $event->get_event_ticket_types('publish'); if ($event->details->post_status == 'publish') { ?> <div class="tickera"> <table class="<?php echo $event_table_class; ?> "> <tr> <?php do_action('tc_event_col_title_before_ticket_title'); ?> <th><?php echo $ticket_type_title; ?> </th> <?php do_action('tc_event_col_title_before_ticket_price'); ?> <th><?php echo $price_title; ?> </th> <?php if ($quantity) { ?> <th><?php echo $quantity_title; ?> </th> <?php } ?> <?php do_action('tc_event_col_title_before_cart_title'); ?> <th><?php echo $cart_title; ?> </th> </tr> <?php foreach ($event_tickets as $event_ticket_id) { $event_ticket = new TC_Ticket($event_ticket_id); ?> <tr> <?php do_action('tc_event_col_value_before_ticket_type', $event_ticket_id); ?> <td><?php echo $event_ticket->details->post_title; ?> </td> <?php do_action('tc_event_col_value_before_ticket_price', $event_ticket_id); ?> <td><?php echo do_shortcode('[ticket_price id="' . $event_ticket->details->ID . '"]'); ?> </td> <?php do_action('tc_event_col_value_before_cart_title', $event_ticket_id); ?> <?php if ($quantity) { ?> <td><?php tc_quantity_selector($event_ticket->details->ID); ?> </td> <?php } ?> <td><?php echo do_shortcode('[ticket id="' . $event_ticket->details->ID . '" type="' . $type . '" title="' . $title . '" soldout_message="' . $soldout_message . '"]'); ?> </td> </tr> <?php } ?> </table> </div><!-- tickera --> <?php $content = ob_get_clean(); return $content; } }
function tickets_info($echo = true) { if ($this->get_api_key_id()) { global $wpdb; /* $event_id = $this->get_api_event(); $query = apply_filters( 'tc_tickets_info_query', "SELECT tcp.ID, tcp.post_type, tco.post_status FROM $wpdb->posts tcp LEFT JOIN $wpdb->posts tco ON tcp.post_parent = tco.ID WHERE tcp.post_type = 'tc_tickets_instances' AND (tco.post_status = 'order_paid') ORDER BY tco.post_date DESC LIMIT %d OFFSET %d " ); $results = $wpdb->get_results( $wpdb->prepare( $query, $this->results_per_page, (( $this->page_number - 1 ) * $this->results_per_page ) ) , OBJECT ); */ /* START OF THE NEW API */ $event_id = $this->get_api_event(); $event_ticket_types = array(); if ($event_id == 'all') { $wp_events_search = new TC_Events_Search('', '', '', 'publish'); foreach ($wp_events_search->get_results() as $event) { $event_obj = new TC_Event($event->ID); $event_ticket_types = array_merge($event_ticket_types, $event_obj->get_event_ticket_types()); } } else { $event = new TC_Event($event_id); $event_ticket_types = $event->get_event_ticket_types(); } $meta_query = array('relation' => 'OR'); foreach ($event_ticket_types as $event_ticket_type) { $meta_query[] = array('key' => 'ticket_type_id', 'value' => (string) $event_ticket_type); } $orders_args = array('posts_per_page' => -1, 'post_type' => apply_filters('tc_order_post_type_name', array('tc_orders')), 'post_status' => apply_filters('tc_paid_post_statuses', array('order_paid')), 'fields' => 'ids', 'cache_results' => false); $query = new WP_Query($orders_args); $paid_orders_ids = $query->get_posts(); $args = array('post_type' => 'tc_tickets_instances', 'post_status' => 'publish', 'meta_query' => $meta_query, 'posts_per_page' => $this->results_per_page, 'offset' => ($this->page_number - 1) * $this->results_per_page, 'post_parent__in' => $paid_orders_ids); $results = get_posts($args); /* END OF THE NEW API */ $results_count = 0; foreach ($results as $result) { $ticket_instance = new TC_Ticket_Instance($result->ID); $ticket_type = new TC_Ticket($ticket_instance->details->ticket_type_id); //$ticket_type_event_id = get_post_meta( apply_filters( 'tc_ticket_type_id', $ticket_type->details->ID ), apply_filters( 'tc_event_name_field_name', 'event_name' ), true ); $order = new TC_Order($ticket_instance->details->post_parent); $continue = false; if (in_array($order->details->post_status, apply_filters('tc_paid_post_statuses', array('order_paid')))) { $order_is_paid = true; } else { $order_is_paid = false; } $order_is_paid = apply_filters('tc_order_is_paid', $order_is_paid, $order->details->ID); if ($order_is_paid) { /* OLD */ $check_ins = get_post_meta($ticket_instance->details->ID, 'tc_checkins', true); $checkin_date = ''; if (!empty($check_ins)) { foreach ($check_ins as $check_in) { $checkin_date = tc_format_date($check_in['date_checked']); } } $r['date_checked'] = $checkin_date; $r['payment_date'] = tc_format_date(strtotime($order->details->post_modified)); //date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), strtotime( $order->details->post_modified ), false ) $r['transaction_id'] = $ticket_instance->details->ticket_code; $r['checksum'] = $ticket_instance->details->ticket_code; $buyer_full_name = isset($order->details->tc_cart_info['buyer_data']['first_name_post_meta']) ? $order->details->tc_cart_info['buyer_data']['first_name_post_meta'] . ' ' . $order->details->tc_cart_info['buyer_data']['last_name_post_meta'] : ''; $buyer_email = isset($order->details->tc_cart_info['buyer_data']['email_post_meta']) ? $order->details->tc_cart_info['buyer_data']['email_post_meta'] : ''; if (!empty($ticket_instance->details->first_name) && !empty($ticket_instance->details->last_name)) { $r['buyer_first'] = $ticket_instance->details->first_name; $r['buyer_last'] = $ticket_instance->details->last_name; } else { $r['buyer_first'] = apply_filters('tc_ticket_checkin_buyer_first_name', $order->details->tc_cart_info['buyer_data']['first_name_post_meta'], $order->details->ID); $r['buyer_last'] = apply_filters('tc_ticket_checkin_buyer_last_name', $order->details->tc_cart_info['buyer_data']['last_name_post_meta'], $order->details->ID); } $r['custom_fields'] = array(array(apply_filters('tc_ticket_checkin_custom_field_title', 'Ticket Type'), apply_filters('tc_checkout_owner_info_ticket_title', $ticket_type->details->post_title, $ticket_type->details->ID)), array(apply_filters('tc_ticket_checkin_custom_field_title', 'Buyer Name'), apply_filters('tc_ticket_checkin_buyer_full_name', $buyer_full_name, $order->details->ID)), array(apply_filters('tc_ticket_checkin_custom_field_title', 'Buyer E-mail'), apply_filters('tc_ticket_checkin_buyer_email', $buyer_email, $order->details->ID))); $r['custom_fields'] = apply_filters('tc_checkin_custom_fields', $r['custom_fields'], $result->ID, $event_id, $order, $ticket_type); $r['custom_field_count'] = count($r['custom_fields']); $r['address'] = ''; if ($r['address'] == '') { $r['address'] = 'N/A'; } $r['city'] = ''; if ($r['city'] == '') { $r['city'] = 'N/A'; } $r['state'] = ''; if ($r['state'] == '') { $r['state'] = 'N/A'; } $r['country'] = ''; if ($r['country'] == '') { $r['country'] = 'N/A'; } $rows[] = array('data' => $r); /* END OLD */ $results_count++; } } $additional['results_count'] = $results_count; $rows[] = array('additional' => $additional); echo json_encode($rows); exit; } }
$events->add_new_event(); $message = __('Event data has been saved successfully.', 'tc'); } else { $message = __('You do not have required persmissions for this action.', 'tc'); } } } if (isset($_GET['action']) && $_GET['action'] == 'edit') { $event = new TC_Event($_GET['ID']); $post_id = (int) $_GET['ID']; } if (isset($_GET['action']) && $_GET['action'] == 'delete') { if (!isset($_POST['_wpnonce'])) { check_admin_referer('delete_' . $_GET['ID']); if (current_user_can('manage_options') || current_user_can('delete_event_cap')) { $event = new TC_Event($_GET['ID']); $event->delete_event(); $message = __('Event has been successfully deleted.', 'tc'); } else { $message = __('You do not have required persmissions for this action.', 'tc'); } } } if (isset($_GET['page_num'])) { $page_num = (int) $_GET['page_num']; } else { $page_num = 1; } if (isset($_GET['s'])) { $eventssearch = $_GET['s']; } else {
function tc_get_events_and_tickets_shortcode_select_box() { ?> <select name="tc_events_tickets_shortcode_select" class="tc_events_tickets_shortcode_select"> <?php $wp_events_search = new TC_Events_Search('', '', -1); foreach ($wp_events_search->get_results() as $event) { $event_obj = new TC_Event($event->ID); $ticket_types = $event_obj->get_event_ticket_types(); ?> <option class="option_event" value="<?php echo $event_obj->details->ID; ?> "><?php echo $event_obj->details->post_title; ?> </option> <?php foreach ($ticket_types as $ticket_type) { $ticket_type_obj = new TC_Ticket($ticket_type); ?> <option class="option_ticket" value="<?php echo $ticket_type_obj->details->ID; ?> "><?php echo $event_obj->details->post_title; ?> > <?php echo $ticket_type_obj->details->post_title; ?> </option> <?php } } ?> </select> <?php }
function get_event_essentials($echo = true) { if ($this->get_api_key_id()) { $event_id = $this->get_api_event(); $event_ticket_types = array(); if ($event_id == 'all') { $wp_events_search = new TC_Events_Search('', '', '', 'publish'); foreach ($wp_events_search->get_results() as $event) { $event_obj = new TC_Event($event->ID); $event_ticket_types = array_merge($event_ticket_types, $event_obj->get_event_ticket_types()); } } else { $event = new TC_Event($event_id); $event_ticket_types = $event->get_event_ticket_types(); } $event_tickets_total = 0; $event_checkedin_tickets = 0; $meta_query = array('relation' => 'OR'); foreach ($event_ticket_types as $event_ticket_type) { $meta_query[] = array('key' => 'ticket_type_id', 'value' => (string) $event_ticket_type); } $args = array('post_type' => 'tc_tickets_instances', 'post_status' => 'any', 'posts_per_page' => -1, 'meta_query' => $meta_query); $ticket_instances = get_posts($args); $tickets_sold = 0; foreach ($ticket_instances as $ticket_instance) { $order = new TC_Order($ticket_instance->post_parent); if ($order->details->post_status == 'order_paid') { $tickets_sold++; } $checkins = get_post_meta($ticket_instance->ID, 'tc_checkins', true); if (isset($checkins) && is_array($checkins)) { $event_checkedin_tickets++; } } $event_tickets_total = $tickets_sold; $data = array('event_name' => $event_id == 'all' ? __('Multiple Events', 'tc') : stripslashes($event->details->post_title), 'event_date_time' => $event_id == 'all' ? __('N/A', 'tc') : date_i18n(get_option('date_format') . ' ' . get_option('time_format'), strtotime($event->details->event_date_time), false), 'event_location' => $event_id == 'all' ? __('N/A', 'tc') : stripslashes($event->details->event_location), 'event_logo' => $event_id == 'all' ? __('N/A', 'tc') : stripslashes($event->details->event_logo_file_url), 'event_sponsors_logos' => $event_id == 'all' ? __('N/A', 'tc') : stripslashes($event->details->sponsors_logo_file_url), 'sold_tickets' => $event_tickets_total, 'checked_tickets' => $event_checkedin_tickets, 'pass' => true); $json = json_encode(apply_filters('tc_get_event_essentials_data_output', $data, $event_id)); if ($echo) { echo $json; exit; } else { return $json; } } }