<!DOCTYPE html>
<html>
<?php
include('conn.php');
$page=' Daily Sales';?>


<head>


<?php
include('common/head.php')
?> 
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet"/>
<style>
#items {
    height: 100% !important;

}

#unit {
    height: 40px !important;
    max-width: 400px;
}
#panel {
  display: none;
}
#panel1 {
  display: none;
}
</style>

</head>
<body>

<?php 
$today= date("F j, Y ,h:ia");
$order_id='T'.date('ymdhi').mt_rand(10,100);
$yesterday = new DateTime('yesterday');
$yest=$yesterday->format('F j, Y');
$todays= date("F j, Y");

      
            ?>
  <!-- Modal Add users -->
  <div  class="modal-box " >
    <div class="modal-dialog" role="document">
      <div class="modal-content ">
        <div class="modal-header">
          <h5 class="modal-title text-center text-dark" id="exampleModalLabel">Daily Sales</h5>
          <a href="sales" type="button" class="close">
            <span aria-hidden="true">&times;</span>
          </a>


        </div>
        <div class="modal-body">


<form method="post"  class="">
    <div class="row">
    <div id="" class="form-group col-sm-6 mb-3">
        <label for="date">Select Date</label>
        <select id="inputState" name="date" class="form-control">
                        <option selected>Select Date</option>
                        <option value="<?php echo $todays ?>">Today</option>
                        <option value="<?php echo $yest ?>">Yesterday</option>
                       
                      </select>
               </div>

               <div id="" class="form-group col-sm-6  mb-3">
               <label for="date">Bar Earnings</label>
                 <input type="number" class="form-control" name="bar" id="exampleFormControlInput1" placeholder="Enter Bar Earnings"  >
               </div>



               <div id="" class="form-group col-sm-6  mb-3">
               <label for="date">Restaurant Earning</label>
                 <input type="number" class="form-control" name="restaurant" id="exampleFormControlInput1" placeholder="Enter Restaurant Earnings"  >
               </div>

               <div id="" class="form-group col-sm-6  mb-3">
               <label for="date">Total</label>
                 <input type="number" class="form-control" name="total" id="exampleFormControlInput1" placeholder="Total"  >
               </div>
       




      
  
                <input type="hidden" name="datein" value="<?php echo $today ?>">
                <input type="hidden" name="by" value="<?php echo $id_user ?>">
                
                  <button class="btn btn-success btn-sm btn-block"  name="submit">Submit</button>
    </div>

</form>



        </div>
        <div class="modal-footer">
        </div>
      </div>
    </div>
  </div>


  <?php 


include('conn.php');


if(isset($_POST['submit'])){
 

     $date=$_POST['date'];
     $bar=$_POST['bar'];
     $restaurant=$_POST['restaurant'];
     $total=$_POST['total'];
     $by=$_POST['by'];
    $datein=$_POST['datein'];
  
 
		// Image db insert sql
		$sql = "INSERT INTO `account`( `date`, `bar`, `restaurant`,`total`, `by`, `datein`) VALUES ('$date','$bar','$restaurant','$total','$by','$datein')";
		if(mysqli_query($conn,$sql)){

      echo"<script>alert('sales successfully added ');</script>";
		}
		else{
		  echo 'Error: '.mysqli_error($conn);
		}

     }



?>


  </div>
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>

</body>
</html>
