/** * Prepares the list of items for displaying. */ public function prepare_items() { $this->process_bulk_action(); $event_id = isset($_GET['event_id']) ? $_GET['event_id'] : 0; $items = Tribe__Events__Tickets__Tickets::get_event_attendees($event_id); $this->items = $items; $total_items = count($this->items); $per_page = $total_items; $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page, 'total_pages' => 1)); }
/** * Generates a list of attendees taking into account the Screen Options. * It's used both for the Email functionality, as for the CSV export. * * @param $event_id * * @return array */ private function _generate_filtered_attendees_list($event_id) { if (empty($this->attendees_page)) { $this->attendees_page = 'tribe_events_page_tickets-attendees'; } $columns = $this->attendees_table->get_columns(); $hidden = get_hidden_columns($this->attendees_page); // We dont want to export html inputs or private data $hidden[] = 'cb'; $hidden[] = 'provider'; // remove the hidden fields from the final list of columns $hidden = array_filter($hidden); $hidden = array_flip($hidden); $export_columns = array_diff_key($columns, $hidden); $columns_names = array_filter(array_values($export_columns)); $export_columns = array_filter(array_keys($export_columns)); // Get the data $items = Tribe__Events__Tickets__Tickets::get_event_attendees($event_id); $rows = array($columns_names); //And echo the data foreach ($items as $item) { $row = array(); foreach ($item as $key => $data) { if (in_array($key, $export_columns)) { if ($key == 'check_in' && $data == 1) { $data = __('Yes', 'tribe-events-calendar'); } $row[$key] = $data; } } $rows[] = array_values($row); } return array_filter($rows); }
/** * Returns the sum of all checked-in attendees for an event. Queries all registered providers. * * @static * * @param $event_id * * @return mixed */ public static final function get_event_checkedin_attendees_count($event_id) { $checkedin = Tribe__Events__Tickets__Tickets::get_event_attendees($event_id); return array_reduce($checkedin, array("Tribe__Events__Tickets__Tickets", "_checkedin_attendees_array_filter"), 0); }