<?php include("conn.php");
$page='Order Status Management';?>
<!DOCTYPE html>
<html lang="en">
<?php include("common/head.php")?>
<body>
<?php include("common/menu.php")?>
<!---side nav bar end-->
<?php include("common/tittle.php")?>
            <!--Main body Start-->
            <!--Nav menu end-->

            <!--Main body Start-->
            <div id="accordions" class="col-sm-12  mt-2">
              
      <center>
        <div class="row no-gutters">
            <div class="col-sm-12">
                <div id="filters" class="d-flex button-group">
                    <div class="col-sm-2 ">
                        <a  href="orders"class=" btn-order  text-center btn ">
                            <i class="fa fa-hourglass-half" aria-hidden="true"></i>
                            <p class="text-center order-text-order-managment">Orders</p>
                        </a>
                    </div>
                    <div class="col-sm-2 ">
                        <a  href="order_status" class="btn-order bg-primary text-center btn ">
                            <i class="fa fa-check-square-o" aria-hidden="true"></i>
                            <p class="text-center order-text-order-managment">Order Status</p>
                        </a>
                    </div>
                    <div class="col-sm-2 ">
                        <a href="order_by_customer"class=" btn-order   collapsed text-center btn ">
                            <i class="fa fa-times" aria-hidden="true"></i>
                            <p class="text-center order-text-order-managment">Orders By Customer</p>
                        </a>
                    </div>
                    <div class="col-sm-2 ">
                        <a href="#collapseFour" class="collapsed btn-order    text-center btn " >
                            <i class="fa fa-cog" aria-hidden="true"></i>
                            <p class="text-center order-text-order-managment">Settings</p>
                        </a>
                    </div>
                  
                </div>
            </div>
        </div>
      
      </center> 
      <hr class="bg-success">
                <!--search section end-->
                <!--Orders start-->

                <!--order-items-->
                <!--order-items-one-->
            
                   <!--order-items-two-->
             

               <!--order-items-three-->
               <div  class="orders " >
                <h5 class="text-center"> Orders by Customers</h5>
               
                <table id="example_table" class="table-customer table-striped table-hover  w-100 table-bordered">
                        <thead>
                        <tr>
                            <th>Id</th>
                            <th>Item name</th>
                            <th>Quantity</th>
                            <th>Amount</th>
                            <th>Date</th>
                            <th>Status</th>
                            <th>Action</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php

$sql2="SELECT * FROM currency ";
$result2 = mysqli_query($conn,$sql2)or die( mysqli_error($conn));
$row2=mysqli_fetch_array($result2) ;
$currency=$row2['curency'];

$sql="select * from orders order by id desc";
$result = mysqli_query($conn,$sql)or die( mysqli_error($conn));
while ($row=mysqli_fetch_array($result)) {
 $data=$row['orderid'];
   $itme_name=$row['item_name'];
   $quantity=$row['quantity'];
   $price=$row['price'];
   $status=$row['status'];
   
   $real_id=substr($data,-2);
$ord = sprintf('%03d',$real_id);   

 $link="delete/del_blog.php?id=".urlencode(base64_encode($data));
 $edit_user="edit/edit_user.php?id=".urlencode(base64_encode($data));
 $activate="edit/user_status.php?id=".urlencode(base64_encode($data));
 $dat=$data;
 $sql1="select * from orders_details where orderid='$data' ";
              $result1 = mysqli_query($conn,$sql1)or die( mysqli_error($conn));
              $row1=mysqli_fetch_array($result1);

              $date=$row1['date'];
 $text='';

 if ($status==='1') {
   $text='Deliverd';
   $read='btn-success';
   $de='deactivate';
   $sta=0;
 }
elseif ($status==='0') {
    $text='Inprogress';
    $read='btn-warning';
}
elseif ($status==='2') {
    $text='Cancelled';
    $read='btn-danger';
}
$amount='';
$amount=$price*$quantity;
?>
                        <tr>
                            <td>#<?php echo $ord ?></td>
                            <td><?php echo $itme_name ?></td>
                            <td><?php echo $quantity?></td>
                            <td><?php echo $currency ."". number_format($amount,2) ?></td>
                            <td><?php echo $date ?></td>
                            <td>
                           

                            <span  class="btn   <?php echo $read ?>  "><?php echo $text ?></span>
                        
                        
                        </td>
                            <td>
                                
                            <input  type="button" name="view" value="View" id="<?php echo $row["id"]; ?>" class="btn  btn-success btn-sm view_datas" />


                        </tr>
                        <?php } ?>
                        <thead>
                        <th>Id</th>
                            <th>Item name</th>
                            <th>Quantity</th>
                            <th>Amount</th>
                            <th>Date</th>
                            <th>Status</th>
                            <th>Action</th>
                    </tbody>
                    </table>

            </div>

        

          


       
<!--modal delete-->
<!-- Large modal -->
<div id="dataModal1" class="modal fade bd-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-lg">
    <div  id="employee_detail1" class="modal-content text-dark">
      
     
    
    </div>
  </div>
</div>
         
                <!--Order end-->
            </div>
            <!--Main body end-->

      
        </div>

    </div>
    
 
        <!--  isotope plugin cdn  -->
        <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.isotope/3.0.6/isotope.pkgd.min.js" integrity="sha256-CBrpuqrMhXwcLLUd5tvQ4euBHCdh7wGlDfNz8vbu/iI=" crossorigin="anonymous"></script>
    <script src="js/script.js"></script>
     <!-- jQuery js-->
 
     <!-- Bootstrap js -->
     <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
     <!-- jQuery Datatable js -->
     <script src="https://cdn.datatables.net/1.10.21/js/jquery.dataTables.min.js"></script>
     <!-- Bootstrap Datatable js -->    
     <script src="https://cdn.datatables.net/1.10.21/js/dataTables.bootstrap4.min.js"></script>
     <script>
       $(document).ready( function () {
           $('#example_table').DataTable();
       } );


   

       $(document).ready(function(){  
      $('.view_datas').click(function(){  
           var employee_ids = $(this).attr("id");  
           $.ajax({  
                url:"order_status_ajax.php",  
                method:"post",  
                data:{employee_ids:employee_ids},  
                success:function(data){  
                     $('#employee_detail1').html(data);  
                     $('#dataModal1').modal("show");  
                }  
           });  
      });  
 });  
</script>
</body>

</html>