<?php session_start();
include("conn.php");
if($_POST['action'])
{
  $action=$_POST['action'];
  //Add Data Start
 if($action=="Delete")
  {
    $id=$_POST['id'];

    $sql="update tbl_vendor set deleted_at=CURRENT_TIMESTAMP() where id='$id'";
    if(mysqli_query($conn,$sql))
    {
      echo "Record deleted successfully.";
    }
    else
    {
      echo "Record not deleted. Error:".mysqli_error($conn);
    }
  }
  //Delete Data End
}
else
{
  echo "Invalid action specified.";
}



if($action=="Activate")
{

 $id = mysqli_real_escape_string($conn, $_POST['id']);

  $sql="update tbl_vendor set status='Active' where id='$id'";
  if(mysqli_query($conn,$sql))
  {
    echo "User activated.";
  }
  else
  {
    echo "Vendor Not Activated. Error:".mysqli_error($conn);
  }
}
//Add Data End  
//Update Data Start
else if($action=="Deactivate")
{
 $id = mysqli_real_escape_string($conn, $_POST['id']);

  $sql="update tbl_vendor set status='Deactive' where id='$id'";
  if(mysqli_query($conn,$sql))
  {
    echo "Vendor deactivated.";
  }
  else
  {
    echo "Vendor Not Deactivated. Error:".mysqli_error($conn);
  }
}else{ 
  mysqli_close($conn);
}
