<?php

include 'load.php';

if(isset($_GET['kotid']) && isset($_GET['status'])){
   $kid =  $_GET['kotid'];
    $status = $_GET['status'];

    $sql = "UPDATE mobile_kot SET status ='$status' WHERE kot_id='$kid'";
    $conn->query($sql);
}


?>
 
 <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0">
<meta name="description" content="POS - Eat More Resturant   | Pos & Invetory System | Dashboard

">
<meta name="keywords" content="Eat More Resturant   | Pos & Invetory System | Dashboard

">
<meta name="author" content="Eat More Resturant   | Pos & Invetory System | Dashboard

">
<meta name="robots" content="noindex, nofollow">

<title>Kitchen Order List | Eat More Resturant   | Pos & Invetory System | Dashboard

</title>

<?php
require_once 'headercss.php';
?>

</head>
<body>
<div id="global-loader">
<div class="whirly-loader"> </div>
</div>

<div class="main-wrapper">
<?php
require_once 'header.php';
?>

<?php
require_once 'navbar.php';
?>

<div class="page-wrapper">
<div class="content">
<div class="page-header">
<div class="page-title">
<h4 style="text-align: center;">Kitchen Display System</h4>

</div>

</div>

<div class="row">

		<?php 
            $kot = mysqli_query($conn, "SELECT * FROM mobile_kot order by added_date DESC");
            if ($kot->num_rows > 0) {
                while($row = $kot->fetch_assoc()) { 
                    $kotid = $row['kot_id'];
                    $status = $row['status'];
                    $cartsingle = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobiletemporarycart WHERE kot_id='$kotid'")); ?>
					<div class="col-md-3">
					<div class="wrap">
                        <div class="wrap1">
                        <div class="kot-no">
                                    <h6>KOT - <?php echo $kotid; ?> (<?php echo $row['order_type']; ?>)</h6>

                                </div>
                                <div class="tb">
                                <table class="table">
                                    <thead class="thead-light">
                                        <tr>
                                        
                                        <th scope="col">Item</th>
                                        <th scope="col">Qty</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php $cart = mysqli_query($conn, "SELECT * FROM mobiletemporarycart WHERE kot_id='$kotid'"); 
                                         if ($cart->num_rows > 0) {
                                            while($row1 = $cart->fetch_assoc()) { 
                                                $pid = $row1['proid']; 
                                                $productinfo = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM mobileproducts WHERE prid ='$pid'")); ?>
                                        <tr>
                                        
                                        <td><?php echo $productinfo['proname']; ?></td>
                                        <td><?php echo $row1['pro_qty']; ?></td>
                                        </tr>

                                        <?php }  } ?>
                                    
                                    </tbody>
                                    </table>
                                </div>
							</div>
							<br>
							<div class="row">
                                <div class="col-md-12 mb-2">
                                    <?php 
                                        if($status==0){ ?>
                                                <span class="badge badge-danger">Pending</span>
                                       <?php }else if($status==1){ ?>
                                             <span class="badge badge-warning">Accepted</span>
                                        <?php  }else if($status==2){ ?>
                                            <span class="badge badge-warning">Delivered</span>
                                       <?php }
                                    
                                    ?>
                                </div>
							<div class="col-md-6">
							<a href="view-kot.php?kotid=<?php echo $kotid; ?>&status=1" class="btn btn-success btn-sm btn-block" style="width:100%;"><i class="fa fa-check-circle" aria-hidden="true"></i> Accept</a>
							</div>
							<div class="col-md-6">
							<a href="view-kot.php?kotid=<?php echo $kotid; ?>&status=2" class="btn btn-warning btn-sm btn-block" style="width:100%;"><i class="fa fa-thumbs-up" aria-hidden="true"></i> Delivered</a>
							</div>
							</div>
					</div>  
					</div>
       

              <?php }
            }
        
        ?>

</div>
<style>
    .badge-danger {
    color: #fff;
    background-color: #dc3545;
}
.badge {
    display: inline-block;
    padding: .25em .4em;
    font-size: 75%;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: .25rem;
}
.badge-warning {
    color: #212529;
    background-color: #ffc107;
}
.badge-success {
    color: #fff;
    background-color: #28a745;
}
</style>
<!-- -->

</div>

</div>
</div>
</div>
<style>
    .wrap{
        box-shadow: 0px 0px 30px 0px rgba(193, 193, 193, 0.5);
        background-color: #fff;
        padding: 10px;
    }
    .order-type{
        background-color: green;
        text-align: center;
        color: #fff;
        padding: 5px;
    }
    .kot-no{
        text-align: center;
        background: red;
        color: #fff;
        padding: 5px;
        margin-top: 5px;
        margin-bottom: 5px;;
    }
</style>

<script src="assets/js/jquery-3.6.0.min.js"></script>

<script src="assets/js/feather.min.js"></script>

<script src="assets/js/jquery.slimscroll.min.js"></script>

<script src="assets/js/jquery.dataTables.min.js"></script>
<script src="assets/js/dataTables.bootstrap4.min.js"></script>

<script src="assets/js/bootstrap.bundle.min.js"></script>

<script src="assets/plugins/select2/js/select2.min.js"></script>

<script src="assets/plugins/sweetalert/sweetalert2.all.min.js"></script>
<script src="assets/plugins/sweetalert/sweetalerts.min.js"></script>

<script src="assets/js/script.js"></script>
</body>
</html>