function espresso_display_admin_reports_filters($total = 0)
{
    $event_admin_reports = isset($_REQUEST['event_admin_reports']) ? wp_strip_all_tags($_REQUEST['event_admin_reports']) : FALSE;
    $event_id = isset($_REQUEST['event_id']) && $_REQUEST['event_id'] != '' ? absint($_REQUEST['event_id']) : FALSE;
    $category_id = isset($_REQUEST['category_id']) ? absint($_REQUEST['category_id']) : FALSE;
    $payment_status = isset($_REQUEST['payment_status']) ? wp_strip_all_tags($_REQUEST['payment_status']) : '';
    $event_status = isset($_REQUEST['event_status']) ? wp_strip_all_tags($_REQUEST['event_status']) : '';
    $month_range = isset($_REQUEST['month_range']) ? wp_strip_all_tags($_REQUEST['month_range']) : '';
    // then figure out the current "view"
    $view = isset($_REQUEST['all']) && $_REQUEST['all'] == 'true' ? 'all' : '';
    $view = isset($_REQUEST['this_month']) && $_REQUEST['this_month'] == 'true' ? 'this_month' : $view;
    $view = isset($_REQUEST['today']) && $_REQUEST['today'] == 'true' ? 'today' : $view;
    $view = isset($_REQUEST['all_a']) && $_REQUEST['all_a'] == 'true' ? 'all_a' : $view;
    $view = isset($_REQUEST['this_month_a']) && $_REQUEST['this_month_a'] == 'true' ? 'this_month_a' : $view;
    $view = isset($_REQUEST['today_a']) && $_REQUEST['today_a'] == 'true' ? 'today_a' : $view;
    // query params we need to remove
    $remove = array($view, 'event_admin_reports', 'event_id');
    // if a specific date period has been clicked
    if (!empty($view)) {
        $remove[] = 'month_range';
        $month_range = '';
    }
    // then remove the current view from the query args so that the view can be changed
    $query_args = espresso_remove_filter_from_query_args($remove);
    //printr( $query_args, '$query_args  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
    // EVT_ADMIN_URL
    ?>
 
	  <h3 style="margin-bottom: -8px;">
		  <?php 
    echo __('Filters', 'event_espresso');
    ?>
	  </h3>
	 
	  <ul class="subsubsub">
	  	<li>
		  	<strong>
	  			<?php 
    _e('Events', 'event_espresso');
    ?>
 :
	  		</strong>
	  	</li>
	  	<li>	  		
		  	<a <?php 
    echo $view == 'all' ? ' class="current" ' : '';
    ?>
 href="<?php 
    echo add_query_arg(array_merge(array('all' => 'true', 'max_rows' => 100000), $query_args), EVT_ADMIN_URL);
    ?>
">
	  			<?php 
    _e('All Events', 'event_espresso');
    ?>
 <span class="count">(<?php 
    echo espresso_total_events();
    ?>
)</span>
	  		</a> |
	  	</li>
	  	<li>
		  	<a <?php 
    echo $view == 'this_month' ? ' class="current" ' : '';
    ?>
  href="<?php 
    echo add_query_arg(array_merge(array('this_month' => 'true'), $query_args), EVT_ADMIN_URL);
    ?>
">
	  			<?php 
    _e('This Month', 'event_espresso');
    ?>
 <span class="count">(<?php 
    echo espresso_total_events_this_month();
    ?>
)</span>
	  		</a>
	  	</li>
	  	<li>| 
		  	<a <?php 
    echo $view == 'today' ? ' class="current" ' : '';
    ?>
 href="<?php 
    echo add_query_arg(array_merge(array('today' => 'true'), $query_args), EVT_ADMIN_URL);
    ?>
">
	  			<?php 
    _e('Today', 'event_espresso');
    ?>
 <span class="count">(<?php 
    echo espresso_total_events_today();
    ?>
)</span>
	  		</a>
	  	</li>
	  </ul>
	 
	  <ul class="subsubsub">
	  	<li>
		  	<strong>
	  			<?php 
    _e('Attendees', 'event_espresso');
    ?>
 :
	  		</strong>
	  	</li>
	  	<li>
		  	<a <?php 
    echo $view == 'all_a' ? ' class="current" ' : '';
    ?>
 href="<?php 
    echo add_query_arg(array_merge(array('event_admin_reports' => 'event_list_attendees', 'all_a' => 'true', 'max_rows' => 100000), $query_args), EVT_ADMIN_URL);
    ?>
">
	  			<?php 
    _e('All Attendees', 'event_espresso');
    ?>
	  			<span class="count">
		  			(<?php 
    echo espresso_total_all_attendees();
    ?>
)
	  			</span>
	  		</a> |
	  	</li>
	  	<li>
		  	<a <?php 
    echo $view == 'this_month_a' ? ' class="current" ' : '';
    ?>
  href="<?php 
    echo add_query_arg(array_merge(array('event_admin_reports' => 'event_list_attendees', 'this_month_a' => 'true'), $query_args), EVT_ADMIN_URL);
    ?>
">
	  			<?php 
    _e('This Month', 'event_espresso');
    ?>
	  			<span class="count">
		  			(<?php 
    echo espresso_total_attendees_this_month();
    ?>
)
	  			</span>
	  		</a>
	  	</li>
	  	<li> | 
		  	<a <?php 
    echo $view == 'today_a' ? ' class="current" ' : '';
    ?>
 href="<?php 
    echo add_query_arg(array_merge(array('event_admin_reports' => 'event_list_attendees', 'today_a' => 'true'), $query_args), EVT_ADMIN_URL);
    ?>
">
	  			<?php 
    _e('Today', 'event_espresso');
    ?>
	  			<span class="count">
		  			(<?php 
    echo espresso_total_attendees_today();
    ?>
)
	  			</span>
	  		</a>
	  	</li>
	  	<?php 
    if ($event_id && (!$event_admin_reports || $event_admin_reports != 'charts')) {
        ?>
	  		<li>
		  		|
	  			<a href="<?php 
        echo add_query_arg(array_merge(array('event_admin_reports' => 'charts', 'event_id' => $event_id), $query_args), EVT_ADMIN_URL);
        ?>
">
	  				<?php 
        _e('View Report', 'event_espresso');
        ?>
	  			</a>
	  		</li>
	  		<?php 
    }
    ?>
	  </ul>
	 
	<div style="clear:both"></div>

	<div class="ee_tablenav tablenav">
		<div class="actions">
			<form id="ee_tablenav" name="ee_tablenav" method="get" action="<?php 
    echo EVT_ADMIN_URL;
    ?>
">	
	<?php 
    // what page are we doing filtering for ?
    if ($event_admin_reports) {
        // add event_admin_reports back into query args
        $query_args['event_admin_reports'] = $event_admin_reports;
        // Filter Month
        espresso_attendees_by_month_dropdown($month_range);
        ?>
		<input type="submit" class="button-secondary" value="Filter Month" id="post-query-month"/> &nbsp; &nbsp; 
		
		<?php 
        // Filter Category
        // when viewing the attendee list for a specific event we no longer need or would want the category filter
        if (!$event_id) {
            if (espresso_category_dropdown($category_id)) {
                ?>
			<input type="submit" class="button-secondary" value="Filter Category" id="post-query-category"/> &nbsp; &nbsp; 			
			<?php 
            }
        }
        // Filter Payment Status
        $status = array(array('id' => '', 'text' => __('Show All Completed/Incomplete', 'event_espresso')), array('id' => 'Completed', 'text' => __('Completed', 'event_espresso')), array('id' => 'Pending', 'text' => __('Pending', 'event_espresso')), array('id' => 'Incomplete', 'text' => __('Incomplete', 'event_espresso')), array('id' => 'Payment Declined', 'text' => __('Payment Declined', 'event_espresso')), array('id' => 'Refund', 'text' => __('Refund', 'event_espresso')));
        echo select_input('payment_status', $status, $payment_status);
        ?>
		<input type="submit" class="button-secondary" value="Filter Status" id="post-query-payment"/>
		
		<a class="button-secondary" href="admin.php?page=events&event_admin_reports=event_list_attendees">
			<?php 
        _e('Reset Filters', 'event_espresso');
        ?>
		</a>
		<?php 
    } else {
        espresso_event_months_dropdown($month_range);
        ?>
		<input type="submit" class="button-secondary" value="Filter Month" id="post-query-submit-month"/>
		<?php 
        if (espresso_category_dropdown($category_id)) {
            ?>
			<input type="submit" class="button-secondary" value="Filter Category" id="post-query-submit-category"/>
		<?php 
        }
        ?>
		<?php 
        $status = array(array('id' => 'A', 'text' => __('Active / Ongoing', 'event_espresso')), array('id' => 'L', 'text' => __('ALL ( Active / Inactive )', 'event_espresso')), array('id' => 'IA', 'text' => __('Inactive', 'event_espresso')), array('id' => 'P', 'text' => __('Pending', 'event_espresso')), array('id' => 'R', 'text' => __('Draft', 'event_espresso')), array('id' => 'S', 'text' => __('Waitlist', 'event_espresso')), array('id' => 'O', 'text' => __('Ongoing', 'event_espresso')), array('id' => 'X', 'text' => __('Denied', 'event_espresso')), array('id' => 'D', 'text' => __('Deleted', 'event_espresso')));
        echo select_input('event_status', $status, $event_status);
        ?>
		<input type="submit" class="button-secondary" value="Filter Status" id="post-query-submit-event-status"/>
		
		<a class="button-secondary" href="admin.php?page=events">
		<?php 
        _e('Reset Filters', 'event_espresso');
        ?>
		</a>
		<?php 
    }
    // query params we need to remove now
    $remove = array('month_range', 'category_id', 'event_status', 'payment_status');
    // then remove the current view from the query args so that the view can be changed
    $query_args = espresso_remove_filter_from_query_args($remove);
    // add view  back into query args
    if (!empty($view)) {
        $query_args[$view] = 'true';
    }
    //because we're doing a get request, we'll need to explicitly preserve the old GET querystring
    foreach ($query_args as $query_arg => $value) {
        echo espresso_hidden_form_input($query_arg, $value);
    }
    $max_rows = isset($_REQUEST['max_rows']) ? absint($_REQUEST['max_rows']) : 50;
    $max_rows = min($max_rows, 100000);
    $start_rec = isset($_REQUEST['start_rec']) && !empty($_REQUEST['start_rec']) ? absint($_REQUEST['start_rec']) : 0;
    $rows = array(5 => 5, 50 => 50, 100 => 100, 250 => 250, 500 => 500, 100000 => 'all');
    $prev_start_rec = $start_rec - $max_rows;
    $next_start_rec = $start_rec + $max_rows;
    ?>

				<div id='ee_table_pagination'>
					<button class='button-secondary'><?php 
    _e("Retrieve", 'event_espresso');
    ?>
</button>		
					<select name="max_rows" size="1">
						<?php 
    foreach ($rows as $key => $value) {
        ?>
							<?php 
        $selected = $key == $max_rows ? ' selected="selected"' : '';
        ?>
							<option value="<?php 
        echo $key;
        ?>
"<?php 
        echo $selected;
        ?>
><?php 
        echo $value;
        ?>
&nbsp;&nbsp;</option>
					<?php 
    }
    ?>
					</select>		
					<?php 
    _e('rows from the Database at a time', 'event_espresso');
    ?>
					
					<input name="start_rec" id='event-list-start-rec' value="<?php 
    echo $start_rec;
    ?>
" class="textfield" type="hidden">
					<?php 
    //show db-level pagination buttons
    if ($prev_start_rec >= 0) {
        ?>
						<a id="event-admin-load-prev-rows-btn" title="load prev rows" class="event-pagination-button button-secondary">
							<?php 
        echo __('Previous', 'event_espresso') . ' ' . $max_rows . ' ' . __('rows', 'event_espresso');
        ?>
						</a>
					<?php 
    }
    if ($total >= $max_rows) {
        ?>
	
					<a  id="event-admin-load-next-rows-btn"  title="load next rows" class="event-pagination-button button-secondary">
						<?php 
        echo __('Next', 'event_espresso') . ' ' . $max_rows . ' ' . __('rows', 'event_espresso');
        ?>
				
					</a> 
					<?php 
    }
    ?>
					
				</div>

			</form>
		</div>
	</div>	
	
	<?php 
    //	echo '<h4>$max_rows : ' . $max_rows . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
    //	echo '<h4>$total : ' . $total . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
    //setup jquery for previous and next buttons,
    //but don't output them here.
    //we actually don't know if we want them both yet anyways
    //because don't know how many records are in the curren tquery, because
    //the query hasn't been run yet. (Hence why its nice to setup all your variables FIRST and then start outputting
    //although sometimes it requires some work and discipline
    //anyways, to output the previous/next buttons, just have some HTML like
    //<a id='event-admin-load-prev-rows-btn'>Previous</a>
    //<a id='event-admin-load-next-rows-btn'>Previous</a>
    //and it can be placed anywher ein the page
    ?>
	<script>
		jQuery(document).ready(function( $ ){
			$('#event-admin-load-prev-rows-btn').click(function(e){
				e.preventDefault();
				event_set_start_rec_and_send_form(<?php 
    echo $prev_start_rec;
    ?>
);
			});
			$('#event-admin-load-next-rows-btn').click(function(e){
				e.preventDefault();
				event_set_start_rec_and_send_form(<?php 
    echo $next_start_rec;
    ?>
);
			});
			$('#ee_tablenav input').click(function(){
				event_reset_start_rec();
			});			
			$('#ee_table_pagination button').click(function(){
				event_reset_start_rec();
			});
			
			function event_set_start_rec_and_send_form(value){ 
				event_reset_view();
				$('#event-list-start-rec').val(value);
				$('#ee_tablenav').submit();
			}
			
			function event_reset_start_rec(){
				event_reset_view();
				$('#event-list-start-rec').val(0);
			}
			
			function event_reset_view(){
				var month_range = $('select[name="month_range"]').val();
				if( month_range != '' ) {
					$('input[name="<?php 
    echo $view;
    ?>
"]').val('');
					$('input[name="<?php 
    echo $view;
    ?>
"]').remove();
				}
			}
			
		});
	</script>
	<?php 
}
<?php

global $espresso_premium;
if ($espresso_premium != true) {
    return;
}
$total_events = espresso_total_events();
?>
<ul class="subsubsub">
	<li><h3><?php 
echo __('Filters', 'event_espresso');
?>
</h3></li>
	<li><strong>
			<?php 
_e('Events', 'event_espresso');
?>
			: </strong> </li>
	<li><a <?php 
echo isset($_REQUEST['all']) && $_REQUEST['all'] == 'true' ? ' class="current" ' : '';
?>
 href="admin.php?page=events&all=true">
			<?php 
_e('All Events', 'event_espresso');
?>
			<span class="count">(<?php 
echo $total_events;
?>
)</span></a> |</li>
	<li><a <?php 
echo isset($_REQUEST['today']) && $_REQUEST['today'] == 'true' ? ' class="current" ' : '';
function event_espresso_edit_list()
{
    global $wpdb, $org_options;
    $wpdb->show_errors();
    //Dates
    $curdate = date("Y-m-d");
    $pieces = explode('-', $curdate, 3);
    $this_year_r = $pieces[0];
    $this_month_r = $pieces[1];
    $days_this_month = date('t', strtotime($curdate));
    if (isset($_POST['delete_event'])) {
        if (is_array($_POST['checkbox'])) {
            while (list($key, $value) = each($_POST['checkbox'])) {
                $del_id = $key;
                event_espresso_delete_event($del_id);
            }
        }
        ?>
		<div id="message" class="updated fade">
			<p><strong>
					<?php 
        _e('Event(s) have been permanently deleted.', 'event_espresso');
        ?>
				</strong></p>
		</div>
		<?php 
    }
    if (isset($_POST['perm_delete_event'])) {
        if (is_array($_POST['checkbox'])) {
            while (list($key, $value) = each($_POST['checkbox'])) {
                $del_id = $key;
                event_espresso_empty_event_trash($del_id);
            }
        }
        ?>

		<div id="message" class="updated fade">
			<p><strong>
					<?php 
        _e('Event(s) have been permanently deleted.', 'event_espresso');
        ?>
				</strong></p>
		</div>
		<?php 
    }
    $recurrence_icon = '';
    if (defined('EVENT_ESPRESSO_RECURRENCE_MODULE_ACTIVE')) {
        $recurrence_icon = '<img src="' . EVENT_ESPRESSO_PLUGINFULLURL . 'images/arrow_rotate_clockwise.png" alt="Recurring Event" title="Recurring Event" class="re_fr" />';
    }
    require_once 'queries.php';
    $total_events = espresso_total_events();
    $records_to_show = '';
    if (file_exists(EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/admin-files/admin_reports_filters.php')) {
        require_once EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/admin-files/admin_reports_filters.php';
    } else {
        echo '<p><strong>' . __('Advanced filters are now available in the premium versions.', 'event_espresso') . '</strong> <a href="http://eventespresso.com/download/" target="_blank">' . __('Upgrade Now!', 'event_espresso') . '</a></p>';
    }
    if ($total_events > 0) {
        if ($total_events > 500) {
            $max_rows = empty($_POST['max_rows']) ? 500 : $_POST['max_rows'];
            $start_rec = empty($_POST['start_rec']) ? 0 : $_POST['start_rec'];
            ?>
			<form method="post" action="admin.php?page=events">
				<p><span style="color: red;"><?php 
            _e('You have more than 500 records.');
            ?>
</span>
				<input name="navig" value="Show:" type="submit" class="button-secondary">
				<input name="max_rows" size="3" value="<?php 
            echo $max_rows;
            ?>
" class="textfield" onfocus="this.select()" type="text">
				<?php 
            _e('row(s) starting from record #', 'event_espresso');
            ?>
				<input name="start_rec" size="6" value="<?php 
            echo $start_rec;
            ?>
" class="textfield" onfocus="this.select()" type="text"></p>
			</form>
			<?php 
            $records_to_show = " LIMIT {$max_rows} OFFSET {$start_rec} ";
        }
        if (!empty($_REQUEST['month_range'])) {
            $pieces = explode('-', $_REQUEST['month_range'], 3);
            $year_r = $pieces[0];
            $month_r = $pieces[1];
        }
        $group = '';
        if (function_exists('espresso_member_data') && espresso_member_data('role') == 'espresso_group_admin') {
            $group = get_user_meta(espresso_member_data('id'), "espresso_group", true);
            $group = unserialize($group);
            $sql = "(SELECT e.id event_id, e.event_name, e.event_identifier, e.reg_limit, e.registration_start, ";
            $sql .= " e.start_date, e.is_active, e.recurrence_id, e.registration_startT ";
            //Get the venue information
            if ($org_options['use_venue_manager'] == 'Y') {
                $sql .= ", v.name AS venue_title, v.address AS venue_address, v.address2 AS venue_address2, v.city AS venue_city, v.state AS venue_state, v.zip AS venue_zip, v.country AS venue_country ";
            } else {
                $sql .= ", e.venue_title, e.phone, e.address, e.address2, e.city, e.state, e.zip, e.country ";
            }
            if ($org_options['use_venue_manager'] == 'Y') {
                $sql .= ", lc.name AS locale_name, e.wp_user ";
            }
            $sql .= " FROM " . EVENTS_DETAIL_TABLE . " e ";
            if ($_REQUEST['category_id'] != '') {
                $sql .= " JOIN " . EVENTS_CATEGORY_REL_TABLE . " cr ON cr.event_id = e.id ";
                $sql .= " JOIN " . EVENTS_CATEGORY_TABLE . " c ON  c.id = cr.cat_id ";
            }
            if ($group != '' && $org_options['use_venue_manager'] == 'Y') {
                $sql .= " LEFT JOIN " . EVENTS_VENUE_REL_TABLE . " vr ON vr.event_id = e.id ";
                $sql .= " LEFT JOIN " . EVENTS_VENUE_TABLE . " v ON v.id = vr.venue_id ";
                $sql .= " LEFT JOIN " . EVENTS_LOCALE_REL_TABLE . " l ON  l.venue_id = vr.venue_id ";
                $sql .= " LEFT JOIN " . EVENTS_LOCALE_TABLE . " lc ON lc.id = l.locale_id ";
            }
            $sql .= $_POST['event_status'] != '' && $_POST['event_status'] != 'IA' ? " WHERE e.event_status = '" . $_POST['event_status'] . "' " : " WHERE e.event_status != 'D' ";
            $sql .= $_REQUEST['category_id'] != '' ? " AND c.id = '" . $_REQUEST['category_id'] . "' " : '';
            $sql .= $group != '' && $org_options['use_venue_manager'] == 'Y' ? " AND l.locale_id IN (" . implode(",", $group) . ") " : '';
            if ($_POST['month_range'] != '') {
                $sql .= " AND e.start_date BETWEEN '" . date('Y-m-d', strtotime($year_r . '-' . $month_r . '-01')) . "' AND '" . date('Y-m-d', strtotime($year_r . '-' . $month_r . '-31')) . "' ";
            }
            if ($_REQUEST['today'] == 'true') {
                $sql .= " AND e.start_date = '" . $curdate . "' ";
            }
            if ($_REQUEST['this_month'] == 'true') {
                $sql .= " AND e.start_date BETWEEN '" . date('Y-m-d', strtotime($this_year_r . '-' . $this_month_r . '-01')) . "' AND '" . date('Y-m-d', strtotime($this_year_r . '-' . $this_month_r . '-' . $days_this_month)) . "' ";
            }
            $sql .= ") UNION ";
        }
        if (!isset($sql)) {
            $sql = '';
        }
        $sql .= "(SELECT e.id event_id, e.event_name, e.event_identifier, e.reg_limit, e.registration_start, ";
        $sql .= " e.start_date, e.is_active, e.recurrence_id, e.registration_startT ";
        //Get the venue information
        if (isset($org_options['use_venue_manager']) && $org_options['use_venue_manager'] == 'Y') {
            $sql .= ", v.name AS venue_title, v.address AS venue_address, v.address2 AS venue_address2, v.city AS venue_city, v.state AS venue_state, v.zip AS venue_zip, v.country AS venue_country ";
        } else {
            $sql .= ", e.venue_title, e.phone, e.address, e.address2, e.city, e.state, e.zip, e.country ";
        }
        if (function_exists('espresso_is_admin') && espresso_is_admin() == true && $org_options['use_venue_manager'] == 'Y') {
            $sql .= ", lc.name AS locale_name, e.wp_user ";
        }
        $sql .= " FROM " . EVENTS_DETAIL_TABLE . " e ";
        if ($_REQUEST['category_id'] != '') {
            $sql .= " JOIN " . EVENTS_CATEGORY_REL_TABLE . " cr ON cr.event_id = e.id ";
            $sql .= " JOIN " . EVENTS_CATEGORY_TABLE . " c ON  c.id = cr.cat_id ";
        }
        if (isset($org_options['use_venue_manager']) && $org_options['use_venue_manager'] == 'Y') {
            $sql .= " LEFT JOIN " . EVENTS_VENUE_REL_TABLE . " vr ON vr.event_id = e.id ";
            $sql .= " LEFT JOIN " . EVENTS_VENUE_TABLE . " v ON v.id = vr.venue_id ";
        }
        if (function_exists('espresso_is_admin') && espresso_is_admin() == true && $org_options['use_venue_manager'] == 'Y') {
            $sql .= " LEFT JOIN " . EVENTS_LOCALE_REL_TABLE . " l ON  l.venue_id = vr.venue_id ";
            $sql .= " LEFT JOIN " . EVENTS_LOCALE_TABLE . " lc ON lc.id = l.locale_id ";
        }
        $sql .= isset($_POST['event_status']) && ($_POST['event_status'] != '' && $_POST['event_status'] != 'IA') ? " WHERE e.event_status = '" . $_POST['event_status'] . "' " : " WHERE e.event_status != 'D' ";
        $sql .= $_REQUEST['category_id'] != '' ? " AND c.id = '" . $_REQUEST['category_id'] . "' " : '';
        if ($_POST['month_range'] != '') {
            $sql .= " AND e.start_date BETWEEN '" . date('Y-m-d', strtotime($year_r . '-' . $month_r . '-01')) . "' AND '" . date('Y-m-d', strtotime($year_r . '-' . $month_r . '-31')) . "' ";
        }
        if (isset($_REQUEST['today']) && $_REQUEST['today'] == 'true') {
            $sql .= " AND e.start_date = '" . $curdate . "' ";
        }
        if (isset($_REQUEST['this_month']) && $_REQUEST['this_month'] == 'true') {
            $sql .= " AND e.start_date BETWEEN '" . date('Y-m-d', strtotime($this_year_r . '-' . $this_month_r . '-01')) . "' AND '" . date('Y-m-d', strtotime($this_year_r . '-' . $this_month_r . '-' . $days_this_month)) . "' ";
        }
        //If user is an event manager, then show only their events
        if (function_exists('espresso_member_data') && (espresso_member_data('role') == 'espresso_event_manager' || espresso_member_data('role') == 'espresso_group_admin')) {
            $sql .= " AND e.wp_user = '******'id') . "' ";
        }
        $sql .= ") ORDER BY start_date  ASC {$records_to_show} ";
        //Debug
        //echo $sql;
        ?>
		<form id="form1" name="form1" method="post" action="<?php 
        echo $_SERVER["REQUEST_URI"];
        ?>
">
			<table id="table" class="widefat event-list" width="100%">
				<thead>
					<tr>
						<th class="manage-column column-cb check-column" id="cb" scope="col" style="width:28px;"><input type="checkbox"></th>

						<th class="manage-column column-comments num" id="id" style="padding-top:7px; width:3%;" scope="col" title="Click to Sort">
							<span><?php 
        _e('ID', 'event_espresso');
        ?>
</span>
							<span class="sorting-indicator"></span>
						</th>

						<th class="manage-column column-title" id="name" scope="col" title="Click to Sort" style="width:26%;">
							<span><?php 
        _e('Name', 'event_espresso');
        ?>
</span>
							<span class="sorting-indicator"></span>
						</th>

						<th class="manage-column column-title" id="name" scope="col" title="Click to Sort" style="width:12%;">
							<span><?php 
        _e('Venue', 'event_espresso');
        ?>
</span>
							<span class="sorting-indicator"></span>
						</th>

						<th class="manage-column column-author" id="start" scope="col" title="Click to Sort" style="width:12%;">
							<span><?php 
        _e('Start Date', 'event_espresso');
        ?>
</span>
							<span class="sorting-indicator"></span>
						</th>

						<th class="manage-column column-author" id="start" scope="col" title="Click to Sort" style="width:10%;">
							<span><?php 
        _e('Start Time', 'event_espresso');
        ?>
</span>
							<span class="sorting-indicator"></span>
						</th>

						<th class="manage-column column-date" id="dow" scope="col" title="Click to Sort" style="width:6%;";>
								<span><?php 
        _e('DoW', 'event_espresso');
        ?>
</span>
							<span class="sorting-indicator"></span>
						</th>

						<th class="manage-column column-date" id="begins" scope="col" title="Click to Sort" style="width:12%;">
							<span><?php 
        _e('Reg Begins', 'event_espresso');
        ?>
</span>
							<span class="sorting-indicator"></span>
						</th>

						<th class="manage-column column-date" id="status" scope="col" title="Click to Sort" style="width:10%;">
							<span><?php 
        _e('Status', 'event_espresso');
        ?>
</span>
							<span class="sorting-indicator"></span>
						</th>
						<?php 
        if (function_exists('espresso_is_admin') && espresso_is_admin() == true && $espresso_premium == true) {
            ?>
							<th class="manage-column column-date" id="status" scope="col" title="Click to Sort" style="width:10%;">
								<span><?php 
            _e('Creator', 'event_espresso');
            ?>
</span>
								<span class="sorting-indicator"></span>
							</th>
						<?php 
        }
        ?>
						<th class="manage-column column-date" id="attendees" scope="col" title="Click to Sort" style="width:9%;">
							<span><?php 
        _e('Attendees', 'event_espresso');
        ?>
</span>
							<span class="sorting-indicator"></span>
						</th>
						<th class="manage-column column-author" id="actions" scope="col" style="width:25%;">
							<?php 
        _e('Actions', 'event_espresso');
        ?>
						</th>

					</tr>
				</thead>

				<tbody>
					<?php 
        $events = $wpdb->get_results($sql);
        foreach ($events as $event) {
            //print_r ($event);
            $event_id = $event->event_id;
            $event_name = stripslashes_deep($event->event_name);
            $event_identifier = stripslashes_deep($event->event_identifier);
            $reg_limit = isset($event->reg_limit) ? $event->reg_limit : '';
            $registration_start = isset($event->registration_start) ? $event->registration_start : '';
            $start_date = isset($event->start_date) ? $event->start_date : '';
            $end_date = isset($event->end_date) ? $event->end_date : '';
            $is_active = isset($event->is_active) ? $event->is_active : '';
            $status = array();
            $status = event_espresso_get_is_active($event_id);
            $recurrence_id = isset($event->recurrence_id) ? $event->recurrence_id : '';
            $registration_startT = isset($event->registration_startT) ? $event->registration_startT : '';
            $event_address = isset($event->address) ? $event->address : '';
            $event_address2 = isset($event->address2) ? $event->address2 : '';
            $event_city = isset($event->city) ? $event->city : '';
            $event_state = isset($event->state) ? $event->state : '';
            $event_zip = isset($event->zip) ? $event->zip : '';
            $event_country = isset($event->country) ? $event->country : '';
            //added new
            $venue_title = isset($event->venue_title) ? $event->venue_title : '';
            $venue_locale = isset($event->locale_name) ? $event->locale_name : '';
            $wp_user = isset($event->wp_user) ? $event->wp_user : '';
            $location = (!empty($event_address) ? $event_address : '') . (!empty($event_address2) ? '<br />' . $event_address2 : '') . (!empty($event_city) ? '<br />' . $event_city : '') . (!empty($event_state) ? ', ' . $event_state : '') . (!empty($event_zip) ? '<br />' . $event_zip : '') . (!empty($event_country) ? '<br />' . $event_country : '');
            $dow = date("D", strtotime($start_date));
            ob_start();
            ?>
						<tr>
							<td class="check-column" style="padding:7px 0 22px 7px; vertical-align:top;"><!--Delete Events-->
								<?php 
            echo '<input name="checkbox[' . $event_id . ']" type="checkbox"  title="Delete Event ' . $event_name . '" />';
            ?>
</td>

							<td class="column-comments" style="padding-top:3px;"><?php 
            echo $event_id;
            ?>
</td>

							<td class="post-title page-title"><strong><a class="row-title" href="admin.php?page=events&action=edit&event_id=<?php 
            echo $event_id;
            ?>
"><?php 
            echo $event_name;
            ?>
</a> <?php 
            echo $recurrence_id > 0 ? $recurrence_icon : '';
            ?>
 </strong>
								<div class="row-actions"><span><a href="<?php 
            echo espresso_reg_url($event_id);
            ?>
" target="_blank"><?php 
            _e('View', 'event_espresso');
            ?>
</a> | </span><span class='edit'><a href="admin.php?page=events&amp;action=edit&amp;event_id=<?php 
            echo $event_id;
            ?>
"><?php 
            _e('Edit', 'event_espresso');
            ?>
</a> | </span><span class='delete'><a onclick="return confirmDelete();" href='admin.php?page=events&amp;action=delete&amp;event_id=<?php 
            echo $event_id;
            ?>
'><?php 
            _e('Delete', 'event_espresso');
            ?>
</a></span> | <span><a href="admin.php?page=events&amp;event_admin_reports=list_attendee_payments&amp;event_id=<?php 
            echo $event_id;
            ?>
"><?php 
            _e('Attendees', 'event_espresso');
            ?>
</a> | </span><span><a href="#" onclick="window.location='<?php 
            echo get_bloginfo('wpurl') . "/wp-admin/admin.php?event_espresso&amp;event_id=" . $event_id . "&amp;export=report&action=payment&amp;type=excel";
            ?>
'" title="<?php 
            _e('Export to Excel', 'event_espresso');
            ?>
"><?php 
            _e('Export', 'event_espresso');
            ?>
</a></span></div></td>

							<td class="author"><?php 
            echo $venue_title != '' ? $venue_title : '';
            echo $venue_locale != '' ? '<br />[' . $venue_locale . ']' : '';
            ?>
</td>

							<td class="author"><?php 
            echo event_date_display($start_date, get_option('date_format'));
            ?>
</td>

							<td class="author"><?php 
            echo event_espresso_get_time($event_id, 'start_time');
            ?>
</td>

							<td class="date"><?php 
            echo $dow;
            ?>
</td>

							<td class="date"><?php 
            echo event_date_display($registration_start, get_option('date_format'));
            ?>
 <br />
								<?php 
            echo $registration_startT;
            ?>
</td>

							<td class="date"><?php 
            echo $status['display'];
            ?>
</td>

							<?php 
            if (function_exists('espresso_is_admin') && espresso_is_admin() == true && $espresso_premium == true) {
                $user_company = espresso_user_meta($wp_user, 'company') != '' ? espresso_user_meta($wp_user, 'company') : '';
                $user_organization = espresso_user_meta($wp_user, 'organization') != '' ? espresso_user_meta($wp_user, 'organization') : '';
                $user_co_org = $user_company != '' ? $user_company : $user_organization;
                ?>
								<td class="date"><?php 
                echo espresso_user_meta($wp_user, 'user_firstname') != '' ? espresso_user_meta($wp_user, 'user_firstname') . ' ' . espresso_user_meta($wp_user, 'user_lastname') : espresso_user_meta($wp_user, 'display_name');
                ?>
									<?php 
                echo $user_co_org != '' ? '<br />[' . espresso_user_meta($wp_user, 'company') . ']' : '';
                ?>
								</td>
							<?php 
            }
            ?>

							<td class="author"><a href="admin.php?page=events&amp;event_admin_reports=list_attendee_payments&amp;event_id=<?php 
            echo $event_id;
            ?>
"><?php 
            echo get_number_of_attendees_reg_limit($event_id, 'num_attendees_slash_reg_limit');
            ?>
</a></td>
							<td class="date"><div style="width:180px;"><a href="<?php 
            echo espresso_reg_url($event_id);
            ?>
" title="<?php 
            _e('View Event', 'event_espresso');
            ?>
" target="_blank"><div class="view_btn"></div></a>

									<a href="admin.php?page=events&amp;action=edit&amp;event_id=<?php 
            echo $event_id;
            ?>
" title="<?php 
            _e('Edit Event', 'event_espresso');
            ?>
"><div class="edit_btn"></div></a>

									<a href="admin.php?page=events&amp;event_id=<?php 
            echo $event_id;
            ?>
&amp;event_admin_reports=list_attendee_payments" title="<?php 
            _e('View Attendees', 'event_espresso');
            ?>
"><div class="complete_btn"></div></a>
									<a href="admin.php?page=events&event_admin_reports=charts&event_id=<?php 
            echo $event_id;
            ?>
" title="<?php 
            _e('View Report', 'event_espresso');
            ?>
"><div class="reports_btn"></div></a>


									<a class="thickbox" href="#TB_inline?height=300&width=400&inlineId=unique_id_info_<?php 
            echo $event_id;
            ?>
" title="<?php 
            _e('Get Short URL/Shortcode', 'event_espresso');
            ?>
"><div class="shortcode_btn"></div></a>

									<a href="#" onclick="window.location='<?php 
            echo get_bloginfo('wpurl') . "/wp-admin/admin.php?event_espresso&amp;event_id=" . $event_id . "&amp;export=report&action=payment&amp;type=excel";
            ?>
'" title="<?php 
            _e('Export to Excel', 'event_espresso');
            ?>
"><div class="excel_exp_btn"></div></a>

									<a href="#" onclick="window.location='<?php 
            echo get_bloginfo('wpurl') . "/wp-admin/admin.php?event_espresso&event_id=" . $event_id . "&export=report&action=payment&type=csv";
            ?>
'" title="<?php 
            _e('Export to CSV', 'event_espresso');
            ?>
"><div class="csv_exp_btn"></div></a>

									<a href="admin.php?page=events&amp;event_admin_reports=event_newsletter&amp;event_id=<?php 
            echo $event_id;
            ?>
" title="<?php 
            _e('Email Attendees', 'event_espresso');
            ?>
"><div class="newsletter_btn"></div></a></div>

								<div id="unique_id_info_<?php 
            echo $event_id;
            ?>
" style="display:none">
									<?php 
            _e('<h2>Short URL/Shortcode</h2><p>This is the short URL to this event:</p><p><span  class="updated fade">' . espresso_reg_url($event_id) . '</span></p><p>This will show the registration form for this event just about anywhere. Copy and paste the following shortcode into any page or post.</p><p><span  class="updated fade">[SINGLEEVENT single_event_id="' . $event_identifier . '"]</span></p> <p class="red_text"> Do not use in place of the main events page that is set in the Organization Settings page.', 'event_espresso');
            ?>
								</div></td>
						</tr>
						<?php 
            //echo $_REQUEST['event_status'];
            if (!empty($_REQUEST['event_status'])) {
                $content = ob_get_contents();
                ob_end_clean();
                switch ($_REQUEST['event_status']) {
                    case 'A':
                        switch (event_espresso_get_status($event_id, empty($event_meta) ? '' : $event_meta)) {
                            case 'NOT_ACTIVE':
                                //Don't show the event if any of the above are true
                                break;
                            default:
                                echo $content;
                                break;
                        }
                        break;
                    case 'IA':
                        switch (event_espresso_get_status($event_id)) {
                            case 'NOT_ACTIVE':
                                echo $content;
                                break;
                            default:
                                //Don' show the event if any of the above are true
                                break;
                        }
                        break;
                    default:
                        echo $content;
                        break;
                }
            }
        }
        //End foreach ($events as $event){
    }
    ?>

			</tbody>
		</table>
		<div style="clear:both; margin-bottom:30px;">
			<input type="checkbox" name="sAll" onclick="selectAll(this)" />
			<strong>
				<?php 
    _e('Check All', 'event_espresso');
    ?>
			</strong><?php 
    if (isset($_POST['event_status']) && $_POST['event_status'] == 'D') {
        ?>
				<input name="perm_delete_event" type="submit" class="button-secondary" id="perm_delete_event" value="<?php 
        _e('Permanently Delete Events(s)', 'event_espresso');
        ?>
" style="margin:10px 0 0 10px;" onclick="return confirmDelete();" />
			<?php 
    } else {
        ?>
				<input name="delete_event" type="submit" class="button-secondary" id="delete_event" value="<?php 
        _e('Delete Events(s)', 'event_espresso');
        ?>
" style="margin:10px 0 0 10px;" onclick="return confirmDelete();" />

				<a  style="margin-left:5px"class="button-primary" href="admin.php?page=events&amp;action=csv_import"><?php 
        _e('Import CSV', 'event_espresso');
        ?>
</a>

				<a class="button-primary" href="#" onclick="window.location='<?php 
        echo get_bloginfo('wpurl') . "/wp-admin/admin.php?event_espresso&amp;id=" . $event_id . "&amp;export=report&action=payment&amp;type=excel&all_events=true";
        ?>
'" title="<?php 
        _e('Export to Excel', 'event_espresso');
        ?>
"><?php 
        _e('Export All Attendee Data', 'event_espresso');
        ?>
</a>
				<a class="button-primary" href="#" onclick="window.location='<?php 
        echo get_bloginfo('wpurl') . "/wp-admin/admin.php?event_espresso&amp;id=" . $event_id . "&amp;export=report&action=event&amp;type=excel&all_events=true";
        ?>
'" title="<?php 
        _e('Export to Excel', 'event_espresso');
        ?>
"><?php 
        _e('Export All Event Data', 'event_espresso');
        ?>
</a>
				<a style="margin-left:5px" class="button-primary" href="admin.php?page=events&amp;action=add_new_event"><?php 
        _e('Add New Event', 'event_espresso');
        ?>
</a>
			<?php 
    }
    ?>
  </div>
	</form>
	<h4 style="clear:both"><?php 
    _e('Legend', 'event_espresso');
    ?>
</h4>
	<dl style="float:left; margin-left:10px; width:200px">
		<?php 
    echo defined('EVENT_ESPRESSO_RECURRENCE_MODULE_ACTIVE') ? '<dt><img src="' . EVENT_ESPRESSO_PLUGINFULLURL . 'images/arrow_rotate_clockwise.png" alt="Recurring Event" title="Recurring Event"  /> - ' . __('Recurring Event', 'event_espresso') . '</dt>' : '';
    ?>
		<dt><img src="<?php 
    echo EVENT_ESPRESSO_PLUGINFULLURL;
    ?>
images/icons/magnifier.png" width="16" height="16" alt="<?php 
    _e('View Event', 'event_espresso');
    ?>
" /> - <?php 
    _e('View Event', 'event_espresso');
    ?>
</dt>

		<dt><img src="<?php 
    echo EVENT_ESPRESSO_PLUGINFULLURL;
    ?>
images/icons/calendar_edit.png" width="16" height="16" alt="<?php 
    _e('Edit Event', 'event_espresso');
    ?>
" /> - <?php 
    _e('Edit Event', 'event_espresso');
    ?>
</dt>

		<dt><img src="<?php 
    echo EVENT_ESPRESSO_PLUGINFULLURL;
    ?>
images/icons/group.png" width="16" height="16" alt="<?php 
    _e('Event Attendees', 'event_espresso');
    ?>
" /> - <?php 
    _e('Event Attendees', 'event_espresso');
    ?>
</dt>
		<dt><img src="<?php 
    echo EVENT_ESPRESSO_PLUGINFULLURL;
    ?>
images/icons/chart_bar.png" width="16" height="16" alt="<?php 
    _e('Send Event Email', 'event_espresso');
    ?>
" /> - <?php 
    _e('View Report', 'event_espresso');
    ?>
</dt>


	</dl>

	<dl style="float:left; margin-left:10px;">
		<dt><img src="<?php 
    echo EVENT_ESPRESSO_PLUGINFULLURL;
    ?>
images/icons/tag.png" width="16" height="16" alt="<?php 
    _e('Short Code', 'event_espresso');
    ?>
" /> - <?php 
    _e('Short Code', 'event_espresso');
    ?>
</dt>
		<dt><img src="<?php 
    echo EVENT_ESPRESSO_PLUGINFULLURL;
    ?>
images/icons/excel_icon.png" width="16" height="16" alt="<?php 
    _e('Excel Spreadsheet', 'event_espresso');
    ?>
" /> - <?php 
    _e('Excel Export', 'event_espresso');
    ?>
</dt>

		<dt><img src="<?php 
    echo EVENT_ESPRESSO_PLUGINFULLURL;
    ?>
images/icons/csv_icon_sm.gif" width="16" height="16" alt="<?php 
    _e('CSV Spreadsheet', 'event_espresso');
    ?>
" /> - <?php 
    _e('CSV Export', 'event_espresso');
    ?>
</dt>

		<dt><img src="<?php 
    echo EVENT_ESPRESSO_PLUGINFULLURL;
    ?>
images/icons/email_go.png" width="16" height="16" alt="<?php 
    _e('View Report', 'event_espresso');
    ?>
" /> - <?php 
    _e('Event Newsletter', 'event_espresso');
    ?>
</dt>
	</dl>

	<script>
		jQuery(document).ready(function($) {
			/* show the table data */
			var mytable = $('#table').dataTable( {
				"sDom": 'Clfrtip',
				"aoColumns": [
					{ "bSortable": false },
					null,
					null,
					null,
					null,
					null,
					null,
					null,
					null,
	<?php 
    echo function_exists('espresso_is_admin') && espresso_is_admin() == true ? 'null,' : '';
    ?>
					null,
					{ "bSortable": false }
				],
				"aoColumnDefs": [
					{ "bVisible": false, "aTargets": [ <?php 
    echo $org_options['use_venue_manager'] == 'Y' ? '' : '3,';
    ?>
 6, <?php 
    //echo function_exists('espresso_is_admin')&&espresso_is_admin()==true ? '11' : '10';
    ?>
  ] }
				],
				"oColVis": {
					"aiExclude": [ 0, 1, 2 ],
					"buttonText": "Filter: Show / Hide Columns",
					"bRestore": true
				},
				"bAutoWidth": false,
				"bStateSave": true,
				"sPaginationType": "full_numbers",
				"oLanguage": {	"sSearch": "<strong><?php 
    _e('Live Search Filter', 'event_espresso');
    ?>
:</strong>",
					"sZeroRecords": "<?php 
    _e('No Records Found!', 'event_espresso');
    ?>
" }

			} );

		} );
	</script>

	<div id="coupon_code_info" style="display:none">
		<h2><?php 
    _e('Coupon/Promo Code', 'event_espresso');
    ?>
</h2><p><?php 
    _e('This is used to apply discounts to events.', 'event_espresso');
    ?>
</p><p><?php 
    _e('A coupon or promo code could can be anything you want. For example: Say you have an event that costs', 'event_espresso');
    ?>
 <?php 
    echo $org_options['currency_symbol'];
    ?>
200. <?php 
    _e('If you supplied a promo like "PROMO50" and entered 50.00 into the "Discount w/Promo Code" field your event will be discounted', 'event_espresso');
    ?>
  <?php 
    echo $org_options['currency_symbol'];
    ?>
50.00, <?php 
    _e('Bringing the cost of the event to', 'event_espresso');
    ?>
 <?php 
    echo $org_options['currency_symbol'];
    ?>
150.</p>
	</div>
	<div id="unique_id_info" style="display:none">
		<h2><?php 
    _e('Event Identifier', 'event_espresso');
    ?>
</h2><p><?php 
    _e('This should be a unique identifier for the event. Example: "Event1" (without qoutes.)</p><p>The unique ID can also be used in individual pages using the', 'event_espresso');
    ?>
 [SINGLEEVENT single_event_id="<?php 
    _e('Unique Event ID', 'event_espresso');
    ?>
"] <?php 
    _e('shortcode', 'event_espresso');
    ?>
.</p>
	</div>
	<?php 
    echo event_espresso_custom_email_info();
}
function event_list_attendees()
{
    global $wpdb, $org_options, $ticketing_installed;
    //Dates
    $curdate = date("Y-m-d");
    $pieces = explode('-', $curdate, 3);
    $this_year_r = $pieces[0];
    $this_month_r = $pieces[1];
    $days_this_month = date('t', strtotime($curdate));
    if (!empty($_POST['delete_customer'])) {
        if (is_array($_POST['checkbox'])) {
            while (list($key, $value) = each($_POST['checkbox'])) {
                $del_id = $key;
                $sql = "DELETE FROM " . EVENTS_ATTENDEE_TABLE . " WHERE id = '{$del_id}'";
                $wpdb->query($sql);
            }
        }
        ?>

<div id="message" class="updated fade">
  <p><strong>
    <?php 
        _e('Customer(s) have been successfully deleted from the event.', 'event_espresso');
        ?>
    </strong></p>
</div>
<?php 
    }
    //	MARKING USERS AS ATTENDED (OR NOT)
    if ((!empty($_POST['attended_customer']) || !empty($_POST['unattended_customer'])) && $ticketing_installed == true) {
        if (is_array($_POST['checkbox'])) {
            while (list($key, $value) = each($_POST['checkbox'])) {
                $del_id = $key;
                //echo $del_id . " / " . $value . "<br />\n";
                if ($value == "on" && $_POST['attended_customer']) {
                    $checker = 1;
                } else {
                    $checker = 0;
                }
                $wpdb->get_results("SELECT checked_in_quantity FROM " . EVENTS_ATTENDEE_TABLE . " WHERE id = '{$del_id}' LIMIT 0,1 ");
                $ticket_scanned = $wpdb->last_result[0]->checked_in_quantity;
                if ($ticket_scanned >= 1) {
                    ?>
					<div id="message" class="error fade">
					  <p><strong>
						<?php 
                    _e('Scanned tickets cannot be redeemed/un-redeemed here.', 'event_espresso');
                    ?>
						</strong></p>
					</div>
					<?php 
                } else {
                    $sql = "UPDATE " . EVENTS_ATTENDEE_TABLE . " SET checked_in = {$checker} WHERE id = '{$del_id}'";
                    $wpdb->query($sql);
                    //echo $sql;
                    ?>
					<div id="message" class="updated fade">
					  <p><strong>
						<?php 
                    _e('Customer(s) attendance data successfully updated for this event.', 'event_espresso');
                    ?>
						</strong></p>
					</div>
					<?php 
                }
            }
        }
    }
    require_once EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/event-management/queries.php';
    $total_events = espresso_total_events();
    if (file_exists(EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/admin-files/admin_reports_filters.php')) {
        require_once EVENT_ESPRESSO_PLUGINFULLPATH . 'includes/admin-files/admin_reports_filters.php';
    } else {
        echo '<p><strong>' . __('Advanced filters are available in the premium versions.', 'event_espresso') . '</strong> <a href="http://eventespresso.com/download/" target="_blank">' . __('Upgrade Now!', 'event_espresso') . '</a></p>';
    }
    if (isset($_REQUEST['event_id']) && $_REQUEST['event_id'] != '') {
        echo '<h3>' . espresso_event_list_attendee_title($_REQUEST['event_id']) . '</h3>';
    }
    ?>
<style type="text/css">
        .dataTables_paginate {margin-top:10px;}
        .sorting_asc .sorting_desc {}
        th.sorting_asc span.sorting-indicator {display:block; margin-left:3px; background-position: 0 0;}
        th.sorting_desc span.sorting-indicator {display:block; margin-left:3px; background-position: -7px 0;}
        #table thead tr th span {cursor:pointer; float:left;}
        #table thead tr th span:hover {color:#D54E21;}
        #table_filter input {width:250px; background:#fff;}

        /*fixing this */
        .view_btn:hover, .edit_btn:hover, .complete_btn:hover, .shortcode_btn:hover, .excel_exp_btn:hover, .csv_exp_btn:hover, .newsletter_btn:hover  {height: 18px; margin: 2px 3px 0 0;}
    </style>
<?php 
    /*if (!empty($_REQUEST['event_id'])) { ?>
    
            <h3 style="margin-bottom:15px;"><?php _e('Attendee Report for Event ID:', 'event_espresso'); ?> <?php espresso_event_list_attendee_title($_REQUEST['event_id']); ?></h3>
    
        <?php }*/
    ?>
<form id="form1" name="form1" method="post" action="<?php 
    echo $_SERVER["REQUEST_URI"];
    ?>
">
  <table id="table" class="widefat fixed" width="100%">
    <thead>
      <tr>
        <th class="manage-column column-cb check-column" id="cb" scope="col" style="width: 4%;"><input type="checkbox"></th>
        <th class="manage-column column-title" id="name" scope="col" title="Click to Sort"style="width: 10%;"> <span>
          <?php 
    _e('Attendee Name', 'event_espresso');
    ?>
          <span> <span class="sorting-indicator"></span> </th>
        <th class="manage-column column-date" id="registrationid" scope="col" title="Click to Sort" style="width: 10%;"> <span>
          <?php 
    _e('Reg ID', 'event_espresso');
    ?>
          </span> <span class="sorting-indicator"></span> </th>
        <th class="manage-column column-date" id="registration" scope="col" title="Click to Sort" style="width: 10%;"> <span>
          <?php 
    _e('Registered', 'event_espresso');
    ?>
          </span> <span class="sorting-indicator"></span> </th>
        <th class="manage-column column-title" id="event" scope="col" title="Click to Sort" style="width: 10%;"> <span>
          <?php 
    _e('Event Title', 'event_espresso');
    ?>
          </span> <span class="sorting-indicator"></span> </th>
        <th class="manage-column column-title" id="event" scope="col" title="Click to Sort" style="width: 8%;"> <span>
          <?php 
    _e('Event Time', 'event_espresso');
    ?>
          </span> <span class="sorting-indicator"></span> </th>
        <?php 
    if ($ticketing_installed == true) {
        ?>
        <th class="manage-column column-title" id="attended" scope="col" title="Click to Sort" style="width: 8%;"> <span>
          <?php 
        _e('Attended', 'event_espresso');
        ?>
          </span> <span class="sorting-indicator"></span> </th>
        <?php 
    }
    ?>
        <th class="manage-column column-title" id="event" scope="col" title="Click to Sort" style="width: 8%;"> <span>
          <?php 
    _e('Option', 'event_espresso');
    ?>
          </span> <span class="sorting-indicator"></span> </th>
        <th align="center" class="manage-column column-date" id="amount" style="width: 10%;" title="Click to Sort" scope="col"> <span>
          <?php 
    _e('Payment', 'event_espresso');
    ?>
          </span> <span class="sorting-indicator"></span> </th>
        <th class="manage-column column-date" id="payment_type" scope="col" title="Click to Sort" style="width: 10%;"> <span>
          <?php 
    _e('Type', 'event_espresso');
    ?>
          </span> <span class="sorting-indicator"></span> </th>
        <th class="manage-column column-date" id="coupon" scope="col" title="Click to Sort" style="width: 12%;"> <span>
          <?php 
    _e('Coupon', 'event_espresso');
    ?>
          </span> <span class="sorting-indicator"></span> </th>
        <th class="manage-column column-date" id="txn_id" scope="col" title="Click to Sort" style="width: 15%;"> <span>
          <?php 
    _e('Transaction ID', 'event_espresso');
    ?>
          </span> <span class="sorting-indicator"></span> </th>
        <th class="manage-column column-date" id="action" scope="col" title="Click to Sort"style="width: 8%;"><?php 
    _e('Action', 'event_espresso');
    ?>
</th>
      </tr>
    </thead>
    <tbody>
      <?php 
    $temp_reg_id = '';
    //will temporarily hold the registration id for checking with the next row
    $attendees_group = '';
    //will hold the names of the group members
    $counter = 0;
    //used for keeping track of the last row.  If counter = num_rows, print
    $go = false;
    //triggers the output when true.  Set when the next reg id != temp_reg_id
    $sql_clause = " WHERE ";
    $sql_a = "(";
    if (function_exists('espresso_member_data') && espresso_member_data('role') == 'espresso_group_admin') {
        $group = get_user_meta(espresso_member_data('id'), "espresso_group", true);
        $group = unserialize($group);
        $group = implode(",", $group);
        $sql_a .= "SELECT a.*, e.id event_id, e.event_name, checked_in FROM " . EVENTS_ATTENDEE_TABLE . " a ";
        $sql_a .= " LEFT JOIN " . EVENTS_DETAIL_TABLE . " e ON e.id=a.event_id ";
        if ($_REQUEST['category_id'] != '') {
            $sql_a .= " JOIN " . EVENTS_CATEGORY_REL_TABLE . " r ON r.event_id = e.id ";
            $sql_a .= " JOIN " . EVENTS_CATEGORY_TABLE . " c ON  c.id = r.cat_id ";
        }
        if ($group != '') {
            $sql_a .= " JOIN " . EVENTS_VENUE_REL_TABLE . " r ON r.event_id = e.id ";
            $sql_a .= " JOIN " . EVENTS_LOCALE_REL_TABLE . " l ON  l.venue_id = r.venue_id ";
        }
        $sql_a .= $_REQUEST['category_id'] != '' ? " AND c.id = '" . $_REQUEST['category_id'] . "' " : '';
        $sql_clause = " WHERE ";
        if ($_REQUEST['payment_status'] != '') {
            $sql_a .= " {$sql_clause} a.payment_status = '" . $_REQUEST['payment_status'] . "' ";
            $sql_clause = " AND ";
        }
        if ($_POST['month_range'] != '') {
            $pieces = explode('-', $_REQUEST['month_range'], 3);
            $year_r = $pieces[0];
            $month_r = $pieces[1];
            $sql_a .= " {$sql_clause} a.date BETWEEN '" . event_espresso_no_format_date($year_r . '-' . $month_r . '-01', $format = 'Y-m-d') . "' AND '" . event_espresso_no_format_date($year_r . '-' . $month_r . '-31', $format = 'Y-m-d') . "' ";
            $sql_clause = " AND ";
        }
        if ($_REQUEST['event_id'] != '') {
            $sql_a .= " {$sql_clause} a.event_id = '" . $_REQUEST['event_id'] . "' ";
            $sql_clause = " AND ";
        }
        if ($_REQUEST['today_a'] == 'true') {
            //$sql_a .= " $sql_clause a.date = '" . event_espresso_no_format_date($curdate,$format = 'Y-m-d') ."' ";
            $sql_a .= " {$sql_clause} a.date BETWEEN '" . $curdate . ' 00:00:00' . "' AND '" . $curdate . ' 23:59:59' . "' ";
            $sql_clause = " AND ";
        }
        if ($_REQUEST['this_month_a'] == 'true') {
            $sql_a .= " {$sql_clause} a.date BETWEEN '" . event_espresso_no_format_date($this_year_r . '-' . $this_month_r . '-01', $format = 'Y-m-d') . "' AND '" . event_espresso_no_format_date($this_year_r . '-' . $this_month_r . '-' . $days_this_month, $format = 'Y-m-d') . "' ";
            $sql_clause = " AND ";
        }
        $sql_a .= $group != '' ? $sql_clause . "  l.locale_id IN (" . $group . ") " : '';
        $sql_a .= " AND e.event_status != 'D' ";
        $sql_a .= ") UNION (";
    }
    $sql_a .= "SELECT a.*, e.id event_id, e.event_name, checked_in FROM " . EVENTS_ATTENDEE_TABLE . " a ";
    $sql_a .= " LEFT JOIN " . EVENTS_DETAIL_TABLE . " e ON e.id=a.event_id ";
    if (!empty($_REQUEST['category_id'])) {
        $sql_a .= " JOIN " . EVENTS_CATEGORY_REL_TABLE . " r ON r.event_id = e.id ";
        $sql_a .= " JOIN " . EVENTS_CATEGORY_TABLE . " c ON  c.id = r.cat_id ";
    }
    $sql_a .= !empty($_REQUEST['category_id']) ? " AND c.id = '" . $_REQUEST['category_id'] . "' " : '';
    $sql_clause = " WHERE ";
    if (!empty($_REQUEST['payment_status'])) {
        $sql_a .= " {$sql_clause} a.payment_status = '" . $_REQUEST['payment_status'] . "' ";
        $sql_clause = " AND ";
    }
    if (!empty($_POST['month_range'])) {
        $pieces = explode('-', $_REQUEST['month_range'], 3);
        $year_r = $pieces[0];
        $month_r = $pieces[1];
        $sql_a .= " {$sql_clause} a.date BETWEEN '" . event_espresso_no_format_date($year_r . '-' . $month_r . '-01', $format = 'Y-m-d') . "' AND '" . event_espresso_no_format_date($year_r . '-' . $month_r . '-31', $format = 'Y-m-d') . "' ";
        $sql_clause = " AND ";
    }
    if (!empty($_REQUEST['event_id'])) {
        $sql_a .= " {$sql_clause} a.event_id = '" . $_REQUEST['event_id'] . "' ";
        $sql_clause = " AND ";
    }
    if (!empty($_REQUEST['today_a'])) {
        //$sql_a .= " $sql_clause a.date = '" . event_espresso_no_format_date($curdate,$format = 'Y-m-d') ."' ";
        $sql_a .= " {$sql_clause} a.date BETWEEN '" . $curdate . ' 00:00:00' . "' AND '" . $curdate . ' 23:59:59' . "' ";
        $sql_clause = " AND ";
    }
    if (!empty($_REQUEST['this_month_a'])) {
        $sql_a .= " {$sql_clause} a.date BETWEEN '" . event_espresso_no_format_date($this_year_r . '-' . $this_month_r . '-01', $format = 'Y-m-d') . "' AND '" . event_espresso_no_format_date($this_year_r . '-' . $this_month_r . '-' . $days_this_month, $format = 'Y-m-d') . "' ";
        $sql_clause = " AND ";
    }
    if (function_exists('espresso_member_data') && (espresso_member_data('role') == 'espresso_event_manager' || espresso_member_data('role') == 'espresso_group_admin')) {
        $sql_a .= $sql_clause . " e.wp_user = '******'id') . "' ";
    }
    $sql_a .= " {$sql_clause} e.event_status != 'D' ";
    $sql_a .= ") ORDER BY date DESC, id ASC ";
    $attendees = $wpdb->get_results($sql_a);
    //echo $sql_a;
    $total_attendees = $wpdb->num_rows;
    $quantity = 0;
    $attendees_group = '';
    if ($total_attendees > 0) {
        foreach ($attendees as $attendee) {
            /**
            		09-07-11 Edit Seth
            		Removing the grouping functionality to make attendees easier to manage
            	**/
            #if (isset($attendees[$i])){
            //if (isset($attendees[$i])){
            //$attendee = $attendees[$i];
            //echo 'Reg. Id: '.$registration_id.'<br />';
            $registration_id = $attendee->registration_id;
            $lname = $attendee->lname;
            $fname = $attendee->fname;
            $address = $attendee->address;
            $city = $attendee->city;
            $state = $attendee->state;
            $zip = $attendee->zip;
            $email = '<span style="visibility:hidden">' . $attendee->email . '</span>';
            $phone = $attendee->phone;
            $quantity = $attendee->quantity > 1 ? '<br />(' . __('Total Attendees', 'event_espresso') . ': ' . $attendee->quantity . ')' : '';
            //if ($temp_reg_id == '') {
            $id = $attendee->id;
            //$temp_reg_id = $registration_id;
            //echo 'Temp Reg. Id: '.$registration_id.'<br />';
            $attended = $attendee->checked_in;
            $ticket_scanned = $attendee->checked_in_quantity;
            $amount_pd = $attendee->amount_pd;
            $payment_status = $attendee->payment_status;
            $payment_date = $attendee->payment_date;
            $date = $attendee->date;
            $event_id = $attendee->event_id;
            $coupon_code = $attendee->coupon_code;
            $txn_id = $attendee->txn_id;
            $txn_type = $attendee->txn_type;
            $price_option = $attendee->price_option;
            $event_time = $attendee->event_time;
            $event_name = $attendee->event_name;
            $event_date = $attendee->start_date;
            ?>
                  <tr>
                    <td class="check-column" style="padding:7px 0 22px 7px; vertical-align:top;"><input name="checkbox[<?php 
            echo $id;
            ?>
]" type="checkbox"  title="Delete <?php 
            echo $fname;
            echo $lname;
            ?>
"></td>
                    <td class="row-title"  nowrap="nowrap"><a href="admin.php?page=events&amp;event_admin_reports=edit_attendee_record&amp;event_id=<?php 
            echo $event_id;
            ?>
&amp;registration_id=<?php 
            echo $registration_id;
            ?>
&amp;form_action=edit_attendee&amp;id=<?php 
            echo $id;
            ?>
" title="<?php 
            echo 'ID#:' . $id . ' [ REG#: ' . $registration_id . ' ]';
            ?>
"><?php 
            echo $fname;
            ?>
 <?php 
            echo $lname;
            ?>
                      <?php 
            /*?><ul>
                 <?php echo $attendees_group ?>
              </ul><?php */
            ?>
                      </a></td>
                    <td nowrap="nowrap"><?php 
            echo $registration_id;
            ?>
</td>
                    <td class="date column-date"><?php 
            echo event_date_display($date, get_option('date_format') . ' g:i a');
            ?>
</td>
                    <td nowrap="nowrap"><a href="admin.php?page=events&amp;event_admin_reports=list_attendee_payments&amp;event_id=<?php 
            echo $event_id;
            ?>
" title="<?php 
            _e('View attendees for this event', 'event_espresso');
            ?>
"><?php 
            echo stripslashes_deep($event_name);
            ?>
</a></td>
                    <td nowrap="nowrap"><?php 
            echo event_date_display($event_time, get_option('time_format'));
            ?>
</td>
                    <?php 
            if ($ticketing_installed == true) {
                ?>
                    <td nowrap="nowrap"><p style="padding-left:15px"><?php 
                echo $attended == 1 || $ticket_scanned >= 1 ? event_espresso_paid_status_icon('Checkedin') : event_espresso_paid_status_icon('NotCheckedin');
                ?>
</p></td>
                    <?php 
            }
            ?>
                    <td nowrap="nowrap"><?php 
            echo $price_option;
            ?>
</td>
                    <td class="date column"><a href="admin.php?page=events&amp;attendee_pay=paynow&amp;form_action=payment&amp;registration_id=<?php 
            echo $registration_id;
            ?>
&amp;event_admin_reports=enter_attendee_payments&amp;event_id=<?php 
            echo $event_id;
            ?>
" title="<?php 
            _e('Edit Payment', 'event_espresso');
            ?>
 ID: <?php 
            echo $registration_id;
            ?>
">
                      <p style="padding-left:17px"><?php 
            event_espresso_paid_status_icon($payment_status);
            ?>
</p>
                      </a> <?php 
            /*?><a href="admin.php?page=events&amp;attendee_pay=paynow&amp;form_action=payment&amp;registration_id=<?php echo $temp_reg_id ?>&amp;event_admin_reports=enter_attendee_payments&amp;event_id=<?php echo $event_id ?>" title="<?php _e('Edit Payment', 'event_espresso'); ?> ID: <?php echo $temp_reg_id ?>"><?php //echo $org_options['currency_symbol'] ?><?php //echo $total_amount_pd ?></a><?php */
            ?>
</td>
                    <td class="date column-date"><?php 
            echo espresso_payment_type($txn_type);
            ?>
</td>
                    <td class="date column-date"><?php 
            echo $coupon_code;
            ?>
</td>
                    <td class="date column-date"><?php 
            echo $txn_id;
            ?>
</td>
                    <td class="date column-date" >
                    
                    <a href="admin.php?page=events&amp;attendee_pay=paynow&amp;form_action=payment&amp;registration_id=<?php 
            echo $registration_id;
            ?>
&amp;event_admin_reports=enter_attendee_payments&amp;event_id=<?php 
            echo $event_id;
            ?>
" title="<?php 
            _e('Edit Payment', 'event_espresso');
            ?>
 ID: <?php 
            echo $registration_id;
            ?>
"><img src="<?php 
            echo EVENT_ESPRESSO_PLUGINFULLURL;
            ?>
images/icons/money.png" width="16" height="16" alt="<?php 
            _e('Edit Payment', 'event_espresso');
            ?>
" /></a>
                    
                    <a href="admin.php?page=events&amp;event_admin_reports=edit_attendee_record&amp;registration_id=<?php 
            echo $registration_id;
            ?>
&amp;event_id=<?php 
            echo $event_id;
            ?>
&amp;form_action=edit_attendee" title="<?php 
            _e('Edit Attendee', 'event_espresso');
            ?>
"><img src="<?php 
            echo EVENT_ESPRESSO_PLUGINFULLURL;
            ?>
images/icons/user_edit.png" width="16" height="16" alt="<?php 
            _e('Edit Attendee', 'event_espresso');
            ?>
" /></a>
                    
                    <a href="admin.php?page=events&amp;event_admin_reports=resend_email&amp;registration_id=<?php 
            echo $registration_id;
            ?>
&amp;event_id=<?php 
            echo $event_id;
            ?>
&amp;form_action=resend_email" title="<?php 
            _e('Resend Registration Details', 'event_espresso');
            ?>
"><img src="<?php 
            echo EVENT_ESPRESSO_PLUGINFULLURL;
            ?>
images/icons/email_link.png" width="16" height="16" alt="<?php 
            _e('Resend Registration Details', 'event_espresso');
            ?>
" /></a>
                    
                    <a href="<?php 
            echo home_url();
            ?>
/?download_invoice=true&amp;admin=true&amp;registration_id=<?php 
            echo $registration_id;
            ?>
" target="_blank"  title="<?php 
            _e('Download Invoice', 'event_espresso');
            ?>
"><img src="<?php 
            echo EVENT_ESPRESSO_PLUGINFULLURL;
            ?>
images/icons/page_white_acrobat.png" width="16" height="16" alt="<?php 
            _e('Download Invoice', 'event_espresso');
            ?>
" /></a>
          <?php 
            if ($org_options["use_attendee_pre_approval"] == "Y") {
                ?>
          <br/>
          <a href="admin.php?page=events&amp;attendee_pay=paynow&amp;form_action=payment&amp;registration_id=<?php 
                echo $registration_id;
                ?>
&amp;event_admin_reports=enter_attendee_payments&amp;event_id=<?php 
                echo $event_id;
                ?>
" title="<?php 
                _e('Edit Payment', 'event_espresso');
                ?>
 ID: <?php 
                echo $registration_id;
                ?>
">
          <?php 
                if (is_attendee_approved($event_id, $id)) {
                    ?>
          <strong>
          <?php 
                    _e('Approved', 'event_espresso');
                    ?>
          </strong><br/>
          <?php 
                } else {
                    ?>
          <span style="color:#FF0000"><strong>
          <?php 
                    _e('Awaiting approval', 'event_espresso');
                    ?>
          </strong></span>
          <?php 
                }
                ?>
          </a>
          <?php 
            }
            ?>
</td>
      </tr>
      <?php 
            $temp_reg_id = $registration_id;
            $registration_id = '';
        }
    }
    ?>
    </tbody>
  </table>
  <div style="clear:both; margin-bottom:30px;">
    <input name="delete_customer" type="submit" class="button-secondary" id="delete_customer" value="<?php 
    _e('Delete Attendee(s)', 'event_espresso');
    ?>
" style="margin:10px 0 0 0;" onclick="return confirmDelete();" />
    <?php 
    if ($ticketing_installed == true) {
        ?>
    <input name="attended_customer" type="submit" class="button-secondary" id="attended_customer" value="<?php 
        _e('Mark as Attended', 'event_espresso');
        ?>
" style="margin:10px 0 0 10px;" />
    <input name="unattended_customer" type="submit" class="button-secondary" id="attended_customer" value="<?php 
        _e('Unmark as Attended', 'event_espresso');
        ?>
" style="margin:10px 0 0 10px;" />
    <?php 
    }
    ?>
    <a style="margin-left:5px" class="button-primary" href="admin.php?page=events&amp;action=csv_import">
    <?php 
    _e('Import CSV', 'event_espresso');
    ?>
    </a> <a class="button-primary" style="margin-left:5px" href="#" onclick="window.location='<?php 
    echo get_bloginfo('wpurl') . "/wp-admin/admin.php?event_espresso&amp;event_id=" . $_REQUEST['event_id'] . "&amp;export=report&action=payment&amp;type=excel";
    echo $_REQUEST['event_id'] == '' ? '&amp;all_events=true' : '';
    ?>
'" title="<?php 
    _e('Export to Excel', 'event_espresso');
    ?>
">
    <?php 
    _e('Export to Excel', 'event_espresso');
    ?>
    </a> <?php 
    echo isset($_REQUEST['event_id']) ? '<a style="margin-left:5px"  class="button-primary"  href="admin.php?page=events&amp;event_admin_reports=add_new_attendee&amp;event_id=' . $_REQUEST['event_id'] . '">' . __('Add Attendee', 'event_espresso') . '</a>' : '';
    ?>
 <?php 
    echo isset($_REQUEST['event_id']) ? '<a style="margin-left:5px" class="button-primary" href="admin.php?page=events&amp;action=edit&amp;event_id=' . $_REQUEST['event_id'] . '">' . __('Edit Event', 'event_espresso') . '</a>' : '';
    ?>
 </div>
</form>
 <h4 style="clear:both"><?php 
    _e('Legend', 'event_espresso');
    ?>
</h4>
<dl style="float:left; margin-left:10px; width:200px">
  <dt><?php 
    event_espresso_paid_status_icon('Completed');
    ?>
 - <?php 
    _e('Completed', 'event_espresso');
    ?>
</dt>
  <dt><?php 
    event_espresso_paid_status_icon('Incomplete');
    ?>
 - <?php 
    _e('Incomplete', 'event_espresso');
    ?>
</dt>
    <dt><?php 
    event_espresso_paid_status_icon('Pending');
    ?>
 - <?php 
    _e('Pending', 'event_espresso');
    ?>
</dt>

  <dt><img src="<?php 
    echo EVENT_ESPRESSO_PLUGINFULLURL;
    ?>
images/icons/money.png" width="16" height="16" alt="<?php 
    _e('Payment Details', 'event_espresso');
    ?>
" /> - <?php 
    _e('Payment Details', 'event_espresso');
    ?>
</dt>

  
  </dl>
  <dl style="float:left; margin-left:10px; width:200px">
  <dt><img src="<?php 
    echo EVENT_ESPRESSO_PLUGINFULLURL;
    ?>
images/icons/email_link.png" width="16" height="16" alt="<?php 
    _e('Resend Details', 'event_espresso');
    ?>
" /> - <?php 
    _e('Resend Email', 'event_espresso');
    ?>
</dt>
  <dt><img src="<?php 
    echo EVENT_ESPRESSO_PLUGINFULLURL;
    ?>
images/icons/page_white_acrobat.png" width="16" height="16" alt="<?php 
    _e('Download Invoice', 'event_espresso');
    ?>
" /> - <?php 
    _e('Download Invoice', 'event_espresso');
    ?>
</dt>
  <dt><img src="<?php 
    echo EVENT_ESPRESSO_PLUGINFULLURL;
    ?>
images/icons/user_edit.png" width="16" height="16" alt="<?php 
    _e(' Attendee Details', 'event_espresso');
    ?>
" /> - <?php 
    _e('Attendee Details', 'event_espresso');
    ?>
</dt>
</dl>
<script>
		jQuery(document).ready(function($) {
			/* show the table data */
			var mytable = $('#table').dataTable( {
				"sDom": 'Clfrtip',
				"bAutoWidth": false,
				"bStateSave": true,
				"sPaginationType": "full_numbers",
				"oLanguage": {    "sSearch": "<strong><?php 
    _e('Live Search Filter', 'event_espresso');
    ?>
:</strong> (eg, email, txn id, event, etc.)",
				"sZeroRecords": "<?php 
    _e('No Records Found!', 'event_espresso');
    ?>
" },
				"aoColumns": [
					{ "bSortable": false },
					null,
					<?php 
    echo $ticketing_installed == true ? 'null,' : '';
    ?>
					null,
					null,
					null,
					null,
					null,
					null,
					null,
					null,
					null,
					{ "bSortable": false }
				],
				"aoColumnDefs": [
					{ "bVisible": false, "aTargets": [  <?php 
    if (isset($_REQUEST['event_id'])) {
        echo '4,';
    } else {
        echo '2,';
    }
    ?>
 <?php 
    echo $ticketing_installed == true ? '10,11' : '9,10';
    ?>
 ] }
				],
				"oColVis": {
					"aiExclude": [ 0, 1],
					"buttonText": "Filter: Show / Hide Columns",
					"bRestore": true
				},
			});
		});
	</script>
<?php 
}