<?php session_start();?>
<!DOCTYPE html>
<html lang="en">
<?php
    if(!isset($_SESSION['id'])){
        echo"<script>alert('you have to log back in to continue');</script>";
        header("Location: Logout.php");
       
    }
    include("db.php");
    $sql="SELECT `Product_id`,`ProductName`, `ProductImage`, `ProductPrice` FROM `Products` WHERE `STOCK`>0";
    $stmt=mysqli_stmt_init($conn);
    mysqli_stmt_prepare($stmt,$sql);
    if(mysqli_stmt_execute($stmt)){
        $result=mysqli_stmt_get_result($stmt);
    }

    

?>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.13.1/font/bootstrap-icons.min.css">

    <title>Product page</title>
</head>
<style>
    .pill-navbar{
        border-radius: 50px;  
        padding:10px 20px;
        
    }
    @media(max-width:900px){
        
        .pill-navbar{
        border-radius: 25px;  
        margin-top:10px;

        }
        .pill-navbar .collapse-navbar{
            margin-top:10px;
            padding-top:10px;
            border-top:1px#eee
        }
    }
    .card{
        min-width:70vw;
        border-radius: 40px;  
        padding: 50px;
        max-height:90vh;
        overflow-y:auto;
    }

   
    .button{
        min-height:5vh;
        max-height:5vh;
    }

    body{

        background-image: linear-gradient(rgba(0,0,0,0.2),rgba(0,0,0,0.7)), url("Dark-theme.jpg");
        background-position: center;
        background-repeat: no-repeat;
        background-size: cover;
        min-height:100vh;
      
    }
    .form-group{
        margin-bottom:1rem;
    }

</style>
<body>
    
  
    
    
    <!-- navbar -->
    <nav class="navbar navbar-expand-lg navbar-light bg-light shadow pill-navbar w-50 mx-auto my-4  ">
    
        <a class="navbar-brand" href="CustomerHome.php">Logo</a>

        <!-- expand/collapse button -->
        <button
            class="navbar-toggler"
            type="button"
            data-bs-toggle="collapse"
            data-bs-target="#Navbar">
            <span class="navbar-toggler-icon"></span>
        </button>

        <!-- nav links -->
        <div class="collapse navbar-collapse ms-4" id="Navbar">
            <ul class="navbar-nav mt-auto">
                <li class="nav-item"><a class="nav-link" href="CustomerProducts.php">Products</a></li>
                <li class="nav-item"><a class="nav-link" href="CustomerSuppliers.php">Suppliers</a></li>
                <li class="nav-item"><a class="nav-link" href="CustomerOrders.php">Orders</a></li>
                <li class="nav-item"><a class="nav-link" href="CustomerLoyalty.php">Loyalty</a></li>
            </ul>
            <!-- right side nav links -->
            <ul class="navbar-nav ms-auto ">
                <li class="nav-item"><a class="nav-link" href="Logout.php">Log out<span class="bi bi-person-fill"></span></a></li>
                <li class="nav-item"><a class="nav-link" href="">Settings<span class="bi bi-gear-fill"></span></a></li>
            </ul>
        </div>

    </nav>

    
    
    <!-- main content -->
   <div class="container p-auto mt-5 ">
        <div class="col-lg-12 mx-auto">
            <div class="card">
                <div class="header">
                    <div class="card-title text-center" style="padding-left:9rem; padding-right:9rem;">  
                        <h1>Suppliers</h1><p></p><h5 class="text-muted">All of our suppliers are local based and provide our store with fresh produce</h5>
                    </div>
                </div>
                <a href="CustomerCheckout.php"><--Go to checkout</a>
                <div class="card-body px-auto mt-3">
                    <div class="card-text px-auto">
                        <?php while($row=mysqli_fetch_assoc($result)){?>
                            <div class="card mx-auto">
                                <img class="card-img-top" src="<?php echo htmlspecialchars($row['CompanyLogo'])?>" alt="Image not available" />
                                <div class="card-body">
                                    <h4 class="card-title"><?php echo htmlspecialchars($row['CompanyName'])?></h4>
                                </div>
                                <a class="stretched-link" href="Suppliers.php?id=<?php echo($row['Producer_id'])?>"></a>
                            </div>
                        <?php };?>
                    </div> 
                </div>
            </div>
        </div>   
    </div>
    
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
</body>
</html>