<?php
session_start();
    if(!$_SESSION['id']){
        header('location:index.php');
    }
require_once '../system/conn.php';
$id=$_GET['id'];
$date=date('Y-m-d');
$branch=$_GET['branch'];
$ldate=$_GET['ldate'];
$uid=$_GET['uid'];
$sn_id=$_GET['sn_id'];


$query = "INSERT INTO rejoin_employee (`emp_id`, `d_o_join`, `left_date`, `branch`) VALUES ('$id','$date','$ldate','$branch')";
$statement = $conn->prepare($query)->execute($data);
if($statement){
  $query1 = " UPDATE `emp_details` SET `status`='1' WHERE e_id= '".$id."' and sn='".$uid."' ";
  $statement1 = $conn->prepare($query1)->execute($data); 
  
  if($statement1){
     $query2=$conn->query(" UPDATE `left_employee` SET `status`='0' WHERE `emp_id`='".$uid."' and id='".$sn_id."'");
     $statement2 = $conn->prepare($query2)->execute($data); ?>
     
    <script>window.location.assign('all-employees.php')</script>
<?php  }
  
}else{
    echo "not inserted";
  }
?>