<?php 
require 'dao/Calendar.php';

if (isset($_POST['add_event'])) {
	$title = $_POST['title'];
	$description = $_POST['description'];
	$priority = $_POST['priority'];
	$icon = $_POST['icon'];

	$data = array("event_title"=>$title,"event_description"=>$description,
				  "priority"=>$priority,"icon"=>$icon);
	$success = $calendar->add_event($data);
	if($success){
		echo 0;
	}else{
		echo 1;
	}
}


if (isset($_POST['set_remove'])) {

	$remove = $_POST['remove'];
	if ($remove) {
		$remove = 1;
	}else{
		$remove = 0;
	}
	$event_id = $_POST['event_id'];
	$data = array("removed"=>$remove);
	$success = $calendar->set_remove($data,$event_id);

}

if (isset($_POST['updateEvent'])) {
	$priority = $_POST['priority'];
	$event_id = $_POST['event_id'];
	$start = $_POST['start'];
	$event_title = $_POST['event_title'];
	$icon = $_POST['icon'];

	$data = array("className"=>$priority,"start"=>$start,
				  "id"=>$event_id,"title"=>$event_title,
				  "icon"=>$icon);
	$success = $calendar->render($data);
	if ($success) {
		# code...
	}
}

$get_all_events = "";
$get_all_events = $calendar->get_all_events();
$get_all_calendar_event = "";
$get_all_calendar_event = $calendar->get_all_calendar_event();
//sizeof($get_all_calendar_event);
 ?>