File: /home/bibuzptr/elearning.bibu-edu.us/backup/admin/lec.php
<?php
ob_start();
session_start();
include_once('../includes/db_connect.php');
$today = date('Y-m-d');
$now = date('Y-m-d H:i:s');
$year = date("Y");
if(isset($_SESSION["OpenUni^###DHSG"])){
$email = $_SESSION["OpenUni^###DHSG"];
$chkuser = mysqli_query($con,"SELECT * FROM users WHERE email='$email'");
while($row = mysqli_fetch_assoc($chkuser)){
$id = $row["id"];
$name = $row["first_name"];
}
}
else{
header("Location:../adminlogin.php");
}
?>
<!DOCTYPE php>
<php lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0">
<title>Departments | Breakthrough Open University</title>
<link rel="shortcut icon" type="image/x-icon" href="../assets/img/logo.png">
<link rel="stylesheet" href="../assets/css/bootstrap.min.css">
<link rel="stylesheet" href="../assets/plugins/fontawesome/css/fontawesome.min.css">
<link rel="stylesheet" href="../assets/plugins/fontawesome/css/all.min.css">
<link rel="stylesheet" href="../assets/css/feather.css">
<link rel="stylesheet" href="../assets/css/style.css">
<link rel="stylesheet" href="../assets/css/dashboard2.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.11.3/css/dataTables.bootstrap4.min.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.11.3/css/jquery.dataTables.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.13.1/css/bootstrap-select.min.css">
<!--<link href="a.css" rel="stylesheet" />-->
<!--<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.10.0/css/bootstrap-select.min.css" rel="stylesheet" />-->
<!--<link href="http://cdn.rawgit.com/davidstutz/bootstrap-multiselect/master/dist/css/bootstrap-multiselect.css"rel="stylesheet" type="text/css" />-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdn.datatables.net/1.11.3/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.ckeditor.com/4.14.0/standard/ckeditor.js"></script>
<!-- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>-->
<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.10.0/js/bootstrap-select.min.js"></script>-->
<!--<script src="https://cdn.rawgit.com/davidstutz/bootstrap-multiselect/master/dist/js/bootstrap-multiselect.js"type="text/javascript"></script>-->
<style>
#lec{
background: #102044;
border-left: 6px solid #06bf1c;
color: #fff;
}
#lecmodal #login{
width: 90%;
margin: 10px;
display: block;
}
#lecmodal h2{
text-align: left;
}
#edtlecturermodal #login{
width: 90%;
margin: 10px;
display: block;
}
#edtlecturermodal h2{
text-align: left;
}
.menu{
background: #fff;
margin-top: -20px;
margin-bottom: 5px;
padding: 10px 0px 10px 20px;
border-bottom: 1px solid #ddd;
}
.menu .item{
background: #1e8c70;
font-size: 13px;
color: #fff;
padding: 5px 10px 5px 10px;
cursor: pointer;
}
#dataTable td{
padding: 1px;
font-size: 12px;
}
.table-responsive {
min-height: 0.01%;
overflow-x: auto;
}
@media screen and (max-width: 767px) {
.table-responsive {
width: 100%;
margin-bottom: 15px;
overflow-y: hidden;
-ms-overflow-style: -ms-autohiding-scrollbar;
border: 1px solid #ddd;
}
.table-responsive > .table {
margin-bottom: 0;
}
.table-responsive > .table > tbody > tr > td,
.table-responsive > .table > tbody > tr > th,
.table-responsive > .table > tfoot > tr > td,
.table-responsive > .table > tfoot > tr > th,
.table-responsive > .table > thead > tr > td,
.table-responsive > .table > thead > tr > th {
white-space: nowrap;
}
.table-responsive > .table-bordered {
border: 0;
}
.table-responsive > .table-bordered > tbody > tr > td:first-child,
.table-responsive > .table-bordered > tbody > tr > th:first-child,
.table-responsive > .table-bordered > tfoot > tr > td:first-child,
.table-responsive > .table-bordered > tfoot > tr > th:first-child,
.table-responsive > .table-bordered > thead > tr > td:first-child,
.table-responsive > .table-bordered > thead > tr > th:first-child {
border-left: 0;
}
.table-responsive > .table-bordered > tbody > tr > td:last-child,
.table-responsive > .table-bordered > tbody > tr > th:last-child,
.table-responsive > .table-bordered > tfoot > tr > td:last-child,
.table-responsive > .table-bordered > tfoot > tr > th:last-child,
.table-responsive > .table-bordered > thead > tr > td:last-child,
.table-responsive > .table-bordered > thead > tr > th:last-child {
border-right: 0;
}
.table-responsive > .table-bordered > tbody > tr:last-child > td,
.table-responsive > .table-bordered > tbody > tr:last-child > th,
.table-responsive > .table-bordered > tfoot > tr:last-child > td,
.table-responsive > .table-bordered > tfoot > tr:last-child > th {
border-bottom: 0;
}
}
</style>
</head>
<body>
<div class="main-wrapper">
<?php include_once("../includes/header-course.php") ?>
<div class="page-content1" style="background: #fafafa; padding: 10px 0;">
<div class="container1">
<div class="row">
<div class="col-xl-3 col-lg-9 col-md-12 theiaStickySidebar">
<?php include_once("includes/aside.php") ?>
</div>
<div class="col-xl-9 col-lg-9 col-md-12">
<div class="row">
<div class="col-md-12">
<div class="settings-widget">
<div class="settings-inner-blk p-0">
<div class="sell-lecturer-head comman-space1" style="padding:2px">
<div class="row">
<div class="col-md-6">
<h3>Lecturers </h3>
<p></p>
</div>
<div class="col-md-6">
<div class="go-dashboard text-center">
<a style="display:none" class="btn btn-primary item item1" data-bs-toggle="modal" data-bs-target="#lecmodal">Add New Lecturer</a>
</div>
</div>
</div>
</div>
<div class="comman-space pb-0">
<div class="settings-tickets-blk lecturer-instruct-blk table-responsive1">
<table id="dataTable" class="table table-striped table-responsive table-nowrap1 mb-21">
<thead>
<tr>
<th>Name</th>
<th>Phone</th>
<th>Country</th>
<th>Campus</th>
<th>Photo</th>
<th>ID</th>
<th>Academic Papers</th>
<th>Licences</th>
<th>Experiences</th>
<th>Certified Courses</th>
<th>Join Date</th>
<th></th>
</tr>
</thead>
<tbody>
<?php
$chkplanners = mysqli_query($con,"SELECT * FROM lecturers ORDER BY id DESC");
while($row = mysqli_fetch_assoc($chkplanners)){
$lecturerid = $row["id"];
$country = $row["country"];
$campus = $row["campus"];
$status = $row["status"];
?>
<tr>
<td><?php echo $row["fullname"];?></td>
<td><?php echo $row["phone"];?></td>
<td><?php echo mysqli_fetch_assoc(mysqli_query($con,"SELECT * FROM countries WHERE id='$country'"))["Country"];?></td>
<td><?php if($campus=="0"){ echo "Online"; }else{ echo mysqli_fetch_assoc(mysqli_query($con,"SELECT * FROM campuses WHERE id='$campus'"))["campusname"]; }?></td>
<td><a target="_blank" href="../lecturer-images/<?php echo $row['profilepic'] ?>">Picture</a></td>
<td><a target="_blank" href="../lecturer-images/<?php echo $row['nationalid'] ?>">ID</a></td>
<td><a target="_blank" href="../lecturer-images/<?php echo $row['academic'] ?>">Academic</a></td>
<td><a target="_blank" href="../lecturer-images/<?php echo $row['licenses'] ?>">Licenses</a></td>
<td><?php echo substr($row["experiences"],0,20);?>...</td>
<td><?php echo substr($row["courses"],0,20);?>...</td>
<td><?php echo date("d/m/Y",strtotime($row["createdon"])) ?></td>
<td>
<?php
if($status=="0"){ ?>
<a id="<?php echo $lecturerid ?>" class="approvelec btn btn-warning btn-sm">Approve</a>
<?php }else{
}
?>
<a data-toggle="tooltip" data-placement="bottom" title="Edit Lecturer"><button class="btn btn-sm btn-success edtlecturer" id="<?php echo $lecturerid;?>" data-fullname="<?php echo $row["fullname"];?>" data-phone="<?php echo $row["phone"];?>" data-country="<?php echo $row["country"];?>" data-campus="<?php echo $row["campus"];?>" data-experiences="<?php echo $row["experiences"];?>" data-courses="<?php echo $row["courses"];?>" data-profilepic="<?php echo $row["profilepic"];?>" data-nationalid="<?php echo $row["nationalid"];?>" data-academic="<?php echo $row["academic"];?>" data-licences="<?php echo $row["licences"];?>"><i class="fa fa-edit"></i></button></a>
<button style="display:none" title="update image" class="imagebutton btn btn-warning btn-sm" id="<?php echo $lecturerid ?>">image</button>
<a data-toggle="tooltip" data-placement="bottom" title="Assign Courses">
<button class="btn btn-sm btn-primary assigncourse" id="<?php echo $lecturerid;?>" data-courseid="<?php echo $row["assignedcourses"];?>">Assign Courses</button></a>
<a class="dellecturer btn btn-warning btn-sm" id="<?php echo $lecturerid ?>" >Delete</a>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="lecmodal" class="lecmodal modal fade" role="dialog">
<div class="modal-dialog modal-md">
<div class="modal-content" style="padding:15px">
<div class="modal-header">
<h4><i class="fa fa-list-alt"></i> <span id="addlecturer">Add Lecturer</span></h4>
</div>
<div style="margin-left:10px; margin-right:10px" class="add-lecturer-form">
<form method="post" role="form" id="lecfrm" enctype="multipart/form-data">
<div class="add-lecturer-inner-header">
</div>
<div class="input-block">
<label class="add-lecturer-label">Lecturer Name</label>
<input type="hidden" name="id" id="id">
<input type="text" class="form-control" placeholder="Lecturer name" name="lecname" id="lecname" required>
</div>
<div class="input-block">
<label class="add-lecturer-label">Lecturer Phone</label>
<input type="text" class="form-control" placeholder="Lecturer phone" name="lecphone" id="lecphone">
</div>
<div class="input-block">
<label class="add-lecturer-label">Lecturer Country</label>
<select class="form-control" name="leccountry" id="leccountry">
<?php
$listcat=mysqli_query($con,"SELECT * FROM countries ORDER BY Country ASC");
while($lc=mysqli_fetch_assoc($listcat)){
?>
<option value="<?php echo $lc['id'] ?>"><?php echo $lc['Country'] ?></option>
<?php } ?>
</select>
</div>
<div class="input-block">
<label class="add-lecturer-label">Lecturer Campus</label>
<select class="form-control" name="leccampus" id="leccampus">
<?php
$listcat=mysqli_query($con,"SELECT * FROM campuses ORDER BY campusname ASC");
while($lc=mysqli_fetch_assoc($listcat)){
?>
<option value="<?php echo $lc['id'] ?>"><?php echo $lc['campusname'] ?></option>
<?php } ?>
</select>
</div>
<div class="input-block">
<label class="add-lecturer-label">Lecturer Experiences</label>
<input type="text" class="form-control" placeholder="" name="lecexperiences" id="lecexperiences">
</div>
<div class="input-block">
<label class="add-lecturer-label">Lecturer Courses</label>
<input type="text" class="form-control" placeholder="" name="leccourses" id="leccourses">
</div>
<div class="input-block">
<label class="add-lecturer-label">Photo (leave blank if not available)</label>
<input type="file" class="form-control" placeholder="" name="lecphoto" id="lecphoto" accept="image/*">
</div>
<div style="display:none" class="input-block">
<label class="add-lecturer-label">ID (leave blank if not available)</label>
<input type="file" class="form-control" placeholder="" name="lecid" id="lecid">
</div>
<div style="display:none" class="input-block">
<label class="add-lecturer-label">Academic (leave blank if not available)</label>
<input type="file" class="form-control" placeholder="" name="lecacademic" id="lecacademic">
</div>
<div style="display:none" class="input-block">
<label class="add-lecturer-label">Licences (leave blank if not available)</label>
<input type="file" class="form-control" placeholder="" name="leclicense" id="leclicense">
</div>
<button type="submit" class="btn btn-success btn-lg"><i class="fa fa-save"> </i>Save</button>
<p id="status11"></p>
</form>
</div>
</div>
</div>
</div>
<div id="assigncoursemodal" class="lecmodal1 modal fade" role="dialog">
<div class="modal-dialog modal-lg">
<div class="modal-content" style="padding:15px">
<div class="modal-header">
<h4><i class="fa fa-list-alt"></i> <span id="assigncourse">Assign Course</span></h4>
</div>
<div class="add-lecturer-form">
<div style="display:none" id="existingcourses">
<h4>Assigned Courses</h4>
<p id="thecourses"></p>
</div>
<form method="post" role="form" id="assignfrm" enctype="multipart/form-data">
<div class="add-lecturer-inner-header1">
</div>
<div class="form-group">
<label class="add-lecturer-label">Lecturers Course</label>
<input type="hidden" name="lecid2" id="lecid2">
<!--<select class="form-control selectpicker" name="leccourse[]" id="leccourse" multiple data-live-search="true" required>-->
<select class="form-control selectpicker" id="productid" name="productid" data-live-search="true">
<?php
$listcat=mysqli_query($con,"SELECT * FROM courses ORDER BY title ASC");
while($lc=mysqli_fetch_assoc($listcat)){
?>
<option value="<?php echo $lc['id'] ?>"><?php echo $lc['title'] ?></option>
<?php } ?>
</select>
</div>
<button type="submit" class="btn btn-success btn-lg"><i class="fa fa-save"> </i>Save</button>
<p id="status12"></p>
</form>
</div>
</div>
</div>
</div>
<?php include_once("../includes/footer-course.php") ?>
<script>
$('#dataTable').DataTable({"aaSorting" : []});
// function dataTables(tb){
// var table = $('#'+tb+'').DataTable({
// lengthChange: false,
// "aaSorting": [],
// "buttons": [
// {"extend": 'copy', "text":'<i class="fas fa-copy"></i> Copy',"className": 'btn btn-success btn-sm'},
// {"extend": 'csv', "text":'<i class="fas fa-file-csv"></i> CSV',"className": 'btn btn-success btn-sm'},
// {"extend": 'excel', "text":'<i class="fas fa-file-excel"></i> Excel',"className": 'btn btn-success btn-sm' },
// {"extend": 'pdf', "text":'<i class="fas fa-file-pdf"></i> PDF',"className": 'btn btn-success btn-sm'},
// {"extend": 'print', "text":'<i class="fas fa-print"></i> Print',"className": 'btn btn-success btn-sm'}
// ]
// });
// table.buttons().container().appendTo( '#'+tb+'_wrapper .col-md-6:eq(0)' );
// }
// dataTables("dataTable");
$("#lecfrm").submit(function(e){
e.preventDefault();
$("#status11").html("<p class=' bg-success'><i class='fa fa-spinner fa-pulse'></i> Saving the lecturer...</p>");
$.ajax({
method: "POST",
url: "app/lecturers",
data: new FormData(this),
contentType: false,
processData: false,
cache:false
}).done(function(data){
if(data.status == "200"){
$("#status11").html("<p class=' bg-success'><i class='fa fa-check'></i> lecturer saved successfully.</p>");
window.location.replace("lecturers");
}
if(data.message == "ERROR"){
$("#status11").html("<p class=' bg-danger'><i class='fa fa-exclamation-circle'></i> An error occured, please try again later.</p>");
}
});
});
$("#assignfrm").submit(function(e){
e.preventDefault();
$("#status12").html("<p class=' bg-success'><i class='fa fa-spinner fa-pulse'></i> Saving courses...</p>");
$.ajax({
method: "POST",
url: "app/activate-lecturer",
data: new FormData(this),
contentType: false,
processData: false,
cache:false
}).done(function(data){
if(data.status == "200"){
$("#status12").html("<p class=' bg-success'><i class='fa fa-check'></i> courses saved successfully.</p>");
window.location.replace("lecturers");
}
if(data.message == "ERROR"){
$("#status12").html("<p class=' bg-danger'><i class='fa fa-exclamation-circle'></i> An error occured, please try again later.</p>");
}
});
});
//upload image
$('#dataTable').on('click', '.imagebutton', function(){
//$(".imagebutton").click(function () {
var lecturerid=$(this).attr("id");
$('#pproductid').val(lecturerid);
$('#uploadimage').modal('show');
});
//Activate a lecturer
//$(".approvelec").click(function(){
$("#dataTable").on('click', '.approvelec', function(){
var lecturerid = $(this).attr("id");
var d = confirm('Are you sure you want to approve this lecturer?');
if(d == false){
return false;
}
else{
$.ajax({
method:"post",
url:"app/activate-lecturer",
data:{lecturerid:lecturerid},
cache:false
}).done(function(data){
if(data.status == "200"){
alert("lecturer approved successfully");
window.location.replace("lecturers");
}else{
alert("error approving lecturer");
}
});
}
});
//DeActivate a lecturer
//$(".deactivate").click(function(){
$("#dataTable").on('click', '.deactivate', function(){
var lecturerid2 = $(this).attr("id");
var d = confirm('Are you sure you want to deactivate this lecturer?');
if(d == false){
return false;
}
else{
$.ajax({
method:"post",
url:"app/activate-lecturer",
data:{lecturerid2:lecturerid2},
cache:false
}).done(function(data){
if(data.status == "200"){
alert("lecturer deactivated successfully");
window.location.replace("lecturers");
}else{
alert("error deactivating lecturer");
}
});
}
});
//Delete a lecturer
// $(".dellecturer").click(function(){
$("#dataTable").on('click', '.dellecturer', function(){
var lecturerid3 = $(this).attr("id");
var d = confirm('Are you sure you want to delete this lecturer?');
if(d == false){
return false;
}
else{
$.ajax({
method:"post",
url:"app/activate-lecturer",
data:{lecturerid3:lecturerid3},
cache:false
}).done(function(data){
if(data.status == "200"){
alert("lecturer deleted successfully");
window.location.replace("lecturers");
}else{
alert("error deleting lecturer");
}
});
}
});
//edit lecturer
// $(".edtlecturer").click(function(){
$("#dataTable").on('click', '.edtlecturer', function(){
$("#id").val($(this).attr("id"));
$("#lecname").val($(this).attr("data-fullname"));
$("#lecphone").val($(this).attr("data-phone"));
$("#leccountry").val($(this).attr("data-country"));
$("#leccampus").val($(this).attr("data-campus"));
$("#lecexperiences").val($(this).attr("data-experiences"));
$("#leccourses").val($(this).attr("data-courses"));
$("#addlecturer").html("Edit Lecturer")
$('.lecmodal').modal('show');
});
//assign course
// $(".assigncourse").click(function(){
$("#dataTable").on('click', '.assigncourse', function(){
var lecid2=$(this).attr("id");
$("#lecid2").val(lecid2);
$("#leccourse").val($(this).attr("data-courseid"));
$.ajax({
method:"post",
url:"app/lecturer-courses",
data:{lecid2:lecid2},
cache:false
}).done(function(data){
if(data!=""){
$("#existingcourses").css("display","block")
$("#thecourses").html(data)
}else{
$("#existingcourses").css("display","none")
}
});
$("#assigncourse").html("Assign Course")
$('#assigncoursemodal').modal('show');
});
</script>
</div>
</php>