<!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="" style="min-width: 745px">
                                        <thead>
                                            <tr>
                                                <th>Product Name</th>
                                               
                                                <th>Qty</th>
                                               
                                                
                                                <th>Date</th> 
                                                 <th>Action</th> 
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <?php if(!empty($get_recods_packing_in)){
     
                                        foreach ($get_recods_packing_in as $value) {  ?>
                                            <tr>
                                                <td><?php  echo material_name($value['material_id']); ?></td>
                                                    
                                                   <td><?php  echo $value['qty']; ?></td>
                                                   
                                                   <td><?php  echo  date("d-m-Y", strtotime($value['insert_date'])); ?></td>
                                                    
                                                 <td>
                                                  <a href="javascript:void(0);" onclick="delete_data(<?php echo $value['id']; ?>)" class="btn btn-sm btn-danger"><i class="la la-trash-o"></i></a>
                                              </td>  
                                                   
                                                                                             
                                            </tr>

                                            <?php }} ?>
                                           
                                        </tbody>
                                    </table>
                       
<script type="text/javascript">


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/delete_record_packing/'); ?>'+id,
                data:id,
                dataType:'json',
                success:function(data){
                    console.log('first'+data.status);
                    
                        console.log('second'+data.status);
                        //debugger;
                        /*$('#empolyee_danger').show().html('Empolyee Deleted Successfully');*/
                       setTimeout(function(){location.href="<?php echo base_url('Stock/update_stock'); ?>"} , 3000);
                    
                },
                error:function(data){console.log(data.responseText);}
            });
        } 

    }




    
   $(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 Semi Report</div>'
   
  },
{
    extend: 'pdf',
    title: 'Production Report'
  },
  ]
    } );

} );
</script>