<?php
include("../../../include/startup.php"); 

if(isset($_REQUEST['action']) && $_REQUEST['action']=='delete_event_itinerary'){
	$id = $_REQUEST['event_itinerary_mapping_id'];
	mysqli_query($conn,"DELETE FROM ess_event_itinerary_mapping WHERE id = '$id' ");
	$returnArray["status"] = "success";
	echo json_encode($returnArray);
}else if(isset($_REQUEST['action']) && $_REQUEST['action']=='delete_email'){
	$id = $_REQUEST['email_mapping_id'];
	mysqli_query($conn,"DELETE FROM ess_email_mapping WHERE id = '$id' ");
	$returnArray["status"] = "success";
	echo json_encode($returnArray);
}else if(isset($_REQUEST['action']) && $_REQUEST['action']=='get_template_by_id'){
	$dataArray = array();
	$dataArray["status"] = 0;
	$template_id = $_REQUEST['template_id'];
	$sql = "SELECT * FROM ess_image_template WHERE id = '$template_id' ";
	$rs = mysqli_query($conn,$sql);
	if(mysqli_num_rows($rs) > 0){
		$row = mysqli_fetch_assoc($rs);
		$row=utility::validate_crypt_data($row);
		
		$dataArray["ess_image_1"] 	= $row['ess_image_1'];
		$dataArray["ess_image_2"] 	= $row['ess_image_2'];
		$dataArray["ess_image_3"] 	= $row['ess_image_3'];
		$dataArray["ess_image_4"] 	= $row['ess_image_4'];
		
		$dataArray["status"]		= 1;
	}
	echo json_encode($dataArray);

}else if(isset($_REQUEST['action']) && $_REQUEST['action']=='delete_ess_template_image_1'){
	$id = $_REQUEST['id'];
	mysqli_query($conn,"UPDATE ess_image_template SET ess_image_1 = '' WHERE id = '$id' ");
	$returnArray["status"] = "success";
	echo json_encode($returnArray);
}else if(isset($_REQUEST['action']) && $_REQUEST['action']=='delete_ess_template_image_2'){
	$id = $_REQUEST['id'];
	mysqli_query($conn,"UPDATE ess_image_template SET ess_image_2 = '' WHERE id = '$id' ");
	$returnArray["status"] = "success";
	echo json_encode($returnArray);
}else if(isset($_REQUEST['action']) && $_REQUEST['action']=='delete_ess_template_image_3'){
	$id = $_REQUEST['id'];
	mysqli_query($conn,"UPDATE ess_image_template SET ess_image_3 = '' WHERE id = '$id' ");
	$returnArray["status"] = "success";
	echo json_encode($returnArray);
}else if(isset($_REQUEST['action']) && $_REQUEST['action']=='delete_ess_template_image_4'){
	$id = $_REQUEST['id'];
	mysqli_query($conn,"UPDATE ess_image_template SET ess_image_4 = '' WHERE id = '$id' ");
	$returnArray["status"] = "success";
	echo json_encode($returnArray);
}

else if(isset($_REQUEST['action']) && $_REQUEST['action']=='delete_ess_image_1'){
	$id = $_REQUEST['id'];
	mysqli_query($conn,"UPDATE ess SET ess_image_1 = '' WHERE id = '$id' ");
	$returnArray["status"] = "success";
	echo json_encode($returnArray);
}else if(isset($_REQUEST['action']) && $_REQUEST['action']=='delete_ess_image_2'){
	$id = $_REQUEST['id'];
	mysqli_query($conn,"UPDATE ess SET ess_image_2 = '' WHERE id = '$id' ");
	$returnArray["status"] = "success";
	echo json_encode($returnArray);
}else if(isset($_REQUEST['action']) && $_REQUEST['action']=='delete_ess_image_3'){
	$id = $_REQUEST['id'];
	mysqli_query($conn,"UPDATE ess SET ess_image_3 = '' WHERE id = '$id' ");
	$returnArray["status"] = "success";
	echo json_encode($returnArray);
}else if(isset($_REQUEST['action']) && $_REQUEST['action']=='delete_ess_image_4'){
	$id = $_REQUEST['id'];
	mysqli_query($conn,"UPDATE ess SET ess_image_4 = '' WHERE id = '$id' ");
	$returnArray["status"] = "success";
	echo json_encode($returnArray);
}
?>