<html>
  <head>
    
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Rizwan </title>
    <!-- Favicon icon -->
    <link rel="icon" type="image/png" sizes="16x16" href="<?php echo base_url();?>assets/images/favicon.png">
    <link rel="stylesheet" href="<?php echo base_url();?>assets/vendor/bootstrap-select/dist/css/bootstrap-select.min.css">
    <link rel="stylesheet" href="<?php echo base_url();?>assets/css/style.css">
    <!-- Pick date -->
    <link rel="stylesheet" href="<?php echo base_url();?>assets/vendor/pickadate/themes/default.css">
    <link rel="stylesheet" href="<?php echo base_url();?>assets/vendor/pickadate/themes/default.date.css">
     <link href="<?php echo base_url();?>assets/vendor/datatables/css/jquery.dataTables.min.css" rel="stylesheet">
    <!-- Custom Stylesheet -->
    <style type="text/css">
  
 main {
  display: flex;
  justify-content: center;
}

table {
  max-width: 100%;
}

tr:nth-child(odd) {
  background-color: #eee;
}

th {
  background-color: #555;
  color: #fff;
}

th,
td {
  text-align: left;
  padding: 0.5em 1em;
}
</style> 

</head>
<body>
 


<?php 

$TotalNoOfRecords = count($get_products_production);
//print_r($TotalNoOfRecords);
$Count = 0;
 ?>

<div id="container">
  <div class="card-header">
                             <img src="<?php echo base_url();?>assets/logo.png" style="width:105px;"/><br/>
                                <span class="float-right">
                                    <strong>Production Compound Report -:</strong><?php echo date('d-m-Y') ?><br/>
                                   
                                      <strong> </strong></span>
                                </div>
     <main>
                                  <table id="tab">
                                        <thead>
                                            <tr style="font-size: 12px;">
                                                <th>Material</th>
                                                <th>Machine</th>
                                                <th>QCR</th>
                                                <th>Color Code</th>
                                                <th>Color Ratio</th>
                                                <th>QTY</th>
                                                <th>W Lot</th> 
                                                <th>Weight Wast</th>
                                                 <th>Date/Time</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <?php if(!empty($get_products_production)){
     
                                foreach ($get_products_production as $value) {  ?>
                                            <tr style="font-size: 13px;">
                                                <td><?php  echo material_name($value['material_id']); ?></td>
                                                    <td><?php
                                                         echo machine_name($value['machine_id']);
                                                    
                                                    ?></td>
                                                             
                                                    <td><?php 
                                                             echo $value['qcr'];
                                                     ?></td>
                                                    
                                                    <td><?php 
                                                             echo $value['color_code'];
                                                     ?></td>

                                                     <td><?php 
                                                             echo $value['color_ratio'];
                                                     ?></td>
                                                    
                                                    <td><?php
                                                             echo $value['qty'];
                                                              echo " Bag";
                                                     ?></td>
                                                            
                                                    <td><?php 

                                                             echo $value['wlot'];
                                                   

                                                    ?></td> 

                                                    <td><?php 

                                                             echo $value['weight_wast'];
                                                             echo " Kg";

                                                    ?></td> 

                                                    <td><?php 

                                                             echo $value['created'];
                                                   

                                                    ?></td> 
                                                                                             
                                            </tr>

                                            <?php }} ?>
                                           
                                        </tbody>
                                    </table>

                                  </main> 
                                 <input type="button" value="Print Table" onclick="myApp.printTable()" />
</div>

</body>
</html>
<script type="text/javascript">



 var myApp = new function () {
        this.printTable = function () {
            var tab = document.getElementById('tab');
            var win = window.open('', '', 'height=700,width=700');
            win.document.write(tab.outerHTML);
            win.document.close();
            win.print();
        }
    }




  function btnExport_monthly()
{
    
    var tab_text="<table border='2px'><tr bgcolor='#ebebeb'>";
    var textRange; var j=0;
    tab = document.getElementById('example5'); // id of table

    for(j = 0 ; j < tab.rows.length ; j++) 
    {     
        tab_text=tab_text+tab.rows[j].innerHTML+"</tr>";
        //tab_text=tab_text+"</tr>";
    }

    tab_text=tab_text+"</table>";
    tab_text= tab_text.replace(/<A[^>]*>|<\/A>/g, "");//remove if u want links in your table
    tab_text= tab_text.replace(/<img[^>]*>/gi,""); // remove if u want images in your table
    tab_text= tab_text.replace(/<input[^>]*>|<\/input>/gi, ""); // reomves input params


    var ua = window.navigator.userAgent;
    var msie = ua.indexOf("MSIE "); 

    if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./))      // If Internet Explorer
    {
        txtArea2.document.open("txt/html","replace");
        txtArea2.document.write(tab_text);
        txtArea2.document.close();
        txtArea2.focus(); 
        sa=txtArea2.document.execCommand("SaveAs",true,"Generation_School_Report");
    }  
    else                 //other browser not tested on IE 11
        sa = window.open('data:application/vnd.ms-excel,' + encodeURIComponent(tab_text));  

    return (sa);
}
</script>