Initial checkin v13.0
This commit is contained in:
88
ext/admin/reports/reportClasses/ActiveEmployeeReport.php
Normal file
88
ext/admin/reports/reportClasses/ActiveEmployeeReport.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
if(!class_exists('ReportBuilder')){
|
||||
include_once MODULE_PATH.'/reportClasses/ReportBuilder.php';
|
||||
}
|
||||
class ActiveEmployeeReport extends ReportBuilder{
|
||||
|
||||
public function getMainQuery(){
|
||||
$query = "Select id, employee_id as 'Employee ID',
|
||||
concat(`first_name`,' ',`middle_name`,' ', `last_name`) as 'Name',
|
||||
(SELECT name from Nationality where id = nationality) as 'Nationality',
|
||||
birthday as 'Birthday',
|
||||
gender as 'Gender',
|
||||
marital_status as 'Marital Status',
|
||||
ssn_num as 'SSN Number',
|
||||
nic_num as 'NIC Number',
|
||||
other_id as 'Other IDs',
|
||||
driving_license as 'Driving License Number',
|
||||
(SELECT name from EmploymentStatus where id = employment_status) as 'Employment Status',
|
||||
(SELECT name from JobTitles where id = job_title) as 'Job Title',
|
||||
(SELECT name from PayGrades where id = pay_grade) as 'Pay Grade',
|
||||
work_station_id as 'Work Station ID',
|
||||
address1 as 'Address 1',
|
||||
address2 as 'Address 2',
|
||||
city as 'City',
|
||||
(SELECT name from Country where code = country) as 'Country',
|
||||
(SELECT name from Province where id = province) as 'Province',
|
||||
postal_code as 'Postal Code',
|
||||
home_phone as 'Home Phone',
|
||||
mobile_phone as 'Mobile Phone',
|
||||
work_phone as 'Work Phone',
|
||||
work_email as 'Work Email',
|
||||
private_email as 'Private Email',
|
||||
joined_date as 'Joined Date',
|
||||
confirmation_date as 'Confirmation Date',
|
||||
(SELECT title from CompanyStructures where id = department) as 'Department',
|
||||
(SELECT concat(`first_name`,' ',`middle_name`,' ', `last_name`,' [Employee ID:',`employee_id`,']') from Employees e1 where e1.id = e.supervisor) as 'Supervisor', notes as 'Notes'
|
||||
FROM Employees e";
|
||||
|
||||
return $query;
|
||||
|
||||
}
|
||||
|
||||
public function getWhereQuery($request){
|
||||
$query = "";
|
||||
$params = array();
|
||||
|
||||
if(empty($request['department']) || $request['department'] == "NULL"){
|
||||
$params = array();
|
||||
$query = "where ((termination_date = '0001-01-01 00:00:00' or termination_date = '0000-00-00 00:00:00') and joined_date < NOW()) or (termination_date > NOW() and joined_date < NOW())";
|
||||
}else{
|
||||
$depts = $this->getChildCompanyStuctures($request['department']);
|
||||
$query = "where department in (".implode(",",$depts).") and (((termination_date = '0001-01-01 00:00:00' or termination_date = '0000-00-00 00:00:00') and joined_date < NOW()) or (termination_date > NOW() and joined_date < NOW()))";
|
||||
}
|
||||
|
||||
|
||||
return array($query, $params);
|
||||
}
|
||||
|
||||
public function getChildCompanyStuctures($companyStructId){
|
||||
$childIds = array();
|
||||
$childIds[] = $companyStructId;
|
||||
$nodeIdsAtLastLevel = $childIds;
|
||||
$count = 0;
|
||||
do{
|
||||
$count++;
|
||||
$companyStructTemp = new CompanyStructure();
|
||||
if(empty($nodeIdsAtLastLevel) || empty($childIds)){
|
||||
break;
|
||||
}
|
||||
$idQuery = "parent in (".implode(",",$nodeIdsAtLastLevel).") and id not in(".implode(",",$childIds).")";
|
||||
LogManager::getInstance()->debug($idQuery);
|
||||
$list = $companyStructTemp->Find($idQuery, array());
|
||||
if(!$list){
|
||||
LogManager::getInstance()->debug($companyStructTemp->ErrorMsg());
|
||||
}
|
||||
$nodeIdsAtLastLevel = array();
|
||||
foreach($list as $item){
|
||||
$childIds[] = $item->id;
|
||||
$nodeIdsAtLastLevel[] = $item->id;
|
||||
}
|
||||
}while(count($list) > 0 && $count < 10);
|
||||
|
||||
return $childIds;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
50
ext/admin/reports/reportClasses/EmployeeAttendanceReport.php
Normal file
50
ext/admin/reports/reportClasses/EmployeeAttendanceReport.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
if(!class_exists('ReportBuilder')){
|
||||
include_once MODULE_PATH.'/reportClasses/ReportBuilder.php';
|
||||
}
|
||||
class EmployeeAttendanceReport extends ReportBuilder{
|
||||
|
||||
public function getMainQuery(){
|
||||
$query = "SELECT
|
||||
(SELECT `employee_id` from Employees where id = at.employee) as 'Employee',
|
||||
(SELECT concat(`first_name`,' ',`middle_name`,' ', `last_name`) from Employees where id = at.employee) as 'Employee',
|
||||
in_time as 'Time In',
|
||||
out_time as 'Time Out',
|
||||
note as 'Note'
|
||||
FROM Attendance at";
|
||||
|
||||
return $query;
|
||||
|
||||
}
|
||||
|
||||
public function getWhereQuery($request){
|
||||
|
||||
$employeeList = array();
|
||||
if(!empty($request['employee'])){
|
||||
$employeeList = json_decode($request['employee'],true);
|
||||
}
|
||||
|
||||
if(in_array("NULL", $employeeList) ){
|
||||
$employeeList = array();
|
||||
}
|
||||
|
||||
if(!empty($employeeList)){
|
||||
$query = "where employee in (".implode(",", $employeeList).") and in_time >= ? and out_time <= ? order by in_time desc;";
|
||||
$params = array(
|
||||
$request['date_start']." 00:00:00",
|
||||
$request['date_end']." 23:59:59",
|
||||
);
|
||||
}else{
|
||||
$query = "where in_time >= ? and out_time <= ? order by in_time desc;";
|
||||
$params = array(
|
||||
$request['date_start']." 00:00:00",
|
||||
$request['date_end']." 23:59:59",
|
||||
);
|
||||
}
|
||||
|
||||
LogManager::getInstance()->info("Query:".$query);
|
||||
LogManager::getInstance()->info("Params:".json_encode($params));
|
||||
|
||||
return array($query, $params);
|
||||
}
|
||||
}
|
||||
70
ext/admin/reports/reportClasses/EmployeeLeavesReport.php
Normal file
70
ext/admin/reports/reportClasses/EmployeeLeavesReport.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
if(!class_exists('ReportBuilder')){
|
||||
include_once MODULE_PATH.'/reportClasses/ReportBuilder.php';
|
||||
}
|
||||
class EmployeeLeavesReport extends ReportBuilder{
|
||||
|
||||
public function getMainQuery(){
|
||||
$query = "SELECT
|
||||
(SELECT concat(`first_name`,' ',`middle_name`,' ', `last_name`) from Employees where id = employee) as 'Employee',
|
||||
(SELECT name from LeaveTypes where id = leave_type) as 'Leave Type',
|
||||
(SELECT name from LeavePeriods where id = leave_type) as 'Leave Type',
|
||||
date_start as 'Start Date',
|
||||
date_end as 'End Date',
|
||||
details as 'Reason',
|
||||
status as 'Leave Status',
|
||||
(select count(*) from EmployeeLeaveDays d where d.employee_leave = lv.id and leave_type = 'Full Day') as 'Full Day Count',
|
||||
(select count(*) from EmployeeLeaveDays d where d.employee_leave = lv.id and leave_type = 'Half Day - Morning') as 'Half Day (Morning) Count',
|
||||
(select count(*) from EmployeeLeaveDays d where d.employee_leave = lv.id and leave_type = 'Half Day - Afternoon') as 'Half Day (Afternoon) Count'
|
||||
from EmployeeLeaves lv";
|
||||
|
||||
return $query;
|
||||
|
||||
}
|
||||
|
||||
public function getWhereQuery($request){
|
||||
|
||||
$employeeList = array();
|
||||
if(!empty($request['employee'])){
|
||||
$employeeList = json_decode($request['employee'],true);
|
||||
}
|
||||
|
||||
if(in_array("NULL", $employeeList) ){
|
||||
$employeeList = array();
|
||||
}
|
||||
|
||||
|
||||
if(!empty($employeeList) && ($request['status'] != "NULL" && !empty($request['status']))){
|
||||
$query = "where employee in (".implode(",", $employeeList).") and date_start >= ? and date_end <= ? and status = ?;";
|
||||
$params = array(
|
||||
$request['date_start'],
|
||||
$request['date_end'],
|
||||
$request['status']
|
||||
);
|
||||
}else if(!empty($employeeList)){
|
||||
$query = "where employee in (".implode(",", $employeeList).") and date_start >= ? and date_end <= ?;";
|
||||
$params = array(
|
||||
$request['date_start'],
|
||||
$request['date_end']
|
||||
);
|
||||
}else if(($request['status'] != "NULL" && !empty($request['status']))){
|
||||
$query = "where status = ? and date_start >= ? and date_end <= ?;";
|
||||
$params = array(
|
||||
$request['status'],
|
||||
$request['date_start'],
|
||||
$request['date_end']
|
||||
);
|
||||
}else{
|
||||
$query = "where date_start >= ? and date_end <= ?;";
|
||||
$params = array(
|
||||
$request['date_start'],
|
||||
$request['date_end']
|
||||
);
|
||||
}
|
||||
|
||||
LogManager::getInstance()->info("Query:".$query);
|
||||
LogManager::getInstance()->info("Params:".json_encode($params));
|
||||
|
||||
return array($query, $params);
|
||||
}
|
||||
}
|
||||
104
ext/admin/reports/reportClasses/EmployeeTimeTrackReport.php
Normal file
104
ext/admin/reports/reportClasses/EmployeeTimeTrackReport.php
Normal file
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
if(!interface_exists('ReportBuilderInterface')){
|
||||
include_once MODULE_PATH.'/reportClasses/ReportBuilderInterface.php';
|
||||
}
|
||||
class EmployeeTimeTrackReport implements ReportBuilderInterface{
|
||||
public function getData($report,$req){
|
||||
|
||||
LogManager::getInstance()->info(json_encode($report));
|
||||
LogManager::getInstance()->info(json_encode($req));
|
||||
|
||||
$employeeTimeEntry = new EmployeeTimeEntry();
|
||||
|
||||
$timeEntryList = $employeeTimeEntry->Find("employee = ? and date(date_start) >= ? and date(date_end) <= ?",array($req['employee'], $req['date_start'], $req['date_end']));
|
||||
|
||||
|
||||
$seconds = 0;
|
||||
$graphTimeArray = array();
|
||||
foreach($timeEntryList as $entry){
|
||||
$seconds = (strtotime($entry->date_end) - strtotime($entry->date_start));
|
||||
$key = date("Y-m-d",strtotime($entry->date_end));
|
||||
if(isset($graphTimeArray[$key])){
|
||||
$graphTimeArray[$key] += $seconds;
|
||||
}else{
|
||||
$graphTimeArray[$key] = $seconds;
|
||||
}
|
||||
}
|
||||
|
||||
//$minutes = (int)($seconds/60);
|
||||
|
||||
|
||||
//Find Attendance Entries
|
||||
|
||||
$attendance = new Attendance();
|
||||
$atteandanceList = $attendance->Find("employee = ? and date(in_time) >= ? and date(out_time) <= ? and in_time < out_time",array($req['employee'], $req['date_start'], $req['date_end']));
|
||||
|
||||
$seconds = 0;
|
||||
$graphAttendanceArray = array();
|
||||
$firstTimeInArray = array();
|
||||
$lastTimeOutArray = array();
|
||||
foreach($atteandanceList as $entry){
|
||||
$seconds = (strtotime($entry->out_time) - strtotime($entry->in_time));
|
||||
$key = date("Y-m-d",strtotime($entry->in_time));
|
||||
if(isset($graphAttendanceArray[$key])){
|
||||
$graphAttendanceArray[$key] += $seconds;
|
||||
$lastTimeOutArray[$key] = $entry->out_time;
|
||||
}else{
|
||||
$graphAttendanceArray[$key] = $seconds;
|
||||
$firstTimeInArray[$key] = $entry->in_time;
|
||||
$lastTimeOutArray[$key] = $entry->out_time;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////
|
||||
|
||||
$employeeObject = new Employee();
|
||||
$employeeObject->Load("id = ?",array($req['employee']));
|
||||
|
||||
|
||||
$reportData = array();
|
||||
//$reportData[] = array($employeeObject->first_name." ".$employeeObject->last_name,"","","","");
|
||||
$reportData[] = array("Date","First Punch-In Time","Last Punch-Out Time","Time in Office","Time in Timesheets");
|
||||
|
||||
|
||||
//Iterate date range
|
||||
|
||||
$interval = DateInterval::createFromDateString('1 day');
|
||||
$period = new DatePeriod(new DateTime($req['date_start']), $interval, new DateTime($req['date_end']));
|
||||
|
||||
foreach ( $period as $dt ){
|
||||
$dataRow = array();
|
||||
$key = $dt->format("Y-m-d");
|
||||
|
||||
$dataRow[] = $key;
|
||||
|
||||
if(isset($firstTimeInArray[$key])){
|
||||
$dataRow[] = $firstTimeInArray[$key];
|
||||
}else{
|
||||
$dataRow[] = "Not Found";
|
||||
}
|
||||
|
||||
if(isset($lastTimeOutArray[$key])){
|
||||
$dataRow[] = $lastTimeOutArray[$key];
|
||||
}else{
|
||||
$dataRow[] = "Not Found";
|
||||
}
|
||||
|
||||
if(isset($graphAttendanceArray[$key])){
|
||||
$dataRow[] = round(($graphAttendanceArray[$key]/3600),2);
|
||||
}else{
|
||||
$dataRow[] = 0;
|
||||
}
|
||||
|
||||
if(isset($graphTimeArray[$key])){
|
||||
$dataRow[] = round(($graphTimeArray[$key]/3600),2);
|
||||
}else{
|
||||
$dataRow[] = 0;
|
||||
}
|
||||
|
||||
$reportData[] = $dataRow;
|
||||
}
|
||||
return $reportData;
|
||||
}
|
||||
}
|
||||
66
ext/admin/reports/reportClasses/EmployeeTimesheetReport.php
Normal file
66
ext/admin/reports/reportClasses/EmployeeTimesheetReport.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
if(!class_exists('ReportBuilder')){
|
||||
include_once MODULE_PATH.'/reportClasses/ReportBuilder.php';
|
||||
}
|
||||
class EmployeeTimesheetReport extends ReportBuilder{
|
||||
|
||||
public function getMainQuery(){
|
||||
$query = "SELECT
|
||||
(SELECT concat(`first_name`,' ',`middle_name`,' ', `last_name`) from Employees where id = te.employee) as 'Employee',
|
||||
(SELECT name from Projects where id = te.project) as 'Project',
|
||||
details as 'Details',
|
||||
date_start as 'Start Time',
|
||||
date_end as 'End Time',
|
||||
SEC_TO_TIME(TIMESTAMPDIFF(SECOND,te.date_start,te.date_end)) as 'Duration'
|
||||
FROM EmployeeTimeEntry te";
|
||||
|
||||
return $query;
|
||||
|
||||
}
|
||||
|
||||
public function getWhereQuery($request){
|
||||
|
||||
$employeeList = array();
|
||||
if(!empty($request['employee'])){
|
||||
$employeeList = json_decode($request['employee'],true);
|
||||
}
|
||||
|
||||
if(in_array("NULL", $employeeList) ){
|
||||
$employeeList = array();
|
||||
}
|
||||
|
||||
|
||||
if(!empty($employeeList) && ($request['project'] != "NULL" && !empty($request['project']))){
|
||||
$query = "where employee in (".implode(",", $employeeList).") and date_start >= ? and date_end <= ? and project = ?;";
|
||||
$params = array(
|
||||
$request['date_start'],
|
||||
$request['date_end'],
|
||||
$request['project']
|
||||
);
|
||||
}else if(!empty($employeeList)){
|
||||
$query = "where employee in (".implode(",", $employeeList).") and date_start >= ? and date_end <= ?;";
|
||||
$params = array(
|
||||
$request['date_start'],
|
||||
$request['date_end']
|
||||
);
|
||||
}else if(($request['project'] != "NULL" && !empty($request['project']))){
|
||||
$query = "where project = ? and date_start >= ? and date_end <= ?;";
|
||||
$params = array(
|
||||
$request['project'],
|
||||
$request['date_start'],
|
||||
$request['date_end']
|
||||
);
|
||||
}else{
|
||||
$query = "where date_start >= ? and date_end <= ?;";
|
||||
$params = array(
|
||||
$request['date_start'],
|
||||
$request['date_end']
|
||||
);
|
||||
}
|
||||
|
||||
LogManager::getInstance()->info("Query:".$query);
|
||||
LogManager::getInstance()->info("Params:".json_encode($params));
|
||||
|
||||
return array($query, $params);
|
||||
}
|
||||
}
|
||||
34
ext/admin/reports/reportClasses/NewHiresEmployeeReport.php
Normal file
34
ext/admin/reports/reportClasses/NewHiresEmployeeReport.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
if(!class_exists('ActiveEmployeeReport')){
|
||||
include_once MODULE_PATH.'/reportClasses/ActiveEmployeeReport.php';
|
||||
}
|
||||
class NewHiresEmployeeReport extends ActiveEmployeeReport{
|
||||
|
||||
|
||||
public function getWhereQuery($request){
|
||||
$query = "where ";
|
||||
$params = array();
|
||||
if(!empty($request['department']) && $request['department'] != "NULL"){
|
||||
$depts = $this->getChildCompanyStuctures($request['department']);
|
||||
$query.="department in(".implode(",",$depts).") and ";
|
||||
}
|
||||
|
||||
if(empty($request['date_start']) || $request['date_start'] == "NULL"){
|
||||
$request['date_start'] = date("Y-m-d 00:00:00");
|
||||
}
|
||||
|
||||
if(empty($request['date_end']) || $request['date_end'] == "NULL"){
|
||||
$request['date_end'] = date("Y-m-d 23:59:59");
|
||||
}
|
||||
|
||||
$query.="joined_date >= ? ";
|
||||
$params[] = $request['date_start']." 00:00:00";
|
||||
|
||||
|
||||
|
||||
$query.="and joined_date <= ? ";
|
||||
$params[] = $request['date_end']." 23:59:59";
|
||||
|
||||
return array($query, $params);
|
||||
}
|
||||
}
|
||||
57
ext/admin/reports/reportClasses/ReportBuilder.php
Normal file
57
ext/admin/reports/reportClasses/ReportBuilder.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
if(!interface_exists('ReportBuilderInterface')){
|
||||
include_once MODULE_PATH.'/reportClasses/ReportBuilderInterface.php';
|
||||
}
|
||||
abstract class ReportBuilder implements ReportBuilderInterface{
|
||||
|
||||
public function getData($report,$request){
|
||||
$query = $this->getMainQuery();
|
||||
$where = $this->getWhereQuery($request);
|
||||
$query.=" ".$where[0];
|
||||
return $this->execute($report, $query, $where[1]);
|
||||
}
|
||||
|
||||
protected function execute($report, $query, $parameters){
|
||||
$report->DB()->SetFetchMode(ADODB_FETCH_ASSOC);
|
||||
LogManager::getInstance()->debug("Query: ".$query);
|
||||
LogManager::getInstance()->debug("Parameters: ".json_encode($parameters));
|
||||
$rs = $report->DB()->Execute($query,$parameters);
|
||||
if(!$rs){
|
||||
LogManager::getInstance()->info($report->DB()->ErrorMsg());
|
||||
return array("ERROR","Error generating report");
|
||||
}
|
||||
|
||||
$reportNamesFilled = false;
|
||||
$columnNames = array();
|
||||
$reportData = array();
|
||||
foreach ($rs as $rowId => $row) {
|
||||
$reportData[] = array();
|
||||
if(!$reportNamesFilled){
|
||||
$countIt = 0;
|
||||
foreach ($row as $name=> $value){
|
||||
$countIt++;
|
||||
$columnNames[$countIt] = $name;
|
||||
$reportData[count($reportData)-1][] = $value;
|
||||
}
|
||||
$reportNamesFilled = true;
|
||||
}else{
|
||||
foreach ($row as $name=> $value){
|
||||
$reportData[count($reportData)-1][] = $this->transformData($name, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
array_unshift($reportData,$columnNames);
|
||||
|
||||
return $reportData;
|
||||
}
|
||||
|
||||
abstract public function getWhereQuery($request);
|
||||
|
||||
abstract public function getMainQuery();
|
||||
|
||||
public function transformData($name, $value){
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
interface ReportBuilderInterface{
|
||||
public function getData($report,$request);
|
||||
}
|
||||
34
ext/admin/reports/reportClasses/TerminatedEmployeeReport.php
Normal file
34
ext/admin/reports/reportClasses/TerminatedEmployeeReport.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
if(!class_exists('ActiveEmployeeReport')){
|
||||
include_once MODULE_PATH.'/reportClasses/ActiveEmployeeReport.php';
|
||||
}
|
||||
class TerminatedEmployeeReport extends ActiveEmployeeReport{
|
||||
|
||||
|
||||
public function getWhereQuery($request){
|
||||
$query = "where ";
|
||||
$params = array();
|
||||
if(!empty($request['department']) && $request['department'] != "NULL"){
|
||||
$depts = $this->getChildCompanyStuctures($request['department']);
|
||||
$query.="department in(".implode(",",$depts).") and ";
|
||||
}
|
||||
|
||||
if(empty($request['date_start']) || $request['date_start'] == "NULL"){
|
||||
$request['date_start'] = date("Y-m-d 00:00:00");
|
||||
}
|
||||
|
||||
if(empty($request['date_end']) || $request['date_end'] == "NULL"){
|
||||
$request['date_end'] = date("Y-m-d 23:59:59");
|
||||
}
|
||||
|
||||
$query.="termination_date >= ? ";
|
||||
$params[] = $request['date_start']." 00:00:00";
|
||||
|
||||
|
||||
|
||||
$query.="and termination_date <= ? ";
|
||||
$params[] = $request['date_end']." 23:59:59";
|
||||
|
||||
return array($query, $params);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user