Making code PSR2 compliant
This commit is contained in:
@@ -15,7 +15,7 @@ use Utils\LogManager;
|
||||
class PDFReportBuilder extends ReportBuilder
|
||||
{
|
||||
|
||||
var $twig;
|
||||
protected $twig;
|
||||
|
||||
protected function getDefaultData()
|
||||
{
|
||||
@@ -68,7 +68,9 @@ class PDFReportBuilder extends ReportBuilder
|
||||
try {
|
||||
$fileFullNamePdf = CLIENT_BASE_PATH.'data/'.$fileFirstPart.".pdf";
|
||||
//Try generating the pdf
|
||||
LogManager::getInstance()->debug("wkhtmltopdf 1:".print_r(WK_HTML_PATH." ".$fileFullName." ".$fileFullNamePdf, true));
|
||||
LogManager::getInstance()->debug(
|
||||
"wkhtmltopdf 1:".print_r(WK_HTML_PATH." ".$fileFullName." ".$fileFullNamePdf, true)
|
||||
);
|
||||
exec(WK_HTML_PATH." ".$fileFullName." ".$fileFullNamePdf, $output, $ret);
|
||||
|
||||
LogManager::getInstance()->debug("wkhtmltopdf 2:".print_r($output, true));
|
||||
|
||||
@@ -39,7 +39,8 @@ 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'
|
||||
(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;
|
||||
@@ -52,10 +53,15 @@ FROM Employees e";
|
||||
|
||||
if (empty($request['department']) || $request['department'] == "NULL") {
|
||||
$params = array();
|
||||
$query = "where ((termination_date is NULL or 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())";
|
||||
$query = "where ((termination_date is NULL or 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 is NULL or 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()))";
|
||||
$query = "where department in (".implode(",", $depts)
|
||||
.") and (((termination_date is NULL or 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()))";
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -34,7 +34,8 @@ FROM Attendance at";
|
||||
}
|
||||
|
||||
if (!empty($employeeList)) {
|
||||
$query = "where employee in (".implode(",", $employeeList).") and in_time >= ? and out_time <= ? order by in_time desc;";
|
||||
$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",
|
||||
|
||||
@@ -6,8 +6,7 @@ use Leaves\User\Api\LeavesActionManager;
|
||||
use Reports\Admin\Api\ClassBasedReportBuilder;
|
||||
use Reports\Admin\Api\ReportBuilderInterface;
|
||||
|
||||
class EmployeeLeaveEntitlementReport extends ClassBasedReportBuilder
|
||||
implements ReportBuilderInterface
|
||||
class EmployeeLeaveEntitlementReport extends ClassBasedReportBuilder implements ReportBuilderInterface
|
||||
{
|
||||
public function getData($report, $req)
|
||||
{
|
||||
@@ -29,7 +28,10 @@ class EmployeeLeaveEntitlementReport extends ClassBasedReportBuilder
|
||||
}
|
||||
|
||||
$reportData = array();
|
||||
$reportData[] = array("Employee ID","Employee","Leave Type","Pending","Approved","Rejected","Canceled","Available","To be Accrued","Carried Forward from Previous Years");
|
||||
$reportData[] = array(
|
||||
"Employee ID",
|
||||
"Employee","Leave Type","Pending","Approved","Rejected",
|
||||
"Canceled","Available","To be Accrued","Carried Forward from Previous Years");
|
||||
|
||||
foreach ($employees as $employee) {
|
||||
$leaveEntitlements = $leaveActionManager->getEntitlementByEmployee($employee)->getObject();
|
||||
|
||||
@@ -8,33 +8,37 @@ 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)
|
||||
{
|
||||
|
||||
|
||||
$employeeList = array();
|
||||
if (!empty($request['employee'])) {
|
||||
$employeeList = json_decode($request['employee'], true);
|
||||
}
|
||||
|
||||
|
||||
if (in_array("NULL", $employeeList)) {
|
||||
$employeeList = array();
|
||||
}
|
||||
@@ -46,10 +50,11 @@ from EmployeeLeaves lv";
|
||||
$employeeList[] = $empTmp->id;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (!empty($employeeList) && ($request['status'] != "NULL" && !empty($request['status']))) {
|
||||
$query = "where employee in (".implode(",", $employeeList).") and ((date_start >= ? and date_start <= ?) or (date_end >= ? and date_end <= ?)) and status = ?;";
|
||||
$query = "where employee in (".implode(",", $employeeList)
|
||||
.") and ((date_start >= ? and date_start <= ?) or (date_end >= ? and date_end <= ?)) and status = ?;";
|
||||
$params = array(
|
||||
$request['date_start'],
|
||||
$request['date_end'],
|
||||
@@ -58,7 +63,8 @@ from EmployeeLeaves lv";
|
||||
$request['status']
|
||||
);
|
||||
} elseif (!empty($employeeList)) {
|
||||
$query = "where employee in (".implode(",", $employeeList).") and ((date_start >= ? and date_start <= ?) or (date_end >= ? and date_end <= ?));";
|
||||
$query = "where employee in (".implode(",", $employeeList)
|
||||
.") and ((date_start >= ? and date_start <= ?) or (date_end >= ? and date_end <= ?));";
|
||||
$params = array(
|
||||
$request['date_start'],
|
||||
$request['date_end'],
|
||||
@@ -66,7 +72,8 @@ from EmployeeLeaves lv";
|
||||
$request['date_end']
|
||||
);
|
||||
} elseif (($request['status'] != "NULL" && !empty($request['status']))) {
|
||||
$query = "where status = ? and ((date_start >= ? and date_start <= ?) or (date_end >= ? and date_end <= ?));";
|
||||
$query = "where status = ? and ((date_start >= ? and date_start <= ?)
|
||||
or (date_end >= ? and date_end <= ?));";
|
||||
$params = array(
|
||||
$request['status'],
|
||||
$request['date_start'],
|
||||
@@ -83,10 +90,10 @@ from EmployeeLeaves lv";
|
||||
$request['date_end']
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
LogManager::getInstance()->info("Query:".$query);
|
||||
LogManager::getInstance()->info("Params:".json_encode($params));
|
||||
|
||||
|
||||
return array($query, $params);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
namespace Reports\Admin\Reports;
|
||||
|
||||
use Attendance\Common\Model\Attendance;
|
||||
use Employees\Common\Model\Employee;
|
||||
use Reports\Admin\Api\ClassBasedReportBuilder;
|
||||
@@ -11,16 +12,18 @@ class EmployeeTimeTrackReport extends ClassBasedReportBuilder implements ReportB
|
||||
{
|
||||
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;
|
||||
$employeeTimeEntry = new EmployeeTimeEntry();
|
||||
|
||||
$timeEntryList = $employeeTimeEntry->Find(
|
||||
"employee = ? and date(date_start) >= ? and date(date_end) <= ?",
|
||||
array($req['employee'], $req['date_start'], $req['date_end'])
|
||||
);
|
||||
|
||||
|
||||
$graphTimeArray = array();
|
||||
foreach ($timeEntryList as $entry) {
|
||||
$seconds = (strtotime($entry->date_end) - strtotime($entry->date_start));
|
||||
@@ -31,14 +34,16 @@ 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']));
|
||||
|
||||
$seconds = 0;
|
||||
$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'])
|
||||
);
|
||||
|
||||
$graphAttendanceArray = array();
|
||||
$firstTimeInArray = array();
|
||||
$lastTimeOutArray = array();
|
||||
@@ -54,54 +59,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;
|
||||
|
||||
@@ -8,24 +8,25 @@ use Utils\LogManager;
|
||||
|
||||
class EmployeeTimesheetReport extends CSVReportBuilder implements CSVReportBuilderInterface
|
||||
{
|
||||
|
||||
|
||||
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',
|
||||
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);
|
||||
@@ -47,19 +48,24 @@ FROM EmployeeTimeEntry te";
|
||||
}
|
||||
|
||||
if (!empty($employeeList) && ($request['project'] != "NULL" && !empty($request['project']))) {
|
||||
$query = "where employee in (" . implode(",", $employeeList) . ") and date_start >= ? and date_end <= ? and project in (".implode(",", $projectIds).");";
|
||||
$query = "where employee in (" . implode(",", $employeeList)
|
||||
. ") and date_start >= ? and date_end <= ? and project in ("
|
||||
.implode(",", $projectIds).");";
|
||||
$params = array(
|
||||
$request['date_start'],
|
||||
$request['date_end']
|
||||
);
|
||||
} elseif (!empty($employeeList)) {
|
||||
$query = "where employee in (" . implode(",", $employeeList) . ") and date_start >= ? and date_end <= ? and project in (".implode(",", $projectIds).");";
|
||||
$query = "where employee in (" . implode(",", $employeeList)
|
||||
. ") and date_start >= ? and date_end <= ? and project in ("
|
||||
.implode(",", $projectIds).");";
|
||||
$params = array(
|
||||
$request['date_start'],
|
||||
$request['date_end']
|
||||
);
|
||||
} else {
|
||||
$query = "where date_start >= ? and date_end <= ? and project in (".implode(",", $projectIds).");";
|
||||
$query = "where date_start >= ? and date_end <= ? and project in ("
|
||||
.implode(",", $projectIds).");";
|
||||
$params = array(
|
||||
$request['date_start'],
|
||||
$request['date_end']
|
||||
@@ -67,14 +73,16 @@ FROM EmployeeTimeEntry te";
|
||||
}
|
||||
} else {
|
||||
if (!empty($employeeList) && ($request['project'] != "NULL" && !empty($request['project']))) {
|
||||
$query = "where employee in (" . implode(",", $employeeList) . ") and date_start >= ? and date_end <= ? and 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']
|
||||
);
|
||||
} elseif (!empty($employeeList)) {
|
||||
$query = "where employee in (" . implode(",", $employeeList) . ") and date_start >= ? and date_end <= ?;";
|
||||
$query = "where employee in (" . implode(",", $employeeList)
|
||||
. ") and date_start >= ? and date_end <= ?;";
|
||||
$params = array(
|
||||
$request['date_start'],
|
||||
$request['date_end']
|
||||
@@ -94,10 +102,10 @@ FROM EmployeeTimeEntry te";
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LogManager::getInstance()->info("Query:".$query);
|
||||
LogManager::getInstance()->info("Params:".json_encode($params));
|
||||
|
||||
|
||||
return array($query, $params);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,8 @@ class ExpenseReport extends CSVReportBuilder implements CSVReportBuilderInterfac
|
||||
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',
|
||||
expense_date as 'Date',
|
||||
(SELECT name from ExpensesPaymentMethods where id = payment_method) as 'Payment Method',
|
||||
transaction_no as 'Transaction Ref',
|
||||
@@ -39,14 +40,16 @@ from EmployeeExpenses";
|
||||
}
|
||||
|
||||
if (!empty($employeeList) && ($request['status'] != "NULL" && !empty($request['status']))) {
|
||||
$query = "where employee in (".implode(",", $employeeList).") and date(expense_date) >= ? and date(expense_date) <= ? and status = ?;";
|
||||
$query = "where employee in (".implode(",", $employeeList)
|
||||
.") and date(expense_date) >= ? and date(expense_date) <= ? and status = ?;";
|
||||
$params = array(
|
||||
$request['date_start'],
|
||||
$request['date_end'],
|
||||
$request['status']
|
||||
);
|
||||
} elseif (!empty($employeeList)) {
|
||||
$query = "where employee in (".implode(",", $employeeList).") and date(expense_date) >= ? and date(expense_date) <= ?;";
|
||||
$query = "where employee in (".implode(",", $employeeList)
|
||||
.") and date(expense_date) >= ? and date(expense_date) <= ?;";
|
||||
$params = array(
|
||||
$request['date_start'],
|
||||
$request['date_end']
|
||||
|
||||
@@ -24,7 +24,8 @@ class OvertimeReport extends ClassBasedReportBuilder implements ReportBuilderInt
|
||||
$sevenDateBefore = date('Y-m-d', strtotime('-7 days', strtotime($request['date_start'])));
|
||||
|
||||
if (!empty($employeeList)) {
|
||||
$query = "employee in (".implode(",", $employeeList).") and in_time >= ? and out_time <= ? order by in_time;";
|
||||
$query = "employee in (".implode(",", $employeeList)
|
||||
.") and in_time >= ? and out_time <= ? order by in_time;";
|
||||
$params = array(
|
||||
$sevenDateBefore." 00:00:00",
|
||||
$request['date_end']." 23:59:59",
|
||||
@@ -57,9 +58,14 @@ 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) {
|
||||
|
||||
@@ -10,7 +10,8 @@ class TravelRequestReport extends CSVReportBuilder implements CSVReportBuilderIn
|
||||
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',
|
||||
type as 'Type',
|
||||
purpose as 'Purpose',
|
||||
travel_from as 'Travel From',
|
||||
@@ -40,14 +41,16 @@ from EmployeeTravelRecords";
|
||||
}
|
||||
|
||||
if (!empty($employeeList) && ($request['status'] != "NULL" && !empty($request['status']))) {
|
||||
$query = "where employee in (".implode(",", $employeeList).") and date(travel_date) >= ? and date(return_date) <= ? and status = ?;";
|
||||
$query = "where employee in (".implode(",", $employeeList)
|
||||
.") and date(travel_date) >= ? and date(return_date) <= ? and status = ?;";
|
||||
$params = array(
|
||||
$request['date_start'],
|
||||
$request['date_end'],
|
||||
$request['status']
|
||||
);
|
||||
} elseif (!empty($employeeList)) {
|
||||
$query = "where employee in (".implode(",", $employeeList).") and date(travel_date) >= ? and date(return_date) <= ?;";
|
||||
$query = "where employee in (".implode(",", $employeeList)
|
||||
.") and date(travel_date) >= ? and date(return_date) <= ?;";
|
||||
$params = array(
|
||||
$request['date_start'],
|
||||
$request['date_end']
|
||||
|
||||
@@ -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'])
|
||||
);
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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'],
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user