<?php
session_start();
require_once '../../Server/connection.php';

    $staff_id  = $_POST['staff_id'];
	$warnDate  = $_POST['warnDate'];
	$remarks  = addslashes($_POST['remarks']);
	$upl_status = $_POST['upl_status'];
	
	$warn_Date = date('Y-m-d', strtotime($warnDate));
	
	
	
	if($upl_status=='Yes'){
  foreach ($_FILES["file"]["name"] as $key => $name){
		$newFilename = time() . "_" . $name;
		move_uploaded_file($_FILES["file"]["tmp_name"][$key],'../../files/'.$newFilename);
		$location = '../../files/' . $newFilename;
		
		$fSql12 = "INSERT INTO staffdocs (staff_id,fileName) 
				VALUES ('$staff_id','$location')";

		$resFSql12 = $conn->query($fSql12);
	          }
			
              }else{
				  
		$resFSql12 = 'Yes';
				  
			  }
			  
	 $fSql122 = "INSERT INTO staff_warnings (staff_id,warning_date,remarks) 
				VALUES ('$staff_id','$warn_Date','$remarks')";

	 $resFSql122 = $conn->query($fSql122);


	 if($resFSql12&&$resFSql122){
		 
		$_SESSION['success_message'] = "Staff Has Been Warned Successfully";
  header("Location: ../warnStaff..php");
  exit();
		 
	 }
	 

?>