?
Current Path : /home1/savoy/public_html/savoyglobal.net/sgms/application/views/Timesheet/ |
Linux gator3171.hostgator.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64 |
Current File : /home1/savoy/public_html/savoyglobal.net/sgms/application/views/Timesheet/xls_report_invoice.php |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); $html='<html><head><body>'; $html.='<table width="100%"> <tr><td colspan="3" style="font-size:16px;" align="center"><b><u>Invoice Report</u></b></td></tr> </table><br><br>'; $html.='<hr>'; $html.='<table cellspacing="-1" style="width:100%;text-align:left"> <thead> <tr><td style="text-align:left" bgcolor="#7FCEFF">Sl No</td>'; foreach($report as $key=>$val) { $column_name = array_keys($val); } foreach($column_name as $key) $html .= '<td style="text-align:left" bgcolor="#7FCEFF">'.str_replace('_', ' ', $key).'</td>'; $html .='</tr></thead><tbody>'; $i=1; foreach($report as $rep) { //var_dump($rep); $inv=$this->mastermodel->get_data_srow('payroll_invoice',$rep['Total'],'invoice_id'); $start_date=$this->mastermodel->convertdateformat($inv->invoice_start_date); $end_date=$this->mastermodel->convertdateformat($inv->invoice_end_date); $poinfo=$this->timesheetmodel->get_job_info_single($inv->purchase_order_id); $client_timesheet=$this->timesheetmodel->get_client_timesheet_invoice_info($inv->purchase_order_id,$start_date,$end_date); $manpower_timesheet=$this->timesheetmodel->get_manpower_timesheet_invoice_info($inv->purchase_order_id,$start_date,$end_date); $html.='<tr style="color:#555555"> <td>'.$i.'</td>'; foreach($column_name as $key) { $pos=strpos($key, 'Date'); if($pos !== false) { $rep[$key]=$this->mastermodel->convertdatenormalformat($rep[$key]); } if($key=='Total') { $slno=1; $grand_total=0; $man=array(); foreach($manpower_timesheet as $mansheet) { $man[]=$mansheet['trade_id']; } foreach($client_timesheet as $clientsheet) { $ot_type=$this->timesheetmodel->get_ot_type($poinfo->purchase_order_id,$clientsheet['trade_id']); $key=array_search($clientsheet['trade_id'], $man); if(is_numeric($key)) { $manpower=$clientsheet['manpower']+$manpower_timesheet[$key]['manpower']; $normal_hours=($clientsheet['normal_hours']-$clientsheet['ot_hours']-$clientsheet['hot_hours'])+($manpower_timesheet[$key]['normal_hours']-$manpower_timesheet[$key]['ot_hours']-$manpower_timesheet[$key]['hot_hours']); if($ot_type==0) { $ot_hours=0; $hot_hours=0; $ot_rate=0; $hot_rate=0; $normal_hours = $normal_hours+$clientsheet['ot_hours']+$manpower_timesheet[$key]['ot_hours']+$clientsheet['hot_hours']+$manpower_timesheet[$key]['hot_hours']; } else { $ot_hours=$clientsheet['ot_hours']+$manpower_timesheet[$key]['ot_hours']; $hot_hours=$clientsheet['hot_hours']+$manpower_timesheet[$key]['hot_hours']; } unset($manpower_timesheet[$key]); } else { $normal_hours=$clientsheet['normal_hours']-$clientsheet['ot_hours']-$clientsheet['hot_hours']; if($ot_type==0) { $ot_hours=0; $hot_hours=0; $ot_rate=0; $hot_rate=0; $normal_hours = $normal_hours+$clientsheet['ot_hours']+$clientsheet['hot_hours']; } else { $ot_hours=$clientsheet['ot_hours']; $hot_hours=$clientsheet['hot_hours']; } $manpower=$clientsheet['manpower']; } if($ot_type!=0) { if($clientsheet['ot_rate']=="0.00") { $ot_rate= $clientsheet['normal_rate']; } else { $ot_rate= $clientsheet['ot_rate']/100*$clientsheet['normal_rate']; } } if($ot_type!=0) { if($clientsheet['hot_rate']=="0.00") { $hot_rate= $clientsheet['normal_rate']; } else { $hot_rate= $clientsheet['hot_rate']/100*$clientsheet['normal_rate']; } } $total_amount = $clientsheet['normal_rate']*$normal_hours + $ot_rate*$ot_hours + $hot_rate*$hot_hours; $grand_total+=$total_amount; } foreach($manpower_timesheet as $mansheet) { $ot_type=$this->timesheetmodel->get_ot_type($poinfo->purchase_order_id,$mansheet['trade_id']); $manpower=$mansheet['manpower']; $normal_hours=$mansheet['normal_hours']-$mansheet['ot_hours']-$mansheet['hot_hours']; if($ot_type==0) { $ot_hours=0; $hot_hours=0; $ot_rate=0; $hot_rate=0; $normal_hours = $mansheet['ot_hours']+$mansheet['hot_hours']; } else { $ot_hours=$mansheet['ot_hours']; $hot_hours=$mansheet['hot_hours']; } if($ot_type!=0) { if($mansheet['ot_rate']=="0.00") { $ot_rate= $mansheet['normal_rate']; } else { $ot_rate= $mansheet['ot_rate']/100*$mansheet['normal_rate']; } ?> <?php } ?> <?php if($ot_type!=0) { ?> <?php if($mansheet['hot_rate']=="0.00") { $hot_rate= $mansheet['normal_rate']; } else { $hot_rate= $mansheet['hot_rate']/100*$mansheet['normal_rate']; } } $total_amount = $mansheet['normal_rate']*$normal_hours + $ot_rate*$ot_hours + $hot_rate*$hot_hours; $grand_total+=$total_amount; } $rep[$key]=$grand_total; } $html .= '<td>'.$rep[$key].'</td>'; } $html .='</tr>'; $i++; } $html.=' </tbody></table>'; $html.='<hr>'; $html.=' </body></html>'; $filename = "InvoiceReport"; header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=".$filename.".xls"); header("Pragma: no-cache"); header("Expires: 0"); print $html; exit; ?>