<?php
$page_title = "Resources | 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 - Resources</h2>
<?php
include_once($_SERVER['DOCUMENT_ROOT'] . "/admin/php/nav-admin.php");
echo "<a class='btn ces-orange-btn' href='/admin/resources/add.php'>Add Resource</a>";
if(isset($_GET['msg'])){
if($_GET['msg'] == "success"){
echo "<p class='alert alert-success'>The resource was successfully deleted.</p>";
}
}
$db = mysqli_connect($mysql_server, $user, $pass, $database);
$sql = mysqli_query($db, "SELECT resource_id, title, url, phone, description, organization, created, updated FROM ces_resources ORDER BY title");
echo "\n<table id='ces-resource-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>Title</th>";
echo "\n\t<th>Link</th>";
echo "\n\t<th>Phone</th>";
echo "\n\t<th>Description</th>";
echo "\n\t<th>Organization</th>";
echo "\n\t<th>Created</th>";
echo "\n\t<th>Updated</th>";
echo "\n\t</tr>";
echo "\n\t</thead>";
echo "\n\t<tbody>";
//output the query results in html table format
while ($query = mysqli_fetch_array($sql)) {
//echo "\n<tr>\n";
echo "\n\t<tr title='Resource ID: ".$query["resource_id"]."' id='".$query["resource_id"]."'>";
echo "\n\t<td><a href=edit.php?resource_id=" . $query["resource_id"] . " title='Edit'>" . $query["title"] . "</a></td>";
echo "\n\t<td><a href='".$query["url"]."'>" . $query["url"] . "</a></td>";
echo "\n\t<td>" . $query["phone"]. "</td>";
echo "\n\t<td>" . $query["description"] . "</td>";
echo "\n\t<td>" . $query["organization"] . "</td>";
echo "\n\t<td>" . $query["created"] . "</td>";
echo "\n\t<td>" . ($query["updated"] != '0000-00-00 00:00:00'? $query["updated"]: 'N/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-resource-table').DataTable({
paging:false,
searching:false,
info:false
});
});
</script>
?>