コード例 #1
0
 protected function calculate_totals()
 {
     $all_attendees = Tribe__Tickets__Tickets::get_event_attendees($this->event_id);
     $total_attendees = count($all_attendees);
     $this->total_checked_in = Tribe__Tickets__Tickets::get_event_checkedin_attendees_count($this->event_id);
     $this->total_not_checked_in = $total_attendees - $this->total_checked_in;
     $this->total_deleted = Tribe__Tickets__Attendance::instance($this->event_id)->get_deleted_attendees_count();
 }
コード例 #2
0
 /**
  * Prepares the list of items for displaying.
  */
 public function prepare_items()
 {
     $this->process_actions();
     $event_id = isset($_GET['event_id']) ? $_GET['event_id'] : 0;
     $items = Tribe__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));
 }
コード例 #3
0
ファイル: Attendees_List.php プロジェクト: TakenCdosG/chefs
 /**
  * Returns an Array ready for printing of the Attendees List
  *
  * @param  int|WP_Post  $event
  * @param  int $limit
  * @return array
  */
 public function get_attendees($event, $limit = 20)
 {
     $limit = apply_filters('tribe_tickets_plus_attendees_list_limit', $limit);
     $attendees = Tribe__Tickets__Tickets::get_event_attendees($event);
     $total = count($attendees);
     $has_broken = false;
     $listing = array();
     $emails = array();
     foreach ($attendees as $key => $attendee) {
         $html = '';
         // Only Check for optout when It's there
         if (isset($attendee['optout']) && $attendee['optout'] !== false) {
             continue;
         }
         // Skip when we already have another email like this one
         if (in_array($attendee['purchaser_email'], $emails)) {
             continue;
         }
         if (is_numeric($limit) && $limit < $key + 1) {
             $has_broken = true;
         }
         if ($has_broken) {
             $html .= '<span class="tribe-attendees-list-hidden">';
         } else {
             $html .= '<span class="tribe-attendees-list-shown">';
         }
         $html .= get_avatar($attendee['purchaser_email'], 40, '', $attendee['purchaser_name']);
         $html .= '</span>';
         $emails[] = $attendee['purchaser_email'];
         $listing[$attendee['attendee_id']] = $html;
     }
     if ($has_broken) {
         $listing['show-more'] = '<a href="#show-all-attendees" data-offset="' . esc_attr($limit) . '" title="' . esc_attr__('Load all attendees', 'event-tickets-plus') . '" class="tribe-attendees-list-showall avatar">' . get_avatar('', 40, '', esc_attr__('Load all attendees', 'event-tickets-plus')) . '</a>';
     }
     return $listing;
 }
コード例 #4
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)
 {
     /**
      * Fire immediately prior to the generation of a filtered (exportable) attendee list.
      *
      * @param int $event_id
      */
     do_action('tribe_events_tickets_generate_filtered_attendees_list', $event_id);
     if (empty($this->attendees_page)) {
         $this->attendees_page = 'tribe_events_page_tickets-attendees';
     }
     $items = Tribe__Tickets__Tickets::get_event_attendees($event_id);
     $columns = get_column_headers(get_current_screen());
     $hidden = get_hidden_columns($this->attendees_page);
     // We dont want to export html inputs or private data
     $hidden[] = 'cb';
     $hidden[] = 'provider';
     $hidden = array_flip($hidden);
     $export_columns = array_diff_key($columns, $hidden);
     // Add the export column headers as the first row
     $rows = array(array_values($export_columns));
     foreach ($items as $single_item) {
         // Fresh row!
         $row = array();
         foreach ($export_columns as $column_id => $column_name) {
             // If additional columns have been added to the attendee list table we can obtain the
             // values by calling the table object's column_default() method - any other values
             // should simply be passed back unmodified
             $row[$column_id] = $this->attendees_table->column_default($single_item, $column_id);
             // Special handling for the check_in column
             if ('check_in' === $column_id && 1 == $single_item[$column_id]) {
                 $row[$column_id] = esc_html__('Yes', 'event-tickets');
             }
         }
         $rows[] = array_values($row);
     }
     return array_filter($rows);
 }
コード例 #5
0
 /**
  * Fetches from the Cached attendees list the ones that are relevant for this user and event
  * Important to note that this method will bring the attendees from RSVP
  *
  * @param  int       $event_id     The Event ID it relates to
  * @param  int|null  $user_id      An Optional User ID
  * @return array                   Array with the RSVP attendees
  */
 public function get_event_rsvp_attendees($event_id, $user_id = null)
 {
     $all_attendees = Tribe__Tickets__Tickets::get_event_attendees($event_id);
     $attendees = array();
     foreach ($all_attendees as $key => $attendee) {
         // Skip Non RSVP
         if ('rsvp' !== $attendee['provider_slug']) {
             continue;
         }
         // If we have a user_id then test it and ignore the ones that don't have it
         if (!is_null($user_id)) {
             if (empty($attendee['user_id']) || $attendee['user_id'] != $user_id) {
                 continue;
             }
         }
         $attendees[] = $attendee;
     }
     return $attendees;
 }
コード例 #6
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);
 }
コード例 #7
0
ファイル: Tickets_View.php プロジェクト: TakenCdosG/chefs
 /**
  * Fetches from the Cached attendees list the ones that are relevant for this user and event
  * Important to note that this method will bring the attendees organized by order id
  *
  * @param  int       $event_id      The Event ID it relates to
  * @param  int|null  $user_id       An Optional User ID
  * @param  boolean   $include_rsvp  If this should include RSVP, which by default is false
  * @return array                    List of Attendees grouped by order id
  */
 public function get_event_attendees_by_order($event_id, $user_id = null, $include_rsvp = false)
 {
     $attendees = Tribe__Tickets__Tickets::get_event_attendees($event_id);
     $orders = array();
     foreach ($attendees as $key => $attendee) {
         // Ignore RSVP if we don't tell it specifically
         if ('rsvp' === $attendee['provider_slug'] && !$include_rsvp) {
             continue;
         }
         // If we have a user_id then test it and ignore the ones that don't have it
         if (!is_null($user_id)) {
             if (empty($attendee['user_id']) || $attendee['user_id'] != $user_id) {
                 continue;
             }
         }
         $orders[(int) $attendee['order_id']][] = $attendee;
     }
     return $orders;
 }
コード例 #8
0
 /**
  * When a ticket type is moved, the tickets need to move with it. This callback takes
  * care of that process.
  *
  * @see Tribe__Tickets__Admin__Move_Ticket_Types::move_ticket_type()
  *
  * @param int $ticket_type_id
  * @param int $destination_post_id
  * @param int $src_post_id
  * @param int $instigator_id
  */
 public function move_all_tickets_for_type($ticket_type_id, $destination_post_id, $src_post_id, $instigator_id)
 {
     foreach (Tribe__Tickets__Tickets::get_event_attendees($src_post_id) as $issued_ticket) {
         // We're only interested in tickets of the specified type
         if ((int) $ticket_type_id !== (int) $issued_ticket['product_id']) {
             continue;
         }
         if (!class_exists($issued_ticket['provider'])) {
             continue;
         }
         $issued_ticket_id = $issued_ticket['attendee_id'];
         // Move the ticket to the destination post
         $event_key = constant($issued_ticket['provider'] . '::ATTENDEE_EVENT_KEY');
         update_post_meta($issued_ticket_id, $event_key, $destination_post_id);
         // Maintain an audit trail
         $history_message = sprintf(__('This ticket was moved to %1$s from %2$s', 'event-tickets'), '<a href="' . esc_url(get_the_permalink($destination_post_id)) . '" target="_blank">' . get_the_title($destination_post_id) . '</a>', '<a href="' . esc_url(get_the_permalink($src_post_id)) . '" target="_blank">' . get_the_title($src_post_id) . '</a>');
         $history_data = array('src_event_id' => $src_post_id, 'tgt_event_id' => $destination_post_id);
         Tribe__Post_History::load($issued_ticket_id)->add_entry($history_message, $history_data);
     }
 }
コード例 #9
0
ファイル: Tickets_Handler.php プロジェクト: TakenCdosG/chefs
 /**
  * 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)
 {
     /**
      * Fire immediately prior to the generation of a filtered (exportable) attendee list.
      *
      * @param int $event_id
      */
     do_action('tribe_events_tickets_generate_filtered_attendees_list', $event_id);
     if (empty($this->attendees_page)) {
         $this->attendees_page = 'tribe_events_page_tickets-attendees';
     }
     //Add in Columns or get_column_headers() returns nothing
     $filter_name = "manage_{$this->attendees_page}_columns";
     add_filter($filter_name, array($this->attendees_table, 'get_columns'), 15);
     $items = Tribe__Tickets__Tickets::get_event_attendees($event_id);
     //Add Handler for Community Tickets to Prevent Notices in Exports
     if (!is_admin()) {
         $columns = apply_filters($filter_name, array());
     } else {
         $columns = get_column_headers(get_current_screen());
     }
     $hidden = get_hidden_columns($this->attendees_page);
     // We dont want to export html inputs or private data
     $hidden[] = 'cb';
     $hidden[] = 'provider';
     $hidden = array_flip($hidden);
     $export_columns = array_diff_key($columns, $hidden);
     // Add the Purchaser Information
     $export_columns['purchaser_name'] = esc_html__('Customer Name', 'event-tickets');
     $export_columns['purchaser_email'] = esc_html__('Customer Email Address', 'event-tickets');
     /**
      * Used to modify what columns should be shown on the CSV export
      * The column name should be the Array Index and the Header is the array Value
      *
      * @var array Columns, associative array
      * @var array Items to be exported
      * @var int   Event ID
      */
     $export_columns = apply_filters('tribe_events_tickets_attendees_csv_export_columns', $export_columns, $items, $event_id);
     // Add the export column headers as the first row
     $rows = array(array_values($export_columns));
     foreach ($items as $single_item) {
         // Fresh row!
         $row = array();
         foreach ($export_columns as $column_id => $column_name) {
             // If additional columns have been added to the attendee list table we can obtain the
             // values by calling the table object's column_default() method - any other values
             // should simply be passed back unmodified
             $row[$column_id] = $this->attendees_table->column_default($single_item, $column_id);
             // Special handling for the check_in column
             if ('check_in' === $column_id && 1 == $single_item[$column_id]) {
                 $row[$column_id] = esc_html__('Yes', 'event-tickets');
             }
             // Special handling for new human readable id
             if ('attendee_id' === $column_id) {
                 if (isset($single_item[$column_id])) {
                     $ticket_unique_id = get_post_meta($single_item[$column_id], '_unique_id', true);
                     $ticket_unique_id = $ticket_unique_id === '' ? $single_item[$column_id] : $ticket_unique_id;
                     $row[$column_id] = esc_html($ticket_unique_id);
                 }
             }
         }
         $rows[] = array_values($row);
     }
     return array_filter($rows);
 }