<?php

include 'load.php';

?>

<!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>Booking List | Eat More Resturant   | Pos & Invetory System | Dashboard</title>

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

</head>

<body>

    <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>Booking List</h4>
                        <h6>Manage your booking</h6>
                    </div>
                    <div class="page-btn">
                        <a href="addbooking.php" class="btn btn-added"><img src="assets/img/icons/plus.svg" alt="img" class="me-1">Add New Booking</a>
                    </div>
                </div>

                <div class="card">
                    <div class="card-body">
                        <div class="table-top">

                        </div>
						<div class="card mb-0" id="filter_inputs" style="display:block;">
						<div class="card-body pb-0">
						<div class="row">
						<div class="col-lg-12 col-sm-12">
						<form method="GET" enctype="multipart/form-data">
						<div class="row">
						<div class="col-md-6">
                        <select class="form-control select2" name="customer" required>
                        <option value="">Select Customer</option>
                        <?php 
				
						$sql = "SELECT * FROM mobilecustomers";
						$result = $conn->query($sql);

						if ($result->num_rows > 0) {
						while($row = $result->fetch_assoc()) { ?>
                        <option value="<?php echo $row['coid']; ?>"><?php echo $row['cname']; ?> | <?php echo $row['cphone']; ?></option>
						<?php 
						}
						}
						?>
                        </select>
                        </div>
                        <div class="col-md-3">
                        <button class="btn btn-success btn-sm btn-block" type="submit" name="submit" style="width:100%;">Search</button>
                        </div>
                        <div class="col-md-3">
                        <button onclick="deleteSelectedRows()" class="btn btn-danger btn-sm btn-block" style="width:100%;">Delete Selected Rows</button>
                        </div>
						</div>
						</form>
						</div>
						</div>
						</div>
						</div>
		
<?php 
	if(isset($_GET['customer'])){
		$customer = $_GET['customer'];

		$search = "AND customer='$customer'";
	}else{
		$search = "";
	}
?>

<hr>
		
                        <div class="form-check">
  <input class="form-check-input" type="checkbox" value="" id="selectall">
  <label class="form-check-label" for="flexCheckDefault">
    Select All
  </label>
</div>
                        <div class="table-responsive">
<table class="table" id="betable">
                                <thead>
                                    <tr>
                                        <th>#</th>
										<th>ID</th>
                                        <th>Action</th>
                                        <th>Status</th>
                                        <th>Book Number</th>
                                        <th>Customer</th>
                                        <th>Room</th>
                                        <th>Check In Date</th>
                                        <th>Check Out Date</th>
                                        <th>Capacity</th>
                                        <th>Note</th>
                                        <th>Date/Time</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php

										$count=0;

										$stmt = $DB_con->prepare('SELECT * FROM mobileroombooking WHERE rbid != 0 '.$search.' ORDER BY rbid');

										$stmt->execute();

										if($stmt->rowCount() > 0)

										{

										while($row=$stmt->fetch(PDO::FETCH_ASSOC))

										{

										extract($row);

										$count++;

										?>
                                    <tr>
                                        <td><input type="checkbox" class="delete-checkbox" value="<?php echo $row["rbid"]; ?>"></td>
                                        <td><?php echo number_format($count,0); ?></td>
                                        <td>
                                        <a href="bookingreciept2.php?receiptno=<?php echo $row['rbid']; ?>" class="btn btn-block btn-outline-dark active btn-sm text-white" title="Receipt" onClick="JavaScript:return confirm('Are your sure view receipt?');"><i class="fa fa-print" data-bs-toggle="tooltip" title="" data-bs-original-title="Bill" aria-label="fa fa-print"></i></a>
                                        <a href="bookingreciept.php?receiptno=<?php echo $row['rbid']; ?>" class="btn btn-block btn-outline-dark active btn-sm text-white" title="Receipt" onClick="JavaScript:return confirm('Are your sure view receipt?');"><i class="fa fa-print" data-bs-toggle="tooltip" title="" data-bs-original-title="Bill" aria-label="fa fa-print"></i></a>
											<a href="editbooking.php?rbid=<?php echo $row["rbid"]; ?>"
                                                class="btn btn-block btn-outline-primary active btn-sm text-white"><i
                                                    class="fa fa-edit" data-bs-toggle="tooltip" title=""
                                                    data-bs-original-title="fa fa-edit" aria-label="fa fa-edit"></i></a>
                                            <a href="deletebooking.php?rbid=<?php echo $row["rbid"]; ?>"
                                                class="btn btn-block btn-outline-danger active btn-sm text-white"><i
                                                    class="fa fa-trash" data-bs-toggle="tooltip" title=""
                                                    data-bs-original-title="fa fa-trash"
                                                    aria-label="fa fa-trash"></i></a>

                                        </td>
                                        <td><?php 
						
														if($row['status'] == "1"){

														echo '<a class="btn btn-success btn-sm text-white">Active</a>';

													    }else if($row['status'] == "0"){

														echo '<a class="btn btn-danger btn-sm text-white">Deactive</a>';

														}
						
												
											  ?></td>
                                        <td><?php echo $row['booknumber']; ?></td>
                                        <td><?php
if($row['customer'] == "0"){
													
												}else{	
												$id = $row['customer'];  

												$query = $DB_con->prepare('SELECT cname,cphone FROM mobilecustomers WHERE coid='.$id);

												$query->execute();

												$result = $query->fetch();

												echo $result['cname']." | ".$result['cphone'];
}
												?></td>
                                        <td><?php
if($row['room'] == "0"){
													
												}else{	
												$id = $row['room'];  

												$query = $DB_con->prepare('SELECT itemcode,proname FROM mobileproducts where producttype="Room" and prid='.$id);

												$query->execute();

												$result = $query->fetch();

												echo $result['itemcode']." | ".$result['proname'];
}
												?></td>
                                        <td><?php echo date_format(date_create($row['checkindate']), "M d, Y"); ?></td>
                                        <td><?php echo date_format(date_create($row['checkoutdate']), "M d, Y"); ?></td>
										<td><?php echo $row['capacity']; ?></td>
										<td><?php echo $row['note']; ?></td>
                                        <td><?php echo date_format(date_create($row['add_date']), "M d, Y | h:i:s "); ?></td>
                                    </tr> 
<?php 
} 
}
?>
                                </tbody>
                            </table>
                        </div>
                       
                    </div>
                </div>
            </div>
        </div>

    </div>
    </div>
    </div>
	
<?php require_once 'footerjs2.php'; ?>

</body>
</html>