 <button class="btn btn-warning" onclick="printData1();">Print me</button>
  <button type="button" class="btn btn-rounded btn-success" style="margin-left:10px;" onclick="btnExport_monthly();">
    <span class="btn-icon-left text-success"><i class="fa fa-download color-success"></i>
 </span>Download</button> <br/> <br/>
 
 <div class="table-responsive" id="container">


                                
                                     <table id="example5" border="1"  style="min-width: 1000px">
                                     

                                                <thead>
                                                    <tr style="background: #71A79D; font-size: 13px;">
                                                                                                                
                                                        <th style="text-align: center;color:#fff;  width: 265px;">Name</th>
                                                        <th style="text-align: center;color:#fff;  width: 135px;">Total Attendance</th>
                                                        <th style="text-align: center;color:#fff;  width: 115px;">Absents</th>
                                                        <th style="text-align: center;color:#fff;  width: 115px;">Total Late</th>
                                                        <th style="text-align: center;color:#fff;  width: 115px;">Mistap</th>
                                                        <th style="text-align: center;color:#fff;  width: 115px;">Total Salary</th>
                                                        <th style="text-align: center;color:#fff;  width: 115px;">Total Over Time</th>
                                                        <th style="text-align: center;color:#fff;  width: 122px;">Over Time Amount</th>
                                                        <th style="text-align: center;color:#fff;  width: 115px;">Advance</th>
                                                        <th style="text-align: center;color:#fff;  width: 115px;">Monthly Tea/Petrol </th>
                                                       <!--  <th style="text-align: center;color:#fff;  width: 115px;">Take Allowance</th> -->
                                                        <th style="text-align: center;color:#fff;  width: 145px;">Total Salary With Deduction </th>
                                                       
                                                      </tr>
                                                </thead>
                                                <tbody>
                                               <?php

                                                  $workDays = 0;
                                                  $datecounter=0;
                                                  $total_amount1 =0;
                                                  $total_amount =0;
                                                  $all_total=0;
                                                   foreach ($filter_data as $value) { ?>
                                                		
                                                	<tr>
                                                		
                                                		<td style="text-align: center; font-size: 13px;">
                                                      <img class="mr-3 rounded-circle" alt="image" width="50" src="<?php echo base_url('assets/images/profile/'.images($value['emp_id'])); ?>">
                                                      <b><?php echo fullname($value['emp_id']); ?></b></td>

                                                		<td style="text-align: center; background-color: #71A78F;"><b><?php echo $value['count_data']; ?></b></td>

                                                		<td style="text-align: center;"><?php 

                                                		$present = $value['count_data'];
                                                        $mydate = $value['date'];
                                                   $mydate = $value['date'];
                                                    $myTime = strtotime($mydate);
                                                		$month = date("m",strtotime($mydate));
                                                    $year = date("Y",strtotime($mydate));
                                                     

                                                                        
                                                    $sundays=0;
                                                    $total_days=cal_days_in_month(CAL_GREGORIAN, $month, $year);
                                                    for($i=1;$i<=$total_days;$i++)
                                                    if(date('N',strtotime($year.'-'.$month.'-'.$i))==7)
                                                    $sundays++;
                                                    
                                                    $days=cal_days_in_month(CAL_GREGORIAN,$month,$year);
                                                     $Total_days = $days-$sundays;
                                                      echo  $Total_days-$present;



                                                		 ?></td>
                                                     <td style="text-align: center; background-color: #f76149;" ><b>
                                                       <?php  
                                                       $tapin =  get_emp_time($value['emp_id']);
                                                       
                                                       $system = $value['emp_id'];
                                                       $month1 = date("m",strtotime($mydate));
                                                       $year1 = date("Y",strtotime($mydate));

                                                       $systemtapin = get_systemtaps($tapin,$system,$month1,$year1);

                                                       echo $systemtapin;

                                                        ?>


                                                     </b></td>

                                                     <td style="text-align: center;">
                                                       <?php 

                                                           $get_tap_out =  get_tap_out($system,$mydate);
                                                           echo $get_tap_out;
                                                       ?>

                                                     </td>
                                                     <td style="text-align: center;">
                                                       
                                                       <?php echo "Rs/= "; echo salary_emp($value['emp_id']); ?>
                                                     </td>

                                                     <td  style="text-align: center;"><?php echo count_ot($value['emp_id'],$month1,$year1); ?></td>
                                                     <td  style="text-align: center;"><?php 
                                                     $over_time =  get_over_time($value['emp_id']); 
                                                     $ot = count_ot($value['emp_id'],$month1,$year1);

                                                     echo $ot*$over_time;
                                                     ?></td> 
                                                     <td style="text-align: center;"><?php echo total_advance($value['emp_id'],$month1,$year1); ?></td>

                                                     <td style="text-align: center;"><?php echo check_allowance($value['emp_id']); ?></td>

                                                     <!-- <td style="text-align: center;"><?php echo total_allowance(@$value['emp_id'],$month1,$year1); ?></td> -->


                                                      <td style="text-align: center; color:#fff; background-color: #71a72b;">
                                                       
                                                       <?php
                                                             $total_Salary =  salary_emp($value['emp_id']);

                                                             $perday_Salary = $total_Salary / 30;
                                                              $total_absent = $Total_days-$present;


                                                             $perday =  $perday_Salary * 30;

                                                             $per1 = $total_absent*$perday_Salary;

                                                             $total_making = $perday-$per1;

                                                           
                                                              
                                                             $latetotal = $systemtapin/5;

                                                            

                                                             if($latetotal >= 1){
                                                             $total_lates = (int)$latetotal;



                                                             $Totallates = $total_lates * $perday_Salary;
                                                              $res =  $Totallates; 

                                                               $advance = total_advance($value['emp_id'],$month1,$year1);
                                                                  $ot = get_over_time($value['emp_id']);
                                                                  $total_ot = count_ot($value['emp_id'],$month1,$year1);
                                                                  $res_ot = $total_ot * $ot;

                                                                  $allowance = total_allowance(@$value['emp_id'],$month1,$year1);
                                                                  $emp_allowance = check_allowance($value['emp_id']);

                                                              if($emp_allowance ==""){

                                                                 $result1 =  $total_making-$advance-$res+$res_ot;


                                                                  echo "Rs/= "; echo number_format($result1, 2, '.', ' ');


                                                              }else{

                                                                    if($allowance==""){

                                                                        $result1 =  $total_making-$advance-$res+$res_ot+$emp_allowance;


                                                                      echo "Rs/= "; echo number_format($result1, 2, '.', ' ');

                                                                    }else{

                                                                        $result1 =  $total_making-$advance-$res+$res_ot;


                                                                       echo "Rs/= "; echo number_format($result1, 2, '.', ' ');
                                                                    }
                                                                     

                                                              }

                                                            

                                                             @$total_amount+=$result1;
                                                              $all_total = $total_amount;
                                                            }else{
                                                             $res1 = $total_absent;
                                                              $advance = total_advance($value['emp_id'],$month1,$year1);
                                                               $ot = get_over_time($value['emp_id']);
                                                              $total_ot = count_ot($value['emp_id'],$month1,$year1);
                                                              $res_ot = $total_ot * $ot;

                                                               $allowance = total_allowance($value['emp_id'],$month1,$year1);
                                                                  $emp_allowance = check_allowance($value['emp_id']);

                                                              if($emp_allowance ==""){

                                                                 $result2 = $total_making-$advance+$res_ot; 


                                                                  echo "Rs/= "; echo number_format($result2, 2, '.', ' ');


                                                              }else{

                                                                    if($allowance =="0"){

                                                                         $result2 = $total_making-$advance+$res_ot+$emp_allowance; 
                                                                         echo "Rs/= "; echo number_format($result2, 2, '.', ' ');

                                                                    }else{

                                                                         $result2 = $total_making-$advance+$res_ot; 
                                                                          echo "Rs/= "; echo number_format($result2, 2, '.', ' ');
                                                                    }
                                                                     

                                                              }


                                                             

                                                                @$total_amount1+=$result2;
                                                                 $all_total = $total_amount1;
                                                               
                                                           }
                                                         ?>

                                                     </td>
                                                     
                                                	</tr>

                                                     
                                                	<?php $datecounter++; } ?>

                                                 <tr>
                                                   <td></td>
                                                   <td></td>
                                                   <td></td>
                                                   <td></td>
                                                   <td></td>
                                                   <td></td>
                                                   <td></td>
                                                   <td></td>
                                                   <td style="text-align: center;"><b>TOTAL AMOUNT</b></td>
                                                   <td style="text-align: center; "><?php echo $all_total; ?></td>

                                                 </tr>
                                                      
                                                </tbody>
                                     <script type="text/javascript">       
                                             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>   


                                            <script type="text/javascript">
                                                
                                                function printData1()
                                                {
                                                   var divToPrint=document.getElementById("container");
                                                   newWin= window.open("");
                                                   newWin.document.write(divToPrint.outerHTML);
                                                   newWin.print();
                                                   newWin.close();
                                                }
                                            </script>