<?php 

include('../classes/database.class.php');


$db = new database();

if (isset($_POST['action'])) {
	# code...
	$action = $_POST['action'];


	if ($action == 'removeAlert') {
		# code...
		$uid = $_POST['id'];


		$get = $db->db->prepare("SELECT * FROM notification WHERE user = '$uid'");
		$get->execute();
		$getalerts = $get->fetch();

		$alertArray = array();

		if (empty($getalerts)) {
			# code...
			$alertArray = array('result'=>'failed');

		}else{

			$alertArray = array('result'=>'succes', 'notification'=>json_encode($getalerts));
		}

		print_r(json_encode($alertArray));


	}elseif ($action == 'deleteAlert') {
		# code...
		$id = $_POST['id'];

		$deleteAlert = $db->db->prepare("DELETE FROM notification WHERE id = '$id'");
		$deleteAlert->execute();

	}
}

?>