<?php
  session_start();
  if(empty($_SESSION['branch']) || $_SESSION['branch'] == ''){
    header("Location: index.php");
    die();
  }
    require_once 'system/conn.php';
$id=$_GET['id'];
$date=date('Y-m-d');
$branch=$_SESSION['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')";
//print_r($query);exit;
$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){
     $delete=$conn->query("UPDATE `left_employee` SET `status`='0' WHERE `emp_id`='".$uid."' and id='".$sn_id."'");
     
     echo " <script>window.location.assign('all-employees.php')</script>";
  }
  
}else{
    echo "not inserted";
  }
?>