| Current Path : /var/www/cesa.co.za/cesanet/ |
| Current File : /var/www/cesa.co.za/cesanet/inc_dashboard.php |
<?php
$prevMonthStart = new DateTime();
//$prevMonthStart->modify('-7 days');
$cceDocObj = new CCEDocuments($sqlf);
$startDateTime = $prevMonthStart;
$endDateTime = clone $startDateTime;
$endDateTime->modify('+6 days');
$upcomingDocs = $cceDocObj->getUpcomingDocuments($startDateTime, $endDateTime, $_SESSION["StudentID"]);
$startDateTime->modify('-14 days');
$endDateTime = new DateTime();
$previousDocs = $cceDocObj->getUpcomingDocuments($startDateTime, $endDateTime);
$arrOverdue = GetOverdue($_SESSION["StudentID"], $_SESSION["ModulesEnrolled"]);
$arrResubmissions = GetResubmissions($_SESSION["StudentID"], $_SESSION["ModulesEnrolled"]);
//echo $_SESSION["StudentID"];
//exit;
$AssignmentExtensionObj = new CCEStAssigExtensionRequest($sqlf);
$arrExtensions = $AssignmentExtensionObj->findAllByStudent($_SESSION["StudentID"]);
?>
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="upcoming-documents" data-bs-toggle="tab" data-bs-target="#upcoming-documents-pane" type="button"
role="tab" aria-controls="upcoming-documents-pane" aria-selected="true">Upcoming Documents (<?php echo count($upcomingDocs); ?>)</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="assignment-calendar-tab" data-bs-toggle="tab" data-bs-target="#assignment-calendar-tab-pane"
type="button" role="tab" aria-controls="assignment-calendar-tab-pane" aria-selected="false">Assignment Calendar</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="overdue-assignments-tab" data-bs-toggle="tab" data-bs-target="#overdue-assignments-tab-pane" type="button"
role="tab" aria-controls="overdue-assignments-tab-pane" aria-selected="false">Overdue Assignments (<?php echo count($arrOverdue); ?>)</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="resubmissions-tab" data-bs-toggle="tab" data-bs-target="#resubmissions-tab-pane" type="button"
role="tab" aria-controls="resubmissions-tab-pane" aria-selected="false">Resubmissions (<?php echo count($arrResubmissions); ?>)</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="extensions-tab" data-bs-toggle="tab" data-bs-target="#extensions-tab-pane" type="button"
role="tab" aria-controls="extensions-tab-pane" aria-selected="false">Extensions (<?php echo count($arrExtensions); ?>)</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="previous-documents" data-bs-toggle="tab" data-bs-target="#previous-documents-pane" type="button"
role="tab" aria-controls="previous-documents-pane" aria-selected="false">Previous Documents (<?php echo count($previousDocs); ?>)</button>
</li>
</ul>
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="upcoming-documents-pane" role="tabpanel" aria-labelledby="upcoming-documents" tabindex="0">
<?php
if (count($upcomingDocs) > 0) {
?><div style="border:2px solid green; padding:5px"><p><b>The following documents are relevant to the next online session:</b></p>
<table border="0" cellpadding="2" width="95%" align="center">
<tr style="border-bottom: solid 1px #009DDA;">
<?php
$cellCnt = 0;
foreach ($upcomingDocs as $row) {
$bShow = true;
if (!empty($row["ReleaseDate"]) && !empty($row["ReleaseTime"])) {
if (strtotime($row["ReleaseDate"] . " " . $row["ReleaseTime"]) > strtotime("now")) {
// echo 'Not showing document: ' . $row["DocumentName"] . ' because of release date<br>';
$bShow = false;
}
}
if ($bShow && !empty($row["Students"])) {
$arrStudentsAllowed = explode(",", $row["Students"]);
$arrStudentsAllowed[] = 54;
if (!in_array($_SESSION["StudentID"], $arrStudentsAllowed)) {
$bShow = false;
}
}
if ($bShow) {
if ($cellCnt > 0 && $cellCnt % 2 == 0) {
?>
</tr>
<tr><td colspan="3"> </td></tr>
<tr style="border-bottom: solid 1px #009DDA;" data-cell-count="<?php echo $cellCnt; ?>">
<?php
}
?>
<td valign="top" nowrap><?php echo date("d M", strtotime($row["AppliesToDate"])); ?></td>
<td valign="top"><?php
if (!empty($row["DocumentFile"])) {
// echo $row['DisplayInline'] . ' inline!';
if (isset($row['DisplayInline']) && $row['DisplayInline'] > 0) {
$target = '';
$docURL = '/cesanet/document-view.php?CCEDocumentID=' . $row['CCEDocumentID'];
} else {
$docURL = '/cceadmin/documents/' . $row['DocumentFile'];
$target = 'target="_blank"';
}
echo '<a href="' . $docURL . '" ' . $target . '>'; ?><img src="<?php
$thumbfile = "";
if (true || empty($row["DocumentThumb"])) {
$thumbfile = '/cesanet/images/book.jpg';
if (true || strtolower(substr($row["DocumentFile"], -4)) == ".pdf") {
try {
$thumbfile = CreateThumb($row["CCEDocumentID"], $row["DocumentFile"], '', $row);
} catch (Exception $e) {
}
// if (empty($docthumb)) {
// $thumbfile = '/cesanet/images/book.jpg';
// } else {
// $thumbfile = '/cesanet/docthumbs/' . $docthumb;
// }
}
} else {
$thumbfile = $row["DocumentThumb"];
}
echo $thumbfile;
?>" alt="<?php echo $row["DocumentName"]; ?>" height="40" border="0"<?php $size = getimagesize($thumbfile);
}
?> hspace="2" /><?php if (!empty($row["DocumentFile"])) echo "</a>"; ?>
</td>
<td valign=top>
<?php
if (!empty($row["DocumentFile"]))
echo '<a href="' . $docURL . '" ' . $target . '>';
echo $row["DocumentCode"] . ' - ' . $row["DocumentName"];
if (!empty($row["DocumentFile"]))
echo "</a>";
?><br>
<?php
if (!empty($row["PresenterName"]))
echo "<br>" . $row["PresenterName"];
if (!empty($row["PresentationTime"]))
echo "<br>" . $row["PresentationTime"];
?>
</td>
<?php
$cellCnt++;
} else {
// echo 'Not showing document: ' . $row["DocumentName"] . '<br>';
}//if
} //while
?>
</tr>
</table>
</div>
<br>
<?php
} //upcoming documents
?>
</div>
<div class="tab-pane fade" id="assignment-calendar-tab-pane" role="tabpanel" aria-labelledby="assignment-calendar-tab" tabindex="1">
<p style="padding: 12px;">Due dates for assignments are <span style="background-color:#ffba6f">highlighted in orange</span>. Hover your mouse over the date to see the assignments.</p>
<table border="0" width="95%" align="center" cellpadding="4" cellspacing="0">
<?php
if (!isset($_GET["month"])) {
$dtTrimesterStart = "";
$endDate = new \DateTime();
$endDate->modify('+1 months');
$sql = "SELECT MIN(SessionDate) AS FirstDate, MAX(SessionDate) AS LastDate, TrimesterNum
FROM CCEWeeklySessions WHERE TrimesterNum IN (
SELECT MAX(TrimesterNum) AS Trimester
FROM CCEWeeklySessions
WHERE SessionDate<='" . $endDate->format("Y-m-d") . "' AND SessionDate>='" . date("Y-01-01") . "'
)";
$sql = "SELECT MIN(SessionDate) AS FirstDate, MAX(SessionDate) AS LastDate, TrimesterNum
FROM CCEWeeklySessions WHERE TrimesterNum IN (
SELECT MAX(TrimesterNum) AS Trimester
FROM CCEWeeklySessions
WHERE SessionDate<='" . $endDate->format("Y-m-d") . "' AND SessionDate>='" . date("Y-01-01") . "'
)
AND SessionDate<='" . $endDate->format("Y-m-d") . "' AND SessionDate>='" . date("Y-01-01") . "'";
$rec = mysql_query($sql);
// echo 'Please ignore debug info: ' . $sql . '<br />';
if ($row = mysql_fetch_assoc($rec)) {
// var_dump($row);
$dtTrimesterStart = $row["FirstDate"];
$iStartMonth = date("m", strtotime($row["FirstDate"]));
$iEndMonth = date("m", strtotime($row["LastDate"]));
$iTrimester = $row["TrimesterNum"];
if ($iTrimester <= 0) {
$iTrimester = 1;
}
if ($iStartMonth == $iEndMonth) {
$iEndMonth++;
}
} else {
$iStartMonth = date("m");
$iEndMonth = intval($iStartMonth) + 2;
$dtTrimesterStart = date("Y") . "-" . $iStartMonth . "-01";
}
} else {
$iStartMonth = $_GET["month"];
$iEndMonth = intval($iStartMonth) + 2;
$dtTrimesterStart = date("Y") . "-" . $iStartMonth . "-01";
}
if ($iEndMonth > 12)
$iEndMonth = 12;
$sql = "SELECT a.*, CASE WHEN ae.CCEExtensionDate IS NULL THEN a.DueDate ELSE ae.CCEExtensionDate END AS FinalDueDate "
. "FROM CCEAssignments a "
. "LEFT OUTER JOIN CCEStAssigExtensions ae ON a.CCEAssignmentID = ae.CCEAssignmentID AND ae.CCEStudentID = " . $_SESSION["StudentID"] . " "
. "WHERE a.Archived=0 ";
if ($_SESSION["StudentID"] != 54) {
$sql .= " AND (a.ReleaseDate <= '" . date("Y-m-d") . "' OR a.ReleaseDate IS NULL)";
}
$sql .= " AND a.DueDate>='" . $dtTrimesterStart . "' "
. "ORDER BY a.DueDate, a.RefNum";
// echo 'Ignore debug info: ' . $sql . '<br />';
$rec = mysql_query($sql);
?>
<tr>
<td colspan="2">
<h2><?php echo $iStartMonth . '/' . date("Y") . ' - ' . $iEndMonth . '/' . date("Y"); ?></h2>
</td>
</tr>
<?php
for ($iMonth = $iStartMonth; $iMonth <= $iEndMonth; $iMonth++) {
?>
<tr>
<td align="center" valign="top">
<script language="javascript">
myCal = new CALENDAR(<?php echo date("Y"); ?>, <?php echo $iMonth; ?>);
myCal.offset = 2; // start with Monday
// Make Sat and Sun the same format as other days
myCal.saFontColor = myCal.dFontColor;
myCal.saBGColor = myCal.dBGColor;
myCal.suFontColor = myCal.dFontColor;
myCal.suBGColor = myCal.dBGColor;
myCal.weekNumbers = false;
myCal.dFontSize = 18;
<?php
$sList = "";
$sql = "SELECT ws.SessionDate "
. "FROM CCEWeeklySessions ws "
. "INNER JOIN CCESetup s ON (ws.ScheduleID = s.CurrentScheduleID) "
. "WHERE MONTH(ws.SessionDate)=" . $iMonth . (!empty($iTrimester) ? " AND ws.TrimesterNum=" . $iTrimester : "") . " ORDER BY ws.SessionDate";
$recCal = mysql_query($sql);
while ($rowCal = mysql_fetch_assoc($recCal)) {
?>
myCal.viewEvent(<?php echo date("d", strtotime($rowCal["SessionDate"])); ?>, <?php echo date("d", strtotime($rowCal["SessionDate"])); ?>, "#94FA8E", "Online Session");
<?php
}
$arrDates = array();
if ($rec) {
mysqli_data_seek($rec, 0);
while ($row = mysql_fetch_assoc($rec)) {
$sql = "SELECT COUNT(*) AS NumStudents "
. "FROM CCEStudents JOIN CCEStudentCourses USING (CCEStudentID) "
. "JOIN CCESetup ON (CCECourseScheduleID=CurrentScheduleID) "
. "WHERE CCEStudents.Archived=0 "
. "AND CCEStudents.ModulesEnrolled LIKE '%" . $row["CCEModuleID"] . "%' "
. "AND CCEStudentID <> 54";
$recNS = mysql_query($sql);
$rowNS = mysql_fetch_assoc($recNS);
$iNumStudents = $rowNS["NumStudents"];
mysql_free_result($recNS);
if (date("m", strtotime($row["DueDate"])) == $iMonth) {
$sList = "<li>" . date("d M", strtotime($row["DueDate"]))
. ": <a href='/cesanet/assignmentinfo.php?id=" . $row["CCEAssignmentID"] . "'>"
. $row["RefNum"] . ": " . $row["AssignmentName"] . "</a>";
$sql = "SELECT COUNT(DISTINCT CCEStudentAssignments.CCEStudentID) AS NumSub "
. "FROM CCEStudentAssignments JOIN CCEStudentCourses USING (CCEStudentID) "
. "JOIN CCESetup ON (CCECourseScheduleID=CurrentScheduleID) "
. "WHERE CCEAssignmentID=" . $row["CCEAssignmentID"] . " "
. "AND CCEStudentAssignments.CCEStudentID <> 54 "
. "AND YEAR(CCEStudentAssignments.DateSubmitted)=" . date("Y");
// echo 'Ignore debug info: ' . $sql . '<br />';
$recSub = mysql_query($sql);
if (($rowSub = mysql_fetch_assoc($recSub))) {
$sList .= "<br> <small>"
. "<i>" . $rowSub["NumSub"] . " out of " . $iNumStudents . " students have submitted this assignment</i></small>";
}
mysql_free_result($recSub);
$extension = '';
if ($row["DueDate"] != $row["FinalDueDate"]) {
$extDate = new DateTime($row["FinalDueDate"]);
$extension = ' (Extension Granted Until: ' . $extDate->format('j F Y') . ')';
$sList .= '<br />' . $extension;
}
$sList .= "</li>";
$arrDates[date("m-d", strtotime($row["DueDate"])) . '_' . $row["RefNum"] . '_' . $row["CCEAssignmentID"]] = $sList;
?>
myCal.viewEvent(<?php echo date("d", strtotime($row["DueDate"])); ?>, <?php echo date("d", strtotime($row["DueDate"])); ?>, "#ffba6f", "<?php echo $row["RefNum"] . ": " . $row["AssignmentName"]; ?>".$extension);
<?php
}
if (strtotime($row["DueDate"]) < mktime(0)) {
$dtResub = GetResubDate($row["CCEAssignmentID"]);
if (!empty($dtResub) && (date("m", strtotime($dtResub)) == $iMonth)) {
$sql = "SELECT COUNT(DISTINCT CCEStudentAssignments.CCEStudentID) AS NumSub
FROM CCEStudentAssignments JOIN CCEStudentCourses USING (CCEStudentID)
JOIN CCESetup ON (CCECourseScheduleID=CurrentScheduleID)
WHERE CCEAssignmentID=" . $row["CCEAssignmentID"] . " AND YEAR(DateSubmitted)=" . date("Y") . " AND RulingCode='R'";
$recSub = mysql_query($sql);
if (($rowSub = mysql_fetch_assoc($recSub)) && !empty($rowSub["NumSub"])) {
$sList = "<li>" . date("d M", strtotime($dtResub)) . ": <a href='/cesanet/assignmentinfo.php?id=" . $row["CCEAssignmentID"] . "'>" . $row["RefNum"] . " Resubmissions Due</a>";
$iNumResubsDue = $rowSub["NumSub"];
$sql = "SELECT CCEStudentAssignments.CCEStudentID, COUNT(*)
FROM CCEStudentAssignments JOIN CCEStudentCourses USING (CCEStudentID)
JOIN CCESetup ON (CCECourseScheduleID=CurrentScheduleID)
WHERE CCEAssignmentID=" . $row["CCEAssignmentID"] . " AND YEAR(DateSubmitted)=" . date("Y") . "
GROUP BY CCEStudentAssignments.CCEStudentID
HAVING COUNT(*)>1";
$recSub = mysql_query($sql);
$sList .= "<br> <small><i>" . (mysql_num_rows($recSub) > $iNumResubsDue ? $iNumResubsDue : mysql_num_rows($recSub)) . " out of " . $iNumResubsDue . " students have re-submitted this assignment</i></small>";
$sList .= "</li>";
$arrDates[date("m-d", strtotime($dtResub)) . $row["RefNum"] . "_R"] = $sList;
}
mysql_free_result($recSub);
?>
myCal.viewEvent(<?php echo date("d", strtotime($dtResub)); ?>, <?php echo date("d", strtotime($dtResub)); ?>, "#ffba6f", "<?php echo $row["RefNum"] . ": " . $row["AssignmentName"]; ?>");
<?php
}
}
}
}
?>
document.write(myCal.create());
</script>
</td>
<td valign="top">
<ul><?php
ksort($arrDates);
echo implode("\r\n", $arrDates);
?></ul>
</td></tr>
<?php
} //for month
?>
</table>
</div>
<div class="tab-pane fade" id="overdue-assignments-tab-pane" role="tabpanel" aria-labelledby="overdue-assignments-tab" tabindex="2">
<?php
if (!empty($_SESSION["StudentID"]) && !empty($arrOverdue)) {
?><div style="border:2px solid red; padding:5px"><p><b>NB: The following assignments are now <span style="color:red">OVERDUE</span>:</b></p>
<ul><li>
<?php
echo implode("</li><li>", $arrOverdue);
?>
</li></ul>
</div>
<?php
}
?>
</div>
<div class="tab-pane fade" id="resubmissions-tab-pane" role="tabpanel" aria-labelledby="resubmissions-tab" tabindex="3">
<?php
if (!empty($_SESSION["StudentID"]) && !empty($arrResubmissions)) {
?><p><b>NB: The following assignments must be resubmitted:</b></p>
<ul><li>
<?php
echo implode("</li><li>", $arrResubmissions);
?>
</li></ul>
<?php
}
?>
</div>
<div class="tab-pane fade" id="extensions-tab-pane" role="tabpanel" aria-labelledby="extensions-tab" tabindex="4">
<?php
if (!empty($_SESSION["StudentID"]) && is_array($arrExtensions) && count($arrExtensions) > 0) {
?><p><b>NB: The following extensions have been applied for:</b></p>
<ul>
<?php
foreach ($arrExtensions as $arrExtension) {
$extensionDate = new DateTime($arrExtension['CCEExtensionDate']);
$extensionApprovedString = 'Not Approved';
if (strlen($arrExtension['ApprovedCCEExtensionDate']) > 0 || in_array($arrExtension['Status'], array('A', 'P'))) {
$extensionApprovedDate = null;
if (strlen($arrExtension['ApprovedCCEExtensionDate']) <= 0 && strlen ($arrExtension['CCEExtensionDate']) > 0) {
$extensionApprovedDate = new DateTime($arrExtension['CCEExtensionDate']);
} elseif (strlen($arrExtension['ApprovedCCEExtensionDate']) > 0) {
$extensionApprovedDate = new DateTime($arrExtension['ApprovedCCEExtensionDate']);
}
if (is_object($extensionApprovedDate) && $extensionApprovedDate->getTimestamp() >= $extensionDate->getTimestamp()) {
$extensionApprovedString = $extensionApprovedDate->format('j F Y ');
} else {
$extensionApprovedString = 'Error reading approved date. The problem has been reported to our technical staff.';
maill('cesa@igotafrica.com', 'Error on BCE Dashboard extensions', 'No approved date: ' . print_r($arrExtension, true));
}
}
?>
<li>
<a href="/cesanet/assignmentinfo.php?id=<?php echo $arrExtension['CCEAssignmentID']; ?>"><?php echo $arrExtension['RefNum']; ?>:
<?php echo $arrExtension['AssignmentName']; ?></a>
<br />
Requested: <?php echo $extensionDate->format('j F Y'); ?>
<br />
Approved: <?php echo $extensionApprovedString; ?>
</li>
<?php
} //foreach
?></ul>
<?php
}
?>
</div>
<div class="tab-pane fade" id="previous-documents-pane" role="tabpanel" aria-labelledby="previous-documents" tabindex="5">
<?php
if (count($previousDocs) > 0) {
?><div style="border:2px solid green; padding:5px"><p><b>The following documents are relevant to the previous online session:</b></p>
<table border="0" cellpadding="2" width="95%" align="center">
<tr style="border-bottom: solid 1px #009DDA;">
<?php
$cellCnt = 0;
foreach ($previousDocs as $row) {
$bShow = true;
if (!empty($row["ReleaseDate"]) && !empty($row["ReleaseTime"])) {
if (strtotime($row["ReleaseDate"] . " " . $row["ReleaseTime"]) > strtotime("now")) {
$bShow = false;
}
}
if ($bShow && !empty($row["Students"])) {
$arrStudentsAllowed = explode(",", $row["Students"]);
$arrStudentsAllowed[] = 54;
if (!in_array($_SESSION["StudentID"], $arrStudentsAllowed)) {
$bShow = false;
}
}
if ($bShow) {
if ($cellCnt > 0 && $cellCnt % 2 == 0) {
?>
</tr>
<tr><td colspan="3"> </td></tr>
<tr style="border-bottom: solid 1px #009DDA;" data-cell-count="<?php echo $cellCnt; ?>">
<?php
}
?>
<td valign="top" nowrap><?php echo date("d M", strtotime($row["AppliesToDate"])); ?></td>
<td valign="top"><?php if (!empty($row["DocumentFile"])) echo '<a href="/cceadmin/documents/' . $row["DocumentFile"] . '" target="_blank">'; ?><img src="<?php
$thumbfile = "";
if (true || empty($row["DocumentThumb"])) {
$thumbfile = '/cesanet/images/book.jpg';
if (true || strtolower(substr($row["DocumentFile"], -4)) == ".pdf") {
try {
$thumbfile = CreateThumb($row["CCEDocumentID"], $row["DocumentFile"], '', $row);
} catch (Exception $e) {
}
// if (empty($docthumb)) {
// $thumbfile = '/cesanet/images/book.jpg';
// } else {
// $thumbfile = '/cesanet/docthumbs/' . $docthumb;
// }
}
} else {
$thumbfile = $row["DocumentThumb"];
}
echo $thumbfile;
?>" alt="<?php echo $row["DocumentName"]; ?>" height="40" border="0"<?php $size = getimagesize($thumbfile); ?> hspace="2" /><?php if (!empty($row["DocumentFile"])) echo "</a>"; ?>
</td>
<td valign=top><?php if (!empty($row["DocumentFile"])) echo '<a href="/cceadmin/documents/' . $row["DocumentFile"] . '" target="_blank">'; ?><?php echo $row["DocumentName"]; ?><?php if (!empty($row["DocumentFile"])) echo "</a>"; ?><br>
<?php
if (!empty($row["PresenterName"]))
echo "<br>" . $row["PresenterName"];
if (!empty($row["PresentationTime"]))
echo "<br>" . $row["PresentationTime"];
?>
</td>
<?php
$cellCnt++;
} //if
} //while
?>
</tr>
</table>
</div>
<br>
<?php
} //Previous documents
?>
</div>
</div>
<?php