<?php
$page_title = "Locations | CES Admin";
include_once($_SERVER['DOCUMENT_ROOT'] . "/php/common_functions.php"); //common functions in the course registartion system
include_once($_SERVER['DOCUMENT_ROOT'] . "/php/config.php"); //holds global config variables
check_if_authenticated('admin');//check if user is logged in
include_once($_SERVER['DOCUMENT_ROOT'] . "/admin/php/top-admin.php"); //get the HTML heading common to all pages in the CES admin module
?>
<article class="ces-admin">
<h2>CES Admin - Locations</h2>
<?php
include_once($_SERVER['DOCUMENT_ROOT'] . "/admin/php/nav-admin.php");
//opens connection to database
$db = mysqli_connect($mysql_server, $user, $pass, $database);
$location_sql = mysqli_query($db, "SELECT location_id, location_name, address_line1, address_line2, city, province, seats, CASE telehealth WHEN 1 THEN 'Yes' WHEN 0 THEN 'No' ELSE '' END AS telehealth FROM ces_locations ORDER BY location_name");
echo "\n<table id='ces-location-table' class='table table-striped'>"; //table for instructors
//output the session column headings
echo "\n\t<thead>";
echo "\n\t<tr>";
echo "\n\t<th>Location Name</th>";
echo "\n\t<th>Seats</th>";
echo "\n\t<th>Address</th>";
echo "\n\t<th>City</th>";
echo "\n\t<th>Province</th>";
echo "\n\t<th>Sessions</th>";
echo "\n\t<th>Edit</th>";
echo "\n\t</tr>";
echo "\n\t</thead>";
echo "\n\t<tbody>";
//output the query results in html table format
$row_count = 0;
while ($location_query = mysqli_fetch_array($location_sql)) {
//2011-05-23 - wsopko - modified so could do table striping
$row_count++;
//echo "\n<tr>\n";
echo "\n\t<tr title='Location ID: ".$location_query["location_id"]."'>";
echo "\n\t<td>" . $location_query["location_name"] . "</td>";
echo "\n\t<td>" . $location_query["seats"] . "</td>";
echo "\n\t<td>" . $location_query["address_line1"] ."<br>". $location_query["address_line2"]. "</td>";
echo "\n\t<td>" . $location_query["city"] . "</td>";
echo "\n\t<td>" . $location_query["province"] . "</td>";
echo "\n\t<td>" . location_sessions($location_query["location_id"]) . "</td>";
echo "\n\t<td class='ces-list-icons'><a href=edit.php?location_id=" . $location_query["location_id"] . " class='orange-icon'><span title='Edit Location' class='fa fa-edit fa-lg '></span></a></td>";
echo "\n\t</tr>";
} //while
echo "\n</tbody>";
echo "\n</table>";
?>
</article>
</section><!-- #middle-->
</div><!-- #wrapper -->
<?php require_once $_SERVER['DOCUMENT_ROOT'].'/require/footer.php';?>
<script type="text/javascript">
$(document).ready(function(){
$('#ces-location-table').DataTable({
paging:false,
searching:false,
info:false
});
});
</script>