<?php

    include ("sidebar.php");

    include ("header.php");

    require_once('database.php');

    $q1="SELECT * from order_information 

    WHERE status='Ready_for_Delivery' OR status='Cooking_Now'  OR status='Out_for_Delivery' OR status='New Order'";

    $record=db::getRecords($q1);

?>

  <meta http-equiv="refresh" content="30; url="<?php echo $_SERVER['PHP_SELF']; ?>">

      <div class="content" >

        <div class="content">

          <div class="container-fluid" style="margin-top:-40px">

            <div class="row">

              <div class="col-md-12">

                <div class="card" style="min-height:550px;">

                    

                <div class="card-header card-header-info" style="background:#4F0B33"   >

                  <h4 class="card-title "  style="color:white">Active Orders</h4>

                </div>

                   <div class="material-datatables">          

  <table id="datatables" class="table table-striped table-no-bordered table-hover" style="width:100%">

    <thead>

      <tr>

        <th>Date</th>

        <th>Phone Number</th>

        <th>Address</th>

        <th>Floor</th>

        <th>Business Name</th>

        <th>Current Status</th>

        <th>Update Status</th>

        <th>Information</th>

         <th>Update</th>

      </tr>

    </thead>

    <tbody>

       

        <?php			

        if($record)

        {

	    	foreach($record as $data)

			{

             $id=$data["customer_id"];

             $q2="SELECT name,phone from customers where id='$id'";

             $rec2=db::getrecord($q2);

		?>

      <tr 
      <?php if($data["status"]=='New Order'){?> style="background: red;" <?php } ?>
      >

        <td><?php echo $data["date"]?></td>

         <td><?php echo $rec2["phone"];?></td>

        <td><?php echo $data["address"];?></td>

        <td><?php echo $data["floor"];?></td>

        <td><?php echo $data["business_name"];?></td>

        <td><?php echo $data["status"];?></td>

        <form method="POSt" action="action.php">

            <input name="order_id" type="hidden" value="<?php

                                 echo $data['order_id'];?>">

          <td>

              <select name="status" id="status" class="browser-default custom-select custom-select-sm" required>

              <option disabled selected>New Order</option>

              <option value="Cooking_Now">Cooking Now</option>

              <option value="Ready_for_Delivery"> Ready for Delivery</option>

              <option value="Out_for_Delivery">Out for Delivery</option>

              <option value="Delivered">Delivered</option>

              </select>

          </td>

          <td><input name="edit_status" type="submit" value="Submit"></td>

          </form>

        <td><i ><a href="order.php?id_orderid=<?php

         echo $data['order_id'];?>"><i class="material-icons">dvr</i></a></i></td>

     </tr>

        		<?php

											}

										}

										?>

     

    </tbody>

  </table>

  </div>

                      

                   

                          </div>

                    

                          </div>

                          </div>

                        </div>

           

              

                      </div>

                    </div>

                  



<?php

    include ("footer.php");

?>

