Making code PSR2 compliant

This commit is contained in:
gamonoid
2017-09-24 19:23:30 +02:00
parent 05b57e0236
commit 6c61577583
160 changed files with 1432 additions and 1086 deletions

View File

@@ -47,7 +47,8 @@ class ClientProjectTimeReport extends PDFReportBuilder implements PDFReportBuild
$employeeTimeEntry = new EmployeeTimeEntry();
$timeEntryList = $employeeTimeEntry->Find(
"employee = ? and date(date_start) >= ? and date(date_end) <= ? and project in (".implode(",", $projectIds).") order by date_start",
"employee = ? and date(date_start) >= ? and date(date_end) <= ? and project in ("
.implode(",", $projectIds).") order by date_start",
array($employeeId, $request['date_start'], $request['date_end'])
);

View File

@@ -8,30 +8,35 @@ use Utils\LogManager;
class EmployeeLeavesReport extends CSVReportBuilder implements CSVReportBuilderInterface
{
public function getMainQuery()
{
$query = "SELECT
(SELECT concat(`first_name`,' ',`middle_name`,' ', `last_name`) from Employees where id = employee) as 'Employee',
(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_period) as 'Leave Period',
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'
(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)
{
if (($request['status'] != "NULL" && !empty($request['status']))) {
$query = "where employee = ? and status = ? and ((date_start >= ? and date_start <= ?) or (date_end >= ? and date_end <= ?));";
$query = "where employee = ? and status = ? and ((date_start >= ? and date_start <= ?)
or (date_end >= ? and date_end <= ?));";
$params = array(
BaseService::getInstance()->getCurrentProfileId(),
$request['status'],
@@ -41,7 +46,8 @@ from EmployeeLeaves lv";
$request['date_end']
);
} else {
$query = "where employee = ? and ((date_start >= ? and date_start <= ?) or (date_end >= ? and date_end <= ?));";
$query = "where employee = ? and ((date_start >= ? and date_start <= ?)
or (date_end >= ? and date_end <= ?));";
$params = array(
BaseService::getInstance()->getCurrentProfileId(),
$request['date_start'],
@@ -53,7 +59,7 @@ from EmployeeLeaves lv";
LogManager::getInstance()->info("Query:".$query);
LogManager::getInstance()->info("Params:".json_encode($params));
return array($query, $params);
}
}

View File

@@ -14,15 +14,15 @@ class EmployeeTimeTrackReport extends ClassBasedReportBuilder implements ReportB
{
$req['employee'] = BaseService::getInstance()->getCurrentProfileId();
$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) {
@@ -34,15 +34,18 @@ class EmployeeTimeTrackReport extends ClassBasedReportBuilder implements ReportB
$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']));
$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();
@@ -59,54 +62,54 @@ class EmployeeTimeTrackReport extends ClassBasedReportBuilder implements ReportB
$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;

View File

@@ -13,7 +13,8 @@ class EmployeeTimesheetReport extends CSVReportBuilder implements CSVReportBuild
public function getMainQuery()
{
$query = "SELECT
(SELECT concat(`first_name`,' ',`middle_name`,' ', `last_name`) from Employees where id = te.employee) as 'Employee',
(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',
@@ -44,7 +45,8 @@ FROM EmployeeTimeEntry te";
$projectIds[] = $project->id;
}
$query = "where project in (".implode(",", $projectIds).") and employee = ? and date_start >= ? and date_end <= ?;";
$query = "where project in (".implode(",", $projectIds)
.") and employee = ? and date_start >= ? and date_end <= ?;";
$params = array(
BaseService::getInstance()->getCurrentProfileId(),
$request['date_start'],

View File

@@ -43,9 +43,15 @@ class OvertimeReport extends ClassBasedReportBuilder implements ReportBuilderInt
$reportData = array();
if (!$this->isAggregated()) {
$reportData[] = array("Date", "Employee ID", "Employee", "Time in Office", "Regular Time", "Overtime", "Double Time");
$reportData[] = array(
"Date", "Employee ID", "Employee", "Time in Office",
"Regular Time", "Overtime", "Double Time"
);
} else {
$reportData[] = array("Employee ID", "Employee", "Time in Office", "Regular Time", "Overtime", "Double Time");
$reportData[] = array(
"Employee ID", "Employee", "Time in Office", "Regular Time", "Overtime",
"Double Time"
);
}
foreach ($employeeAttendance as $employeeId => $atData) {