<?php
include_once("../class/class.MySQL.php");
$db	=new MySQL();

$action = $_GET['act'];
if($action == "list"){
//$where['is_blocked'] = 0;

	//$holidayes = $db->fetchAll('payroll_holiday_calendar',$where,'','',false,'','id as id, date as start, title as title, color');
	$holidayes = $db->fetchQuery("SELECT id as id, date as start, title as title, color FROM `payroll_holiday_calendar` WHERE `is_blocked` = '0'");
	
	echo json_encode($holidayes);
}
elseif($action == 'update'){
	//$set['title']	= $_GET['title'];
	$set['date']	= date("Y-m-d",strtotime($_GET['start']));
	$where['id']	=$_GET['id'];
	$db->Update('payroll_holiday_calendar',$set,$where);

}elseif($action == 'addNew'){
	$data['title']	= $_GET['title'];
	$data['color']	= $_GET['green'];
	$data['date']	= date("Y-m-d",strtotime($_GET['start']));
	
	$db->Insert($data,'payroll_holiday_calendar');

}elseif($action == "remove"){

	$where['id'] = $_GET['id'];
	
	$set['is_blocked'] = 1;
	$db->Update('payroll_holiday_calendar',$set,$where);
}



?>