<?php

if($text == "Hi Admin"){
	$reply = "Welcome to Homestay Management System";
	$keyboard = array("keyboard" => array(), "remove_keyboard" => true);
	sendMessage($chatID,$reply,$keyboard);
	
	$reply = "Which one you are?";$keyboard = array(
		"keyboard" => 
			array(
				array(
					array("text" => "Housekeeper"),
					array("text" => "Operator"),
					array("text" => "Admin")),
				array(
					array("text" => "Exit"))
			), "one_time_keyboard" => true, "resize_keyboard" => true // Can be FALSE (vertical resize)
		);
	sendMessage($chatID,$reply,$keyboard);
}

if($text == "Housekeeper"){
	$reply = "What's your pin?";
	$keyboard = array("keyboard" => array(), "remove_keyboard" => true);
	sendMessage($chatID,$reply,$keyboard);
}

if($text == "8610"){
	$reply = "Welcome back, Najmi!";
	$keyboard = array("keyboard" => array(), "remove_keyboard" => true);
	sendMessage($chatID,$reply,$keyboard);
	
	$reply = "Pick which one you want me to do?";$keyboard = array(
		"keyboard" => 
			array(
				array(
					array("text" => "Today housekeeping schedule")),
				array(
					array("text" => "Show me room list")),
				array(
					array("text" => "Exit"))
			), "one_time_keyboard" => true, "resize_keyboard" => true // Can be FALSE (vertical resize)
		);
	sendMessage($chatID,$reply,$keyboard);
}

if($text == "Show me room list"){
	include('connection.php');
	
	$reply = "Pick which one you want me to do?";
	
	include('connection.php');
	$result = mysqli_query($conn, "SELECT * FROM rooms");
	while($row = mysqli_fetch_assoc($result)){
		$loopContent = $loopContent.',[{"text":"'.$row['r_no'].'"}]';
	}
	
	$keyboard = '{"keyboard":
	[
		[{"text":"Exit"}]'.$loopContent.'
	],"one_time_keyboard":true,"resize_keyboard":true}';
	
	sendMessage($chatID,$reply,json_decode($keyboard));
}

if($text == "Exit"){
	$reply = "Good bye!";
	$keyboard = array("keyboard" => array(), "remove_keyboard" => true);
	sendMessage($chatID,$reply,$keyboard);
}

?>