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 : 3.16.137.150
Current Path : /var/www/html/oums/src/ |
| Current File : /var/www/html/oums/src/work_entry_report_work_done_excl.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 = "";
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, 4);
$objPHPExcel->getActiveSheet()->getPageMargins()->setTop(1.0);
$objPHPExcel->getActiveSheet()->getPageMargins()->setRight(0.5);
$objPHPExcel->getActiveSheet()->getPageMargins()->setLeft(0.5);
$objPHPExcel->getActiveSheet()->getPageMargins()->setBottom(1.0);
$objPHPExcel->getActiveSheet()->getPageSetup()->setHorizontalCentered(true);
$objPHPExcel->getActiveSheet()->getPageSetup()->setVerticalCentered(false);
$objPHPExcel->getActiveSheet()->setShowGridlines(true);
$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()->getRowDimension(1)->setRowHeight(25);
$objPHPExcel->getActiveSheet()->getRowDimension(2)->setRowHeight(25);
$objPHPExcel->getActiveSheet()->getRowDimension(3)->setRowHeight(25);
$objPHPExcel->getActiveSheet()->getRowDimension(4)->setRowHeight(25);
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(8);
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(12);
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(35);
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(35);
$objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(35);
$objPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(30);
$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 concat('[',d1.fdeptcode,'] ',d1.fdeptname) as fdeptname,
e1.femplcode,concat('[',e1.femplcode,'] ',e1.femplname) as femplname,
date_format(wk.fworkdate,'%d/%m/%Y') as lworkdate,wk.fworkcode as fworkcode,
wk.fworkname as fworkname,wk.fworkdetl as fworkdetl,
concat('[',e2.femplcode,'] ',e2.femplname,'') as lviewempl,
ifnull(wk.fviewdetl,'') as fviewdetl
from workentry wk
left join masempl e1 on wk.femplcode=e1.femplcode
left join masempl e2 on wk.fviewempl=e2.femplcode
left join masdept d1 on wk.fdeptcode=d1.fdeptcode "
. $myqry . "
where wk.fdeptcode like '$_POST[dept_code]' and wk.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.fdeleted,'F')<>'T'
order by wk.femplcode,wk.fworkdate";
$myres = mysqli_query($mycon, $mysql);
$i = 5;
$empl_code = "";
$ShtNo = 0;
while ($myrow = mysqli_fetch_object($myres)) {
if ($empl_code != $myrow->femplcode) {
$objPHPExcel->getActiveSheet()->mergeCells('A1:G1');
$objPHPExcel->setActiveSheetIndex($ShtNo)->setCellValue('A1', 'WORK DONE REPORT [DATE RANGE : ' . $_POST['work_dat1'] . ' TO ' . $_POST['work_dat2'] . ']');
$objPHPExcel->getActiveSheet()->getStyle('A1:G1')->getAlignment()->setHorizontal('center')->setVertical('center');
$objPHPExcel->getActiveSheet()->mergeCells('A2:B2');
$objPHPExcel->setActiveSheetIndex($ShtNo)->setCellValue('A2', 'Employee Name');
$objPHPExcel->getActiveSheet()->getStyle('A2:B2')->getAlignment()->setHorizontal('left')->setVertical('center');
$objPHPExcel->getActiveSheet()->mergeCells('C2:G2');
$objPHPExcel->setActiveSheetIndex($ShtNo)->setCellValue('C2', $myrow->femplname);
$objPHPExcel->getActiveSheet()->getStyle('C2:G2')->getAlignment()->setHorizontal('left')->setVertical('center');
$objPHPExcel->getActiveSheet()->mergeCells('A3:B3');
$objPHPExcel->setActiveSheetIndex($ShtNo)->setCellValue('A3', 'Client Name');
$objPHPExcel->getActiveSheet()->getStyle('A3:B3')->getAlignment()->setHorizontal('left')->setVertical('center');
$objPHPExcel->getActiveSheet()->mergeCells('C3:G3');
$objPHPExcel->setActiveSheetIndex($ShtNo)->setCellValue('C3', $myrow->fdeptname);
$objPHPExcel->getActiveSheet()->getStyle('C3:G3')->getAlignment()->setHorizontal('left')->setVertical('center');
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A4', 'Sl. No.')
->setCellValue('B4', 'Work ID')
->setCellValue('C4', 'Work Date')
->setCellValue('D4', 'Work Name')
->setCellValue('E4', 'Work Details')
->setCellValue('F4', 'Review Details')
->setCellValue('G4', 'Review By');
}
$empl_code = $myrow->femplcode;
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A' . $i, $i - 4)
->setCellValue('B' . $i, $myrow->fworkcode)
->setCellValue('C' . $i, $myrow->lworkdate)
->setCellValue('D' . $i, $myrow->fworkname)
->setCellValue('E' . $i, $myrow->fworkdetl)
->setCellValue('F' . $i, $myrow->fviewdetl)
->setCellValue('G' . $i, $myrow->lviewempl);
$objPHPExcel->getActiveSheet()->getRowDimension($i)->setRowHeight(30);
$objPHPExcel->getActiveSheet()->getRowDimension($i + 1)->setRowHeight(30);
$i++;
}
$i++;
$objPHPExcel->getActiveSheet()->freezePane('A5');
$objPHPExcel->getActiveSheet()->getStyle('A1:G1')->getAlignment()->setWrapText(true);
$objPHPExcel->getActiveSheet()->getStyle('A5:A' . $i)->getAlignment()->setHorizontal('center')->setVertical('center');
$objPHPExcel->getActiveSheet()->getStyle('B5:B' . $i)->getAlignment()->setHorizontal('center')->setVertical('center');
$objPHPExcel->getActiveSheet()->getStyle('C5:C' . $i)->getAlignment()->setHorizontal('center')->setVertical('center');
$objPHPExcel->getActiveSheet()->getStyle('D5:D' . $i)->getAlignment()->setHorizontal('left')->setVertical('center');
$objPHPExcel->getActiveSheet()->getStyle('E5:E' . $i)->getAlignment()->setHorizontal('left')->setVertical('center');
$objPHPExcel->getActiveSheet()->getStyle('F5:F' . $i)->getAlignment()->setHorizontal('left')->setVertical('center');
$objPHPExcel->getActiveSheet()->getStyle('G5:G' . $i)->getAlignment()->setHorizontal('left')->setVertical('center');
$objPHPExcel->getActiveSheet()->getStyle('D5:F' . $i)->getAlignment()->setWrapText(true);
$objPHPExcel->getActiveSheet()->getStyle('A4:G4')->getAlignment()->setHorizontal('center')->setVertical('center');
$objPHPExcel->getActiveSheet()->getStyle('A1:G4')->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()->setTitle('work_done_report');
$objPHPExcel->setActiveSheetIndex(0);
$file_name = "work_done_report_appraisal.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));
function getNameFromNumber($num)
{
$numeric = $num % 26;
$letter = chr(65 + $numeric);
$num2 = intval($num / 26);
if ($num2 > 0) {
return getNameFromNumber($num2 - 1) . $letter;
} else {
return $letter;
}
}
|