<!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>Material</th>
                                                <!-- <th>Last Balance</th>
                                                <th>Qty Receive</th>
                                                <th>Qty Deliver</th> -->
                                                <th>Balance</th> 
                                                <!-- <th>Action</th> -->
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <?php if(!empty($get_products_raw)){
     
                                foreach ($get_products_raw as $value) {  ?>
                                            <tr>
                                                <td><?php  echo material_name($value['material_id']); ?></td>
                                                   <!--  <td><?php

                                                    // echo get_last_all_material_pack($value['material_id'])-get_out_all_pack($value['material_id']);
                                                     
                                                     /*
                                                     $get_log_stock_date = get_log_stock_created_date($value['product_id']);

                                                     $newDate_last = date("Y-m-d", strtotime($get_log_stock_date)); 
                                                      $today_in = date('Y-m-d');
                                                      if( $get_log_stock !="" && $newDate_last != $today_in ){

                                                            $out_Stock = all_get_out($value['product_id']);
                                                            echo $get_log_stock-get_out($value['product_id']);
                                                      }else{
                                                                echo 0;
                                                      }*/
                                                    ?></td>
                                                             
                                                    <td><?php 
                                                    $get_log_stock = get_last_packing($value['material_id']); 
                                                    $get_log_stock_date = get_last_created_date_packing($value['material_id']);
                                                    $newDate_in = date("Y-m-d", strtotime($get_log_stock_date)); 
                                                    $today_in = date('Y-m-d');

                                                    if($get_log_stock !="" && $newDate_in == $today_in){

                                                        //echo get_last($value['material_id']);
                                                    }else{
                                                      // echo get_last($value['material_id']);
                                                    }
                                                     ?></td>
                                                   
                                                    
                                                    <td><?php
                                                    $get_out_stock_date = get_last_created_date_out_packing($value['material_id']);
                                                    $newDate_out = date("Y-m-d", strtotime($get_out_stock_date)); 
                                                    $today_out = date('Y-m-d');
                                                     if($get_out_stock_date !="" && $newDate_out == $today_out){
                                                         //echo get_out_packing($value['material_id']);
                                                        }else {
                                                            //echo get_out_packing($value['material_id']);
                                                        }
                                                     ?></td> -->
                                                            
                                                    <td><?php 

                                                    echo get_in_balance_packing($value['material_id'])-get_out_balance_raw($value['material_id']); echo " Bags";
                                                   

                                                    ?></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 />Raw Material Report</div>'
   
  },
{
    extend: 'pdf',
    title: 'Production Report'
  },
  ]
    } );

} );
</script>