Viewing file: schedule.php (14.36 KB) -rw-rw-r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
include 'header.php';
$course_id = $_GET['id'];
$adjacents = 3;
/*
First get total number of rows in data table.
If you have a WHERE clause in your query, make sure you mirror it here.
*/
$total_pages_sql = $con->query("SELECT COUNT(*) as total FROM syllabus_topics st LEFT JOIN syllabus s on st.syllabus_id=s.id where s.package=$course_id ");
$result = mysqli_fetch_assoc($total_pages_sql);
$total_pages = $result['total'];
if (isset($_GET['page'])) {
$page = $_GET['page'];
} else {
$page = 1;
}
/* Setup vars for query. */
$limit = 17; //how many items to show per page
if ($page)
$start = ($page - 1) * $limit; //first item to display on this page
else
$start = 0; //if no page var is given, set start to 0
/* Get data. */
$query = "SELECT st.id,st.topic FROM syllabus_topics st LEFT JOIN syllabus s on st.syllabus_id=s.id where s.package=$course_id LIMIT $start, $limit";
$coursetopics = $con->query($query);
/* Setup page vars for display. */
if ($page == 0)
$page = 1; //if no page var is given, default to 1.
$prev = $page - 1; //previous page is page - 1
$next = $page + 1; //next page is page + 1
$lastpage = ceil($total_pages / $limit); //lastpage is = total pages / items per page, rounded up.
$lpm1 = $lastpage - 1; //last page minus 1
/*
Now we apply our rules and draw the pagination object.
We're actually saving the code to a variable in case we want to draw it more than once.
*/
$pagination = "";
if ($lastpage > 1) {
$pagination .= "<div class=\"pagination\" style='float: right;'>";
//previous button
if ($page > 1)
$pagination .= "<a href=\"?id=$course_id&page=$prev\">Previous</a>";
else
$pagination .= "<a class=\"disabled\">Previous</a>";
//pages
if ($lastpage < 7 + ($adjacents * 2)) { //not enough pages to bother breaking it up
for ($counter = 1; $counter <= $lastpage; $counter++) {
if ($counter == $page)
$pagination .= "<a href='#' class=\"current\">$counter</a>";
else
$pagination .= "<a href=\"?id=$course_id&page=$counter\">$counter</a>";
}
}
elseif ($lastpage > 5 + ($adjacents * 2)) { //enough pages to hide some
//close to beginning; only hide later pages
if ($page < 1 + ($adjacents * 2)) {
for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++) {
if ($counter == $page)
$pagination .= "<a href='#' class=\"current\">$counter</a>";
else
$pagination .= "<a href=\"?id=$course_id&page=$counter\">$counter</a>";
}
$pagination .= "...";
$pagination .= "<a href=\"?id=$course_id&page=$lpm1\">$lpm1</a>";
$pagination .= "<a href=\"?id=$course_id&page=$lastpage\">$lastpage</a>";
}
//in middle; hide some front and some back
elseif ($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2)) {
$pagination .= "<a href=\"?id=$course_id&page=1\">1</a>";
$pagination .= "<a href=\"?id=$course_id&page=2\">2</a>";
$pagination .= "...";
for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++) {
if ($counter == $page)
$pagination .= "<a href='#' class=\"current\">$counter</a>";
else
$pagination .= "<a href=\"?id=$course_id&page=$counter\">$counter</a>";
}
$pagination .= "...";
$pagination .= "<a href=\"?id=$course_id&page=$lpm1\">$lpm1</a>";
$pagination .= "<a href=\"?id=$course_id&page=$lastpage\">$lastpage</a>";
}
//close to end; only hide early pages
else {
$pagination .= "<a href=\"?id=$course_id&page=1\">1</a>";
$pagination .= "<a href=\"?id=$course_id&page=2\">2</a>";
$pagination .= "...";
for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++) {
if ($counter == $page)
$pagination .= "<a href='#' class=\"current\">$counter</a>";
else
$pagination .= "<a href=\"?id=$course_id&page=$counter\">$counter</a>";
}
}
}
//next button
if ($page < $counter - 1)
$pagination .= "<a href=\"?id=$course_id&page=$next\">Next</a>";
else
$pagination .= "<a class=\"disabled\">Next</a>";
$pagination .= "</div>\n";
}
?>
<link rel="stylesheet" type="text/css" href="css/pb.calendar.css"/>
<style>
.topic-item {
width: 60%;}
.status{
width:20%;
}
.topic-date{
width: 20%;
}
.pagination{
display: flex;
margin-top: 5%;
}
</style>
<section class="project-banner">
<div class="container">
<div class="row">
<div class="col-12">
<div class="banner-sec">
<div class="projectheading btn_right">
<h3 class="main_head" style="text-transform: uppercase;">Class Schedule</h3>
<button class="btn backbtn" onclick="history.go(-1);">Back </button>
<p></p>
</div>
</div>
</div>
</div>
</div>
</section>
<section class="calOuter">
<div class="container-fluid">
<div class="row">
<div class="calendar-block col-md-7">
<h3 class="calTitles">Class Schedule</h3>
<div id="pb-calendar" class="pb-calendar"></div>
<div class="schedule-indicators">
<ul>
<li><span class="completed-class"> </span> Next Classes</li>
<li><span class="missed-class"> </span> Completed Classes</li>
<li><span class="next-class"> </span> Missed Classes</li>
<li><span class="exam"> </span> Exam Dates</li>
</ul>
</div>
</div>
<?php
$next_days = array();
$exam_date=array();
$sql = "select * from `enrolldetails` where course_id='$course_id' and user_id='$u_id'";
$result = $con->query($sql);
$result_row = $result->fetch_assoc();
$enrollid = $result_row['enrollid'];
$user_id = $result_row['user_id'];
$datequery = "SELECT * FROM `student_batch_plan` where enrollid='$enrollid'";
$dateresult = $con->query($datequery);
$daterow = $dateresult->fetch_assoc();
$date_from = date('Y-m-d');
$date_to = $daterow['end_date'];
$days = $daterow['days'];
// echo $days;
$examdate=$daterow['exam_dates'];
$array1 = explode(' , ', $examdate);
foreach ($array1 as $item1) {
$exam_date[]=date("Ymd", strtotime($item1));
}
$date_from = strtotime($date_from);
$date_to = strtotime($date_to);
$array = explode(' , ', $days);
foreach ($array as $item) {
for ($i = $date_from; $i <= $date_to; $i += 86400) {
$day = date("Ymd", $i);
$unixTimestamp = strtotime($day);
$dayOfWeek = date("l", $unixTimestamp);
if ($dayOfWeek == $item) {
// $date = strtotime($day);
// $next_days[] = date('d',$date);
$next_days[] = $day;
}
}
}
?>
<div class="topics-coverd col-md-5">
<h3 class="calTitles">Topics Covered </h3>
<table class="topics">
<tbody>
<?php
// //$query1 = "SELECT st.id,st.topic,tc.completed_date FROM syllabus_topics st LEFT JOIN topics_covered tc ON st.id=tc.topic_id WHERE tc.user_id = '$u_id' and tc.course_id='$course_id' order by st.id ASC";
// $query1="SELECT st.id,st.topic FROM syllabus_topics st LEFT JOIN syllabus s on st.syllabus_id=s.id where s.package=$course_id";
// $res1 = $con->query($query1);
$i = 1;
$completed_days = array();
while ($row1 = $coursetopics->fetch_assoc()) {
$tid = $row1['id'];
$check = $con->query("SELECT completed_date from topics_covered where user_id = '$u_id' and course_id='$course_id' and topic_id='$tid'");
$comp = $check->fetch_assoc();
$date = $comp['completed_date'];
if ($date != '' && $date != '0000-00-00') {
$status = '<span style="color:#2de62d;">Completed</span>';
$date = $date;
$completed_days[] = str_replace('-', '', $date);
} else {
$status = '<span style="color:red;">Pending</span>';
$date = '';
}
?>
<tr>
<td class="topic-item"><?php echo $row1['topic']; ?> <span style="margin-right: 1%;">: </span></td>
<td class="status"><?php echo $status; ?> </td>
<td class="topic-date"><?php if ($date != '') {
echo date('d M Y', strtotime($date));
} ?> </td>
</tr>
<?php
}
?>
</tbody>
</table>
<nav aria-label="Page navigation example">
<?= $pagination ?>
<!-- <ul class="pagination" style="display: flex;justify-content: flex-end;">
<li class="page-item">
<a class="page-link" href="#" aria-label="Previous">
<span aria-hidden="true">«</span>
<span class="sr-only">Previous</span>
</a>
</li>
<li class="page-item"><a class="page-link" href="#">1</a></li>
<li class="page-item"><a class="page-link" href="#">2</a></li>
<li class="page-item"><a class="page-link" href="#">3</a></li>
<li class="page-item">
<a class="page-link" href="#" aria-label="Next">
<span aria-hidden="true">»</span>
<span class="sr-only">Next</span>
</a>
</li>
</ul>-->
</nav>
</div>
</div>
</div>
</section>
<?php
$classdays = array();
$class = explode(',', $days);
for ($i = 0; $i < count($class); $i++) {
if (trim(strtolower($class[$i])) == 'sunday') {
$classdays[] = 0;
} else if (trim(strtolower($class[$i])) == 'monday') {
$classdays[] = 1;
} else if (trim(strtolower($class[$i])) == 'tuesday') {
$classdays[] = 2;
} else if (trim(strtolower($class[$i])) == 'wednesday') {
$classdays[] = 3;
} else if (trim(strtolower($class[$i])) == 'thursday') {
$classdays[] = 4;
} else if (trim(strtolower($class[$i])) == 'friday') {
$classdays[] = 5;
} else if (trim(strtolower($class[$i])) == 'saturday') {
$classdays[] = 6;
}
}
$startdate = $daterow['start_date'];
$startDate = new DateTime($startdate);
$endDate = new DateTime(date('Y-m-d'));
$class_dates = array();
while ($startDate <= $endDate) {
if (in_array($startDate->format('w'), $classdays)) {
$class_dates[] = $startDate->format('Ymd');
}
$startDate->modify('+1 day');
}
$filtereddates1=array();
$filtereddates = array_diff($class_dates, $completed_days);
foreach ($filtereddates as $fd){
$filtereddates1[]=$fd;
}
?>
<?php include 'footer.php'; ?>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.1/moment.min.js" integrity="sha384-F13mJAeqdsVJS5kJv7MZ4PzYmJ+yXXZkt/gEnamJGTXZFzYgAcVtNg5wBDrRgLg9" crossorigin="anonymous"></script>
<script type="text/javascript" src="js/pb.calendar.js"></script>
<script type="text/javascript">
jQuery(document).ready(function () {
var completed_days = <?php echo json_encode($completed_days); ?>;
var current_yyyymm_ = moment().format("YYYYMM");
var next_days = <?php echo json_encode($next_days); ?>;
var missed_class = <?php echo json_encode($filtereddates1) ?>;
var examdate=<?php echo json_encode($exam_date) ?>;
$("#pb-calendar").pb_calendar({
schedule_list: function (callback_, yyyymm_) {
var temp_schedule_list_ = {};
var i; var k;
var j;
for (i = 0; i < completed_days.length; ++i) {
temp_schedule_list_[completed_days[i]] = [
// {'ID': 1, style: "completed-class"}
{'ID': 1, style: "missed-class"}
];
}
for (j = 0; j < next_days.length; j++) {
temp_schedule_list_[next_days[j]] = [
// {'ID': 2, style: "next-class"}
{'ID': 2, style: "completed-class"}
];
}
for (k = 0; k < missed_class.length; k++) {
temp_schedule_list_[missed_class[k]] = [
// {'ID': 3, style: "missed-class"}
{'ID': 3, style: "next-class"}
];
}
for (l = 0; l < examdate.length; l++) {
temp_schedule_list_[examdate[l]] = [
{'ID': 4, style: "exam"}
];
}
callback_(temp_schedule_list_);
},
schedule_dot_item_render: function (dot_item_el_, schedule_data_) {
dot_item_el_.addClass(schedule_data_['style'], true);
return dot_item_el_;
}
});
});
</script>
|