<?php if (!defined('RESTRICTED')) { include ('./../../templates/error/404.php'); } else { ?>

<?php ob_start(); ?>

<?php

if (isset($_GET['id'])) {
	$ID = clean($_GET['id']);
} else {
	$ID = clean("");
}

if (validateResourceAccess($inputToken)) {

	// get image file from table
	$sql = "SELECT image FROM tbl_fcm_template WHERE id = '$ID'";
	$result = $connect->query($sql);
	$row = $result->fetch_assoc();

	$image = $row['image'];

	// delete data from menu table
	$sql_delete = "DELETE FROM tbl_fcm_template WHERE id = '$ID'";
	$delete = $connect->query($sql_delete);

	// if delete data success
	if ($delete) {
		$filePath = 'upload/notification/'.$image;
		if (file_exists($filePath)) {
			unlink($filePath);
		}

		$_SESSION['msg'] = "Notification deleted successfully...";
		header( "Location: notification.php");
		exit;
	}

} else {
	systemUpdateFlag($invalidResponse);
}

?>

<?php } ?>