<?php
     session_start();
      include 'database/shikanisha.kts.php';
        if(!($_SESSION['type'] == 'Manager' || $_SESSION['type'] == 'Cashier' || $_SESSION['type'] == 'Receptionist')){
            header("location:logout.php");
}


?>
<!DOCTYPE html>
<html lang="en">

<head>
    <!-- Required meta tags-->
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="Colorlib Templates">
    <meta name="author" content="Colorlib">
    <meta name="keywords" content="Colorlib Templates">

    <!-- Title Page-->
    <title>Machakos Cottage Hotel</title>

    <!-- Icons font CSS-->
    <link href="./logs/vendor/mdi-font/css/material-design-iconic-font.min.css" rel="stylesheet" media="all">
    <link href="./logs/vendor/font-awesome-4.7/css/font-awesome.min.css" rel="stylesheet" media="all">
    <!-- Font special for pages-->
    <link href="https://fonts.googleapis.com/css?family=Poppins:100,100i,200,200i,300,300i,400,400i,500,500i,600,600i,700,700i,800,800i,900,900i" rel="stylesheet">

    <!-- Vendor CSS-->
    <link href="./logs/vendor/select2/select2.min.css" rel="stylesheet" media="all">
    <link href="./logs/vendor/datepicker/daterangepicker.css" rel="stylesheet" media="all">

    <!-- Main CSS-->
    <link href="./logs/css/main.css" rel="stylesheet" media="all">
</head>

<body>
    <div class="page-wrapper bg-gra-01 p-t-180 p-b-100 font-poppins">
        <div class="wrapper wrapper--w780">
            <div class="card card-3">
                <div class="card-heading"></div>
                <div class="card-body">
                    <h2 class="title">Table Registration</h2>
                    <form id="create_table">
                        <div class="input-group">
                            <input class="input--style-3" type="text" placeholder="Table Name" name="tablename" id="tablename">
                        </div>
                        
                        <div class="p-t-10">
                            <button class="btn btn--pill btn--green" type="submit">Submit</button>
                          <a href="index.php"><button class="btn btn--pill btn--red"  type="button" href="index.php">Close</button></a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>

    <!-- Jquery JS-->
    <script src="./logs/vendor/jquery/jquery.min.js"></script>
    <!-- Vendor JS-->
    <script src="./logs/vendor/select2/select2.min.js"></script>
    <script src="./logs/vendor/datepicker/moment.min.js"></script>
    <script src="./logs/vendor/datepicker/daterangepicker.js"></script>

    <!-- Main JS-->
    <script src="./logs/js/global.js"></script>
    
    <script>
		$(document).ready(function() {
			// Add event listener to form submit button
			$('#create_table').on('submit', function(event) {
				event.preventDefault(); // Prevent default form submission behavior

				// Serialize form data
				var formData = $(this).serialize();

				// Send AJAX request to server
				$.ajax({
					url: './database/addtable.kts.php', // PHP script to handle the request
					type: 'POST',
					data: formData,
					success: function(response) {
                        // Display the response from the PHP script
                        alert(response);

                        // Clear the form input fields
                        $('#reg_customer')[0].reset();
                      },
					error: function(xhr, status, error) {
						// Handle errors
						console.log(xhr.responseText);
					}
				});
			});
		});
	</script>

</body><!-- This templates was made by Colorlib (https://colorlib.com) -->

</html>
<!-- end document-->