<?php
	include_once '../../includes/connectConfig.php';

	if($_POST)
	{
		
		$del_id = test_input($_POST['del_id']);
		$del_ete = test_input($_POST['del_ete']);
		$table = test_input($_POST['del_ete']);
		
		if($table == "swluo")
		{
			$query = "UPDATE tks_users SET delete_status = 1 WHERE tus_id = :del_id";
			$prd = $db_con->prepare($query);
			$prd->bindParam(':del_id',$del_id);
			$prd->execute();
			$chk = getOne('tks_users', " tus_id = '$del_id' ",'delete_status');
			if($chk == 1)
			{
				$rmk = 'deleted user';
				pages($del_id,$rmk);
				
				$output["errorreason"] = 'yea';
				$output["dataid"] = $del_id;
				echo json_encode($output);
				exit;
			}
			else
			{
				$output["errorreason"] = 'nah';
				echo json_encode($output);
				exit;
			}
		}
		elseif($table == "nhaqpk")
		{
			$query = "UPDATE ktmmenu_name SET delete_status = 1 WHERE mn_id = :del_id";
			$prd = $db_con->prepare($query); $prd->bindParam(':del_id',$del_id); $prd->execute();
			$chk = getOne('ktmmenu_name', " mn_id = '$del_id' ",'delete_status');
			if($chk == 1){
				$rmk = 'deleted menu name';
				pages($del_id,$rmk);
				
				$output["errorreason"] = 'yea';
				$output["dataid"] = $del_id;
				echo json_encode($output);
				exit;
			}
			else
			{
				$output["errorreason"] = 'nah';
				echo json_encode($output);
				exit;
			}
		}
		elseif($table == "pqcrl")
		{
			$query = "UPDATE ktmmenu_category SET delete_status = 1 WHERE mc_id = :del_id";
			$prd = $db_con->prepare($query); $prd->bindParam(':del_id',$del_id); $prd->execute();
			$chk = getOne('ktmmenu_category', " mc_id = '$del_id' ",'delete_status');
			if($chk == 1){
				$rmk = 'deleted menu category';
				pages($del_id,$rmk);
				
				$output["errorreason"] = 'yea';
				$output["dataid"] = $del_id;
				echo json_encode($output);
				exit;
			}
			else
			{
				$output["errorreason"] = 'nah';
				echo json_encode($output);
				exit;
			}
		}
		elseif($table == "sdclai")
		{
			$query = "UPDATE ktmmenu_subcategory SET delete_status = 1 WHERE ms_id = :del_id";
			$prd = $db_con->prepare($query); $prd->bindParam(':del_id',$del_id); $prd->execute();
			$chk = getOne('ktmmenu_subcategory', " ms_id = '$del_id' ",'delete_status');
			if($chk == 1){
				$rmk = 'deleted sub category';
				pages($del_id,$rmk);
				
				$output["errorreason"] = 'yea';
				$output["dataid"] = $del_id;
				echo json_encode($output);
				exit;
			}
			else
			{
				$output["errorreason"] = 'nah';
				echo json_encode($output);
				exit;
			}
		}
		elseif($table == "tdaplx")
		{
			$query = "UPDATE kmartstockprds SET delete_status = 1 WHERE ksp_id = :del_id";
			$prd = $db_con->prepare($query); $prd->bindParam(':del_id',$del_id); $prd->execute();
			$chk = getOne('kmartstockprds', " ksp_id = '$del_id' ",'delete_status');
			if($chk == 1){
				$rmk = 'deleted product';
				pages($del_id,$rmk);
				
				$output["errorreason"] = 'yea';
				$output["dataid"] = $del_id;
				echo json_encode($output);
				exit;
			}
			else
			{
				$output["errorreason"] = 'nah';
				echo json_encode($output);
				exit;
			}
		}
		elseif($table == "pdmytw")
		{
			$query = "UPDATE kprdadditional SET delete_status = 1 WHERE ka_id = :del_id";
			$prd = $db_con->prepare($query);
			$prd->bindParam(':del_id',$del_id);
			$prd->execute();
			$chk = getOne('kprdadditional', " ka_id = '$del_id' ",'delete_status');
			if($chk == 1){
				$rmk = 'deleted product attribute';
				pages($del_id,$rmk);
				
				$output["errorreason"] = 'yea';
				$output["dataid"] = $del_id;
				echo json_encode($output);
				exit;
			}
			else
			{
				$output["errorreason"] = 'nah';
				echo json_encode($output);
				exit;
			}
		}
		elseif($table == "opqdejt")
		{
			$query = "UPDATE kprdw_imgs SET delete_status = 1 WHERE kmg_id = :del_id";
			$prd = $db_con->prepare($query);
			$prd->bindParam(':del_id',$del_id);
			$prd->execute();
			$chk = getOne('kprdw_imgs', " kmg_id = '$del_id' ",'delete_status');
			if($chk == 1){
				$rmk = 'deleted product image';
				pages($del_id,$rmk);
				
				$output["errorreason"] = 'yea';
				$output["dataid"] = $del_id;
				echo json_encode($output);
				exit;
			}
			else
			{
				$output["errorreason"] = 'nah';
				echo json_encode($output);
				exit;
			}
		}
		elseif($table == "vctytl")
		{
			$query = "UPDATE  newspost  SET delete_status = 1 WHERE nw_id = :del_id";
			$prd = $db_con->prepare($query);
			$prd->bindParam(':del_id',$del_id);
			$prd->execute();
			$chk = getOne('newspost', " nw_id = '$del_id' ",'delete_status');
			if($chk == 1){
				$rmk = 'deleted news post';
				pages($del_id,$rmk);
				
				$output["errorreason"] = 'yea';
				$output["dataid"] = $del_id;
				echo json_encode($output);
				exit;
			}
			else
			{
				$output["errorreason"] = 'nah';
				echo json_encode($output);
				exit;
			}
		}
		else
		{
			$query = "UPDATE ".$table." SET delete_status = 1 WHERE id = :del_id";
			$prd = $db_con->prepare($query);
			$prd->bindParam(':del_id',$del_id);
			$prd->execute();
			
			
		
			$chk = getOne($table, " id = '$del_id' ",'delete_status');
			if($chk == 1)
			{
				$rmk = 'deleted '.$table;
				pages($log_session,$rmk);
				
				$output["errorreason"] = 'yea';
				$output["dataid"] = $del_id;
				echo json_encode($output);
				exit;
			}
			else
			{
				$output["errorreason"] = 'nah';
				echo json_encode($output);
				exit;
			}					
		}
	}
?>

