<?php
include_once '../session/admin-session.php';
include_once '../classes/class_admin.php';
include_once '../classes/validation.php';
include_once '../classes/common.php';
include_once 'read-configration.php';

ob_start();

$ObjDB = new class_db();
$objadm = new class_admin();
$val = new validation();
$for_sem = $current_sem_num-1;
$objadm->sem_num = $for_sem;
$SemArr = $objadm->GetSemList();
while($res = mysqli_fetch_array($SemArr)){
    $for_sem_name =  $res["sem_name"];
}

$query_str="select any_value(sub_code)as sub_code, any_value(fac_roll) as fac_roll, count(stu_roll) as ccc from isr_reg_repeat_tbl where exam_sem = '$for_sem' and substring(stu_roll,1,2) = '20' group by sub_code";
$i = 1;
$totFI = 0;

$ObjDB->sproc_name = $query_str;
$result_val = $ObjDB->SelectQuery();
?>
<div class="container-fluid">
    <div class="row">
        <div class="col-xl-12 col-xxl-12 col-sm-12">
            <div class="card">
                <div class="card-header">
                    <h5 class="card-title">Repeat Exam Courses of <?php echo $for_sem_name; ?> having grade F or I</h5>
                </div>
                <div class="card-body">
                   
                        <div class="row">
                            <br/>
                            <div class="table-responsive">
                                <table class="table table-bordered align-middle" id="repeat_exam_List">
                                    <thead class="table" style="background: #f3e4c1;" >
                                        <tr>
                                            <th>#</th>
                                            <th>Code</th>
                                            <th>Title Of the course</th>
                                            <th>Co-Ordinator</th>
                                            <th>F/I</th>

                                        </tr>
                                    </thead>
                                    <tbody>
                                       <?php 
                                       while ($row = mysqli_fetch_array($result_val)) {
	$sub_code = $row['sub_code'];
	$fac_roll = $row['fac_roll'];
	$sub_list = 'c'.$for_sem;
	$qf = "select name from isr_faculty_tbl where roll = '$fac_roll'";
        $ObjDB->sproc_name = $qf;
        $row_qf = $ObjDB->SelectQuery();
	list($fac_name) = mysqli_fetch_row($row_qf);
        
	$qf_1 = "select sub_title from isr_curriculum_tbl where sub_list = '$sub_list' and sub_code = '$sub_code'";
        $ObjDB->sproc_name = $qf_1;
        $row_qf_1 = $ObjDB->SelectQuery();
	list($sub_title) = mysqli_fetch_row($row_qf_1);
	$fi_count = $row['ccc'];
	$totFI += $fi_count;
	?>
                                        
                                            <TR>
	<td align=center><?php echo $i++; ?></td>
	<td align=center>
	<FORM METHOD=POST ACTION="registration-repeat-exam-list.php">
	<INPUT TYPE="hidden" NAME="for_sem" value="<?php echo $for_sem; ?>">
	<INPUT TYPE="submit" name="sub_code" value="<?php echo $sub_code; ?>" style="padding:3px; border:1px blue solid;">
	</FORM></td>
	<td align=left><?php echo $sub_title; ?></td>
	<td align=left><?php echo $fac_name; ?></td>
	<td align=left><?php echo $fi_count; ?></td>
	</tr>
                                        
                                       <?php $i=$i+1; } ?>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                   
                </div>

            </div>
        </div>
    </div>
</div>
<?php
$pagemaincontent = ob_get_contents();
ob_clean();
$PAGENAME = 'registration-repeat-exam';
$HTMLTITLE = '';
$HTMLDESCRIPTION = '';
$HTMLKEYWORDS = '';
include("admin-master.php");
?>
<script type="text/javascript">
    $("#repeat_exam_List").DataTable({
        dom: '<"top"lBf>rt<"bottom"ip><"clear">',
        buttons: [
            {
                extend: 'excelHtml5',
                text: 'Download Excel',
                title: 'Data Export',
                className: 'btn btn-success'
            }
        ]
    });
</script>