<?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';

$ObjDB = new class_db();
$log = new common();
$objadm = new class_admin();
$val = new validation();

if ($_POST) {

    $stu_roll = $val->ValidateString($_REQUEST["roll_no"]);
    $subject_code = $val->ValidateString($_REQUEST["subject_code"]);
    $old_grade = $val->ValidateString($_REQUEST["old_grade"]);

    $objadm->roll_number = $stu_roll;
    $RollNumberArr = $objadm->GetStudentDetailsbyRollNumber();

    $num = mysqli_num_rows($RollNumberArr);
    if ($num == 0) {
        $error_msg = "Incorrect Roll Number";
    } else {
        $row = mysqli_fetch_array($RollNumberArr);
        $stu_name = $row["name"];
        $fee_OK = $row["fee_OK"];
        $cgpa_OK = $row["cgpa_OK"];
        $attn_OK = $row["attn_OK"];

        if ($fee_OK == 'Y') {
            $fee_blocked = '';
            $fee_open = 'checked';
        }
        if ($fee_OK == 'N') {
            $fee_blocked = 'checked';
            $fee_open = '';
        }

        if ($cgpa_OK == 'Y') {
            $cgpa_blocked = '';
            $cgpa_open = 'checked';
        }
        if ($cgpa_OK == 'N') {
            $cgpa_blocked = 'checked';
            $cgpa_open = '';
        }

        if ($attn_OK == 'Y') {
            $attn_blocked = '';
            $attn_open = 'checked';
        }
        if ($attn_OK == 'N') {
            $attn_blocked = 'checked';
            $attn_open = '';
        }
    }
}
?>
<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">Block</h5>
                </div>
                <div class="card-body">
                    <form action="" method="POST">
                        <div class="row"><div class="col-lg-12"><?php echo $error_msg; ?></div></div>
                        <div class="row">
                            <div class="col-lg-3">
                                <label>Roll Number:</label>
                                <input type="text" name="roll_no" id="roll_no" class="form-control"/>
                            </div>
                            <div class="col-lg-3">
                                <input type="submit" name="old_block_btn" id="old_block_btn" value="SUBMIT" class="btn btn-primary"/>
                            </div>
                        </div>
                    </form>
                    <?php
                    if ($_POST) {

                        if ($num > 0) {
                            ?>

                            <div class="table-responsive">
                                <FORM METHOD="POST" ACTION="control-new-block-save.php">
                                    <INPUT TYPE="hidden" NAME="stu_roll" value="<?php echo $stu_roll ?>">
                                    <TABLE class="table table-bordered align-middle">
                                        <TR><TD><label style="width:100px">
                                                    Student Roll</label></TD>
                                            <TD><label style="width:200px; font-weight: bold">
        <?php echo $stu_roll; ?></label></TD></TR>
                                        <TR><TD><label style="width:100px">Student Name:</label></TD>
                                            <TD><label style="width:200px; font-weight: bold">
        <?php echo $stu_name; ?></label></TD></TR>


                                        <TR><TD><label style="width:100px">Fee Status:</label></TD>
                                            <TD>
                                                <table>
                                                    <tr class="ctrl">
                                                        <td><INPUT TYPE="radio" NAME="fee_OK" value="N" <?php echo $fee_blocked; ?> /></td>
                                                        <td>Block</td>
                                                        <td><INPUT TYPE="radio" NAME="fee_OK" value="Y" <?php echo $fee_open; ?> /></td>
                                                        <td>Unblock</td>
                                                    </tr>
                                                </table>                 

                                            </TD></TR>

                                        <TR><TD><label style="width:100px">CGPA Status:</label></TD><TD>
                                                <table>
                                                    <tr class="ctrl">
                                                        <td><INPUT TYPE="radio" NAME="cgpa_OK" value="N" <?php echo $cgpa_blocked; ?>></td>
                                                        <td>Block</td>
                                                        <td><INPUT TYPE="radio" NAME="cgpa_OK" value="Y" <?php echo $cgpa_open; ?>></td>
                                                        <td>Unblock</td>
                                                    </tr>
                                                </table>

                                        <TR><TD><label style="width:100px">Attendance Status:</label></TD><TD>
                                                <table>
                                                    <tr class="ctrl">
                                                        <td><INPUT TYPE="radio" NAME="attn_OK" value="N" <?php echo $attn_blocked; ?>></td>
                                                        <td>Block</td>
                                                        <td><INPUT TYPE="radio" NAME="attn_OK" value="Y" <?php echo $attn_open; ?>></td>
                                                        <td>Unblock</td>
                                                    </tr>
                                                </table>

                                            </TD></TR>
                                        <TR>
                                            <TD align=center colspan=2><INPUT TYPE="submit" class="submit" NAME="Submit" value="Submit"></TD>
                                        </TR>
                                    </TABLE>
                                </FORM>
                            </div>
                        <?php
                        }
                    }
                    ?>

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