<?php require_once '../lib/TimeGrid.php'; $timegrid = new TimeGrid(); /* @TODO Implement controller as a class with *Action() methods and do the rouing at index.php to prevent exit() calls and provide more clarity. */ // delete object if (isset($_POST['action']) && $_POST['action'] == 'object_delete') { if (isset($_POST['object_id']) && is_numeric($_POST['object_id'])) { $object_id = intval($_POST['object_id']); if ($timegrid->deleteObject($object_id)) { echo json_encode(true); exit; } echo json_encode(false); exit; } else { echo json_encode(false); exit; } } // delete reservation if (isset($_POST['action']) && $_POST['action'] == 'reservation_delete') { if (isset($_POST['reservation_id']) && is_numeric($_POST['reservation_id'])) { $reservation_id = intval($_POST['reservation_id']); if ($timegrid->deleteReservation($reservation_id)) { echo json_encode(true); exit; } echo json_encode(false);