<?php
chdir('../');
require_once 'autoload.php';
$admin = new admin_controller;
$session = new session;
$uni = new university_controller;
$info = $uni->index();

date_default_timezone_set($info['timezone']);

$page = $utility->get_page();

require_once 'includes/session_validator.php';

if (!empty($is_authenticated) && $is_authenticated == 1) {

?>
<!doctype html>
<html lang="en" class="remember-theme">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>SERS - Academic Programmes</title>
<meta name="description" content="Students Examinations Registration System">
<meta name="author" content="Bwire Mashauri">
<meta name="robots" content="index, follow">
<base href="../">
<link rel="shortcut icon" href="storage/images/misc/<?php echo $info['icon']; ?>">
<link rel="stylesheet" href="assets/js/plugins/datatables-bs5/css/dataTables.bootstrap5.min.css">
<link rel="stylesheet" href="assets/js/plugins/datatables-buttons-bs5/css/buttons.bootstrap5.min.css">
<link rel="stylesheet" href="assets/js/plugins/datatables-responsive-bs5/css/responsive.bootstrap5.min.css">
<link rel="stylesheet" id="css-main" href="assets/css/main.css">
<?php echo $info['theme'] !== '0' ? '<link type="text/css" rel="stylesheet" id="css-theme" href="assets/css/themes/'.$info['theme'].'.css">' : '' ; ?>
<link href="assets/js/plugins/sweetalert2/sweetalert2.min.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="page-loader" class="show"></div>

<div id="page-container" class="sidebar-o <?php echo $info['sidebar'];?> enable-page-overlay side-scroll page-header-fixed page-footer-fixed">

<nav id="sidebar" aria-label="Main Navigation">
<div class="bg-header-dark">
<div class="content-header bg-white-5">
<a class="fw-semibold text-white tracking-wide" href="./app/dashboard">
<span class="smini-hidden desc">
Students Examinations Registration System
</span>
</a>
</div>
</div>
<div class="js-sidebar-scroll">
<div class="content-side">

<div class="text-center"><img class="mb-3 center_img" src="storage/images/misc/<?php echo $info['logo']; ?>" height="140" alt="School Logo"></div>

<ul class="nav-main">

<?php require_once 'includes/header.php'; ?>

</ul>
</div>
</div>
</nav>
<header id="page-header">
<div class="content-header">
<div class="space-x-1">
<button type="button" class="btn btn-alt-secondary" data-toggle="layout" data-action="sidebar_toggle">
<i class="fa fa-fw fa-bars"></i>
</button>
</div>
<div class="space-x-1">
<div class="dropdown d-inline-block">
<button type="button" class="btn btn-alt-secondary" id="page-header-user-dropdown" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fa fa-fw fa-user d-sm-none"></i>
<span class="d-none d-sm-inline-block"><?php echo $profile['first_name'].' '.$profile['last_name']; ?></span>
<i class="fa fa-fw fa-angle-down opacity-50 ms-1 d-none d-sm-inline-block"></i>
</button>
<div class="dropdown-menu dropdown-menu-end p-0" aria-labelledby="page-header-user-dropdown">
<div class="bg-primary-dark rounded-top fw-semibold text-white text-center p-3">
My Profile
</div>
<div class="p-2">
<a class="dropdown-item" href="app/account">
<i class="far fa-fw fa-user me-1"></i> Account Settings
</a>
<div role="separator" class="dropdown-divider"></div>
<a class="dropdown-item" href="app/logout">
<i class="far fa-fw fa-arrow-alt-circle-left me-1"></i> Log Out
</a>
</div>
</div>
</div>
</div>
</div>
</header>
<main id="main-container">
<div class="content">
<div class="block block-rounded">
<div class="block-header block-header-default">
<h3 class="block-title">
Academic Programmes
</h3>
<div class="block-options">
<div class="block-options-item">
<button type="button" class="btn btn-sm btn-primary mr-3" data-bs-toggle="modal" data-bs-target="#modal-add" data-bs-keyboard="false" data-bs-backdrop="static"><i class="fa fa-plus"></i> Add</button>
<button type="button" class="btn btn-sm btn-primary pull-right" data-bs-toggle="modal" data-bs-target="#modal-import" data-bs-keyboard="false" data-bs-backdrop="static"><i class="fa fa-upload"></i> Import</button>
</div>
</div>
</div>
<div class="block-content block-content-full overflow-x-auto">

<table class="table table-bordered table-striped table-vcenter srms_table table-sm app_table">
<thead>
<tr>
<th>Name</th>
<th width="100">Status</th>
<th width="100"></th>
</tr>
</thead>
<tbody>
</tbody>
</table>


<div class="modal fade" id="modal-add" role="dialog" aria-labelledby="modal-add"  data-bs-keyboard="false" data-bs-backdrop="static">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="block block-rounded shadow-none mb-0">
<div class="block-header block-header-default">
<h4 class="block-title">Add Programmes</h4>
</div>
<div class="block-content">
<form autocomplete="off" class="app_frm" action="app/routes/add_programme" method="POST">
<div class="mb-2">
<label class="form-label">Name</label>
<input type="text" required class="form-control" name="name" placeholder="Enter name">
</div>
<div class="mb-3">
<label class="form-label">Status</label>
<select required class="form-control" name="status">
<option value="" selected disabled>Select Option</option>
<option value="enabled">ENABLED</option>
<option value="disabled">DISABLED</option>
</select>
</div>
<?= $waf->csrf_field('add_programme.php', 600) ?>
<div class="mb-4">
<button type="submit" class="btn btn-primary app_btn">Save</button>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>

<div class="modal fade" id="modal-import" role="dialog" aria-labelledby="modal-import"  data-bs-keyboard="false" data-bs-backdrop="static">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="block block-rounded shadow-none mb-0">
<div class="block-header block-header-default">
<h4 class="block-title">Import Programmes</h4>
</div>
<div class="block-content">
<form autocomplete="off" class="app_frm" enctype="multipart/form-data" action="app/routes/import_programmes" method="POST">
<div class="mb-2">
<label class="form-label">Excel File</label>
<input type="file" name="file" accept="application/msexcel" required class="form-control">
</div>
<div class="mb-3">
<div class="alert alert-info" role="alert">
Download excel template from <a download href="storage/templates/import_programmes.xlsx" class="alert-link">here</a>.
</div>
</div>
<?= $waf->csrf_field('import_programmes.php', 600) ?>
<div class="mb-4">
<button type="submit" class="btn btn-primary app_btn">Save</button>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>

<div class="modal fade" id="modal-edit" role="dialog" aria-labelledby="modal-add"  data-bs-keyboard="false" data-bs-backdrop="static">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="block block-rounded shadow-none mb-0">
<div class="block-header block-header-default">
<h4 class="block-title">Edit Programme</h4>
</div>
<div class="block-content">
<form autocomplete="off" class="app_frm" action="app/routes/update_programme" method="POST">
<div id="ajax_response"></div>
<?= $waf->csrf_field('update_programme.php', 600) ?>
</form>
</div>
</div>
</div>
</div>
</div>

</div>
</div>
</div>
</main>
<footer id="page-footer" class="bg-body-light">
<div class="content py-0">
<div class="row fs-sm">
<div class="col-sm-6 order-sm-2 mb-1 mb-sm-0 text-center text-sm-end">
<?php echo $info['name']; ?>
</div>
<div class="col-sm-6 order-sm-1 text-center text-sm-start">
<a class="fw-semibold">Students Examinations Registration System</a> &copy; <span data-toggle="year-copy"></span>
</div>
</div>
</div>
</footer>
</div>
<script src="assets/js/main.js"></script>
<script src="assets/js/lib/jquery.min.js"></script>
<script src="assets/js/forms.js"></script>
<script src="assets/js/plugins/datatables/dataTables.min.js"></script>
<script src="assets/js/plugins/datatables-bs5/js/dataTables.bootstrap5.min.js"></script>
<script src="assets/js/plugins/datatables-responsive/js/dataTables.responsive.min.js"></script>
<script src="assets/js/plugins/datatables-responsive-bs5/js/responsive.bootstrap5.min.js"></script>
<script src="assets/js/plugins/sweetalert2/sweetalert2.min.js"></script>
<script nonce="<?php echo $wafConfig['nonce']; ?>">
$(".app_table").DataTable({
layout: {
topStart: {
pageLength: {
menu: [10, 15, 20, 50, 100]
}
}
},

ajax: {
url: 'ajax_tables/programme_list',
type: "GET"
},

columnDefs: [{className: 'text-center', targets: [1,2]}],


processing: true,
serverSide: true,
pageLength: 10,
autoWidth: !1,
responsive: !0,
"ordering": false
})
</script>
<?php require_once('includes/check_reply.php'); ?>
</body>
</html>
<?php

}else{

header("location:../");

}
?>
