File: /home/awaldron/_domains/pennhillscdc.org/wp-content/themes/phcdc/admin/aw_events_list.php
<?php
$hidden_list = (isset($_GET['hid']) || $action=='show');
$events = $db->get_results("
SELECT e.*, COUNT(d.event_id) as num_dates, c.cat_title
FROM events as e
LEFT JOIN event_date as d ON e.event_id=d.event_id
LEFT JOIN event_categories as c ON e.event_cat_id=c.event_cat_id
WHERE e.event_src='cdc' AND e.event_hidden=0
GROUP BY d.event_id
ORDER BY e.title ASC", ARRAY_A);
?>
<div class="wrap">
<h1 class="wp-heading">Events Manager : <?=($hidden_list?'Archived Events':'Active Events')?></h1><br><br>
</div>
<div class="container">
<div class="row">
<div class="col-sm-6">
<a href="/wp-admin/admin.php?page=aw_events<?=(isset($_GET['hid'])?'':'&hid=1')?>" class="btn btn-primary"><i class="fas fa-eye<?=(isset($_GET['hid'])?'':'-slash')?>"></i> Show <?=(isset($_GET['hid'])?'Active':'Archived')?> Events</a></p>
</div>
<div class="col-sm-6">
<a href="/wp-admin/admin.php?page=aw_events&action=create" class="btn btn-success" style="float:right;"><i class="far fa-plus-circle"></i> Create New Event</a></p>
</div>
</div>
<div class="row">
<div class="col-sm">
<br/>
<table class="table thead-dark table-striped">
<tr>
<th>Actions</th>
<th>Event Name</th>
<th>Category</th>
<th style="text-align:center;">Dates</th>
<th style="text-align:center;">Private</th>
<!-- <th style="text-align:center;">Seats</th>-->
</tr>
<?php foreach ($events as $e): ?>
<tr>
<td>
<a href="/wp-admin/admin.php?page=aw_events&action=edit&eid=<?=$e['event_id']?>" title="Edit Event"><i class="fas fa-edit"></i></a>
<a href="/wp-admin/admin.php?page=aw_events&action=<?=(isset($_GET['hid'])?'show':'hide')?>&eid=<?=$e['event_id']?>" title="<?=(isset($_GET['hid'])?'Restore':'Archive')?> Event"><i class="fas fa-eye<?=(isset($_GET['hid'])?'':'-slash')?>"></i></a>
</td>
<td><?=$e['title']?></td>
<td><?=$e['cat_title']?></td>
<td align="center"><a href="/wp-admin/admin.php?page=aw_events&action=view_dates&eid=<?=$e['event_id']?>"><?=$e['num_dates']?></a></td>
<td align="center"><?=($e['event_private'] ? 'Private' : '-')?></td>
<!-- <td align="center">--><?//=($e['event_seats'] ? $e['event_seats'] : '-')?><!--</td>-->
</tr>
<?php endforeach; ?>
</table>
</div>
</div>
</div>