<?php
session_start();
if(isset($_SESSION['user_email']))
{
    include ("sidebar.php");
    include ("header.php");
    require_once('database.php');
    $user_email=$_SESSION['user_email'];
    $query= "SELECT id FROM customers WHERE email='$user_email'";
    $user_id=db::getCell($query);
    $q1= "SELECT * FROM order_information WHERE customer_id='$user_id'";
    $u=db::getRecords($q1);
?>
  <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:#E93E21"   >
                  <h4 class="card-title "  style="color:white">My 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 style="width:10%">Date</th>
        <th style="width:25%">Address</th>
        <th style="width:15%">Business Name</th>
        <!--<th style="width:20%">Phone Number</th>-->
        <th style="width:10%">Status</th>
        <th style="width:10%">View Order</th>
      </tr>
    </thead>
    <tbody>
       
        <?php			
        if($u)
        {
	    	foreach($u as $data)
			{
             $id=$data["customer_id"];
             $q2="SELECT name,phone FROM customers WHERE id='$id'";
             $rec2=db::getRecord($q2);
             $icon=$data["status"];
		?>
      <tr>
        <td><?php echo $data["date"];?></td>
        <td><?php echo $data["address"];?></td>
        <td><?php echo $data["business_name"];?></td>
        <!--<td><?php echo $rec2["phone"];?></td>-->
        <td>
        <?php if($icon==Cooking_Now){?>
        <img src="images/cook.png" style="height:40px;width:50px">
        <?php } elseif($icon==Ready_for_Delivery){?> 
        <img src="images/ready.png" style="height:40px;width:50px">
        <?php } elseif($icon==Out_for_Delivery){?> 
        <img src="images/delievery.jpg" style="height:40px;width:50px">
       <?php } elseif($icon==Delivered){?> 
        <img src="images/thank.png" style="height:50px;width:60px">
         <?php } else{?>
        Ordered
        <?php } ?>
        </td>
        <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");
    }
else
{
   echo "<script>
            window.location.href = '../index.php';
            </script>";
}
?>
