worknova.manus/hr-attendance-export-by-month.php
LAPTOP-V9RRD1TL\Michelle's Computer f8f8fcaf96 first commit
2025-07-21 21:38:17 +08:00

520 lines
24 KiB
PHP

<?php
include 'PhpExcel/PHPExcel.php' ;
$page_filename = 'ReportMonth-'.date( str_replace("/","",$dateformat), time() ) ;
$objPHPExcel = new PHPExcel() ;
$objPHPExcel->getProperties()->setCreator(COMPANY)->setTitle(COMPANY)->setSubject(COMPANY)->setDescription(COMPANY)->setKeywords(COMPANY)->setCategory(COMPANY) ;
$objPHPExcel->getActiveSheet()->setTitle( $page_filename ) ;
$objPHPExcel->setActiveSheetIndex(0);
$objWriter = PHPExcel_IOFactory::createWriter( $objPHPExcel, 'Excel5' ) ;
$cacheMethod = PHPExcel_CachedObjectStorageFactory:: cache_to_phpTemp;
$cacheSettings = array(
'memoryCacheSize' => '50MB',
'cacheTime' => 1200
) ;
PHPExcel_Settings::setCacheStorageMethod( $cacheMethod, $cacheSettings ) ;
$styleArrayTitle = array(
'font' => array(
'bold' => true ,
'color' => array( 'rgb' => '000000' ) ,
'size' => 15
),
'alignment' => array(
'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
)
);
$styleArrayDay = array(
'font' => array(
'bold' => true
),
'borders' => array(
'outline' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN
)
),
'alignment' => array(
'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
)
) ;
$styleArrayBg1 = array(
'fill' => array(
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'color' => array('rgb' => 'AFABAB')
),
'borders' => array(
'outline' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN
)
),
'alignment' => array(
'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
)
) ;
$styleArrayBg2 = array(
'fill' => array(
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'color' => array('rgb' => 'FFDA65')
),
'borders' => array(
'outline' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN
)
),
'alignment' => array(
'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
)
) ;
$styleArray = array(
'borders' => array(
'outline' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN
)
),
'alignment' => array(
'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
)
) ;
$styleArrayLeft = array(
'borders' => array(
'outline' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN
)
),
'alignment' => array(
'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_LEFT,
)
) ;
$styleArray2 = array(
'alignment' => array(
//'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER,
)
) ;
$styleArrayRed = array(
'font' => array(
'color' => array('rgb' => 'FF0000'),
));
$count = 1 ;
$firstChar = 'A' ;
$lastChar = '';
if (EXCELDETAIL == "YES"){
$lastChar = 'w' ;
}else{
$lastChar = 'U' ;
}
// title name
$objPHPExcel->getActiveSheet()->mergeCells( $firstChar.$count.':'.$lastChar.$count ) ;
$objPHPExcel->getActiveSheet()->getStyle( $firstChar.$count.':'.$lastChar.$count )->applyFromArray( $styleArrayTitle ) ;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $firstChar.$count, 'Attendance Report' ) ;
$count++ ;
// loop all attendance record
$arr_att = array();
if ( $mysqli_page->num_rows > 0 ){
while ( $att = $mysqli_page->fetch_assoc() ){
$arr_att[] = $att;
}
}
// sum all working hours
$total_all_list_work_day = 0 ;
$total_all_list_ot_day = 0 ;
$total_all_list_work = [] ;
$total_all_list_rest = [] ;
$total_all_list_time_off = [] ;
$total_all_list_rest2 = [] ;
$total_all_list_time_off2 = [] ;
$total_all_list_early = [] ;
$total_all_list_late = [] ;
$total_all_list_early_out = [] ;
$total_all_list_ot_normal = [] ;
$total_all_work = [] ;
if(arrayCheck($arr_att)){
$all_staffid = [] ;
$all_date = [] ;
$all_attendances = [] ;
foreach($arr_att as $attendances){
$all_staffid[] = $attendances['staff_id'] ;
}
$mysqli_date = $mysqli->query("SELECT * FROM staff_attendance_list a
WHERE a.staff_id IN ( ".implode( ', ', $all_staffid )." ) AND a.list_date LIKE '%".$date_time."%' AND a.deleted_at IS NULL AND a.list_date BETWEEN '".$date_from." 00:00:00' and '".$date_to." 23:59:59' ORDER BY a.list_date ASC") ;
if ( $mysqli_date->num_rows > 0 ){
while ( $row_date = $mysqli_date->fetch_assoc() ){
$all_date[$row_date['staff_id']][] = $row_date ;
}
}
$time_attendances = $mysqli->query("SELECT staff_id, list_id, record_from, latitude, longitude, created_at FROM staff_attendance
WHERE deleted_at IS NULL AND staff_id IN ( ".implode( ', ', $all_staffid )." ) AND check_group LIKE '%".$date_time."%' ORDER BY created_at ASC") ;
if ( $time_attendances->num_rows > 0 ){
while ( $row_attendances = $time_attendances->fetch_assoc() ){
$all_attendances[$row_attendances['staff_id']][] = $row_attendances ;
}
}
foreach($arr_att as $attendances){
$count++ ;
$count++ ;
$staff_idno = ucwords($attendances['staff_idno']) ;
$objPHPExcel->getActiveSheet()->getStyle($firstChar.$count)->applyFromArray( $styleArray ) ;
$firstChar2 = $firstChar ;
$mc1 = $firstChar2.$count;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $firstChar2.$count, 'ID: '.$staff_idno.' Name: '.$attendances['staff_name'] ) ;
$mc2 = $lastChar.$count ;
$objPHPExcel->getActiveSheet()->mergeCells($mc1.':'.$mc2) ;
$objPHPExcel->getActiveSheet()->getStyle($mc1.':'.$mc2)->applyFromArray( $styleArrayLeft ) ;
$count++ ;
$get_staffdate = $all_date[$attendances['staff_id']] ;
if ( $get_staffdate != null && $get_staffdate != undefined && count($get_staffdate) > 0 ){
// get all attendance time
$attendances_list = [] ;
$get_staffattendances = $all_attendances[$attendances['staff_id']] ;
if ( $get_staffattendances != null && $get_staffattendances != undefined && count($get_staffattendances) > 0 ){
foreach ( $get_staffattendances as $row ){
$attendances_list[$row['list_id']][] = $row ;
}
}
$firstChar2 = $firstChar ;
$array_title = [ 'Date', 'Day' ] ;
for ( $a = 0 ; $a < 8 ; $a++ ){
$array_title[] = ( $a%2 == 0 ? 'In' : 'Out' ) ;
}
if ( EXCELDETAIL == "YES" ){
$array_title[] = 'Work Day' ;
$array_title[] = 'OT Day' ;
}
$array_title[] = 'Work' ;
$array_title[] = 'Rest 1' ;
$array_title[] = 'Time Off 1' ;
$array_title[] = 'Rest 2' ;
$array_title[] = 'Time Off 2' ;
$array_title[] = 'Early' ;
$array_title[] = 'Late' ;
$array_title[] = 'Early Out' ;
$array_title[] = 'OT' ;
$array_title[] = 'Remark' ;
$array_title[] = 'Work + OT' ;
foreach ( $array_title as $kk => $vv ){
$objPHPExcel->getActiveSheet()->getStyle($firstChar2.$count)->applyFromArray( $styleArray ) ;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $firstChar2.$count, $vv ) ;
$firstChar2++ ;
}
$count++ ;
// sum working hours
$total_list_work_day = 0 ;
$total_list_ot_day = 0 ;
$total_list_work = [] ;
$total_list_rest = [] ;
$total_list_time_off = [] ;
$total_list_rest2 = [] ;
$total_list_time_off2 = [] ;
$total_list_early = [] ;
$total_list_late = [] ;
$total_list_early_out = [] ;
$total_list_ot_normal = [] ;
$total_work = [] ;
foreach ( $get_staffdate as $value ){
$firstChar2 = $firstChar ;
$newlistdate = date($dateformat,strtotime($value['list_date']));
$date = date('w', strtotime($newlistdate)) ;
$date = $date_array[$date] ;
$attendances_date = $attendances_list[$value['list_id']] ;
$objPHPExcel->getActiveSheet()->getStyle($firstChar2.$count)->applyFromArray( $styleArray ) ;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $firstChar2.$count, $newlistdate ) ;
$firstChar2++ ;
$objPHPExcel->getActiveSheet()->getStyle($firstChar2.$count)->applyFromArray( $styleArray ) ;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $firstChar2.$count, $date ) ;
$firstChar2++ ;
for ( $a = 0 ; $a < 8 ; $a++ ){
$coordinates = ( $attendances_date[$a]['latitude'] != '' && $attendances_date[$a]['longitude'] != '' ? $attendances_date[$a]['latitude'].','.$attendances_date[$a]['longitude'] : '' ) ;
$map_link = 'https://maps.google.com/?q='.$coordinates ;
$current_time = $attendances_date[$a]['created_at'] ;
$record_from = $attendances_date[$a]['record_from'] ;
$record_from_w = '' ;
switch ( $record_from ){
case 'qrcode' : $record_from_w = ' (Q)' ; break ;
case 'machine' : $record_from_w = ' (D)' ; break ;
case 'button' : $record_from_w = ' (M)' ; break ;
case 'system' : $record_from_w = ' (S)' ; break ;
case 'manual' : $record_from_w = ' (S)' ; break ;
}
//$current_time = ( $current_time != '' ? resetTimeWithoutSec($current_time) : '' ) ;
$current_time = ( $current_time != '' ? date('H:i:s', strtotime($current_time)).$record_from_w : '' ) ;
$objPHPExcel->getActiveSheet()->getStyle($firstChar2.$count)->applyFromArray( $styleArray ) ;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $firstChar2.$count, $current_time ) ;
if ( $coordinates != '' ){
$objPHPExcel->setActiveSheetIndex(0)->getCell( $firstChar2.$count )->setDataType(PHPExcel_Cell_DataType::TYPE_STRING2) ;
$objPHPExcel->setActiveSheetIndex(0)->getCell( $firstChar2.$count )->getHyperlink()->setUrl(strip_tags( $map_link )) ;
}
$firstChar2++ ;
}
if (EXCELDETAIL == "YES"){
$objPHPExcel->getActiveSheet()->getStyle($firstChar2.$count)->applyFromArray( $styleArray ) ;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $firstChar2.$count, resetTimeWithoutSec($value['list_work_day']) ) ;
$firstChar2++ ;
$objPHPExcel->getActiveSheet()->getStyle($firstChar2.$count)->applyFromArray( $styleArray ) ;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $firstChar2.$count, resetTimeWithoutSec($value['list_ot_day']) ) ;
$firstChar2++ ;
}
$objPHPExcel->getActiveSheet()->getStyle($firstChar2.$count)->applyFromArray( $styleArray ) ;
$objPHPExcel->getActiveSheet()->setCellValue( $firstChar2.$count, resetTimeWithoutSec($value['list_work']) ) ;
$firstChar2++ ;
$objPHPExcel->getActiveSheet()->getStyle($firstChar2.$count)->applyFromArray( $styleArray ) ;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $firstChar2.$count, resetTimeWithoutSec($value['list_rest']) ) ;
$firstChar2++ ;
$objPHPExcel->getActiveSheet()->getStyle($firstChar2.$count)->applyFromArray( $styleArray ) ;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $firstChar2.$count, resetTimeWithoutSec($value['list_time_off']) ) ;
$firstChar2++ ;
$objPHPExcel->getActiveSheet()->getStyle($firstChar2.$count)->applyFromArray( $styleArray ) ;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $firstChar2.$count, resetTimeWithoutSec($value['list_rest2']) ) ;
$firstChar2++ ;
$objPHPExcel->getActiveSheet()->getStyle($firstChar2.$count)->applyFromArray( $styleArray ) ;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $firstChar2.$count, resetTimeWithoutSec($value['list_time_off2']) ) ;
$firstChar2++ ;
$objPHPExcel->getActiveSheet()->getStyle($firstChar2.$count)->applyFromArray( $styleArray ) ;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $firstChar2.$count, resetTimeWithoutSec($value['list_early']) ) ;
$firstChar2++ ;
$objPHPExcel->getActiveSheet()->getStyle($firstChar2.$count)->applyFromArray( $styleArray ) ;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $firstChar2.$count, resetTimeWithoutSec($value['list_late']) ) ;
$firstChar2++ ;
$objPHPExcel->getActiveSheet()->getStyle($firstChar2.$count)->applyFromArray( $styleArray ) ;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $firstChar2.$count, resetTimeWithoutSec($value['list_early_out']) ) ;
$firstChar2++ ;
$objPHPExcel->getActiveSheet()->getStyle($firstChar2.$count)->applyFromArray( $styleArray ) ;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $firstChar2.$count, resetTimeWithoutSec($value['list_ot_normal']) ) ;
$firstChar2++ ;
$objPHPExcel->getActiveSheet()->getStyle($firstChar2.$count)->applyFromArray( $styleArray ) ;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $firstChar2.$count, $value['list_remark'] ) ;
$firstChar2++ ;
$time = $value['list_ot_normal'];
$time2 = $value['list_work'];
$secs = strtotime($time2)-strtotime("00:00:00");
$result = date("H:i:s",strtotime($time)+$secs);
$objPHPExcel->getActiveSheet()->getStyle($firstChar2.$count)->applyFromArray( $styleArray ) ;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $firstChar2.$count, resetTimeWithoutSec($result) ) ;
$count++ ;
// count total working hours
$total_list_work_day += $value['list_work_day'] ;
$total_list_ot_day += $value['list_ot_day'] ;
$total_list_work = setTotalHoursArray( $total_list_work, resetTimeWithoutSec($value['list_work']) ) ;
$total_list_rest = setTotalHoursArray( $total_list_rest, resetTimeWithoutSec($value['list_rest']) ) ;
$total_list_time_off = setTotalHoursArray( $total_list_time_off, resetTimeWithoutSec($value['list_time_off']) ) ;
$total_list_rest2 = setTotalHoursArray( $total_list_rest2, resetTimeWithoutSec($value['list_rest2']) ) ;
$total_list_time_off2 = setTotalHoursArray( $total_list_time_off2, resetTimeWithoutSec($value['list_time_off2']) ) ;
$total_list_early = setTotalHoursArray( $total_list_early, resetTimeWithoutSec($value['list_early']) ) ;
$total_list_late = setTotalHoursArray( $total_list_late, resetTimeWithoutSec($value['list_late']) ) ;
$total_list_early_out = setTotalHoursArray( $total_list_early_out, resetTimeWithoutSec($value['list_early_out']) ) ;
$total_list_ot_normal = setTotalHoursArray( $total_list_ot_normal, resetTimeWithoutSec($value['list_ot_normal']) ) ;
$total_work = setTotalHoursArray( $total_work, resetTimeWithoutSec($result) ) ;
//calculate all
$total_all_list_work = setTotalHoursArray( $total_all_list_work, resetTimeWithoutSec($value['list_work']) ) ;
$total_all_list_rest = setTotalHoursArray( $total_all_list_rest, resetTimeWithoutSec($value['list_rest']) ) ;
$total_all_list_time_off = setTotalHoursArray( $total_all_list_time_off, resetTimeWithoutSec($value['list_time_off']) ) ;
$total_all_list_rest2 = setTotalHoursArray( $total_all_list_rest2, resetTimeWithoutSec($value['list_rest2']) ) ;
$total_all_list_time_off2 = setTotalHoursArray( $total_all_list_time_off2, resetTimeWithoutSec($value['list_time_off2']) ) ;
$total_all_list_early = setTotalHoursArray( $total_all_list_early, resetTimeWithoutSec($value['list_early']) ) ;
$total_all_list_late = setTotalHoursArray( $total_all_list_late, resetTimeWithoutSec($value['list_late']) ) ;
$total_all_list_early_out = setTotalHoursArray( $total_all_list_early_out, resetTimeWithoutSec($value['list_early_out']) ) ;
$total_all_list_ot_normal = setTotalHoursArray( $total_all_list_ot_normal, resetTimeWithoutSec($value['list_ot_normal']) ) ;
$total_all_work = setTotalHoursArray( $total_all_work, resetTimeWithoutSec($result) ) ;
}
// column for total
$firstChar2 = $firstChar ;
$firstChar2++ ;
$firstChar2++ ;
$firstChar2++ ;
$firstChar2++ ;
$firstChar2++ ;
$firstChar2++ ;
$firstChar2++ ;
$firstChar2++ ;
$firstChar2++ ;
$objPHPExcel->getActiveSheet()->getStyle($firstChar2.$count)->applyFromArray( $styleArray ) ;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $firstChar2.$count, 'Total' ) ;
$firstChar2++ ;
if (EXCELDETAIL == "YES"){
$objPHPExcel->getActiveSheet()->getStyle($firstChar2.$count)->applyFromArray( $styleArray ) ;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $firstChar2.$count, $total_list_work_day ) ;
$firstChar2++ ;
$objPHPExcel->getActiveSheet()->getStyle($firstChar2.$count)->applyFromArray( $styleArray ) ;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $firstChar2.$count, $total_list_ot_day ) ;
$firstChar2++ ;
}
$objPHPExcel->getActiveSheet()->getStyle($firstChar2.$count)->applyFromArray( $styleArray ) ;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $firstChar2.$count, setTotalHoursSum($total_list_work) ) ;
$firstChar2++ ;
$objPHPExcel->getActiveSheet()->getStyle($firstChar2.$count)->applyFromArray( $styleArray ) ;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $firstChar2.$count, setTotalHoursSum($total_list_rest) ) ;
$firstChar2++ ;
$objPHPExcel->getActiveSheet()->getStyle($firstChar2.$count)->applyFromArray( $styleArray ) ;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $firstChar2.$count, setTotalHoursSum($total_list_time_off) ) ;
$firstChar2++ ;
$objPHPExcel->getActiveSheet()->getStyle($firstChar2.$count)->applyFromArray( $styleArray ) ;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $firstChar2.$count, setTotalHoursSum($total_list_rest2) ) ;
$firstChar2++ ;
$objPHPExcel->getActiveSheet()->getStyle($firstChar2.$count)->applyFromArray( $styleArray ) ;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $firstChar2.$count, setTotalHoursSum($total_list_time_off2) ) ;
$firstChar2++ ;
$objPHPExcel->getActiveSheet()->getStyle($firstChar2.$count)->applyFromArray( $styleArray ) ;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $firstChar2.$count, setTotalHoursSum($total_list_early) ) ;
$firstChar2++ ;
$objPHPExcel->getActiveSheet()->getStyle($firstChar2.$count)->applyFromArray( $styleArray ) ;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $firstChar2.$count, setTotalHoursSum($total_list_late) ) ;
$firstChar2++ ;
$objPHPExcel->getActiveSheet()->getStyle($firstChar2.$count)->applyFromArray( $styleArray ) ;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $firstChar2.$count, setTotalHoursSum($total_list_early_out) ) ;
$firstChar2++ ;
$objPHPExcel->getActiveSheet()->getStyle($firstChar2.$count)->applyFromArray( $styleArray ) ;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $firstChar2.$count, setTotalHoursSum($total_list_ot_normal) ) ;
$firstChar2++ ;
$firstChar2++ ;
$objPHPExcel->getActiveSheet()->getStyle($firstChar2.$count)->applyFromArray( $styleArray ) ;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $firstChar2.$count, setTotalHoursSum($total_work) ) ;
$count++ ;
$total_all_list_work_day += $total_list_work_day ;
$total_all_list_ot_day += $total_list_ot_day ;
}
}
}
$count++;
$firstChar2 = "J";
$objPHPExcel->getActiveSheet()->getStyle($firstChar2.++$count)->applyFromArray( $styleArray ) ;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $firstChar2.$count, 'Total All' ) ;
$firstChar2++ ;
if (EXCELDETAIL == "YES"){
$objPHPExcel->getActiveSheet()->getStyle($firstChar2.$count)->applyFromArray( $styleArray ) ;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $firstChar2.$count, $total_all_list_work_day ) ;
$firstChar2++ ;
$objPHPExcel->getActiveSheet()->getStyle($firstChar2.$count)->applyFromArray( $styleArray ) ;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $firstChar2.$count, $total_all_list_ot_day ) ;
$firstChar2++ ;
}
$objPHPExcel->getActiveSheet()->getStyle($firstChar2.$count)->applyFromArray( $styleArray ) ;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $firstChar2.$count, setTotalHoursSum($total_all_list_work) ) ;
$firstChar2++ ;
$objPHPExcel->getActiveSheet()->getStyle($firstChar2.$count)->applyFromArray( $styleArray ) ;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $firstChar2.$count, setTotalHoursSum($total_all_list_rest) ) ;
$firstChar2++ ;
$objPHPExcel->getActiveSheet()->getStyle($firstChar2.$count)->applyFromArray( $styleArray ) ;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $firstChar2.$count, setTotalHoursSum($total_all_list_time_off) ) ;
$firstChar2++ ;
$objPHPExcel->getActiveSheet()->getStyle($firstChar2.$count)->applyFromArray( $styleArray ) ;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $firstChar2.$count, setTotalHoursSum($total_all_list_rest2) ) ;
$firstChar2++ ;
$objPHPExcel->getActiveSheet()->getStyle($firstChar2.$count)->applyFromArray( $styleArray ) ;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $firstChar2.$count, setTotalHoursSum($total_all_list_time_off2) ) ;
$firstChar2++ ;
$objPHPExcel->getActiveSheet()->getStyle($firstChar2.$count)->applyFromArray( $styleArray ) ;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $firstChar2.$count, setTotalHoursSum($total_all_list_early) ) ;
$firstChar2++ ;
$objPHPExcel->getActiveSheet()->getStyle($firstChar2.$count)->applyFromArray( $styleArray ) ;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $firstChar2.$count, setTotalHoursSum($total_all_list_late) ) ;
$firstChar2++ ;
$objPHPExcel->getActiveSheet()->getStyle($firstChar2.$count)->applyFromArray( $styleArray ) ;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $firstChar2.$count, setTotalHoursSum($total_all_list_early_out) ) ;
$firstChar2++ ;
$objPHPExcel->getActiveSheet()->getStyle($firstChar2.$count)->applyFromArray( $styleArray ) ;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $firstChar2.$count, setTotalHoursSum($total_all_list_ot_normal) ) ;
$firstChar2++ ;
$firstChar2++ ;
$objPHPExcel->getActiveSheet()->getStyle($firstChar2.$count)->applyFromArray( $styleArray ) ;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $firstChar2.$count, setTotalHoursSum($total_all_work) ) ;
$firstChar2++ ;
// Submission from
header( 'Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' ) ;
header( 'Content-Disposition: attachment;filename="'.$page_filename.'.xls"' ) ;
header( 'Cache-Control: max-age=0' ) ;
// save to pc
$objWriter->save('php://output') ;
// header( "Refresh: 0" ) ;
exit ;
?>