<?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();
$log = new common();
$objadm = new class_admin();
$val = new validation();

$date_time = date("Y-m-d H:i:s");
$act = $_POST['act'];
if($act == 'Approve') {
	$sroll  = $val->ValidateString($_POST['sroll']);
	$qup = "update isr_ra_request_tbl set ra_status = 'A', app_date = '$date_time' where roll = '$sroll'";
	$ObjDB->sproc_name = $qup;
        $ObjDB->ExecuteQuery();
	header('Location: control-csir-ra-request.php');
}

$qqsel = "select a.*, b.name from isr_ra_request_tbl a, isr_stu_main_tbl b where a.b1_sem > 34 and a.roll = b.roll order by a.roll";
$ObjDB->sproc_name = $qqsel;
$res_qqsel = $ObjDB->SelectQuery();

$found = mysqli_num_rows($res_qqsel);
$view_table .= "<table class='table table-bordered align-middle'>";
$view_table .= "<thead><tr>
<th>&nbsp;
<th><B>Roll</B>
<th><B>Name</B>
<th><B>Req.Date</B>
<th><B>Status</B>
<th><B>Action</B>
</tr></thead>";
$i = 1;
if ($found > 0) {
    while ($row = mysqli_fetch_array($res_qqsel)) {
        $roll = $row['roll'];
        $name = $row['name'];
        $ra_status = $row['ra_status'];
        $req_date = substr($row['req_date'], 0, 10);

        if ($ra_status == 'R') {
            $status_show = "<FONT COLOR=red>Requested</FONT>";
        } else {
            $status_show = "Approved";
        }
        $view_table .= "<tr>";
        $view_table .= "<td>" . $i;
        $view_table .= "<td>" . $roll;
        $view_table .= "<td>" . $name;
        $view_table .= "<td>" . $req_date;
        $view_table .= "<td>" . $status_show;
        $view_table .= "<td>";
        if ($ra_status == 'R') {
            $view_table .= '<FORM METHOD="POST" ACTION="">
                <INPUT TYPE="hidden" NAME="sroll" value="'.$roll.'">
                <INPUT TYPE="submit" name="act" value="Approve" class="btn btn-primary">
            </FORM>';
        }
        $view_table .= '</td>';

        $i++;
        $view_table .= "</tr>";
    }
} else {
    $view_table .= "<tr><td colspan='6'>No Records Found!</td></tr>";
}
$view_table .= "</table>";
?>
<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">CSIR Result Awaited Certificate</h5>
                </div>
                <div class="text-success"><?php echo $success_msg; ?></div>
                <div class="card-body">

                    <div class="row">
                        <div class="col-lg-12">
                            <div class="table-responsive">
                                <?php echo $view_table; ?>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<?php
$pagemaincontent = ob_get_contents();
ob_clean();
$PAGENAME = 'control-bulk-change';
$HTMLTITLE = '';
$HTMLDESCRIPTION = '';
$HTMLKEYWORDS = '';
include("admin-master.php");
?>