<?php 
session_start();
require_once '../../Server/connection.php';
if($_POST){	


  $leaveRequest_id  = $_POST['leaveRequest_id'];
  $leave_requestCode  = $_POST['leave_requestCode'];
  $leaveType_id  = $_POST['leaveType_id'];
  $remarks  = addslashes($_POST['leave_remarks']);
  
  
  if($leaveType_id==1){
  $days_requested = $_POST['days_requested_annual'];  
  }else if($leaveType_id==2){
  $days_requested = $_POST['days_requested_maternity'];  
  }else if($leaveType_id==3){
  $days_requested = $_POST['days_requested_paternity'];  
  }else{
  $days_requested = $_POST['days_requested'];  
  }
  
  $sql = "UPDATE leave_requests SET leaveType_id = '$leaveType_id' WHERE leave_requestId = {$leaveRequest_id}";		

  $result = $conn->query($sql);
  
  $sql2 = "UPDATE leavestatus SET staff_remarks = '$remarks',leave_days_requested = '$days_requested' WHERE leave_requestCode = {$leave_requestCode}";		

  $result2 = $conn->query($sql2);
  
  if($result&&$result2){
  
  $_SESSION['success_message'] = "You have successfully Edited Leave Requests";
  header("Location: ../editLeaveRequest.php?i=$leaveRequest_id");
  exit();
  
      }
  
  
} 