<?php
	session_start();
	include("library/conn.php");
?>
<!DOCTYPE html>
<html lang="en">
	<head>
        <?php include("library/head.php");?>
        <title>Kitchens | <?php echo $_SESSION['systemName']; ?></title>
	</head>
	<body class="app sidebar-mini">

		<!-- Navbar-->
		<?php include("library/header.php");?>
		<!-- Sidebar menu-->
		<div class="app-sidebar__overlay" data-toggle="sidebar"></div>
		<?php include("library/sidebar.php");?>
  
		<main class="app-content">
			<div class="app-title">
				<div>
					<h4 class="text-primary"><i class="fa fa-fire fa-lg"></i> KITCHENS</h4>
					<p>Kitchens List Page</p>
				</div>
				<ul class="app-breadcrumb breadcrumb">
					<li class="breadcrumb-item"><i class="fa fa-home"></i></li>
					<li class="breadcrumb-item"><a href="kitchens">Kitchens</a></li>
				</ul>
			</div>
      
			<?php include("models/admin_config.php");?>
			<?php include("models/system_config.php");?>

			<div class="row">
				
				<div class="col-md-4">
					<div class="tile">
						<div class="tile-body">
							<div class="row">
								<div class="col-md-12">
                                    <h5 class="text-primary"><i class="fa fa-plus-square"></i> Register Kitchen</h5>									
                                    <hr />
								</div>
    							<div class="col-md-12">
									<form action="#" method="POST" id="registerNewKitchenForm">
										<div class="row">
											<div class="form-group col-md-12">
												<label class="control-label">Kitchen Name</label>
												<input class="form-control font-weight-bold" type="text" name="txtKitchenNameNewKitchen" id="txtKitchenNameNewKitchen" placeholder="Enter kitchen name" required>
											</div>
											<div class="form-group col-md-12">
												<label class="control-label">Description</label>
												<textarea class="form-control" rows="2" name="txtKitchenDescriptionNewKitchen" id="txtKitchenDescriptionNewKitchen" required></textarea>
												<input class="form-control" type="hidden" name="txtRegisteredByNewKitchen" id="txtRegisteredByNewKitchen" value="<?php echo $_SESSION['userIdd']; ?>" required>
												<input class="form-control" type="hidden" name="txtRegisterDateNewKitchen" id="txtRegisterDateNewKitchen" value="<?php echo date("Y-m-d H:i:s"); ?>" required>
											</div>
											<div class="form-group col-md-12 text-right">
												<button type="submit" class="btn btn-success" name="btnRegisterNewKitchen" id="btnRegisterNewKitchen"><i class="fa fa-fw fa-lg fa-save"></i>Register Kitchen</button>
											</div>
										</div>
									</form> 							
					            </div>
						    </div>
					    </div>
				    </div>
			    </div>
			
			    <div class="col-md-8">
					<div class="tile">
						<div class="tile-body">
							<div class="row">
								<div class="col-md-12">
									<h5 class="text-primary"><i class="fa fa-list-ul"></i> Kitchen List</h5>
									<hr />
								</div>
    							<div class="col-md-12">
    								<table class="table table-bordered table-sm" id="kitchensTable">
    									<thead>
    										<tr class="text-center bg-dark text-white" height="35px">
                                                <th class="align-middle">No</th>
                                                <th class="align-middle">Kitchen Name</th>
                                                <th class="align-middle">Description</th>
                                                <th class="align-middle">Action</th>
    										</tr>
    									</thead>
    									<tbody>
    										<?php
    										    $count_kitchens = 1;
    											$getKitchens = mysqli_query($conn, "SELECT * FROM kitchens ORDER BY kitchenName ASC") or die(mysqli_error($conn));
    											while ($kitchens_rs = mysqli_fetch_array($getKitchens)) { ?>
                                                    <tr>
                                                        <td class="align-middle text-center"><?php echo $count_kitchens; ?></td>
                                                        <td class="align-middle font-weight-bold"><?php echo $kitchens_rs[2]; ?></td>
                                                        <td class="align-middle" width="40%"><?php echo $kitchens_rs[3]; ?></td>
                                                        <td class="align-middle text-center" width="25%">
                                                            <div class="btn-group col-md-12">
                                                                <button type="button" class="btn btn-primary" data-toggle="dropdown">Action</button>
                                                                <button type="button" class="btn btn-primary dropdown-toggle dropdown-toggle-split" data-toggle="dropdown">
                                                                    <span class="caret"></span>
                                                                </button>
                                                                <div class="dropdown-menu" style="min-width: 8rem;">
                                                                    <a href="#" class="dropdown-item text-primary btnUpdateKitchen" id="<?php echo "Update". $kitchens_rs[1]; ?>" data-id="<?php echo $kitchens_rs[1]; ?>" data-toggle="modal" data-target="#updateKitchenModal"><i class="fa fa-edit"></i> Edit</a>
                                                                    <a href="#" class="dropdown-item text-danger btnDeleteKitchen" id="<?php echo "Delete". $kitchens_rs[1]; ?>" data-id="<?php echo $kitchens_rs[1]; ?>"><i class="fa fa-trash"></i> Delete</a>
                                                                </div>
                                                            </div>
                                                        </td>
                                                    </tr><?php
                                                    $count_kitchens++;
    											}
    										?>
    									</tbody>
    								</table>
    							</div>
						</div>
					</div>
				</div>


			</div>
			
		</main>
  
		<!-- Essential javascripts for application to work-->
		<?php include("library/footer.php");?>  
		<?php include("library/scripts.php");?>
		
		<script type="text/javascript">
		    $("#kitchensTable").DataTable({"pageLength": 100, "order": []})
		</script>

	</body>
</html>