<?php 

require_once '../includes/DbOperations.php';

$response = array();

if($_SERVER['REQUEST_METHOD'] == 'POST'){


	if(!empty($_POST['day']) and !empty($_POST['meal1']) and !empty($_POST['meal2'])) {
		if(isset($_POST['day']) and isset($_POST['meal1']) and isset($_POST['meal2'])) {
			$db =  new DbOperations();

			$result = $db -> createSaturdayMenu( $_POST['day'],$_POST['meal1'], $_POST['meal2']);
	

	if($result == 1){
				
				$response['error'] = false;
				$response['message'] = "Menu created successfully";	
			}
			elseif($result == 0){
				$response['error'] = true;
				$response['message'] = "Menu creation failed";
			}

	}else{
		echo "no";
	}
}else{
			$response['error'] = true;
			$response['message'] = "Required fields are missing";
		}
}else{
	$response['error'] = true;
	$response['message'] = "Invalid Request";
}

echo json_encode($response);
?>