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

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

$i = 0;
$stu_roll = $val->ValidateString($_REQUEST["stu_roll"]);
if (!empty($stu_roll)) {
    $objadm->roll_number = $stu_roll;
    $query = $objadm->GetStudentDetailsbyRollNumber();
    $num = mysqli_num_rows($query);
    if ($num > 0) {
        $row = mysqli_fetch_array($query);
        $stu_name = $row['name'];
        $batch = $row['batch'];
    } else {
        $query2 = "SELECT student_name FROM isr_gsam_student_tbl where student_roll = '$stu_roll'";
        $ObjDB->sproc_name = $query2;
        $res_query2 = $ObjDB->SelectQuery();
        list($stu_name) = mysqli_fetch_row($res_query2);
        $batch = 'PhD';
    }
}
?>
<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">Office Notes on Students</h5>
                </div>
                <div class="card-body">
                    <div class="table-responsive">
                        <table class="table table-bordered align-middle">
                            <thead>
                                <tr><th><?php echo $stu_roll; ?></th><th><?php echo $stu_name; ?></th><th><?php echo $batch; ?></th></tr> 
                            </thead>
                        </table><br/><br/>

                        <FORM METHOD="POST" ACTION="reports-stu-notes-save2.php">
                            <table class="table table-bordered align-middle">
                                <tr><td>

                                        <TEXTAREA NAME="reco2" ROWS="5" COLS="60" class="form-control"></TEXTAREA>
</td></tr>
<tr><td>
<INPUT TYPE="hidden" name="stu_roll" value="<?php echo $stu_roll; ?>">
<INPUT TYPE="submit" NAME="notes_btn" id="notes_btn" value="Submit" class="btn btn-primary"/>
</td></tr>

</table>
    </FORM>
                        
                        <?php
                        $query = "SELECT * FROM isr_stu_notes_tbl where stu_roll = '$stu_roll' order by note_date desc";
                        $ObjDB->sproc_name = $query;
                        $res_query = $ObjDB->SelectQuery();

                        $num_notes = mysqli_num_rows($res_query);
                        if ($num_notes > 0) {
                            ?>
        <BR>
        	<table class="table table-bordered align-middle">
                    <thead>
                        <tr>
                            <th colspan="4">
                                <h3>Previous Notes</h3>
                            </th>
                        </tr>
                    </thead>
                    <tbody>
        	<tr><th width="5%">&nbsp;</th><th width="15%">Date</th><th width="15%">Author</th><th width="65%">Note</th></tr>
                                    <?php
                                    $i = 0;
                                    while ($row = mysqli_fetch_array($res_query)) {
                                        $i++;
                                        $ds = strtotime($row['note_date']);
                                        $date_show = date("d M Y", $ds);
                                        ?>
                		<tr>
                		<td><?php echo $i; ?></td>
                		<td><?php echo $date_show; ?></td>
                		<td><?php echo $row['admin_roll']; ?></td>
                		<td><?php echo $row['note_text']; ?></td>
                		</tr>
                                        <?php
                                    }
                                    ?>
                    </tbody>
                </table>
                            <?php
                        }
                        ?>
                        
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<?php
$pagemaincontent = ob_get_contents();
ob_clean();
$PAGENAME = 'reports-stu-notes';
$HTMLTITLE = '';
$HTMLDESCRIPTION = '';
$HTMLKEYWORDS = '';
include("admin-master.php");
?>