Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64
Your IP : 13.59.62.63
Current Path : /var/www/html/oums/src/ |
| Current File : /var/www/html/oums/src/workentry_report.php |
<?php
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
include("sys_session.php");
include("sys_connect.php");
include("sys_mainphp.php");
$resp_mesg = "";
$resp_stat = "";
$resp_file = "";
$mysql = "SET SESSION group_concat_max_len = 1000000;";
$myres = mysqli_query($mycon, $mysql);
$myqry = "";
if ($type_id == "ADMIN") {
$myqry = " ";
} elseif ($type_id == "CHIEF") {
$myqry = " inner join masdept_user du on wk.fdeptcode = du.fdeptcode and du.fusercode = '$user_id' ";
} else {
$myqry = " and wk.femplcode = '$empl_id' ";
}
$mysql = "select wa.fassnempl,wa.fworkempl,
ifnull(e1.fdeptcode,'NA') as fworkdept,ifnull(concat('[',e1.femplcode,'] ',e1.femplname),'NA') as lworkempl,
ifnull(e2.fdeptcode,'NA') as fassndept,ifnull(concat('[',e2.femplcode,'] ',e2.femplname),'NA') as lassnempl,
ifnull(wa.fassnname,'NA') as fassnname,wk.fworkdetl,wk.fworkstat,wk.fviewdetl,
ifnull(date_format(wa.fassndate,'%d/%m/%Y'),'NA') as lassndate,
ifnull(date_format(wa.flastdate,'%d/%m/%Y'),'NA') as llastdate,
ifnull(date_format(wk.fworkdate,'%d/%m/%Y'),'NA') as lworkdate,
if(wk.fworkstat='COMPLETED',date_format(wk.fworkdate,'%d/%m/%Y'),'') as lcompdate
from workentry wk
left join workassign wa on wk.fassncode = wa.fassncode and ifnull(wa.fdelestat,'F')<>'T'
left join masempl e1 on wk.femplcode = e1.femplcode
left join masempl e2 on wa.fassnempl = e2.femplcode
" . $myqry . "
where e1.fdeptcode like '%$_POST[dept_code]%' and e1.femplcode like '%$_POST[empl_code]%' and
wk.fworkdate between str_to_date('$_POST[work_dat1]','%d/%m/%Y') and str_to_date('$_POST[work_dat2]','%d/%m/%Y') and ifnull(wk.fdelestat,'F')<>'T'
order by wk.fworkdate,wk.fdeptcode,wk.femplcode,wk.fworkcode;";
$myres = mysqli_query($mycon, $mysql);
if (mysqli_num_rows($myres) == 0) {
$resp_mesg = "No details found!";
$resp_stat = 'F';
} else {
require_once("phpexcel/Classes/PHPExcel.php");
$objPHPExcel = new PHPExcel();
$objPHPExcel->getProperties()->setCreator("Logisys")
->setLastModifiedBy("Logisys")
->setTitle("Office 2007 XLSX Test Document")
->setSubject("Office 2007 XLSX Test Document")
->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
->setKeywords("office 2007 openxml php")
->setCategory("Report File");
$objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE);
$objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
$objPHPExcel->getActiveSheet()->getPageSetup()->setRowsToRepeatAtTopByStartAndEnd(1, 2);
$objPHPExcel->getActiveSheet()->setPrintGridlines(TRUE);
$objPHPExcel->getActiveSheet()->getPageSetup()->setFitToWidth(1);
$objPHPExcel->getActiveSheet()->getPageSetup()->setFitToHeight(0);
$objPHPExcel->getActiveSheet()->getPageMargins()->setTop(0.5);
$objPHPExcel->getActiveSheet()->getPageMargins()->setRight(0.2);
$objPHPExcel->getActiveSheet()->getPageMargins()->setLeft(0.2);
$objPHPExcel->getActiveSheet()->getPageMargins()->setBottom(0.5);
$objPHPExcel->getActiveSheet()->getPageSetup()->setHorizontalCentered(true);
$objPHPExcel->getActiveSheet()->getPageSetup()->setVerticalCentered(false);
$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader('&L&G&C&HLogisys, Bangalore');
$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddFooter('&L&B' . '&CPage &P of &N');
$objPHPExcel->getActiveSheet()->getDefaultColumnDimension()->setWidth(10);
$objPHPExcel->getActiveSheet()->getDefaultRowDimension()->setRowHeight(25);
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(8);
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(12);
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(8);
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(25);
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(12);
$objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(25);
$objPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(35);
$objPHPExcel->getActiveSheet()->getColumnDimension('H')->setWidth(12);
$objPHPExcel->getActiveSheet()->getColumnDimension('I')->setWidth(35);
$objPHPExcel->getActiveSheet()->getColumnDimension('J')->setWidth(12);
$objPHPExcel->getActiveSheet()->getColumnDimension('K')->setWidth(12);
$objPHPExcel->getActiveSheet()->getColumnDimension('L')->setWidth(35);
$i = 3;
$empl_code = "";
$ShtNo = 0;
$objPHPExcel->getActiveSheet()->mergeCells('A1:L1');
$objPHPExcel->setActiveSheetIndex($ShtNo)->setCellValue('A1', 'WORK DONE REPORT [DATE RANGE : ' . $_POST['work_dat1'] . ' TO ' . $_POST['work_dat2'] . ']');
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A2', 'Sl. No.')
->setCellValue('B2', 'Work Date')
->setCellValue('C2', 'Client')
->setCellValue('D2', 'Employee')
->setCellValue('E2', 'Assigned date')
->setCellValue('F2', 'Assigned by')
->setCellValue('G2', 'Work Assigned')
->setCellValue('H2', 'Target Date')
->setCellValue('I2', 'Work Details')
->setCellValue('J2', 'Work Status?')
->setCellValue('K2', 'Completed Date')
->setCellValue('L2', 'Review Details');
$objPHPExcel->getActiveSheet()->getRowDimension(1)->setRowHeight(30);
$objPHPExcel->getActiveSheet()->getRowDimension(2)->setRowHeight(30);
$objPHPExcel->getActiveSheet()->getStyle('A1:L2')->getAlignment()->setHorizontal('center')->setVertical('center');
$objPHPExcel->getActiveSheet()->getStyle('A1:L2')->getAlignment()->setWrapText(true);
$objPHPExcel->getActiveSheet()->getStyle('A1:L2')->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()->freezePane('A3');
while ($myrow = mysqli_fetch_object($myres)) {
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A' . $i, $i - 2)
->setCellValue('B' . $i, $myrow->lworkdate)
->setCellValue('C' . $i, $myrow->fworkdept)
->setCellValue('D' . $i, $myrow->lworkempl)
->setCellValue('E' . $i, $myrow->lassndate)
->setCellValue('F' . $i, $myrow->lassnempl)
->setCellValue('G' . $i, $myrow->fassnname)
->setCellValue('H' . $i, $myrow->llastdate)
->setCellValue('I' . $i, $myrow->fworkdetl)
->setCellValue('J' . $i, $myrow->fworkstat)
->setCellValue('K' . $i, $myrow->lcompdate)
->setCellValue('L' . $i, $myrow->fviewdetl);
$objPHPExcel->getActiveSheet()->getStyle('A' . $i)->getAlignment()->setHorizontal('center')->setVertical('center');
$objPHPExcel->getActiveSheet()->getStyle('B' . $i)->getAlignment()->setHorizontal('center')->setVertical('center');
$objPHPExcel->getActiveSheet()->getStyle('C' . $i)->getAlignment()->setHorizontal('center')->setVertical('center');
$objPHPExcel->getActiveSheet()->getStyle('D' . $i)->getAlignment()->setHorizontal('left')->setVertical('center');
$objPHPExcel->getActiveSheet()->getStyle('E' . $i)->getAlignment()->setHorizontal('center')->setVertical('center');
$objPHPExcel->getActiveSheet()->getStyle('F' . $i)->getAlignment()->setHorizontal('left')->setVertical('center');
$objPHPExcel->getActiveSheet()->getStyle('G' . $i)->getAlignment()->setHorizontal('left')->setVertical('center');
$objPHPExcel->getActiveSheet()->getStyle('H' . $i)->getAlignment()->setHorizontal('center')->setVertical('center');
$objPHPExcel->getActiveSheet()->getStyle('I' . $i)->getAlignment()->setHorizontal('left')->setVertical('center');
$objPHPExcel->getActiveSheet()->getStyle('J' . $i)->getAlignment()->setHorizontal('center')->setVertical('center');
$objPHPExcel->getActiveSheet()->getStyle('K' . $i)->getAlignment()->setHorizontal('center')->setVertical('center');
$objPHPExcel->getActiveSheet()->getStyle('L' . $i)->getAlignment()->setHorizontal('left')->setVertical('center');
$objPHPExcel->getActiveSheet()->getStyle('A' . $i . ':L' . $i)->getAlignment()->setWrapText(true);
$objPHPExcel->getActiveSheet()->getRowDimension($i)->setRowHeight(30);
$objPHPExcel->getActiveSheet()->getRowDimension($i + 1)->setRowHeight(30);
$i++;
}
$i++;
$objPHPExcel->getActiveSheet()->setTitle('work_done_list');
$objPHPExcel->setActiveSheetIndex(0);
$file_name = "work_done_report.xlsx";
// Redirect output to a client’s web browser (Excel2007)
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="' . $file_name . '"');
header('Cache-Control: max-age=0');
// If you're serving to IE 9, then the following may be needed
header('Cache-Control: max-age=1');
// If you're serving to IE over SSL, then the following may be needed
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
header('Pragma: public'); // HTTP/1.0
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
ob_end_clean();
$objWriter->save($file_name);
$resp_file = $file_name;
}
echo json_encode(array("mesg" => $resp_mesg, "stat" => $resp_stat, "file" => $resp_file));
|