Exemple #1
0
										<th><?php 
    _e('Price', 'dbem');
    ?>
</th>
									</tr>
									</thead>
									<tbody>
										<?php 
    foreach ($EM_Booking->get_tickets_bookings()->tickets_bookings as $EM_Ticket_Booking) {
        /* @var $EM_Ticket_Booking EM_Ticket_Booking */
        ?>

										<tr>
											<td class="ticket-type"><a class="row-title" href="<?php 
        echo em_add_get_params($EM_Event->get_bookings_url(), array('ticket_id' => $EM_Ticket_Booking->ticket_id));
        ?>
"><?php 
        echo $EM_Ticket_Booking->get_ticket()->ticket_name;
        ?>
</a></td>
											<td>
												<span class="em-booking-single-info"><?php 
        echo $EM_Ticket_Booking->get_spaces();
        ?>
</span>
												<div class="em-booking-single-edit"><input name="em_tickets[<?php 
        echo $EM_Ticket_Booking->ticket_id;
        ?>
][spaces]" class="em-ticket-select" id="em-ticket-spaces-<?php 
        echo $EM_Ticket_Booking->ticket_id;
        ?>
" value="<?php 
        echo $EM_Ticket_Booking->get_spaces();
        ?>
" /></div>
											</td>
											<td><?php 
        echo $EM_Ticket_Booking->get_price(true, true);
        ?>
</td>
										</tr>
										<?php 
        $shown_tickets[] = $EM_Ticket_Booking->ticket_id;
        do_action('em_bookings_admin_ticket_row', $EM_Ticket_Booking->get_ticket(), $EM_Booking);
        ?>

										<?php 
    }
    ?>

										<?php 
    if (count($shown_tickets) < count($EM_Event->get_bookings()->get_tickets()->tickets)) {
        ?>
<tr>
											<?php 
        foreach ($EM_Event->get_bookings()->get_tickets()->tickets as $EM_Ticket) {
            /* @var $EM_Ticket EM_Ticket */
            ?>

												<?php 
            if (!in_array($EM_Ticket->ticket_id, $shown_tickets)) {
                ?>

												<tr>
													<td class="ticket-type"><a class="row-title" href="<?php 
                echo em_add_get_params($EM_Event->get_bookings_url(), array('ticket_id' => $EM_Ticket->ticket_id));
                ?>
"><?php 
                echo $EM_Ticket->ticket_name;
                ?>
</a></td>
													<td>
														<span class="em-booking-single-info">0</span>
														<div class="em-booking-single-edit"><input name="em_tickets[<?php 
                echo $EM_Ticket->ticket_id;
                ?>
][spaces]" class="em-ticket-select" id="em-ticket-spaces-<?php 
                echo $EM_Ticket_Booking->ticket_id;
                ?>
" value="0" /></div>
													</td>
/**
 * Handles AJAX Bookings admin table filtering, view changes and pagination
 */
function em_ajax_bookings_table()
{
    check_admin_referer('em_bookings_table');
    $EM_Bookings_Table = new EM_Bookings_Table();
    $EM_Bookings_Table->output_table();
    exit;
}
Exemple #3
0
function em_ajax_bookings_table()
{
    $EM_Bookings_Table = new EM_Bookings_Table();
    $EM_Bookings_Table->output_table();
    exit;
}
 /**
  * Intercepts a CSV export request before the core version hooks in and using similar code generates a breakdown of bookings with all attendees included at the end.
  * Hooking into the original version of this will cause more looping, which is why we're flat out overriding this here.
  */
 public static function intercept_csv_export()
 {
     if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'export_bookings_csv' && !empty($_REQUEST['show_attendees']) && wp_verify_nonce($_REQUEST['_wpnonce'], 'export_bookings_csv')) {
         //sort out cols
         if (!empty($_REQUEST['cols']) && is_array($_REQUEST['cols'])) {
             $cols = array();
             foreach ($_REQUEST['cols'] as $col => $active) {
                 if ($active) {
                     $cols[] = $col;
                 }
             }
             $_REQUEST['cols'] = $cols;
         }
         $_REQUEST['limit'] = 0;
         //generate bookings export according to search request
         $EM_Bookings_Table = new EM_Bookings_Table(true);
         header("Content-Type: application/octet-stream; charset=utf-8");
         header("Content-Disposition: Attachment; filename=" . sanitize_title(get_bloginfo()) . "-bookings-export.csv");
         do_action('em_csv_header_output');
         echo "";
         // UTF-8 for MS Excel (a little hacky... but does the job)
         if (!defined('EM_CSV_DISABLE_HEADERS') || !EM_CSV_DISABLE_HEADERS) {
             if (!empty($_REQUEST['event_id'])) {
                 $EM_Event = em_get_event($_REQUEST['event_id']);
                 _e_emp('Event', 'dbem') . ' : ' . $EM_Event->event_name . "\n";
                 if ($EM_Event->location_id > 0) {
                     _e_emp('Where', 'dbem') . ' - ' . $EM_Event->get_location()->location_name . "\n";
                 }
                 _e_emp('When', 'dbem') . ' : ' . $EM_Event->output('#_EVENTDATES - #_EVENTTIMES') . "\n";
             }
             echo sprintf(__emp('Exported bookings on %s', 'dbem'), date_i18n('D d M Y h:i', current_time('timestamp'))) . "\n";
         }
         $headers = $EM_Bookings_Table->get_headers(true);
         if (!empty($_REQUEST['event_id'])) {
             foreach (self::get_form($_REQUEST['event_id'])->form_fields as $field) {
                 if ($field['type'] != 'html') {
                     $headers[] = $field['label'];
                 }
             }
         }
         echo '"' . implode('","', $headers) . '"' . "\n";
         //Rows
         $EM_Bookings_Table->limit = 150;
         //if you're having server memory issues, try messing with this number
         $EM_Bookings = $EM_Bookings_Table->get_bookings();
         $handle = fopen("php://output", "w");
         while (!empty($EM_Bookings->bookings)) {
             foreach ($EM_Bookings->bookings as $EM_Booking) {
                 /* @var $EM_Booking EM_Booking */
                 /* @var $EM_Ticket_Booking EM_Ticket_Booking */
                 $attendees_data = self::get_booking_attendees($EM_Booking);
                 foreach ($EM_Booking->get_tickets_bookings()->tickets_bookings as $EM_Ticket_Booking) {
                     $orig_row = $EM_Bookings_Table->get_row_csv($EM_Ticket_Booking);
                     if (!empty($attendees_data[$EM_Ticket_Booking->ticket_id])) {
                         foreach ($attendees_data[$EM_Ticket_Booking->ticket_id] as $attendee_title => $attendee_data) {
                             $row = $orig_row;
                             foreach ($attendee_data as $field_value) {
                                 $row[] = $field_value;
                             }
                             fputcsv($handle, $row);
                         }
                     }
                 }
             }
             //reiterate loop
             $EM_Bookings_Table->offset += $EM_Bookings_Table->limit;
             $EM_Bookings = $EM_Bookings_Table->get_bookings();
         }
         fclose($handle);
         exit;
     }
 }