function generate_financials_csv($export_event_id)
{
    $orders = TribeEventsTickets::get_event_attendees($export_event_id);
    $counter = 1;
    $export_financials = array();
    $temp_order_id = 0;
    $temp_product_id = 0;
    $temp_counter = 1;
    foreach ($orders as $order) {
        $number = $counter;
        $order_id = $order['order_id'];
        $order_meta = get_post_meta($order_id);
        $temp_product_id = $order['product_id'];
        $ticket = $order['ticket'];
        $purchase_date = get_the_date('F j, Y g:i a', $order_id);
        // $order_meta['_paid_date'][0];
        $purchaser_name = $order_meta['_billing_first_name'][0] . ' ' . $order_meta['_billing_last_name'][0];
        $user_id = $order_meta['_customer_user'][0];
        $purchaser_email = $order_meta['_billing_email'][0];
        $purchaser_phone = $order_meta['_billing_phone'][0];
        $company = $order_meta['_billing_company'][0];
        $address1 = $order_meta['_billing_address_1'][0];
        $address2 = $order_meta['_billing_address_2'][0];
        $address = $address1 . ', ' . $address2;
        $city = $order_meta['_billing_city'][0];
        $state = $order_meta['_billing_state'][0];
        $zip = $order_meta['_billing_postcode'][0];
        $discount = round($order_meta['_cart_discount'][0], 2);
        $total = $order_meta['_order_total'][0];
        $payment_method = $order_meta['_payment_method_title'][0];
        if ($temp_order_id == $order_id && $temp_product_id == $order['product_id']) {
            $temp_counter++;
        } else {
            $temp_counter = 1;
        }
        $attendee_first_name = $order_meta["attendee_first_name_" . $temp_product_id . "_" . $temp_counter][0];
        if (empty($attendee_first_name)) {
            $attendee_first_name = $order_meta["attendee_name_" . $temp_product_id . "_" . $temp_counter][0];
        }
        $attendee_last_name = $order_meta["attendee_last_name_" . $temp_product_id . "_" . $temp_counter][0];
        $attendee_job = $order_meta["attendee_job_title_" . $temp_product_id . "_" . $temp_counter][0];
        $attendee_phone = $order_meta["attendee_primary_phone_" . $temp_product_id . "_" . $temp_counter][0];
        $order_cst = new WC_Order($order_id);
        $order_items = $order_cst->get_items();
        foreach ($order_items as $item_id => $values) {
            $attendee_count = $values['qty'];
            break;
        }
        $coupons = $order_cst->get_used_coupons();
        $coupon = $coupons[0];
        if (!$coupon) {
            $coupon = "";
        }
        if ($discount == 0) {
            $discount = "";
        } else {
            $discount = "\$" . $discount;
        }
        $export_financials[$counter] = array($order_id, $purchase_date, $ticket, $user_id, $purchaser_name, $purchaser_email, $purchaser_phone, $company, $address, $city, $state, $zip, $attendee_first_name, $attendee_last_name, $attendee_job, $attendee_cell_phone, $attendee_work_phone, $attendee_count, $total, $payment_method, $coupon, $discount);
        $counter++;
        $temp_order_id = $order_id;
        $temp_product_id = $order['product_id'];
    }
    $event = get_post($export_event_id);
    if (!empty($export_financials)) {
        $charset = get_option('blog_charset');
        $start_date = strtotime(get_post_meta($event, '_EventStartDate', true));
        $filename = $event->post_name;
        // output headers so that the file is downloaded rather than displayed
        header("Content-Type: text/csv; charset={$charset}");
        header("Content-Disposition: attachment; filename={$filename}-fiancial-data.csv");
        // create a file pointer connected to the output stream
        $output = fopen('php://output', 'w');
        fputcsv($output, array('Order ID', 'Purchase Date', 'Ticket Name', 'User ID', 'Purchaser Name', 'Purchaser Email', 'Purchaser Phone', 'Purchaser Company', 'Address', 'City', 'State', 'Zip', 'Attendee First Name', 'Attendee Last Name', 'Job Title', 'Cell Phone', 'Work Phone', 'Number of Tickets Purchased', 'Total Paid', 'Payment Method', 'Coupon Code', 'Discount Amount'));
        // And echo the data
        foreach ($export_financials as $item) {
            fputcsv($output, $item);
        }
        fclose($output);
        exit;
    }
}
function calculate_attendee_financial_Data()
{
    global $value_to_display;
    // Load the ajax js in header after jquery
    wp_enqueue_script('btcg-attendees-finance-data', plugin_dir_url(__FILE__) . 'js/btcg-event-attendees-finance-data.js', array('jquery'), false, false);
    // Get Event ID and load the event tickets
    $current_event_id = isset($_GET['event_id']) ? intval($_GET['event_id']) : 0;
    //$current_event = get_post( $current_event_id );
    $current_event_tickets = TribeEventsTickets::get_event_tickets($current_event_id);
    // Getting Ticket Ids
    $ticket_ids = array();
    foreach ($current_event_tickets as $current_event_ticket) {
        $ticket_ids[] = $current_event_ticket->ID;
    }
    // Fetching all orders and searching the ticket id in the orders
    $attendees_list = TribeEventsTickets::get_event_attendees($current_event_id);
    $amount_sold_online = 0;
    $amount_sold_offline = 0;
    foreach ($attendees_list as $attendee) {
        $current_order_id = $attendee['order_id'];
        $order_details = new WC_Order($current_order_id);
        // Getting order detail
        $current_order_items = $order_details->get_items();
        // Getting line items in the order
        $current_orderpayment_method = get_post_meta($current_order_id, '_payment_method', true);
        // Get payment method
        $offline_methods = array('bacs', 'cod', 'cheque');
        $online_methods = array('paypal', 'simplify_commerce', 'authorize_net_cim_credit_card', 'authorize_net_cim_echeck');
        foreach ($current_order_items as $current_order_item) {
            if (in_array($current_order_item['product_id'], $ticket_ids)) {
                if (in_array($current_orderpayment_method, $offline_methods)) {
                    $amount_sold_offline = $amount_sold_offline + $current_order_item['line_total'];
                }
                if (in_array($current_orderpayment_method, $online_methods)) {
                    $amount_sold_online = $amount_sold_online + $current_order_item['line_total'];
                }
            }
        }
    }
    $value_to_display = '<strong>Online Sales:</strong> ' . wc_price($amount_sold_online) . '<br/>';
    $value_to_display .= '<strong>Offline Sales:</strong> ' . wc_price($amount_sold_offline) . '<br/>';
    $value_to_display .= '<strong>Gross Sales:</strong> ' . wc_price($amount_sold_offline + $amount_sold_online);
    // Adding inline javascript
    add_action('admin_head', 'attendees_inline_js');
}
Beispiel #3
0
    $stock = $ticket->stock;
    $sold = !empty($ticket->qty_sold) ? $ticket->qty_sold : 0;
    if (empty($stock) && $stock !== 0) {
        echo sprintf(__("Sold %d", 'tribe-events-calendar'), esc_html($sold));
    } else {
        echo sprintf(__("Sold %d of %d", 'tribe-events-calendar'), esc_html($sold), esc_html($sold + $stock));
    }
    $total_sold += $sold;
    echo "<br/>";
}
?>
					</td>
					<td width="33%" valign="middle">
						<div class="totals">
							<?php 
$checkedin = TribeEventsTickets::get_event_checkedin_attendees_count($event_id);
echo '<span id="total_tickets_sold_wrapper">';
echo sprintf('%s <span id="total_tickets_sold">%d</span>', esc_html(__('Tickets sold:', 'tribe-events-calendar')), $total_sold);
echo '</span>';
echo '<span id="total_checkedin_wrapper">';
echo "<br/>";
echo sprintf('%s <span id="total_checkedin">%d</span>', esc_html(__('Checked in:', 'tribe-events-calendar')), $checkedin);
echo '</span>';
?>
						</div>
					</td>
				</tr>
			</table>
		</div>
	</div>
 /**
  * Prepares the list of items for displaying.
  */
 function prepare_items()
 {
     $this->process_bulk_action();
     $event_id = isset($_GET['event_id']) ? $_GET['event_id'] : 0;
     $items = TribeEventsTickets::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));
 }
Beispiel #5
0
 /**
  * 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 = TribeEventsTickets::get_event_attendees($event_id);
     return array_reduce($checkedin, array("TribeEventsTickets", "_checkedin_attendees_array_filter"), 0);
 }
Beispiel #6
0
<?php

// Don't load directly
if (!defined('ABSPATH')) {
    die('-1');
}
$header_id = get_post_meta(get_the_ID(), $this->image_header_field, true);
$header_id = !empty($header_id) ? $header_id : '';
$header_img = '';
if (!empty($header_id)) {
    $header_img = wp_get_attachment_image($header_id, 'full');
}
$modules = TribeEventsTickets::modules();
?>

<table id="event_tickets" class="eventtable">
	<?php 
if (get_post_meta(get_the_ID(), '_EventOrigin', true) === 'community-events') {
    ?>
		<tr>
			<td colspan="2" class="tribe_sectionheader updated">
				<p class="error-message"><?php 
    _e('This event was created using Community Events. Are you sure you want to sell tickets for it?', 'tribe-events-calendar');
    ?>
</p>
			</td>
		</tr>
	<?php 
}
?>
	<tr>
Beispiel #7
0
 /**
  * Includes the tickets metabox inside the Event edit screen
  *
  * @param $post_id
  */
 public function do_meta_box($post_id)
 {
     $startMinuteOptions = TribeEventsViewHelpers::getMinuteOptions(null);
     $endMinuteOptions = TribeEventsViewHelpers::getMinuteOptions(null);
     $startHourOptions = TribeEventsViewHelpers::getHourOptions(null, true);
     $endHourOptions = TribeEventsViewHelpers::getHourOptions(null, false);
     $startMeridianOptions = TribeEventsViewHelpers::getMeridianOptions(null, true);
     $endMeridianOptions = TribeEventsViewHelpers::getMeridianOptions(null);
     $tickets = TribeEventsTickets::get_event_tickets($post_id);
     include $this->path . 'admin-views/tickets/meta-box.php';
 }
 /**
  * Adds ticket data to the offers property of the event object.
  */
 protected function add_ticket_offers()
 {
     foreach (TribeEventsTickets::get_all_event_tickets($this->event_id) as $this->ticket) {
         $this->add_individual_offer();
     }
 }
Beispiel #9
0
/**
 * Accepts the post object or ID for a product and, if it represents an event
 * ticket, returns the corresponding event object.
 *
 * If this cannot be determined boolean false will be returned instead.
 *
 * @param $possible_ticket
 *
 * @return bool|WP_Post
 */
function tribe_events_get_ticket_event($possible_ticket)
{
    return TribeEventsTickets::find_matching_event($possible_ticket);
}
Beispiel #10
0
 public function attendees_page_register()
 {
     if (self::$done_attendees_admin_page) {
         return;
     }
     $this->attendees_page = add_submenu_page(null, 'Attendee list', 'Attendee list', 'edit_posts', $this->attendees_slug, array($this, 'attendees_page_inside'));
     add_action('admin_enqueue_scripts', array($this, 'attendees_page_load_css_js'));
     self::$done_attendees_admin_page = true;
 }
 function prepare_items()
 {
     global $wpdb;
     $this->process_bulk_action();
     $per_page = 10000;
     $columns = $this->get_columns();
     $hidden = array();
     $sortable = array();
     $this->_column_headers = array($columns, $hidden, $sortable);
     $current_page = $this->get_pagenum();
     $event_id = isset($_GET['event_id']) ? $_GET['event_id'] : 0;
     $items = TribeEventsTickets::get_event_attendees($event_id);
     $this->items = $items;
     $total_items = count($this->items);
     $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page, 'total_pages' => ceil($total_items / $per_page)));
 }
Beispiel #12
0
	<div id="icon-edit" class="icon32 icon32-tickets-attendees"><br></div>
	<h2><?php 
_e("Attendees");
?>
</h2>

	<div id="tribe-filters" class="metabox-holder">
		<div id="filters-wrap" class="postbox">
			<h3 title="Click to toggle"><?php 
_e("Summary");
?>
</h3>
			<table class="eventtable ticket_list">
				<?php 
$event_id = isset($_GET["event_id"]) ? $_GET["event_id"] : 0;
$tickets = TribeEventsTickets::get_event_tickets($event_id);
$provider = null;
$count = 0;
foreach ($tickets as $ticket) {
    $provider = $ticket->provider_class;
    $provider_obj = call_user_func(array($provider, 'get_instance'));
    if ($ticket->provider_class !== $provider || $count == 0) {
        ?>
						<td colspan="3">
							<h4><?php 
        echo esc_html(self::$active_modules[$ticket->provider_class]);
        ?>
</h4>
						</td>
						<?php 
    }
function generate_attendee_csv($export_event_id)
{
    $all_attendees = TribeEventsTickets::get_event_attendees($export_event_id);
    $export_attendee_list = array();
    $counter = 0;
    $attendee_counter = 1;
    $old_order_id = 0;
    foreach ($all_attendees as $attendee) {
        $order_id = $attendee['order_id'];
        $order = new WC_Order($order_id);
        $order_meta = get_post_meta($order_id);
        $_product_id = $attendee['product_id'];
        // Purchaser Name
        $purchaser_name = $order_meta['_billing_first_name'][0] . ' ' . $order_meta['_billing_last_name'][0];
        // Company
        $company = $order_meta['_billing_company'][0];
        // Address
        $address1 = $order_meta['_billing_address_1'][0];
        $address2 = $order_meta['_billing_address_2'][0];
        $address = $address1 . ' ' . $address2;
        // City, State & Zip
        $city = $order_meta['_billing_city'][0];
        $state = $order_meta['_billing_state'][0];
        $zip = $order_meta['_billing_postcode'][0];
        // Email
        $purchaser_email = $order_meta['_billing_email'][0];
        // Amount paid
        $amt_paid = $order->get_formatted_order_total();
        $amt_paid = html_entity_decode(strip_tags($amt_paid), ENT_QUOTES, 'utf-8');
        // Reset the counter after each order
        if ($old_order_id == 0) {
            $old_order_id = $order_id;
        } else {
            if ($order_id != $old_order_id) {
                $attendee_counter = 1;
                $old_order_id = $order_id;
            }
        }
        // Attendee Name, Attendee Email, Job Title, Dietary Restrictions & Phone
        //$attendee_name                 = get_post_meta( $order_id, 'attendee_name_'.$_product_id.'_'.$attendee_counter, true);
        $attendee_first_name = get_post_meta($order_id, 'attendee_first_name_' . $_product_id . '_' . $attendee_counter, true);
        if (empty($attendee_first_name)) {
            $attendee_first_name = get_post_meta($order_id, 'attendee_name_' . $_product_id . '_' . $attendee_counter, true);
        }
        $attendee_last_name = get_post_meta($order_id, 'attendee_last_name_' . $_product_id . '_' . $attendee_counter, true);
        $attendee_email = get_post_meta($order_id, 'attendee_email_' . $_product_id . '_' . $attendee_counter, true);
        $attendee_job_title = get_post_meta($order_id, 'attendee_job_title_' . $_product_id . '_' . $attendee_counter, true);
        $attendee_dietary_restrictions = get_post_meta($order_id, 'attendee_dietary_restrictions_' . $_product_id . '_' . $attendee_counter, true);
        $phone = $order_meta['_billing_phone'][0];
        $discount = round($order_meta['_cart_discount'][0], 2);
        $coupons = $order->get_used_coupons();
        $coupon = $coupons[0];
        if (!$coupon) {
            $coupon = $discount = "";
        } else {
            $discount = "\$" . $discount;
        }
        $export_attendee_list[$counter] = array($purchaser_name, $phone, $company, $address, $city, $state, $zip, $purchaser_email, $amt_paid, $attendee_first_name, $attendee_last_name, $attendee_email, $attendee_company, $attendee_job_title, $attendee_dietary_restrictions, $attendee_cell_phone, $attendee_work_phone, $coupon, $discount);
        $counter++;
        $attendee_counter++;
    }
    $event = get_post($export_event_id);
    if (!empty($export_attendee_list)) {
        $charset = get_option('blog_charset');
        $start_date = strtotime(get_post_meta($event, '_EventStartDate', true));
        $filename = $event->post_name;
        // output headers so that the file is downloaded rather than displayed
        header("Content-Type: text/csv; charset={$charset}");
        header("Content-Disposition: attachment; filename={$filename}-attendees.csv");
        // create a file pointer connected to the output stream
        $output = fopen('php://output', 'w');
        fputcsv($output, array('Purchaser Name', 'Purchaser Phone', 'Purchaser Company', 'Address', 'City', 'State', 'Zip', 'Purchaser Email', 'Amount Paid', 'Attendee First Name', 'Attendee Last Name', 'Attendee Email', 'Attendee Company', 'Job Title', 'Dietary Restrictions', 'Cell Phone', 'Work Phone', 'Coupon Code', 'Coupon Amount'));
        foreach ($export_attendee_list as $item) {
            fputcsv($output, $item);
        }
        fclose($output);
        exit;
    }
}
 function braintrust_class_attendee_list($post)
 {
     global $wpdb;
     $order_id = $post->ID;
     $order = new WC_Order($order_id);
     $ordered_items = $order->get_items();
     $tickets = TribeEventsTickets::get_event_tickets($event_id);
     foreach ($ordered_items as $item_id => $values) {
         $_product_id = $values['product_id'];
         if (get_post_meta($_product_id, '_tribe_wooticket_for_event', true) > 0) {
             $event_id = get_post_meta($_product_id, '_tribe_wooticket_for_event', true);
             echo '<h3>' . __(get_the_title($event_id)) . '</h3>';
             echo '<table class="wp-list-table widefat fixed attendees">';
             echo '<thead>';
             echo '<tr>';
             echo '<th scope="col" id="btcg_attendee" class="manage-column column-btcg_attendee" style="">First Name</th>';
             echo '<th scope="col" id="btcg_attendee" class="manage-column column-btcg_attendee" style="">Last Name</th>';
             echo '<th scope="col" id="btcg_attendee" class="manage-column column-btcg_attendee" style="">Email</th>';
             echo '<th scope="col" id="btcg_attendee" class="manage-column column-btcg_attendee" style="">Job Title</th>';
             echo '<th scope="col" id="btcg_attendee" class="manage-column column-btcg_attendee" style="">Dietary Restrictions</th>';
             echo '</tr>';
             echo '</thead>';
             $attendee_count = $values['qty'];
             if ($attendee_count > 0) {
                 echo '<tbody id="the-list" data-wp-lists="list:attendee">';
                 $alternate_class = "alternate";
                 for ($n = 1; $n <= $attendee_count; $n++) {
                     $alternate_class = $n % 2 == 0 ? "" : "alternate";
                     echo '<tr class="' . $alternate_class . '">';
                     echo '<td>';
                     $first_name = get_post_meta($order_id, 'attendee_first_name_' . $_product_id . '_' . $n, true);
                     if (empty($first_name)) {
                         $first_name = get_post_meta($order_id, 'attendee_name_' . $_product_id . '_' . $n, true);
                     }
                     echo $first_name;
                     echo '</td>';
                     echo '<td>';
                     echo get_post_meta($order_id, 'attendee_last_name_' . $_product_id . '_' . $n, true);
                     echo '</td>';
                     echo '<td>';
                     echo get_post_meta($order_id, 'attendee_email_' . $_product_id . '_' . $n, true);
                     echo '</td>';
                     echo '<td>';
                     echo get_post_meta($order_id, 'attendee_job_title_' . $_product_id . '_' . $n, true);
                     echo '</td>';
                     echo '<td>';
                     echo get_post_meta($order_id, 'attendee_dietary_restrictions_' . $_product_id . '_' . $n, true);
                     echo '</td>';
                     echo '</tr>';
                 }
                 echo '</tbody>';
             }
             echo '</table>';
         }
     }
 }