<?php

include "../../src/config.php";

// Check for valid parameters
if (!isset($_GET["id"])) {
    endrequest("Invalid Request");
}

// Check Calendar item exists
$calendaritem = calendar::get($_GET["id"]);
if (!$calendaritem) {
    endrequest("Invalid ID");
}

// Check pesrmission
if ($calendaritem["created_by"] != auth::user_id()) {
    endrequest("Permission Error");
}

$delete = calendar::query("delete from mis_calendar where id = :id", ["id" => $_GET["id"]]);

echo json_encode($delete);
