function get_number_of_sold_tickets()
 {
     $ticket_search = new TC_Tickets_Instances_Search('', '', -1, false, false, 'ticket_type_id', $this->id);
     if (is_array($ticket_search->get_results())) {
         return count($ticket_search->get_results());
     } else {
         return 0;
     }
 }
        } else {
            $message = __('You do not have required permissions for this action.', 'tc');
        }
    }
}
if (isset($_GET['page_num'])) {
    $page_num = (int) $_GET['page_num'];
} else {
    $page_num = 1;
}
if (isset($_GET['s'])) {
    $attendeesearch = $_GET['s'];
} else {
    $attendeesearch = '';
}
$wp_tickets_instances_search = new TC_Tickets_Instances_Search($attendeesearch, $page_num);
$fields = $tickets_instances->get_tickets_instances_fields();
$columns = $tickets_instances->get_columns();
?>
<div class="wrap tc_wrap">
    <h2><?php 
echo $tickets_instances->form_title;
if (isset($_GET['action']) && $_GET['action'] == 'details') {
    ?>
<a href="admin.php?page=<?php 
    echo $_GET['page'];
    ?>
" class="add-new-h2"><?php 
    _e('Back', 'tc');
    ?>
</a><?php 
 function tickets_info($echo = true)
 {
     if ($this->get_api_key_id()) {
         $event_id = $this->get_api_event();
         $ticket_search = new TC_Tickets_Instances_Search($this->keyword, $this->page_number, $this->results_per_page, false, true, 'event_id', $event_id);
         $results = $ticket_search->get_results();
         $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);
             $order = new TC_Order($ticket_instance->details->post_parent);
             if ($order->details->post_status == 'order_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 = date('Y-m-d H:i:s', $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;
                 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'] = $order->details->tc_cart_info['buyer_data']['first_name_post_meta'];
                     $r['buyer_last'] = $order->details->tc_cart_info['buyer_data']['last_name_post_meta'];
                 }
                 $r['custom_fields'] = array(array('Ticket Type', $ticket_type->details->post_title), array('Buyer Name', $order->details->tc_cart_info['buyer_data']['first_name_post_meta'] . ' ' . $order->details->tc_cart_info['buyer_data']['last_name_post_meta']), array('Buyer E-mail', $order->details->tc_cart_info['buyer_data']['email_post_meta']));
                 $r['custom_fields'] = apply_filters('tc_checkin_custom_fields', $r['custom_fields'], $result->ID, $event_id);
                 $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;
     }
 }