<?php include("cn.php"); ?>
<?php $title = "Dashboard"; ?>
<?php include("info.php"); ?>
<!DOCTYPE html>
<html lang="en">
<?php include("head-tag.php"); ?>

<?php
$sql_1 = mysqli_query($connect, "select * from app_users where
        Id = '" . $_SESSION["userid"] . "' ");
$data_1 = mysqli_fetch_assoc($sql_1);
?>


<body>

    <div class="inner-wrapper">

        <?php include("header.php"); ?>

        <div class="page-wrapper">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-xl-3 col-lg-3 col-md-3 theiaStickySidebar">
                        <aside class="sidebar sidebar-user">
                            <!--<div class="card ctm-border-radius shadow-sm">
            <div class="card-body py-4">
                <div class="row">
                    <div class="col-md-12 mr-auto text-left">
                        <div class="custom-search input-group">
                            <div class="custom-breadcrumb">
                                <ol class="breadcrumb no-bg-color d-inline-block p-0 m-0 mb-2">
                                    <li class="breadcrumb-item d-inline-block"><a href="index.php" class="text-dark">Home</a></li>
                                    <li class="breadcrumb-item d-inline-block active"><?php echo $title ?></li>
                                </ol>
                                <h4 class="text-dark">Dashboard</h4>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>-->
                            <div class="user-card card shadow-sm bg-white text-center ctm-border-radius">
                                <div class="user-info card-body">
                                    <div class="user-avatar mb-4">
                                        <img src="<?php echo $data_1["Image"]; ?>" alt="User Avatar" class="img-fluid rounded-circle" width="100">
                                    </div>
                                    <div class="user-details">
                                        <h4><b>Welcome <?php echo $_SESSION["name"]; ?></b></h4>
                                    </div>
                                </div>
                            </div>
                            
                            
                            
                            
                         <?php
                         

                         $guestqry = mysqli_query($connect, "SELECT * FROM guest WHERE guest_id =" .$_SESSION["guestid"]);
                         $guestdata = mysqli_fetch_assoc($guestqry);
                            ?>
                        
                       
                             <div class="quicklink-sidebar-menu ctm-border-radius shadow-sm bg-white card">
                                <div class="card-body">
                                    <form action="" method="post">
                                        <!-- CARLISTS VERSION 2 -->
                                        <div class="form-group">
                                            <div class="input-group mb-3">
                                                <input type="text" name="nameplate" placeholder="-- SEARCH CAR BY NAMEPLATE --" class="form-control" aria-label="Default" aria-describedby="inputGroup-sizing-default">
                                            </div>


                                            <!-- CARLISTS VERSION 1 -->
                                            <!-- <select class="form-control select" name="brand">
                                                <option value="">-- SELECT CAR --</option>

                                                <?php

                                                $sql = mysqli_query($connect, "SELECT DISTINCT brands.* FROM brands LEFT JOIN cars ON brands.Id = cars.Brand");

                                                while ($data_m = mysqli_fetch_assoc($sql)) {

                                                    echo '<option style="border-radius: 15px; background-color: red;" value="' . $data_m['Id'] . '">...' . $data_m['Title'] . '</option>';

                                                    $sql1 = "SELECT car_name, car_nameplate FROM cars where cars.Brand=" . $data_m['Id'];
                                                    $sql1 = mysqli_query($connect, $sql1);
                                                    while ($cars1 = mysqli_fetch_assoc($sql1)) {
                                                        echo '<option value="' . $cars1['car_nameplate'] . '">&nbsp&nbsp&nbsp' . $cars1['car_name'] . ' (' . $cars1['car_nameplate'] . ')</option>';
                                                    }
                                                } ?>
                                            </select> -->
                                        </div>
                                        <div class="form-group">
                                            <button type="submit" name="submit_form" class="btn btn-theme button-1 ctm-border-radius text-white btn-block"><span>
                                                    <i class="fa fa-search"></i></span> Search</button>
                                        </div>
                                    </form>
                                </div>

                            </div>
                    
                        </aside>
                    </div>
                    <div class="col-xl-9 col-lg-9 col-md-9">

                        <!--<div class="row">
<div class="col-xl-3 col-lg-3 col-sm-3 col-6">
<div class="card dash-widget ctm-border-radius shadow-sm">
<div class="card-body">
<div class="card-icon bg-info" style="width: 40px;
    height: 40px;">
<i class="fa fa-car" aria-hidden="true"></i>
</div>
<?php
$sql = mysqli_query($connect, "select count(car_Id) as total from cars");
$data = mysqli_fetch_assoc($sql);
?>
<div class="card-right">
<h4 class="card-title"><a href="../admin/cars.php">Cars</a></h4>
<p class="card-text"><?php echo $data['total'] ?></p>
</div>
</div>
</div>
</div>
<?php
$sql = mysqli_query($connect, "select count(Id) as total from brands");
$data = mysqli_fetch_assoc($sql);
?>
<div class="col-xl-3 col-lg-3 col-sm-3 col-6">
    <div class="card dash-widget ctm-border-radius shadow-sm">
        <div class="card-body">
            <div class="card-icon bg-danger" style="width: 40px;
    height: 40px;">
                <i class="fa fa-tasks"></i>
            </div>
            <div class="card-right">
                <h4 class="card-title"><a href="../admin/brands.php">Brands</a></h4>
                <p class="card-text"><?php echo $data['total'] ?></p>
            </div>
        </div>
    </div>
</div>
<?php
$sql = mysqli_query($connect, "select count(guest_id) as total from guest");
$data = mysqli_fetch_assoc($sql);
?>
<div class="col-xl-3 col-lg-3 col-sm-3 col-6">
    <div class="card dash-widget ctm-border-radius shadow-sm">
        <div class="card-body">
            <div class="card-icon bg-success" style="width: 40px;
    height: 40px;">
                <i class="fa fa-user-secret" aria-hidden="true"></i>
            </div>
            <div class="card-right">
                <h4 class="card-title"><a href="../admin/guests.php">Guest</a></h4>
                <p class="card-text"><?php echo $data['total'] ?></p>
            </div>
        </div>
    </div>
</div>
<?php
$sql = mysqli_query($connect, "SELECT count(Id) as total from users WHERE Type = 'user'");
$data = mysqli_fetch_assoc($sql);
?>
<div class="col-xl-3 col-lg-3 col-sm-3 col-6">
    <div class="card dash-widget ctm-border-radius shadow-sm">
        <div class="card-body">
            <div class="card-icon bg-warning" style="width: 40px;
    height: 40px;">
                <i class="fa fa-user-o" aria-hidden="true"></i>
            </div>
            <div class="card-right">
                <h4 class="card-title"><a href="../admin/users.php">User</a></h4>
                <p class="card-text"><?php echo $data['total'] ?></p>
            </div>
        </div>
    </div>
</div>

</div>
-->
                        <div class="row">
                            <?php

                            if ($_SESSION['guestid'] > 0)
                                $sql = 'SELECT * FROM rentedcars WHERE guest_id=' . $data_1['GuestId'] . ' AND status=\'assigned\' ORDER BY rentedcars.id DESC';
                            else

                                $sql = 'SELECT * FROM rentedcars WHERE AppUser=' . $data_1['Id'] . ' AND status=\'assigned\' ORDER BY rentedcars.id DESC';

                            $sql = mysqli_query($connect, $sql);
                            $row = mysqli_num_rows($sql);
                            if ($row > 0) {
                                $sql = mysqli_fetch_assoc($sql);
                                include("pre-loader.php");
                                include("scripts.php");
                                die('
        <div class="card-body">
        <center>
            You have already <br/>an <h1>Booking</h1> <br/>Booking Number: <h1>' . $sql['BookingNumber'] . ' <br/>In-Progress.</h1>
            <br/><h2>You can make a new booking only after it\'s Completion</h2>
           
        </center>
        </div>
        ');
                            } else {
                                include("pre-loader.php");
                            }

                            ?>

                            <!-- CARLISTS VERSION 1 -->

                            <?php // include("carslist.php"); 
                            ?>

                            <!-- CARLISTS VERSION 2 -->

                            <?php  include("carslist2.php"); 
                            ?>

                        </div>
                    </div>
                </div>
            </div>

        </div>


        <?php include("scripts.php"); ?>

        <div class="sidebar-overlay" id="sidebar_overlay"></div>

</body>

</html>