<?php include_once("include/head.php"); ?>
<div class="main-panel">
    <div class="content-wrapper">
        <div class="card">
            <div class="card-body">
                <div class="row">
                    <div class="col-md-3">
                        <h4 class="card-title">PRODUCT LIST</h4>
                    </div>
                    <div class="col-md-9">
                        <a href="add-inventory.php" class="btn btn-primary" style="float: right; margin-bottom: 10px;">Add Inventory</a>
                    </div>
                </div>

                <div class="row">
                    <div class="col-12">
                        <div class="table-responsive">
                            <table id="order-listing" class="table">
                                <thead>
                                    <tr>
                                        <th>S.No</th>
                                        <th>Product Id</th>
                                        <th>Product Name</th>
                                        <th>Type</th>
                                        <th>Qty</th>
                                        <th>Vendor</th>
                                        <th>Price</th>
                                        <th>Added Date</th>
                                        <th>Status</th>
                                        <th>Actions</th>
                                    </tr>
                                </thead>
                                 <tbody>
                                  
                                 <?php
                                 $count=1;
                                  $sql = "SELECT * FROM products";
                                  $result = mysqli_query($conn, $sql);
                                  if (mysqli_num_rows($result) > 0) {
                                    while ($row = mysqli_fetch_assoc($result)) {
                                       
                                        $status = $row['status'];
                                        if($status == 1){
                                           $status = 'Active'; 
                                        }else{
                                            $status = 'Inactive';  
                                        }
                                  ?>
                                        <tr>
                                          <td><?php echo $count++ ?></td>
                                          <td><?php echo 'PID-00'. $row['id'] ?></td>
                                          <td><?php echo $row['name'] ?></td>
                                          <td><?php echo $row['type'] ?></td>
                                          <td><?php echo $row['quantity'] ?></td>
                                          <td><?php echo $row['vendor'] ?></td>
                                          <td><?php echo $row['price'] ?></td>
                                          <td><?php echo $row['created_at'] ?></td>
                                          <td><?php echo $status ?></td>

                                          <td>
                                            <a href="inventory-edit.php?id=<?php echo $row['id']?>" class="btn btn-primary btn-sm">Edit</a>
                                            <button type="button" class="btn btn-danger btn-sm ml-2" data-toggle="modal" data-target="#exampleModal-5">Delete</button> 
                                          </td>
                                        </tr>
                                  <?php
                                    }
                                  }
                                  ?>
                                
                              </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<?php include_once("include/footer.php"); ?>
</body>
</html>