<?php 
ob_start();
include "../../db.php";
date_default_timezone_set('Asia/Kolkata');
$currentCoreDate = date("Y-m-d");
$currentDT = date('M j, Y g:i a');
session_start();


if (isset($_POST['action']) && $_POST['action'] == 'insertRemark') {
    
    $newRemark=$_POST["newRemark"];
    $sid=$_POST["sid"];
  
    $sql = "INSERT INTO remark (r_sid, remark, uploadDate, uploadCoreDate, r_by) VALUES ('$sid', '$newRemark','$currentDT', '$currentCoreDate', '$_SESSION[uid]')";

    $up_sql = "UPDATE student_details SET st_lastRemarkDate = '$currentCoreDate' WHERE st_no = '$sid'"; 
    if(mysqli_query($con, $sql)){
        mysqli_query($con, $up_sql);
        $output = "successful";
    }else{
        $output = "";
    }
    echo $output ;  
}



if (isset($_POST['action']) && $_POST['action'] == 'insertAdminRemark') {
    
    $newRemark=$_POST["newRemark"];
    $sid=$_POST["sid"];
  
    $sql = "INSERT INTO admin_remark (r_sid, remark, uploadDate, uploadCoreDate, r_by) VALUES ('$sid', '$newRemark','$currentDT', '$currentCoreDate', '$_SESSION[uid]')";
 
    if(mysqli_query($con, $sql)){
        $output = "successful";
    }else{
        $output = "";
    }
    echo $output ;   
}
?>