
<?php 
    include'include/session.php';
    
    $tableName1="unit";
    $tableName2="course";
    $tableName3="semisterperiod";
    $tableName4="staffunit";
    $tableName5="staff";
    
    if(isset($_GET['vo'])=="original"){
        $tableName="exam_added";
        
        $query1 = "SELECT e.*,u.abbreviation AS unit,u.yosID,u.semisterID,c.abbreviation AS course,sp.start AS semStart,sp.end AS semEnd,CONCAT(s.fname,' ',s.lname,' ',s.sname) AS staff
                FROM $tableName e
                LEFT JOIN $tableName1 u
                ON e.unitID = u.unitID
                LEFT JOIN $tableName2 c
                ON u.courseID = c.courseID
                LEFT JOIN $tableName3 sp
                ON e.periodID = sp.periodID
                LEFT JOIN $tableName4 sf
                ON sf.unitID = u.unitID
                LEFT JOIN $tableName5 s
                ON sf.staffID = s.staffID
                ORDER BY e.start DESC";
        $result = mysql_query($query1);
        $rowcount=  mysql_num_rows($result);
    }else
    if(isset($_GET['vu'])=="update"){
        $tableName="exam_updated";
    
        $query1 = "SELECT e.*,u.abbreviation AS unit,u.yosID,u.semisterID,c.abbreviation AS course,sp.start AS semStart,sp.end AS semEnd,CONCAT(s.fname,' ',s.lname,' ',s.sname) AS staff
                FROM $tableName e
                LEFT JOIN $tableName1 u
                ON e.unitID = u.unitID
                LEFT JOIN $tableName2 c
                ON u.courseID = c.courseID
                LEFT JOIN $tableName3 sp
                ON e.periodID = sp.periodID
                LEFT JOIN $tableName4 sf
                ON sf.unitID = u.unitID
                LEFT JOIN $tableName5 s
                ON sf.staffID = s.staffID
                ORDER BY e.start DESC";
        $result = mysql_query($query1);
        $rowcount=  mysql_num_rows($result);
    }else
    if(isset($_GET['vd'])=="delete"){
        $tableName="exam_deleted";
     
        $query1 = "SELECT e.*,u.abbreviation AS unit,u.yosID,u.semisterID,c.abbreviation AS course,sp.start AS semStart,sp.end AS semEnd,CONCAT(s.fname,' ',s.lname,' ',s.sname) AS staff
                FROM $tableName e
                LEFT JOIN $tableName1 u
                ON e.unitID = u.unitID
                LEFT JOIN $tableName2 c
                ON u.courseID = c.courseID
                LEFT JOIN $tableName3 sp
                ON e.periodID = sp.periodID
                LEFT JOIN $tableName4 sf
                ON sf.unitID = u.unitID
                LEFT JOIN $tableName5 s
                ON sf.staffID = s.staffID
                ORDER BY e.start DESC";
        $result = mysql_query($query1);
        $rowcount=  mysql_num_rows($result);
    }else{
        $tableName="exam";
    
        $query1 = "SELECT e.*,u.abbreviation AS unit,u.yosID,u.semisterID,c.abbreviation AS course,sp.start AS semStart,sp.end AS semEnd,CONCAT(s.fname,' ',s.lname,' ',s.sname) AS staff
                FROM $tableName e
                LEFT JOIN $tableName1 u
                ON e.unitID = u.unitID
                LEFT JOIN $tableName2 c
                ON u.courseID = c.courseID
                LEFT JOIN $tableName3 sp
                ON e.periodID = sp.periodID
                LEFT JOIN $tableName4 sf
                ON sf.unitID = u.unitID
                LEFT JOIN $tableName5 s
                ON sf.staffID = s.staffID
                ORDER BY e.start DESC";
        $result = mysql_query($query1);
        $rowcount=  mysql_num_rows($result);
    }
    
?>
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Time Tabler - View  Online Exam | Administrator | WAKA CMEC</title>
    <link rel="shortcut icon" href="../../../assets/img/logo.png" />
    <link rel="stylesheet" href="../../../assets/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,700">
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto+Slab:300,400|Roboto:300,400,700">
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto">
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto+Slab:300,400">
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Romanesco">
    <link rel="stylesheet" href="../../../assets/fonts/font-awesome.min.css">
    <link rel="stylesheet" href="../../../assets/fonts/material-icons.css">
    <link rel="stylesheet" href="../../../assets/css/ebs-simple-login-form1.css">
    <link rel="stylesheet" href="../../../assets/css/ebs-simple-login-form2.css">
    <link rel="stylesheet" href="../../../assets/css/Data-Table.css">
    <link rel="stylesheet" href="../../../assets/css/Data-Table1.css">
    <link rel="stylesheet" href="../../../assets/css/ebs-simple-login-form.css">
    <link rel="stylesheet" href="../../../assets/css/FPE-Gentella-form-elements.css">
    <link rel="stylesheet" href="../../../assets/css/FPE-Gentella-form-elements1.css">
    <link rel="stylesheet" href="https://cdn.datatables.net/1.10.15/css/dataTables.bootstrap.min.css">
    <link rel="stylesheet" href="../../../assets/css/MUSA_no-more-tables.css">
    <link rel="stylesheet" href="../../../assets/css/MUSA_no-more-tables1.css">
    <link rel="stylesheet" href="../../../assets/css/MUSA_panel-table.css">
    <link rel="stylesheet" href="../../../assets/css/MUSA_panel-table1.css">
    <link rel="stylesheet" href="../../../assets/css/nav.css">
    <link rel="stylesheet" href="../../../assets/css/Navbar---App-Toolbar--LG--MD---Mobile-Nav--SM--XS.css">
    <link rel="stylesheet" href="../../../assets/css/JLX-Fixed-Nav-on-Scroll.css">
    <link rel="stylesheet" href="../../../assets/css/Navbar---App-Toolbar--LG--MD---Mobile-Nav--SM--XS1.css">
    <link rel="stylesheet" href="../../../assets/css/Navbar-Fixed-Side1.css">
    <link rel="stylesheet" href="../../../assets/css/Pretty-Table.css">
    <link rel="stylesheet" href="../../../assets/css/Pretty-Table1.css">
    <link rel="stylesheet" href="../../../assets/css/Profile-Edit.css">
    <link rel="stylesheet" href="../../../assets/css/Profile-Edit1.css">
    <link rel="stylesheet" href="../../../assets/css/Responsive-Form.css">
    <link rel="stylesheet" href="../../../assets/css/Responsive-Form1.css">
    <link rel="stylesheet" href="../../../assets/css/Sidebar-Menu.css">
    <link rel="stylesheet" href="../../../assets/css/Sidebar-Menu1.css">
    <link rel="stylesheet" href="../../../assets/css/styles.css">
    <link rel="stylesheet" href="../../../assets/css/tabela-mloureiro1973.css">
    <link rel="stylesheet" href="../../../assets/css/Team-Clean.css">
</head>

<body style="background-color:rgba(42,63,84,0);">
    <nav class="navbar navbar-default" style="background-color:rgb(62,140,228);">
        <div class="container-fluid">
            <div class="navbar-header"><a class="navbar-brand navbar-link" href="#" style="font-weight:bold;background-color:rgb(62,140,228);">Administrator | Waka CMEC Training Institute</a>
                <button class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navcol-2" style="background-color:rgb(62,140,228);color:rgb(255,255,255);"><span class="sr-only">Toggle navigation</span><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button>
            </div>
            <div class="collapse navbar-collapse" id="navcol-2">
                <ul class="nav navbar-nav hidden-xs hidden-sm navbar-right" id="desktop-toolbar">
                    <li class="dropdown">
                        <a class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false" href="#"> <i class="fa fa-user"></i> &nbsp; <?php echo $pro;?>  <i class="fa fa-chevron-down fa-fw"></i></a>
                        <ul class="dropdown-menu" role="menu" style="background-color:rgb(249,249,249);">
                            <li role="presentation"><a href="settings.php"><i class="fa fa-user fa-fw"></i> Profile </a></li>
                            <li role="presentation"><a href="password.php"><i class="fa fa-lock fa-fw"></i> Password</a></li>
                            <li role="presentation"><a href="../validate/logout.php"><i class="fa fa-power-off fa-fw"></i>Logout </a></li>
                        </ul>
                    </li>
                </ul>
                <ul class="nav navbar-nav visible-xs-block visible-sm-block" id="mobile-nav">
                    
                    <li class="dropdown">
                        <a class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false" href="#"> <i class="fa fa-user"></i> &nbsp; <?php echo $pro;?> </i> <i class="fa fa-chevron-down fa-fw"></i></a>
                        <ul class="dropdown-menu" role="menu" style="background-color:rgb(249,249,249);">
                            <li role="presentation"><a href="settings.php"><i class="fa fa-user fa-fw"></i> Profile </a></li>
                            <li role="presentation"><a href="password.php"><i class="fa fa-lock fa-fw"></i> Password</a></li>
                            <li role="presentation"><a href="../validate/logout.php"><i class="fa fa-power-off fa-fw"></i>Logout </a></li>
                        </ul>
                    </li>
                    <li role="presentation"><a>&nbsp;</a></li>
                    <li role="presentation"><a>&nbsp;</a></li>
                    
                </ul>
            </div>
        </div>
    </nav>
    <div class="top">
        <nav class="navbar navbar-default" id="navbar-main">
            <div class="container-fluid">
                <div class="navbar-header">
                    <a class="navbar-brand hidden navbar-link" href="#" style="padding:0px;"> </a>
                    <button class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navcol-1"><span class="sr-only">Toggle navigation</span><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button>
                </div>
                <div class="collapse navbar-collapse" id="navcol-1">
                    <ul class="nav navbar-nav">
                        <li role="presentation">
                            <a href="index.php">
                                <i class="fa fa-table" style="margin-right:5px;"></i>
                                Dashboard
                            </a>
                        </li>
                        <li role="presentation">
                            <a href="staff.php">
                                <i class="fa fa-users" style="margin-right:5px;"></i>
                                Staff 
                            </a>
                        </li>
                        <li role="presentation">
                            <a href="faculty.php">Faculty</a>
                        </li>
                        <li role="presentation">
                            <a href="course.php">Course</a>
                        </li>
                        <li role="presentation">
                            <a href="class.php">Class</a>
                        </li>
                        <li role="presentation">
                            <a href="unit.php">Unit</a>
                        </li>
                        <li role="presentation">
                            <a href="assigned-unit.php">
                                <i class="fa fa-bookmark" style="margin-right:5px;"></i>
                                Assigned Units
                            </a>
                        </li>
                        <li role="presentation">
                            <a href="period.php">Block Period</a>
                        </li>
                        <li class="dropdown">
                            <a class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false" href="#">
                                Others <span class="badge bg-red" id="notificationCounter"></span>
                                <span class="caret"></span>
                            </a>
                            <ul class="dropdown-menu" role="menu">
                                <li role="presentation"><a href="pass-request.php">Gate Pass Request <span class="badge bg-red" id="requestCounter"></span></a></li>
                                <li role="presentation"><a href="expired-pass.php">Expired Gate Pass &nbsp;<span class="badge bg-red" id="expiredCounter"></span></a></li>
                                <li role="presentation"><a href="leave-request.php">Staff Leave Request <span class="badge bg-red" id="requestLeaveCounter"></span></a></li>
                                <li role="presentation"><a href="expired-leave.php">Expired Staff Leave &nbsp;<span class="badge bg-red" id="expiredLeaveCounter"></span></a></li>
                                <li role="presentation"><a href="pass.php">Gate Pass</a></li>
                                <li role="presentation"><a href="leave.php">Leave Type</a></li>
                            </ul>
                        </li>
                    </ul>
                </div>
            </div>
        </nav>
    </div>
    <div class="row" style="width:98%;margin-right:auto;margin-left:auto;-webkit-box-shadow:0px 4px 4px 0px rgba(0,0,0,1);-moz-box-shadow:0px 4px 4px 0px rgba(0,0,0,1);box-shadow:0px 4px 4px 0px rgba(0,0,0,1);margin-bottom:5%;overflow:hidden;">
        <form method="POST">
            <div class="col-md-12" style="margin-bottom:1%;padding-top:2px;padding-bottom:2px;background-color:rgb(239,239,239);">
                <div class="col-md-6">
                    <p style="margin-left:1%;padding-top:5px;padding-bottom:5px;font-size:14px;color:rgb(1,1,1);">
                        <b><i class="fa fa-info-circle"></i> You are Here:</b> 
                        <?php 
                            if(isset($_GET['vo'])=="original"){
                                echo '<em>Time Tabler > Original Online Exams Records</em>';
                            }else
                            if(isset($_GET['vu'])=="update"){
                                echo '<em>Time Tabler >Updated Online Exams</em>';
                            }else
                            if(isset($_GET['vd'])=="delete"){
                                echo '<em>Time Tabler >Deleted Online Exams</em>';
                            }else
                            {
                                echo '<em>Time Tabler > Online Exams</em>';
                            }   
                        ?>
                    </p>
                </div>
                <div class="col-md-2">
                    <b>View:</b>&nbsp;
                    <a class="btn btn-link" href="tt-exam.php?vo=original" <?php if(isset($_GET['vo'])=="original"){ echo 'style="text-decoration: underline;color:black;background-color:transparent;"';}?> >Original Records</a>
                </div>
                <div class="col-md-2">
                    <a class="btn btn-link" href="tt-exam.php?vu=update" <?php if(isset($_GET['vu'])=="update"){ echo 'style="text-decoration: underline;color:black;background-color:transparent;"';}?> >Updated History</a>
                </div>
                <div class="col-md-2">
                    <a class="btn btn-link" href="tt-exam.php?vd=delete" <?php if(isset($_GET['vd'])=="delete"){ echo 'style="text-decoration: underline;color:black;background-color:transparent;"';}?> >Delete History</a>
                </div>
            </div>
            <?php 
                if(empty($result)){
                    echo'<div class="col-md-12 alert alert-danger absolue center text-center" role="alert">
                            <span class="text-danger">No records found</span>
                        </div>';
                }else{
                    //include 'validate/deletePass.php';
                    
            ?>
                <div class="col-md-12" style="width:100%;">
                    <div class="table-responsive" style="margin-right:auto;margin-left:auto;">
                        <table class="table table-striped" id="myTable">
                            <thead style="background-color:rgb(42,63,84);color:rgb(254,255,255);">
                                <tr>
                                    <th style="width:60px;text-align:center;"># </th>
                                    <th style="text-align:center;">Code</th>
                                    <th>Course</th>
                                    <th>Unit</th>
                                    <th>YoS/Block</th>
                                    <th>Start</th>
                                    <th>Deadline</th>
                                    <th>Time</th>
                                    <th>Block</th>
                                    <th>Lecturer</th>
                                    <th>Status</th>
                                    <th>Uploaded</th>
                                    <th>Uploaded By</th>
                                    <?php 
                                        if(isset($_GET['vo'])=="original" || isset($_GET['vu'])=="update" || isset($_GET['vd'])=="delete"){
                                         if(isset($_GET['vu'])=="update"){
                                    ?>
                                            <th>Received</th>
                                            <th>Received by</th>
                                        <?php }else if(isset($_GET['vd'])=="delete"){ ?>
                                            <th>Deleted</th>
                                            <th>Deleted by</th>
                                    <?php } }?>
                                </tr>
                            </thead>
                            <tbody>
                                <?php 
                                    $i=$p=$s=$p1=$p2=$p3=$pp1=$pp2=$pp3=$s1=$s2=$s3=1;
                                    while($row = mysql_fetch_array($result)) { 
                                        
                                        $tableNamex="exam";
                                        $tableName1x="unit";
                                        $tableName2x="course";
                                        $tableName3x="semisterperiod";
                                        $tableName4x="staffunit";
                                        $tableName5x="staff";

                                        $queryx = "SELECT e.*,u.abbreviation AS unit,u.yosID,u.semisterID,c.abbreviation AS course,sp.start AS semStart,sp.end AS semEnd,CONCAT(s.fname,' ',s.lname,' ',s.sname) AS staff
                                                    FROM $tableNamex e
                                                    LEFT JOIN $tableName1 u
                                                    ON e.unitID = u.unitID
                                                    LEFT JOIN $tableName2x c
                                                    ON u.courseID = c.courseID
                                                    LEFT JOIN $tableName3x sp
                                                    ON e.periodID = sp.periodID
                                                    LEFT JOIN $tableName4x sf
                                                    ON sf.unitID = u.unitID
                                                    LEFT JOIN $tableName5x s
                                                    ON sf.staffID = s.staffID
                                                    WHERE e.examNo='".$row['examNo']."'
                                                    ORDER BY e.start DESC";
                                        $resultx = mysql_query($queryx);
                                        $rowcounx=  mysql_num_rows($resultx);

                                        $query2x = "SELECT * FROM quiz WHERE examNo='".$row['examNo']."' ORDER BY quizID ASC";
                                        $resultsx = mysql_query($query2x);
                                ?>
                                    <tr>
                                        <td style="text-align:center;font-size:12px;font-weight:normal;color:rgb(3,3,3);"> <?php echo $i++;?> </td>
                                        <td style="font-size:12px;font-weight:normal;color:rgb(3,3,3);">
                                            <a style="display:block;" href="#myModal<?php echo $p++;?>" data-toggle="modal" title="View Exam Questions">
                                                <?php echo $row['examNo'];?> 
                                            </a>
                                            
                                            
                                            <div class="bs-example">
                                                <!--current questions -->
                                                <div id="myModal<?php echo $s++;?>" class="modal fade">
                                                    <div class="modal-dialog modal-lg">
                                                        <div class="modal-content">
                                                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                                            <div class="modal-header">
                                                                <div class="col-md-4">
                                                                    <h4>Online Exam Quizes</h4>
                                                                </div>
                                                                <!--
                                                                <div class="col-md-2">
                                                                    <a class="btn btn-link" href="#originalModal<?php echo $p1++;?>" data-toggle="modal">Original</a>
                                                                </div>
                                                                <div class="col-md-2">
                                                                    <a class="btn btn-link" href="#updatedModal<?php echo $p2++;?>" data-toggle="modal">Updated</a>
                                                                </div>
                                                                <div class="col-md-2">
                                                                    <a class="btn btn-link" href="#deletedModal<?php echo $p3++;?>" data-toggle="modal">Deleted</a>
                                                                </div>
                                                                -->                                                         
                                                            </div>
                                                            
                                                            <div class="modal-body" style="color:black;">
                                                                <div class="row">
                                                                    <?php
                                                                        while($rowx = mysql_fetch_array($resultx)) { 
                                                                            $examDate = date_format(date_create($rowx['deadline']),"Y-m-d");
                                                                    ?>
                                                                        <div class="col-md-12">
                                                                            <div class="col-md-2">
                                                                                <label>Exam Code</label>
                                                                                <p><?php echo $rowx['examNo'];?></p>
                                                                            </div>
                                                                            <div class="col-md-2">
                                                                                <label>Unit</label>
                                                                                <p><?php echo $rowx['unit'];?></p>
                                                                            </div>
                                                                            <div class="col-md-2">
                                                                                <label>Course</label>
                                                                                <p><?php echo $rowx['course'];?></p>
                                                                            </div>
                                                                            <div class="col-md-2">
                                                                                <label>YoS/Block</label>
                                                                                <p><?php echo "Yr.".$rowx['yosID'].", Block".$rowx['semisterID'];?></p>
                                                                            </div>
                                                                            <div class="col-md-2">
                                                                                <label>Start</label>
                                                                                <p><?php echo date_format(date_create($rowx['start']),"D d-M, Y");?></p>
                                                                            </div>
                                                                            <div class="col-md-2">
                                                                                <label>Deadline</label>
                                                                                <p><?php echo date_format(date_create($rowx['deadline']),"D d-M, Y");?></p>
                                                                            </div>
                                                                        </div>
                                                                        <div class="col-md-12">
                                                                            <div class="col-md-2">
                                                                                <label>Time</label>
                                                                                <p>
                                                                                    <?php 
                                                                                        $time=$rowx['time'];
                                                                                        function convertToHoursMins($time, $format = '%02d:%02d') {
                                                                                            if ($time < 1) {
                                                                                                return;
                                                                                            }
                                                                                            $hours = floor($time / 60);
                                                                                            $minutes = ($time % 60);
                                                                                            return sprintf($format, $hours, $minutes);
                                                                                        }
                                                                                        echo convertToHoursMins($time, '%2d Hrs. %2d min.');
                                                                                    ?>
                                                                                </p>
                                                                            </div>
                                                                            <div class="col-md-4">
                                                                                <label>Sem. Period</label>
                                                                                <p><?php echo date_format(date_create($rowx['semStart']),"M,Y")." - ".date_format(date_create($rowx['semEnd']),"M,Y");?></p>
                                                                            </div>
                                                                            <div class="col-md-4">
                                                                                <label>Lecturer</label>
                                                                                <p><?php echo $rowx['staff'];?></p>
                                                                            </div>
                                                                            <div class="col-md-2">
                                                                                <label>Status</label>
                                                                                <p style="color:white; padding-left:10px;background-color:
                                                                                                          <?php 
                                                                                                                if(date('Y-m-d') < date_format(date_create($rowx['start']),"Y-m-d")){
                                                                                                                    echo '#B8860B';
                                                                                                                }else
                                                                                                                if(date_format(date_create($rowx['start']),"Y-m-d") <= date('Y-m-d') && date_format(date_create($rowx['deadline']),"Y-m-d") >= date('Y-m-d')){
                                                                                                                    echo '#00BFFF';
                                                                                                                }else
                                                                                                                if (date('Y-m-d') > date_format(date_create($rowx['deadline']),"Y-m-d")){
                                                                                                                    echo '#006400';
                                                                                                                }

                                                                                                                ?>;">
                                                                                                <?php 
                                                                                                    if(date('Y-m-d') < date_format(date_create($rowx['start']),"Y-m-d") ){
                                                                                                        echo 'Pending';
                                                                                                    }else
                                                                                                    if(date('Y-m-d') >= date_format(date_create($rowx['start']),"Y-m-d") && date('Y-m-d') <= date_format(date_create($rowx['deadline']),"Y-m-d")){
                                                                                                        echo 'Ongoing';
                                                                                                    }else
                                                                                                    if (date('Y-m-d') > date_format(date_create($rowx['deadline']),"Y-m-d")){
                                                                                                        echo 'Done';
                                                                                                    }                                            
                                                                                                ?>
                                                                                   </p>
                                                                            </div>
                                                                        </div>
                                                                        <div class="col-md-12">
                                                                           <hr>
                                                                        </div>
                                                                    <?php } ?>

                                                                    <div class="col-md-12" style="width:100%;">
                                                                        <div class="table-responsive" style="margin-right:auto;margin-left:auto;">
                                                                            
                                                                            <table class="table table-striped" id="myTable">
                                                                                <thead style="background-color:rgb(42,63,84);color:rgb(254,255,255);">
                                                                                    <tr>
                                                                                        <th style="width:7%;text-align:center;">#</th>
                                                                                        <th>Question</th>
                                                                                        <th>Option</th>
                                                                                        <th>Answer</th>
                                                                                        <th style="width:80px;">Marks</th>
                                                                                        <th>Added</th>
                                                                                        <th>Added by</th>
                                                                                        <?php 
                                                                                            if(isset($_GET['vo'])=="original" || isset($_GET['vu'])=="update" || isset($_GET['vd'])=="delete"){
                                                                                             if(isset($_GET['vu'])=="update"){
                                                                                        ?>
                                                                                                <th>Updated</th>
                                                                                                <th>Updated by</th>
                                                                                            <?php }else if(isset($_GET['vd'])=="delete"){ ?>
                                                                                                <th>Deleted</th>
                                                                                                <th>Deleted by</th>
                                                                                        <?php } }?>
                                                                                    </tr>
                                                                                </thead>
                                                                                <tbody>
                                                                                    <?php 
                                                                                        $x=1;
                                                                                        while($rw = mysql_fetch_array($resultsx)) { 
                                                                                    ?>
                                                                                        <tr>
                                                                                            <td style="text-align:center;font-size:12px;font-weight:normal;color:rgb(3,3,3);"> <?php echo $x++;?> </td>

                                                                                            <td style="font-size:12px;font-weight:normal;"> 
                                                                                                <p><?php echo $rw['quiz'];?></p>
                                                                                            </td>
                                                                                            <td style="font-size:12px;font-weight:normal;"> 
                                                                                                <p><label>A:</label> <?php echo $rw['option_a'];?></p>
                                                                                                <p><label>B:</label> <?php echo $rw['option_b'];?></p>
                                                                                                <p><label>C:</label> <?php echo $rw['option_c'];?></p>
                                                                                                <p><label>D:</label> <?php echo $rw['option_d'];?></p>
                                                                                            </td>
                                                                                            <td style="font-size:12px;font-weight:normal;"> 
                                                                                                <p><?php echo $rw['answer'];?></p>
                                                                                            </td>

                                                                                            <td style="font-size:12px;font-weight:normal;"> 
                                                                                                <p><?php echo $rw['marks'];?></p>
                                                                                            </td>
                                                                                            <td style="font-weight:normal;font-size:12px;color:rgb(6,6,6);"> <?php echo date_format(date_create($row['added']),"D d-M y. H:i");?> </td>
                                                                                            <td style="font-weight:normal;font-size:12px;color:rgb(6,6,6);"> <?php echo $row['added_by'];?> </td>
                                                                                            <?php 
                                                                                                if(isset($_GET['vo'])=="original" || isset($_GET['vu'])=="update" || isset($_GET['vd'])=="delete"){
                                                                                                if(isset($_GET['vu'])=="update"){
                                                                                            ?>
                                                                                                    <td style="font-size:12px;font-weight:normal;color:rgb(4,4,4);"> <?php echo date_format(date_create($row['updated']),"D d-M y. H:i");?> </td>
                                                                                                    <td style="font-size:12px;font-weight:normal;color:rgb(4,4,4);"> <?php echo $row['updated_by'];?> </td>
                                                                                            <?php }else if(isset($_GET['vd'])=="delete"){ ?>
                                                                                                    <td style="font-size:12px;font-weight:normal;color:rgb(4,4,4);"> <?php echo date_format(date_create($row['deleted']),"D d-M y. H:i");?> </td>
                                                                                                    <td style="font-size:12px;font-weight:normal;color:rgb(4,4,4);"> <?php echo $row['deleted_by'];?> </td>
                                                                                            <?php } }?>
                                                                                        </tr>
                                                                                    <?php } ?>
                                                                                </tbody>
                                                                            </table>
                                                                        </div>
                                                                    </div>
                                                                    <div class="col-md-12">
                                                                        <hr>
                                                                     </div>
                                                                </div>
                                                            </div>
                                                            
                                                            <div class="modal-footer">
                                                                <button type="button"  data-dismiss="modal"  style="padding:5px 20px;color:rgb(1,1,1);">Close</button>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </td>
                                        <td style="font-size:12px;font-weight:normal;color:rgb(3,3,3);"> <?php echo $row['course'];?> </td>
                                        <td style="font-size:12px;font-weight:normal;color:rgb(3,3,3);"> <?php echo $row['unit'];?> </td>
                                        <td style="font-size:12px;font-weight:normal;color:rgb(3,3,3);"> <?php echo "Yr.".$row['yosID'].", Block".$row['semisterID'];?> </td>
                                        <td style="font-weight:normal;font-size:12px;color:rgb(6,6,6);"> <?php echo date_format(date_create($row['start']),"d-m-Y");?> </td>
                                        <td style="font-size:12px;font-weight:normal;color:rgb(4,4,4);"> <?php echo date_format(date_create($row['deadline']),"d-m-Y");?> </td>
                                        <td style="font-size:12px;font-weight:normal;color:rgb(3,3,3);"> <?php echo $row['time']." Mins.";?> </td>
                                        <td style="font-size:12px;font-weight:normal;color:rgb(3,3,3);"> 
                                            <?php echo date_format(date_create($row['semStart']),"M,Y")." - ".date_format(date_create($row['semEnd']),"M,Y");?>
                                        </td>
                                        <td style="font-size:12px;font-weight:normal;color:rgb(3,3,3);"> <?php echo $row['staff'];?> </td>
                                        <td style="font-size:12px;font-weight:normal;
                                                    color:
                                                        <?php 
                                                        if(date('Y-m-d') < date_format(date_create($row['start']),"Y-m-d")){
                                                            echo '#B8860B';
                                                        }else
                                                        if(date_format(date_create($row['start']),"Y-m-d") <= date('Y-m-d') && date_format(date_create($row['deadline']),"Y-m-d") >= date('Y-m-d')){
                                                            echo '#00BFFF';
                                                        }else
                                                        if(date('Y-m-d') > date_format(date_create($row['deadline']),"Y-m-d")){
                                                            echo '#006400';
                                                        }

                                                    ?>;"> 
                                            <?php 
                                                if(date('Y-m-d') < date_format(date_create($row['start']),"Y-m-d") ){
                                                echo 'Pending';
                                                }else
                                                if(date('Y-m-d') >= date_format(date_create($row['start']),"Y-m-d") && date('Y-m-d') <= date_format(date_create($row['deadline']),"Y-m-d")){
                                                    echo 'Ongoing';
                                                }else
                                                if(date('Y-m-d') > date_format(date_create($row['deadline']),"Y-m-d")){
                                                    echo 'Done';
                                                }                                         
                                            ?>
                                        </td>
                                        <td style="font-weight:normal;font-size:12px;color:rgb(6,6,6);"> <?php echo date_format(date_create($row['registered']),"D d M,y. H:i");?> </td>
                                        <td style="font-weight:normal;font-size:12px;color:rgb(6,6,6);"> <?php echo $row['added_by'];?> </td>
                                        <?php 
                                            if(isset($_GET['vo'])=="original" || isset($_GET['vu'])=="update" || isset($_GET['vd'])=="delete"){
                                            if(isset($_GET['vu'])=="update"){
                                        ?>
                                                <td style="font-size:12px;font-weight:normal;color:rgb(4,4,4);"> <?php echo date_format(date_create($row['updated']),"D d-M y. H:i");?> </td>
                                                <td style="font-size:12px;font-weight:normal;color:rgb(4,4,4);"> <?php echo $row['updated_by'];?> </td>
                                        <?php }else if(isset($_GET['vd'])=="delete"){ ?>
                                                <td style="font-size:12px;font-weight:normal;color:rgb(4,4,4);"> <?php echo date_format(date_create($row['deleted']),"D d-M y. H:i");?> </td>
                                                <td style="font-size:12px;font-weight:normal;color:rgb(4,4,4);"> <?php echo $row['deleted_by'];?> </td>
                                        <?php } }?>
                                                            
                                    </tr>
                                <?php } ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            <?php } ?>
        </form>    
    </div>
    <script src="../../../assets/js/jquery.min.js"></script>
    <script src="../../../assets/bootstrap/js/bootstrap.min.js"></script>
    <script src="https://cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js"></script>
    <script src="https://cdn.datatables.net/1.10.15/js/dataTables.bootstrap.min.js"></script>
    <script src="../../../assets/js/ebs-simple-login-form.js"></script>
    <script src="../../../assets/js/JLX-Fixed-Nav-on-Scroll.js"></script>
    <script src="../../../assets/js/Profile-Edit.js"></script>
    <script src="../../../assets/js/Sidebar-Menu.js"></script>
    
    <script type="text/javascript">
            $(document).ready(function(){
            setInterval(function(){
                $("#notificationCounter").load("include/counter_3.php");
                $("#requestCounter").load("include/counter.php");
                $("#expiredCounter").load("include/counter_2.php");
                $("#expiredLeaveCounter").load("include/counter_2_1.php");
                $("#requestLeaveCounter").load("include/counter_4.php");
            }, 500); /* time in milliseconds (ie 2 seconds)*/
        });
    </script>
</body>
    <script>
        $(document).ready(function(){
            $('#myTable').dataTable();
        });
    </script>
</html>