<?php
	require_once '../../autoload.php';

	$result = array (
			"status"	=> 'KO',
			"results"	=> -1
	);
	
	$pdo = getPDO ();
		
	if ( $pdo )
	{
		$room_id 	= -1;
		
		if ( isset($_POST['room_id']) )		$room_id 	= $_POST['room_id'];

		$s0 = null;

		$sql .="update room set removed = true  where room_id = :room_id;";
				
		$s0 = $pdo->prepare ( $sql );

		$s0->bindParam ( ':room_id', 	$room_id 	);
		
		if ( $s0->execute () == true )
		{
			$sql ="update modality set removed = true from room where modality.room_id = :room_id;";


			$s1 = $pdo->prepare ( $sql );

			$s1->bindParam ( ':room_id', 	$room_id 	);

			if ( $s1->execute () == true )
			{
				$result['status'] = 'OK';
				$result['results'] = $room_id;
			}
		}
	}
	
	header('Content-type: application/json');
	
	echo json_encode ( $result );
?>