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

   
  <h3 class="p-2">All Sales</h1> 
<div class="d-flex py-3 d-flex justify-content-between">
   <form action="" class="px-1">
     <div class="row g-3 align-items-center">
  <div class="col-auto">
    <label for="inputPassword6" class="col-form-label">Product Name:</label>
  </div>
  <div class="col-auto">
 <select  class="form-control">
            <option value="">Sample</option>
            <option value="">Sample</option>
            <option value="">Sample</option>
          </select>
  </div>
  <div class="col-auto">
    <button class="btn btn-primary" >
  <i class="fa-solid fa-eye"></i>
  View
</button>
  </div>
</div>
       
       
        <div>
         
</div>
</form>
     <div >
      <button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#addProductModal"><i class="fa-solid fa-plus" ></i> Add Inventory</button>
      <button class="btn btn-outline-dark"><i class="fa-solid fa-download"></i> Export</button>
     </div>
     <div class="modal fade modal-form " id="addProductModal" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
  <div class="modal-dialog col-12">
    <div class="modal-content">
      <div class="modal-header">
        <h1 class="modal-title fs-5" id="staticBackdropLabel">Add New Product</h1>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">
        <div class="form">
            <div class="row">
                <div class="col-6">
                    <div class="mb-3">
                         <label for="" class="form-label">ID:</label>
                        <input type="number" class="form-control" placeholder="Enter User Id">
                    </div>
                </div>
                <div class="col-6">
                    <div class="mb-3">
                         <label for="" class="form-label">Expense:</label>
                        <input type="text" class="form-control" placeholder="Enter Name">
                    </div>
                </div>
                <div class="col-6">
                    <div class="mb-3">
                         <label for="" class="form-label">Amount:</label>
                         <input type="number" class="form-control" placeholder="Enter Price">
                        </div>
                    </div>
                    <div class="col-6">
                        <div class="mb-3">
                        <label for="" class="form-label">Date:</label>
                         <input type="date" class="form-control">
                    </div>
                </div>
                <div class="col-6">
                    <div class="mb-3">
                         <label for="" class="form-label">Entry Date:</label>
                      <input type="date" disabled value="" class="form-control" >
                    </div>
                </div>
               
            </div>
        </div>
      </div>
      <div class="modal-footer">
         <button type="button" class="btn btn-primary">Add</button>
      </div>
    </div>
  </div>
</div>
</DIV>
  <div>
   
<p class="float-end fw-bold pt-3">Total Expenses: <span class="fw-light">0</span></p>


</div>
<table class='table table-hover rounded-3'>
  <thead>
    <tr class='table-secondary'>
      <th>ID</th>
      <th>Description</th>
      <th>Date</th>
      <th>Entry Date</th>
      <th>Cost</th>
      <th>Action</th>
      
    </th>
  </thead>
<tbody>
    <?php

 $connection = new mysqli($dbhost,$dbusername,$dbpassword,$dbname); 
if($connection->connect_error){
  die("error while connecting database".$connection->connect_error);
}

$sql="SELECT * FROM  expense";
$result=$connection->query($sql);
if(!$result){die("Invalid Query!!".$connection->error);}

while($row=mysqli_fetch_array($result)){
  ?>
  <tr class='table-light'>
  <td><?php echo"$row[ID]";?></td>
  <td><?php echo"$row[Title]";?></td>
  <td><?php echo"$row[Date]";?></td>
  <td><?php echo"$row[Entry_Date]";?></td>
  <td><?php echo"$row[Cost]";?></td>
  <td>
  <button class='btn btn-primary mx-2 editInventorybtn' 
  data-id= "<?php echo"$row[ID]";?>"
  data-title= "<?php echo"$row[Title]";?>"
  data-date= "<?php echo"$row[Date]";?>"
  data-entrydate= "<?php echo"$row[Entry_Date]";?>"
  data-cost= "<?php echo"$row[Cost]";?>"
  data-bs-toggle='modal' data-bs-target='#editTableModal'><i class='fa-solid fa-pen-to-square'></i> Edit Inventory</button>
  <button class='btn btn-danger mx-2'> <i class='fa-solid fa-trash'></i> Delete Inventory</button>
  </td>
  </tr>
  <div class='modal fade modal-form ' id='editTableModal' data-bs-backdrop='static' data-bs-keyboard='false' tabindex='-1' aria-labelledby='staticBackdropLabel' aria-hidden='true'>
  <div class='modal-dialog col-12'>
    <div class='modal-content'>
      <div class='modal-header'>
        <h1 class='modal-title fs-5' id='staticBackdropLabel'>Edit Expense</h1>
        <button type='button' class='btn-close' data-bs-dismiss='modal' aria-label='Close'></button>
      </div>
      <div class='modal-body'>
        <div class='form'>
            <div class='row'>
                <div class='col-6'>
                    <div class='mb-3'>
                         <label for='' class='form-label'>ID:</label>
                        <input type='number' class='form-control' placeholder='Enter User Id' id="editInventoryid" >
                    </div>
                </div>
                <div class='col-6'>
                    <div class='mb-3'>
                         <label for='' class='form-label'>Expense:</label>
                        <input type='text' class='form-control' placeholder='Enter Name' id="editInventorytitle">
                    </div>
                </div>
                <div class='col-6'>
                    <div class='mb-3'>
                         <label for='' class='form-label'>Amount:</label>
                        <input type='text' class='form-control' placeholder='Enter Name'id="editInventoryamount">
                    </div>
                </div>
                <div class='col-6'>
                    <div class='mb-3'>
                         <label for='' class='form-label'>Date:</label>
                        <input type='date' class='form-control' placeholder='Enter Name' id="editInventorydate">
                    </div>
                </div>
                <div class='col-6'>
                    <div class='mb-3'>
                         <label for='' class='form-label'>Entry date:</label>
                        <input type='date' class='form-control' placeholder='Enter Name' id="editInventoryentrydate">
                    </div>
                </div>
               
            </div>
        </div>
      </div>
      <div class='modal-footer'>
         <button type='button' class='btn btn-primary'>Add</button>
      </div>
    </div>
  </div>
</div>
 </tr>

  <?php
}
?>
</tbody>  
</table>
  
<?php include("footer.php");?>