          <style>
            main {
                  padding: 1em;
                }

                .table-wrapper {
                  overflow: auto;
                  max-width: 100%;
                  background:
                    linear-gradient(to right, white 30%, rgba(255,255,255,0)),
                    linear-gradient(to right, rgba(255,255,255,0), white 70%) 0 100%,
                    radial-gradient(farthest-side at 0% 50%, rgba(0,0,0,.2), rgba(0,0,0,0)),
                    radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,.2), rgba(0,0,0,0)) 0 100%;
                  background-repeat: no-repeat;
                  background-color: white;
                  background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
                  background-position: 0 0, 100%, 0 0, 100%;
                  background-attachment: local, local, scroll, scroll;
                }

                tr {
                  border-bottom: 1px solid;
                }

                th {
                  background-color: #555;
                  color: #fff;
                  white-space: nowrap;
                }

                th,
                td {
                  text-align: left;
                   padding: 0.2em 0.5em;
                }

                .numeric {
                  text-align: center;
                }

                p {
                  text-align: right;
                  margin-top: 1em;
                  font-style: italic;
                }

                .tableFixHead          { overflow: auto; height: 500px; }
                  .tableFixHead thead th { position: sticky; top: 0; z-index: 1; }

                  /* Just common table stuff. Really. */
                  table  { border-collapse: collapse; width: 100%; }
                  th, td { padding: 8px 16px; }
                  th     { background:#555; }



            </style>

                                   <?php
                                    $sumtarget_hours = 0;
                                    $target_hours = 12;
                                    $material_weight_sum =0;
                                     $waste_weight_sum =0;
                                     $counter = 0;
                                     ?>

                                      <button class="btn btn-warning" onclick="PrintElem();">Print me</button>
                                      
                                    <main>

                                        <div class="table-wrapper tableFixHead" tabindex="0" id="container">
                                           <h3 style="text-align: center;">Day Report - <?php echo date("d-m-Y", strtotime($get_day_night[0]['report_date']));  ?></h3>
                                          <table border="1" style="font-size: 10px;">

                                                <thead>
                                                    <tr >
                                                        
                                                        
                                                        <th>Machine</th>
                                                        <th>Product</th>
                                                        <th>Material</th>
                                                        <th>Job#</th>
                                                        <th>Target-Hours</th>
                                                        <th>P-Hour</th> 
                                                        <th>L-Hours</th>
                                                        <th>T-Prod</th>
                                                        <th>M-Weight</th>
                                                        <th>W-Weight</th>
                                                        <th>Lost Prod</th>
                                                        <th>C-H</th>
                                                        <th>Die-Pcs</th>
                                                        <th>10Min-R</th>
                                                        <th>Die Weight</th>
                                                        <th>Qty</th>
                                                        <th>1 HourProd</th>
                                                        <th>Cost/KG</th>
                                                        <th>%</th>
                                                      </tr>
                                                </thead>
                                                <tbody>
                                                   
                                                <?php if(!empty($get_day_night)){
                                                   foreach ($get_day_night as $value) { 
                                                   
                                                  $condition_injection_blow = condition_injection_blow($value['machine_id']);
                                                    if($condition_injection_blow == 2){
                                                    ?>
                                                    <tr>
                                                       
                                                <td><?php echo machine_name($value['machine_id']); ?></td>
                                                <td><?php echo product_name($value['product_id']); ?></td>
                                                <td><?php echo material_name($value['material_id']); ?></td>
                                                <td><?php echo $value['job']; ?></td>
                                            <td class="numeric">
                                                <?php $sumtarget_hours+= $target_hours; echo  $target_hours; ?>
                                                    
                                                </td>
                                            <td class="numeric"><?php echo $value['hrs']; ?></td>
                                            <td class="numeric"><?php echo $target_hours-$value['hrs']-$value['c_h'];?></td>
                                            <td class="numeric"><?php  $target_p = $target_hours*$value['hr'];
                                           //echo substr($target_p, 0,4);
                                           echo number_format((float)$target_p, 1, '.', ''); 
                                            ?></td>
                                            <td class="numeric">
                                                <?php 
                                                $material_weigt = $value['m_weight'];
                                                $total_m_t =  $material_weight_sum+=$material_weigt; 
                                                 echo $value['m_weight']; ?>
                                                    
                                                </td>
                                            <td class="numeric">
                                                <?php 
                                                $waste_weigt = $value['w_weight'];
                                                echo $value['w_weight'];
                                                 
                                                 $total_w_w =  $waste_weight_sum+=$waste_weigt; 
                                                
                                                ?>
                                                    
                                                </td>
                                            <td class="numeric"><?php  
                                            $lost_pro = $target_p-$value['m_weight'];
                                           // echo substr($lost_pro,  2, 1);
                                            echo number_format((float)$lost_pro, 1, '.', ''); 
                                             ?></td>
                                            <td class="numeric"><?php echo $value['c_h']; ?></td>
                                            <td class="numeric"><?php echo $value['pcs_cavity']; ?></td>

                                            <td class="numeric"><?php echo $value['mr_mould']; ?></td>
                                            
                                            <td class="numeric"><?php echo $value['weight']; ?></td>
                                            <td class="numeric"><?php $qty = $value['m_weight']/$value['weight'];
                                            echo number_format((float)$qty, 2, '.', ''); 
                                            ?></td>
                                            <td class="numeric"><?php echo $value['hr']; ?></td>
                                            <td class="numeric"><?php echo $value['cost']; ?></td>
                                              <td class="numeric"><?php $percent = $value['m_weight']/$target_p*100;
                                             // echo $percent;
                                              echo number_format((float)$percent, 1, '.', ''); 
                                              ?></td>         
                                                    </tr>
                                                <?php  $counter++; } } ?>

                                            <tr>
                                                <td><b>Total</b></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td class="numeric"><?php echo $sumtarget_hours;  ?></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td class="numeric"><?php echo $total_m_t;  ?></td>
                                                <td class="numeric"><?php echo $total_w_w;  ?></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>

                                            </tr>
                                            <?php } ?>
                                            <tr>
                                                <td></td>
                                                <td></td>
                                                <td style="width: 50%;"><b>Total Machine Runing</b></td>

                                                <td class="numeric">
                                                    <?php 
                                                    echo $count_active_machine[0]['count_active_machines'];
                                                    ?>
                                                        
                                                    </td>
                                            </tr>
                                                </tbody>

                                            </table> 
                                        
                                         <br/>

                                             <h3 style="text-align: center;">Night Report  - <?php echo date("d-m-Y", strtotime($get_day_night[0]['report_date']));  ?></h3>
                            
                                    <table id="" border="1"  style="font-size: 10px;">
                                     

                                                <thead>
                                                    <tr >
                                                        
                                                        
                                                        <th>Machine</th>
                                                        <th>Product</th>
                                                        <th>Material</th>
                                                        <th>Job#</th>
                                                        <th>Target-Hours</th>
                                                        <th>P-Hour</th> 
                                                        <th>L-Hours</th>
                                                        <th>T-Prod</th>
                                                        <th>M-Weight</th>
                                                        <th>W-Weight</th>
                                                        <th>Lost Prod</th>
                                                        <th>C-H</th>
                                                        <th>Die-Pcs</th>
                                                        <th>10Min-R</th>
                                                        <th>Die Weight</th>
                                                        <th>Qty</th>
                                                        <th>1 HourProd</th>
                                                        <th>Cost/KG</th>
                                                        <th>%</th>
                                                      </tr>
                                                </thead>
                                                <tbody>
                                                   
                                                <?php if(!empty($get_day_night_night)){
                                                   foreach ($get_day_night_night as $value) { ?>
                                                   
                                                   <?php $condition_injection_blow = condition_injection_blow($value['machine_id']);
                                                    if($condition_injection_blow == 2){ ?>
                                                    <tr>
                                                        
                                                    
                                                       
                                            <td><?php echo machine_name($value['machine_id']); ?></td>
                                            <td><?php echo product_name($value['product_id']); ?></td>
                                            <td><?php echo material_name($value['material_id']); ?></td>
                                             <td><?php echo $value['job']; ?></td>
                                            <td class="numeric">12</td>
                                            <td class="numeric"><?php echo $value['hrs']; ?></td>
                                            <td class="numeric"><?php echo $target_hours-$value['hrs']-$value['c_h'];?></td>
                                            <td class="numeric"><?php  $target_p = $target_hours*$value['hr'];
                                          // echo substr($target_p, 0,4);
                                            echo number_format((float)$target_p, 1, '.', '');
                                            ?></td>
                                            <td class="numeric"><?php echo $value['m_weight']; ?></td>
                                            <td class="numeric"><?php echo $value['w_weight']; ?></td>
                                             <td class="numeric"><?php  
                                            $lost_pro = $target_p-$value['m_weight'];
                                           // echo substr($lost_pro,  2, 1);
                                            echo number_format((float)$lost_pro, 1, '.', ''); 
                                             ?></td>
                                            <td class="numeric"><?php echo $value['c_h']; ?></td>
                                            <td class="numeric"><?php echo $value['pcs_cavity']; ?></td>

                                            <td class="numeric"><?php echo $value['mr_mould']; ?></td>
                                            
                                            <td class="numeric"><?php echo $value['weight']; ?></td>
                                            <td class="numeric"><?php $qty = $value['m_weight']/$value['weight'];
                                            echo number_format((float)$qty, 2, '.', ''); 
                                            ?></td>
                                            <td class="numeric"><?php echo $value['hr']; ?></td>
                                            <td class="numeric"><?php echo $value['cost']; ?></td>
                                              <td class="numeric"><?php $percent = $value['m_weight']/$target_p*100;
                                             // echo $percent;
                                              echo number_format((float)$percent, 1, '.', ''); 
                                              ?></td>
                                                       
                                                    </tr>
                                                <?php } } }?>
                                                
                                                
                                                <tr>
                                                <td><b>Total</b></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td class="numeric"><?php echo $sumtarget_hours;  ?></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td class="numeric"><?php echo @$total_m_t;  ?></td>
                                                <td class="numeric"><?php echo @$total_w_w;  ?></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>

                                            </tr>
                                           
                                            <tr>
                                                <td></td>
                                                <td></td>
                                                <td style="width: 50%;"><b>Total Machine Runing</b></td>

                                                <td class="numeric">
                                                    <?php 
                                                    echo $count_active_machine[0]['count_active_machines'];
                                                    ?>
                                                        
                                                    </td>
                                            </tr>
                                                </tbody>

                                            </table>  
                                              </div>  </main>
                                              
                                              
                                              
                                              
                                              
                                                <?php
                                    $sumtarget_hours = 0;
                                    $target_hours = 12;
                                    $material_weight_sum =0;
                                     $waste_weight_sum =0;
                                     $counter = 0;
                                     ?>

                                      <button class="btn btn-warning" onclick="PrintElem1();">Print me</button>
                                      
                                    <main>

                                        <div class="table-wrapper tableFixHead" tabindex="0" id="container1">
                                           <h3 style="text-align: center;">Day Report  - <?php echo date("d-m-Y", strtotime($get_day_night[0]['report_date']));  ?></h3>
                                          <table border="1" style="font-size: 11px;">

                                                <thead>
                                                    <tr >
                                                        
                                                        
                                                        <th>Machine</th>
                                                        <th>Product</th>
                                                        <th>Material</th>
                                                        <th>Job#</th>
                                                        <th>Target-Hours</th>
                                                        <th>P-Hour</th> 
                                                        <th>L-Hours</th>
                                                        <th>T-Prod</th>
                                                        <th>M-Weight</th>
                                                        <th>W-Weight</th>
                                                        <th>Lost Prod</th>
                                                        <th>C-H</th>
                                                        <th>Die-Pcs</th>
                                                        <th>10Min-R</th>
                                                        <th>Die Weight</th>
                                                        <th>Qty</th>
                                                        <th>1 HourProd</th>
                                                        <th>Cost/KG</th>
                                                        <th>%</th>
                                                      </tr>
                                                </thead>
                                                <tbody>
                                                   
                                                <?php if(!empty($get_day_night)){
                                                   foreach ($get_day_night as $value) { 
                                                   
                                                  $condition_injection_blow = condition_injection_blow($value['machine_id']);
                                                    if($condition_injection_blow == 1 || $condition_injection_blow == 3){
                                                    ?>
                                                    <tr>
                                                       
                                                <td><?php echo machine_name($value['machine_id']); ?></td>
                                                <td><?php echo product_name($value['product_id']); ?></td>
                                                <td><?php echo material_name($value['material_id']); ?></td>
                                                <td><?php echo $value['job']; ?></td>
                                            <td class="numeric">
                                                <?php $sumtarget_hours+= $target_hours; echo  $target_hours; ?>
                                                    
                                                </td>
                                            <td class="numeric"><?php echo $value['hrs']; ?></td>
                                            <td class="numeric"><?php echo $target_hours-$value['hrs']-$value['c_h'];?></td>
                                            <td class="numeric"><?php  $target_p = $target_hours*$value['hr'];
                                           //echo substr($target_p, 0,4);
                                           echo number_format((float)$target_p, 1, '.', ''); 
                                            ?></td>
                                            <td class="numeric">
                                                <?php 
                                                $material_weigt = $value['m_weight'];
                                                $total_m_t =  $material_weight_sum+=$material_weigt; 
                                                 echo $value['m_weight']; ?>
                                                    
                                                </td>
                                            <td class="numeric">
                                                <?php 
                                                $waste_weigt = $value['w_weight'];
                                                echo $value['w_weight'];
                                                 
                                                 $total_w_w =  $waste_weight_sum+=$waste_weigt; 
                                                
                                                ?>
                                                    
                                                </td>
                                            <td class="numeric"><?php  
                                            $lost_pro = $target_p-$value['m_weight'];
                                           // echo substr($lost_pro,  2, 1);
                                            echo number_format((float)$lost_pro, 1, '.', ''); 
                                             ?></td>
                                            <td class="numeric"><?php echo $value['c_h']; ?></td>
                                            <td class="numeric"><?php echo $value['pcs_cavity']; ?></td>

                                            <td class="numeric"><?php echo $value['mr_mould']; ?></td>
                                            
                                            <td class="numeric"><?php echo $value['weight']; ?></td>
                                            <td class="numeric"><?php $qty = $value['m_weight']/$value['weight'];
                                            echo number_format((float)$qty, 2, '.', ''); 
                                            ?></td>
                                            <td class="numeric"><?php echo $value['hr']; ?></td>
                                            <td class="numeric"><?php echo $value['cost']; ?></td>
                                              <td class="numeric"><?php $percent = $value['m_weight']/$target_p*100;
                                             // echo $percent;
                                              echo number_format((float)$percent, 1, '.', ''); 
                                              ?></td>         
                                                    </tr>
                                                <?php  $counter++; } } ?>

                                            <tr>
                                                <td><b>Total</b></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td class="numeric"><?php echo $sumtarget_hours;  ?></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td class="numeric"><?php echo $total_m_t;  ?></td>
                                                <td class="numeric"><?php echo $total_w_w;  ?></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>

                                            </tr>
                                            <?php } ?>
                                            <tr>
                                                <td></td>
                                                <td></td>
                                                <td style="width: 50%;"><b>Total Machine Runing</b></td>

                                                <td class="numeric">
                                                    <?php 
                                                    echo $count_active_machine[0]['count_active_machines'];
                                                    ?>
                                                        
                                                    </td>
                                            </tr>
                                                </tbody>

                                            </table> 
                                        
                                         <br/><br/>

                                             <h3 style="text-align: center;">Night Report  - <?php echo date("d-m-Y", strtotime($get_day_night[0]['report_date']));  ?></h3>
                            
                                    <table id="" border="1"  style="font-size: 11px;">
                                     

                                                <thead>
                                                    <tr >
                                                        
                                                        
                                                        <th>Machine</th>
                                                        <th>Product</th>
                                                        <th>Material</th>
                                                        <th>Job#</th>
                                                        <th>Target-Hours</th>
                                                        <th>P-Hour</th> 
                                                        <th>L-Hours</th>
                                                        <th>T-Prod</th>
                                                        <th>M-Weight</th>
                                                        <th>W-Weight</th>
                                                        <th>Lost Prod</th>
                                                        <th>C-H</th>
                                                        <th>Die-Pcs</th>
                                                        <th>10Min-R</th>
                                                        <th>Die Weight</th>
                                                        <th>Qty</th>
                                                        <th>1 HourProd</th>
                                                        <th>Cost/KG</th>
                                                        <th>%</th>
                                                      </tr>
                                                </thead>
                                                <tbody>
                                                   
                                                <?php if(!empty($get_day_night_night)){
                                                   foreach ($get_day_night_night as $value){ ?>
                                                   
                                                   <?php 
                                                   $condition_injection_blow = condition_injection_blow($value['machine_id']);
                                                    if($condition_injection_blow ==1 || $condition_injection_blow == 3){ ?>
                                                    <tr>
                                                       
                                            <td><?php echo machine_name($value['machine_id']); ?></td>
                                            <td><?php echo product_name($value['product_id']); ?></td>
                                            <td><?php echo material_name($value['material_id']); ?></td>
                                             <td><?php echo $value['job']; ?></td>
                                            <td class="numeric">12</td>
                                            <td class="numeric"><?php echo $value['hrs']; ?></td>
                                            <td class="numeric"><?php echo $target_hours-$value['hrs']-$value['c_h'];?></td>
                                            <td class="numeric"><?php  $target_p = $target_hours*$value['hr'];
                                          // echo substr($target_p, 0,4);
                                            echo number_format((float)$target_p, 1, '.', '');
                                            ?></td>
                                            <td class="numeric"><?php echo $value['m_weight']; ?></td>
                                            <td class="numeric"><?php echo $value['w_weight']; ?></td>
                                             <td class="numeric"><?php  
                                            $lost_pro = $target_p-$value['m_weight'];
                                           // echo substr($lost_pro,  2, 1);
                                            echo number_format((float)$lost_pro, 1, '.', ''); 
                                             ?></td>
                                            <td class="numeric"><?php echo $value['c_h']; ?></td>
                                            <td class="numeric"><?php echo $value['pcs_cavity']; ?></td>

                                            <td class="numeric"><?php echo $value['mr_mould']; ?></td>
                                            
                                            <td class="numeric"><?php echo $value['weight']; ?></td>
                                            <td class="numeric"><?php $qty = $value['m_weight']/$value['weight'];
                                            echo number_format((float)$qty, 2, '.', ''); 
                                            ?></td>
                                            <td class="numeric"><?php echo $value['hr']; ?></td>
                                            <td class="numeric"><?php echo $value['cost']; ?></td>
                                              <td class="numeric"><?php $percent = $value['m_weight']/$target_p*100;
                                             // echo $percent;
                                              echo number_format((float)$percent, 1, '.', ''); 
                                              ?></td>
                                                       
                                                    </tr>
                                                <?php } } } ?>
                                                </tbody>

                                            </table>  
                                              </div>  </main>


                                              <script type="text/javascript">
                                                
                                                function PrintElem(elem)
                                                {
                                                    var mywindow = window.open('', 'PRINT', 'height=400,width=600');

                                                    mywindow.document.write('<html><head>');
                                                    mywindow.document.write("<style>.table-wrapper {overflow:auto;max-width:100%;background:linear-gradient(to right,white 30%, rgba(255,255,255,0)),linear-gradient(to right, rgba(255,255,255,0), white 70%) 0 100%, radial-gradient(farthest-side at 0% 50%, rgba(0,0,0,.2), rgba(0,0,0,0)),radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,.2), rgba(0,0,0,0)) 0 100%;background-repeat: no-repeat;background-color: white;background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;background-position: 0 0, 100%, 0 0, 100%;background-attachment: local, local, scroll, scroll;}th {background-color: #555;color: #fff;white-space: nowrap;}.numeric {text-align: center;}</style>")
                                                    mywindow.document.write('</head><body >');
                                                    mywindow.document.write(document.getElementById('container').innerHTML);
                                                    mywindow.document.write('</body></html>');

                                                    mywindow.document.close(); // necessary for IE >= 10
                                                    mywindow.focus(); // necessary for IE >= 10*/


                                                    setTimeout(function () {
                                                    mywindow.print();
                                                    mywindow.close();
                                                    }, 1000)
                                                    return true;
                                                }
                                                
                                                
                                                function PrintElem1(elem)
                                                {
                                                    var mywindow = window.open('', 'PRINT', 'height=400,width=600');

                                                    mywindow.document.write('<html><head>');
                                                    mywindow.document.write("<style>.table-wrapper {overflow:auto;max-width:100%;background:linear-gradient(to right,white 30%, rgba(255,255,255,0)),linear-gradient(to right, rgba(255,255,255,0), white 70%) 0 100%, radial-gradient(farthest-side at 0% 50%, rgba(0,0,0,.2), rgba(0,0,0,0)),radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,.2), rgba(0,0,0,0)) 0 100%;background-repeat: no-repeat;background-color: white;background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;background-position: 0 0, 100%, 0 0, 100%;background-attachment: local, local, scroll, scroll;}th {background-color: #555;color: #fff;white-space: nowrap;}.numeric {text-align: center;}</style>")
                                                    mywindow.document.write('</head><body >');
                                                    mywindow.document.write(document.getElementById('container1').innerHTML);
                                                    mywindow.document.write('</body></html>');

                                                    mywindow.document.close(); // necessary for IE >= 10
                                                    mywindow.focus(); // necessary for IE >= 10*/


                                                    setTimeout(function () {
                                                    mywindow.print();
                                                    mywindow.close();
                                                    }, 1000)
                                                    return true;
                                                }
                                            </script>
                                 