public function export_attendees() { error_reporting(0); if (!$this->_event_id) { wp_die(__('No event to export', Eab_EventsHub::TEXT_DOMAIN)); } $event = new Eab_EventModel(get_post($this->_event_id)); $attendees = array(); $statuses = $this->_get_statuses(); foreach ($statuses as $status => $title) { $bookings = $this->_get_bookings($status); foreach ($bookings as $booking) { $user_data = get_userdata($booking->user_id); if ($event->get_id() !== $booking->event_id) { $event = new Eab_EventModel(get_post($booking->event_id)); } $payment_status = $ticket_count = __('N/A', Eab_EventsHub::TEXT_DOMAIN); if (Eab_EventModel::BOOKING_NO != $status) { $ticket_count = $event->get_booking_meta($booking->id, 'booking_ticket_count'); $ticket_count = $ticket_count ? $ticket_count : 1; if ($event->is_premium()) { $payment_status = $event->user_paid($booking->user_id) ? __('Yes', Eab_EventsHub::TEXT_DOMAIN) : __('No', Eab_EventsHub::TEXT_DOMAIN); } } $attendees[] = apply_filters('eab-exporter-csv-row', array(__('User ID', Eab_EventsHub::TEXT_DOMAIN) => $user_data->id, __('User Name', Eab_EventsHub::TEXT_DOMAIN) => apply_filters('eab-guest_list-export-guest_name', $user_data->display_name, $booking->user_id, $user_data), __('User Email', Eab_EventsHub::TEXT_DOMAIN) => $user_data->user_email, __('Attending', Eab_EventsHub::TEXT_DOMAIN) => $title, __('Ticket Count', Eab_EventsHub::TEXT_DOMAIN) => $ticket_count, __('Payment Status', Eab_EventsHub::TEXT_DOMAIN) => $payment_status), $event, $booking, $user_data); } } $delimiter = apply_filters('eab-exporter-csv-field_delimiter', $this->_delimiter); $fp = fopen('php://output', 'w'); fputcsv($fp, array_keys($attendees[0]), $delimiter); foreach ($attendees as $res) { fputcsv($fp, $res, $delimiter); } }
public static function get_admin_bookings($status, $post) { global $wpdb; if (!current_user_can('edit_posts')) { return false; } // Basic sanity check $event = $post instanceof Eab_EventModel ? $post : new Eab_EventModel($post); $statuses = self::get_rsvp_status_list(); if (!in_array($status, array_keys($statuses))) { return false; } // Unknown status $status_name = $statuses[$status]; //$content = Eab_Template::get_admin_attendance_addition_form($event, $statuses); // Moved to actual bookings areas $content .= '<h4>' . __($status_name, Eab_EventsHub::TEXT_DOMAIN) . '</h4>'; $content .= '<ul class="eab-guest-list">'; $all_events = array($event); if ($event->is_recurring()) { $all_events = Eab_CollectionFactory::get_all_recurring_children_events($event); } $all_event_ids = array(); foreach ($all_events as $e) { $all_event_ids[] = $e->get_id(); } $all_event_ids = array_filter(array_map('intval', $all_event_ids)); $bookings = $wpdb->get_results($wpdb->prepare("SELECT id,user_id,event_id FROM " . Eab_EventsHub::tablename(Eab_EventsHub::BOOKING_TABLE) . " WHERE event_id IN(" . join(',', $all_event_ids) . ") AND status = %s ORDER BY timestamp;", $status)); if (!count($bookings)) { return false; } foreach ($bookings as $booking) { $user_data = get_userdata($booking->user_id); if ($event->get_id() !== $booking->event_id) { $event = new Eab_EventModel(get_post($booking->event_id)); } $content .= '<li>'; $content .= '<div class="eab-guest">'; $content .= '<a href="user-edit.php?user_id=' . $booking->user_id . '" title="' . $user_data->display_name . '">' . get_avatar($booking->user_id, 32) . '<br />' . apply_filters('eab-guest_list-admin-guest_name', $user_data->display_name, $booking->user_id, $user_data) . '</a>'; if ($event->is_premium()) { if ($event->user_paid($booking->user_id)) { $ticket_count = $event->get_booking_meta($booking->id, 'booking_ticket_count'); $ticket_count = $ticket_count ? $ticket_count : 1; $payment_status = '' . '<span class="eab-guest-payment_info-paid">' . __('Paid', Eab_EventsHub::TEXT_DOMAIN) . '</span>' . ' ' . sprintf(__('(%s tickets)', Eab_EventsHub::TEXT_DOMAIN), $ticket_count) . ''; } else { $payment_status = '<span class="eab-guest-payment_info-not_paid">' . __('Not paid', Eab_EventsHub::TEXT_DOMAIN) . '</span>'; } // Added by Hakan $payment_status = apply_filters('eab-event-payment_status', $payment_status, $booking->user_id, $event); $content .= "<div class='eab-guest-payment_info'>{$payment_status}</div>"; } if (in_array($status, array(Eab_EventModel::BOOKING_YES, Eab_EventModel::BOOKING_MAYBE))) { $content .= '<div class="eab-guest-actions"><a href="#cancel-attendance" class="eab-guest-cancel_attendance" data-eab-user_id="' . $booking->user_id . '" data-eab-event_id="' . $event->get_id() . '">' . __('Cancel attendance', Eab_EventsHub::TEXT_DOMAIN) . '</a></div>'; } $content .= '<div class="eab-guest-actions"><a href="#delete-attendance" class="eab-guest-delete_attendance" data-eab-user_id="' . $booking->user_id . '" data-eab-event_id="' . $event->get_id() . '">' . __('Delete attendance entirely', Eab_EventsHub::TEXT_DOMAIN) . '</a></div>'; $content = apply_filters('eab-event-booking_metabox_content', $content, $booking->user_id); $content .= '</div>'; // .eab-guest $content .= '</li>'; } $content .= '</ul>'; $content .= '<div class="clear"></div>'; return $content; }
/** * Add manual payment link inside the RSVP box */ function add_approve_payment($content, $user_id) { global $post; $payments = maybe_unserialize(stripslashes(Eab_EventModel::get_booking_meta($post->ID, "manual_payment"))); if (is_array($payments)) { foreach ($payments as $payment) { if ($payment["id"] == $user_id and $payment["stat"] == 'pending') { $content .= '<div class="eab-guest-actions" id="div_approve_payment_' . $user_id . '"> <a id="approve_payment_' . $user_id . '" href="javascript:void(0)" class="eab-guest-manual_payment" >' . __('Approve Payment', Eab_EventsHub::TEXT_DOMAIN) . '</a></div>'; $content .= '<script type="text/javascript">'; $content .= 'jQuery(document).ready(function($){ $("#approve_payment_' . $user_id . '").click(function() { if (confirm("Are you sure to approve this payment?")){ $.post(ajaxurl, { "action": "eab_approve_manual_payment", "user_id":' . $user_id . ', "event_id":' . $post->ID . ' }, function (data) { if (data && data.error) {alert(data.error);} else { $("#div_approve_payment_' . $user_id . '").parent(".eab-guest").find(".eab-guest-payment_info").html("paid"); $("#div_approve_payment_' . $user_id . '").remove(); } }, "json"); return false; } else {return false;} }); });'; $content .= '</script>'; } } } return $content; }