<?php

include('../db_con.php');

@$id = mysqli_real_escape_string($con, $_POST['id']);
$vstatus_name = mysqli_real_escape_string($con, $_POST['deli_name']);
$vstatus_kword = mysqli_real_escape_string($con, $_POST['deli_kword']);
$status = mysqli_real_escape_string($con, $_POST['status']);



if(($_REQUEST['actionid']=='insert')){

	//$sql = "INSERT INTO `app_status_table`(`vstatus_name`,`status`) VALUES ('$vstatus_name','$status')";
	$sql = "INSERT INTO `deli_location_table`(`deliloc_name`, `deliloc_kword`, `status`) VALUES ('$vstatus_name', '$vstatus_kword', '$status')";

	$result = mysqli_query($con,$sql);

	header("Location:delivery_location.php");

}


if(($_REQUEST['actionid']=='update')){

	//$sql = "UPDATE `app_status_table` SET `vstatus_name`='$vstatus_name',`status`='$status' WHERE `vstatus_id`=$id";

	$sql = "UPDATE `deli_location_table` SET `deliloc_name`='$vstatus_name', `deliloc_kword`='$vstatus_kword', `status`='$status' WHERE `deliloc_id`=$id";

	$result = mysqli_query($con,$sql);

	header("Location:delivery_location.php");
}


if($_REQUEST['actionid']=='remove'){

		$id = intval($_REQUEST['id']);		
				
		$sql = "DELETE FROM `deli_location_table` WHERE `deliloc_id`=$id";

		// var_dump($sql) or die();
		$result = @mysqli_query($con,$sql);
		if ($result){
			
			header("Location:delivery_location.php");
			//echo json_encode(array('success'=>true));
		} else {
			echo json_encode(array('msg'=>'Some errors occured.'));
		}
	}

?>