<?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();

$admin_roll = $_SESSION['user_sesroll'];
$datetime = DATE('Y-m-d H:i:s');

$stu_roll = $val->ValidateString($_REQUEST["stu_roll"]);
$reeg_file = $val->ValidateString($_REQUEST["reeg_file"]);
$reeg_sr_del = $val->ValidateString($_REQUEST["reeg_sr_del"]);
$reeg_sr_recall = $val->ValidateString($_REQUEST["reeg_sr_recall"]);
$REGMSG = "";

if($reeg_sr_del) {
	$SELECT="SELECT * FROM $reeg_file WHERE reg_sr = '$reeg_sr_del'";
        $ObjDB->sproc_name = $SELECT;
        $res_SELECT = $ObjDB->SelectQuery();
	$row = mysqli_fetch_array($res_SELECT);
        
	$sub_code = $row["sub_code"];
        
        $query_del="delete from $reeg_file where reg_sr = '$reeg_sr_del' and stu_roll = '$stu_roll'";
        $ObjDB->sproc_name = $query_del;
        $ObjDB->ExecuteQuery();
    
    
        $REGMSG = "Subject Deleted Successfully";
 	$activity = "Subject ".$sub_code." deleted for ".$stu_roll;
        
	$query1="INSERT INTO isr_actions_tbl (roll, activity, datetime) VALUES('".$admin_roll."','".$activity."','".$datetime."')";
        $ObjDB->sproc_name = $query1;
        $ObjDB->ExecuteQuery();
}
?>
<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">Course Subject Delete</h5>
                </div>
                <div class="card-body">
                    <div class="row">
                        <div class="col-lg-12">
                            <span style="color: green;"><?php echo $REGMSG; ?></span>
                        </div>
                        <form action="control-course-add-drop.php" method="POST" style="display: none;" id="form_subject_delete">
                            <input type="hidden" name="roll_no" id="roll_no" value="<?php echo $stu_roll; ?>"/>
                             <input type="hidden" value="Submit" name="course_add_drop_btn"/>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<?php
$pagemaincontent = ob_get_contents();
ob_clean();
$PAGENAME = 'control-new-block-save';
$HTMLTITLE = '';
$HTMLDESCRIPTION = '';
$HTMLKEYWORDS = '';
include("admin-master.php");
?>
<script type="text/javascript">
  // Auto submit form after 3 seconds (3000 milliseconds)
  setTimeout(function() {
    document.getElementById("form_subject_delete").submit();
  }, 3000);
</script>