public function generateAttendanceSummary($empId, $from, $to) { $reportType = $_POST['hdnReportType']; $records['fromDate'] = $_POST['txtFromDate']; $records['toDate'] = $_POST['txtToDate']; $records['reportType'] = $reportType; $records['reportView'] = $_POST['optReportView']; $records['empId'] = $empId; $records['empName'] = $_POST['hdnEmpName']; $records['noReports'] = false; /* Setting employee list for Auto-Complete */ if ($reportType == 'Emp' && $this->authorizeObj->isAdmin()) { $records['empList'] = EmpInfo::getEmployeeMainDetails(); } elseif ($reportType == 'Emp' && $this->authorizeObj->isSupervisor()) { $records['empList'] = $this->_getSubsForAutoComplete($_SESSION['empID']); } /* Setting summay records: Begins */ /* If the criteria is same use the records array saved in $_SESSION * rather than retrieving from database */ $criteria = array($empId, $from, $to); $sameQuery = false; if (isset($_SESSION['attCriteria'])) { if ($criteria == $_SESSION['attCriteria']) { $sameQuery = true; } else { $_SESSION['attCriteria'] = $criteria; } } else { $_SESSION['attCriteria'] = $criteria; } if (isset($_POST['pageNo']) && $_POST['hdnFromPaging'] == 'Yes') { // If it's from Generate button, it should always display page 1. $pageNo = $_POST['pageNo']; $records['pageNo'] = $pageNo; } else { $pageNo = 1; $records['pageNo'] = $pageNo; } if ($sameQuery) { $records['recordsArr'] = $this->_getAttendanceSummaryForPage($_SESSION['attSummary'], $pageNo); $records['recordsCount'] = count($_SESSION['attSummary']); } else { $attendanceObj = new AttendanceRecord(); $attSummary = $attendanceObj->fetchSummary($empId, $from, $to, AttendanceRecord::STATUS_ACTIVE, AttendanceRecord::DB_FIELD_PUNCHIN_TIME, 'ASC'); $_SESSION['attSummary'] = empty($attSummary) ? array() : $attSummary; // We should alway pass an array to _getAttendanceSummaryForPage() $records['recordsArr'] = $this->_getAttendanceSummaryForPage($_SESSION['attSummary'], $pageNo); $records['recordsCount'] = count($_SESSION['attSummary']); } /* Setting summay records: Ends */ if (empty($records['recordsArr'])) { $records['noReports'] = true; } $path = '/templates/time/attendanceReport.php'; $template = new TemplateMerger($records, $path); $template->display(); }