<?php
$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);

  $student_id=$request->getAttribute ('student_id');
   // $student_id=$request->getParsedBody()['student_id'];
  $status = $request->getParsedBody()['status'];
  $course_id=$request->getParsedBody()['course'];
  $season_id = $request->getParsedBody()['session_id'];
  $dept_id = $request->getParsedBody()['department'];
  $level_id = $request->getParsedBody()['level_id'];
  $year=$request->getParsedBody()['year'];
  $term = $request->getParsedBody()['term'];
  $section = $request->getParsedBody()['section'];
  $rollnumber=$request->getParsedBody()['roll_number'];
  $student_name = $request->getParsedBody()['student_name'];
  $detained = $request->getParsedBody()['detained'];
  $buffered=$request->getParsedBody()['buffered'];
  $papers_undertaking=$request->getParsedBody()['papers_undertaking'];
  $suply_papers=$request->getParsedBody()['suply_papers'];
  $institutename=$request->getParsedBody()['insitute_name'];
  $institute_code=$request->getParsedBody()['institute_no'];
  $password=$request->getParsedBody()['password'];
 
 $response=array();
// $data=array();
 
if ($status==""){
	$status="0";
}
	
	 $query2="SELECT * FROM  student WHERE insitute_name='$institutename' OR institute_no='$institute_code' 
	 OR student_name='$student_name' OR roll_number='rollnumber' OR password='$password' OR student_id='$student_id' OR
	 course='$course_id' OR department='$dept_id'";
 $result2=mysqli_query($con,$query2);
  while($row = mysqli_fetch_assoc($result2)){
	  $checkstudentid=$row['student_id'];
   $checkinstituename=$row['insitute_name'];
   $checkinstituteno=$row['institute_no'];
   $checkstudentname=$row['student_name'];
   $checkrollnumber=$row['roll_number'];
   $checkdept=$row['department'];
   $checkcourse=$row['course'];
   $checkpassword=$row['password'];
   
  }
  
 

  if ($checkinstituteno!=$institute_code AND $checkpassword!=$password AND $checkrollnumber!=$rollnumber 
  AND $checkinstituename!=$institutename AND $checkstudentname!=$student_name AND $checkstudentid!=$student_id
  AND $checkdept!=$dept_id AND $checkcourse!=$course_id ) {
   $response=array('status' => "false",'Message' => "Student Name/student_id/rollnumber/institutecode/institutename/department/course/password Not Matching");
     echo json_encode($response); 
 }
 
 
elseif ($checkinstituename!=$institutename) {
   $response=array('status' => "false",'Message' => "Institutename Not Matching");
     echo json_encode($response); 
 }
 
  elseif ($checkinstituteno!=$institute_code) {
   $response=array('status' => "false",'Message' => "Institutecode Not Matching");
     echo json_encode($response); 
 }
 
 
elseif($checkstudentname!=$student_name) {
   $response=array('status' => "false",'Message' => "StudentName Not Matching");
     echo json_encode($response); 
 }
 
elseif ($checkrollnumber!=$rollnumber) {
   $response=array('status' => "false",'Message' => "StudentRollnumber Not Matching");
     echo json_encode($response); 
 }
 
elseif ($checkdept!=$dept_id) {
   $response=array('status' => "false",'Message' => "department Not Matching");
     echo json_encode($response); 
 }
 
elseif ($checkcourse!=$course_id) {
   $response=array('status' => "false",'Message' => "course Not Matching");
     echo json_encode($response); 
 }
 
  
elseif ($checkpassword!=$password) {
   $response=array('status' => "false",'Message' => "Password Not Matching");
     echo json_encode($response); 
 }

  
 else{
 	$sql= ("UPDATE student SET status='0' WHERE roll_number='$rollnumber'");
     if($con->query($sql)){
	  $data=array(
       "status" => $status,
	             );
	     $message=$data;
              
  
$response=array('status' => "true",'Message' => "Student Archived Succesfully",'Archive Students' => $message);
echo json_encode($response);
        }
        
        else{
          $response=array('status' => "false",'Message' => "Archived Failed");
         echo json_encode($response);
        }
    
 }

 ?>