<!DOCTYPE html>
<html lang="en">

<head>
    
    <link rel="stylesheet" href="https://cdn.datatables.net/1.10.25/css/jquery.dataTables.min.css">
     <link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.7.1/css/buttons.dataTables.min.css">
     
    <script src="https://code.jquery.com/jquery-3.5.1.js"></script>
    <script src="https://cdn.datatables.net/1.10.25/js/jquery.dataTables.min.js"></script>
    <script src="https://cdn.datatables.net/buttons/1.7.1/js/dataTables.buttons.min.js"></script>
    <script src="https://cdn.datatables.net/buttons/1.7.1/js/buttons.print.min.js"></script>

     

</head>
<body>


                                   <table  id="example" class="table table-striped table-bordered" >
                                        <thead>
                                            <tr >
                                                
                                                <th>SO No</th>
                                                <th>Company</th>
                                                <th>Product</th> 
                                                 <th>Deliverd Qty</th>
                                                 <th>Qty</th>
                                                 <th>Remaining Qty</th>
                                                <th>Status</th>
                                                <th>Delivery Date</th>
                                                <th>Gst Apply</th>
                                                <th>Action</th>
                                                
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <?php if(!empty($reporting_data)){
     
                                            foreach ($reporting_data as $all_get_po) {  ?>
                                          
                                            <tr style="font-size: 11px;">
                                                
                                               <td><strong><?php echo $all_get_po['so_no']; ?></strong></td>
                                                 <td><?php echo $all_get_po['party_name']; ?></td>
                                                 <td>
                                                  <?php

                                                  $product =  sale_order_pro($all_get_po['id']); 

                                                  echo product_name($product);

                                                 ?></td>

                                                  <td>
                                                    <?php  $deliver = deliverd_qty($all_get_po['id']); ?>
                                                    <?php if($deliver !=""){ ?>
                                                    <strong><?php echo $deliver; ?></strong>

                                                  <?php }else{ ?>

                                                  <?php echo "0"; } ?>
                                                  </td>


                                                 <td><?php echo qty_so($all_get_po['id']);


                                                  ?></td>

                                                  <td><?php  echo qty_so($all_get_po['id'])-$deliver;


                                                  ?></td>
                                                 <td>
                                                  <?php if($all_get_po['status']==0){ ?>
                                                  <strong><span class="badge badge-warning">
                                                    Open Order
                                                  </span></strong>
                                                <?php }else{ ?>

                                                   <strong><span class="badge badge-success">
                                                    Completed
                                                  </span></strong>

                                                <?php } ?>
                                                </td>
                                                <td>
                                                  <?php   


                                                  $date =  so_delivery_date($all_get_po['id']); 

                                                

                                                  echo date("d-m-Y", strtotime($date) ); 


                                                   ?></td>

                                                   <td> <?php $gst = gst_apply($all_get_po['id']); 

                                                   if($gst ==0 || $gst==""){ ?>

                                                    <span class="badge badge-danger">
                                                    No
                                                  </span>

                                                  <?php  }else{ ?>

                                                    <span class="badge badge-success">
                                                    Yes
                                                  </span>
                                                   <?php } ?></td>
                                               
                                                <td>
                                                  <a href="<?php echo base_url('Sales_order/view_invoice_details_so/'.$all_get_po['id']);?> " target="_blank"  class="badge badge-primary">View</a>

                                                  <a href="<?php echo base_url('Sales_order/view_dc_invoice/'.$all_get_po['id']);?> " target="_blank"  class="badge badge-primary">View DC</a>

                                                     <?php if($all_get_po['status']==0){ ?>
                                                 <!--  <button data-toggle="modal" data-target=".bd-example-modal-lg" class="badge badge-success" onclick="reciving_po(<?php //echo $all_get_po['id']; ?>);">Add Challan</button> -->
                                              <?php } ?>
                                               
                                                </td>                                  
                                            </tr>
                                               <?php } } ?>
                                           
                                        </tbody>
                                    </table>
                       
<script type="text/javascript">
    
   $(document).ready(function() {
    $('#example').DataTable( {

        dom: 'Bfrtip',
        buttons: [{
    extend: 'print',
     title:'<div style="text-align:center;"><h2>Rizwan Associates</h2></div><div style="text-align:center;font-size:15px;"><br />FG Report</div>'
   
  },
{
    extend: 'pdf',
    title: 'Production Report'
  },
  ]
    } );

} );


   function delete_data(id) { 
        var id = id;
        if (confirm('Are you sure you want to Delete.?')) {
  

        
         $.ajax({
                type:'POST',
                url:'<?php echo base_url('Stock/stock_fg_delete_data/'); ?>'+id,
                data:id,
                dataType:'json',
                success:function(data){
                    location.reload();
                    
                },
                error:function(data){console.log(data.responseText);}
            });

         //location.reload();

         } else {
  
            }
        } 
</script>