<?php include("conn.php");
$page='Online order history';?>
<!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-->
            <div id="accordions" class="col-sm-12  mt-2">
  
                <!--search section end-->
                <!--Orders start-->

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

               <!--order-items-three-->
               <div  class="orders m-0 " >
                <h5 class="text-center text-uppercase">Online Order History</h5>
                <table id="example_table" class="table-customer table-striped   w-100 table-bordered">
                        <thead>
                        <tr>
                            <th>Id</th>
                            <th>Customer name</th>
                            <th style="display:<?php echo  $view_cash ?>;">Amount</th>
                            <th>Status</th>
                            <th>Order Date</th>
                            <th>print</th>
                            <th style="display:<?php echo  $view_cash ?>;">Details</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_details where order_type=1";
$result = mysqli_query($conn,$sql)or die( mysqli_error($conn));
while ($row=mysqli_fetch_array($result)) {
 $data=$row['orderid'];
   $customer_name=$row['costomer_name'];
   $price=$row['amount'];
   $status=$row['status'];
   $order_type=$row['order_type'];
   
if ($order_type==1) {
 $order_type='Online Order';
}
else{
  $order_type='In Store Order';
}

   $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';
}
$link="print/order_print.php?item=$data";
?>
                        <tr>
                            <td>#<?php echo $ord ?></td>
                            <td><?php echo $customer_name ?></td>
                            <td style="display:<?php echo  $view_cash ?>;"><?php echo $currency ."". number_format($price,2) ?></td>
                            <td><button class=" btn <?php echo $read ?>"><?php echo $text ?></button></td>
                            <td><?php echo $date ?></td>
                            <td><a href="<?=$link; ?>" class="btn btn-success btn-sm me-1"><i class="fa fa-print"></i></a></td>
                            <td style="display:<?php echo  $view_cash ?>;">
                            

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


                        </tr>
                        <?php } ?>
                        <thead>
                        <th>Id</th>
                            <th>Customer name</th>
                            <th style="display:<?php echo  $view_cash ?>;">Amount</th>
                            <th>Status</th>
                            <th>Order Date</th>
                            <th>print</th>
                            <th style="display:<?php echo  $view_cash ?>;">Details</th>
                    </tbody>
                    </table>


            </div>

          


       <!--modal delete-->
<!-- Large modal -->
<div id="dataModal1" class="modal fade bd-example-modal-lg" tabindex="-1" data-backdrop="static" data-keyboard="false" 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>
    <!--  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-->
   <!-- jQuery Datatable js -->
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" ></script>
     <script src="https://cdn.datatables.net/2.0.5/js/dataTables.js"></script>
     <script src="https://cdn.datatables.net/buttons/3.0.2/js/dataTables.buttons.js"></script>
     <script src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.dataTables.js"></script>
     <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
     <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"></script>
     <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"></script>
     <script src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.html5.min.js"></script>
     <script src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.print.min.js"></script>

     <script>
      $(document).ready( function () {
        new DataTable('#example_table', {
            order:[[2,"asc"]],
            autoFill: true,
            pageLength : 10,
    lengthMenu: [[5, 10, 20, -1], [5, 10, 20, 'Todos']],
    layout: {
        topStart: {
            buttons: ['copy', 'csv', 'excel', 'pdf', 'print']
        }
    }
});
       } );
</script>
     <script>
       $(document).ready(function(){  
      $('.view_datas').click(function(){  
           var employee_ids = $(this).attr("id");  
           $.ajax({  
                url:"order_by_customer_ajax.php",  
                method:"post",  
                data:{employee_ids:employee_ids},  
                success:function(data){  
                     $('#employee_detail1').html(data);  
                     $('#dataModal1').modal("show");  
                }  
           });  
      });  
 });  
</script>
</body>

</html>