예제 #1
0
 /**
  * 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';
     // Get the data
     $items = Tribe__Tickets__Tickets::get_event_attendees($event_id);
     // if there are attendees, hide any column that the attendee array doesn't contain
     if (count($items)) {
         $hidden = array_merge($hidden, array_diff(array_keys($columns), array_keys($items[0])));
     }
     // 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));
     $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 = esc_html__('Yes', 'event-tickets');
                 }
                 $row[$key] = $data;
             }
         }
         $rows[] = array_values($row);
     }
     return array_filter($rows);
 }