public function generateAttendanceReport($empId, $from, $to, $messageType = null, $message = null)
 {
     $reportType = $_POST['hdnReportType'];
     $records['fromDate'] = $_POST['txtFromDate'];
     $records['toDate'] = $_POST['txtToDate'];
     $records['reportType'] = $reportType;
     $records['reportView'] = $_POST['optReportView'];
     $records['messageType'] = $messageType;
     $records['message'] = $message;
     $records['empId'] = $empId;
     $records['empName'] = $_POST['hdnEmpName'];
     $records['noReports'] = false;
     $records['userTimeZoneOffset'] = $_SESSION['userTimeZoneOffset'];
     $records['serverTimeZoneOffset'] = round(date('Z') / 3600, 1);
     /* Setting 'Back' button to summary view */
     if (isset($_POST['hdnFromSummary'])) {
         $records['hdnFromSummary'] = true;
         $records['orgFromDate'] = $_POST['orgFromDate'];
         $records['orgToDate'] = $_POST['orgToDate'];
     }
     /* Setting Edit Mode */
     if ($this->authorizeObj->isAdmin()) {
         $records['editMode'] = true;
     } elseif ($reportType == 'Emp' && $this->authorizeObj->isSupervisor() && Config::getAttendanceSupEditSubmitted()) {
         $records['editMode'] = true;
     } elseif ($reportType == 'My' && Config::getAttendanceEmpEditSubmitted()) {
         $records['editMode'] = true;
     } else {
         $records['editMode'] = 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 AttendanceRecord array */
     $attendanceObj = new AttendanceRecord();
     if (isset($_POST['pageNo']) && $_POST['hdnFromPaging'] == 'Yes') {
         // If it's from Generate button, it should always display page 1.
         $pageNo = $_POST['pageNo'];
     } else {
         $pageNo = 1;
     }
     $limit = $pageNo * 50 - 50 . ', 50';
     $records['recordsArr'] = $attendanceObj->fetchRecords($empId, $from, $to, AttendanceRecord::STATUS_ACTIVE, AttendanceRecord::DB_FIELD_PUNCHIN_TIME, 'ASC', $limit);
     if (empty($records['recordsArr'])) {
         $records['noReports'] = true;
     }
     $records['recordsCount'] = $attendanceObj->countRecords($empId, $from, $to, AttendanceRecord::STATUS_ACTIVE);
     $records['pageNo'] = $pageNo;
     $path = '/templates/time/attendanceReport.php';
     $template = new TemplateMerger($records, $path);
     $template->display();
 }