I have a ReportBuilder class to create a document (Excel). I want to select the employee and the date period , and then calculate the total working hour for this date. this is my php file
<?php
class EmployeeSummaryTimesheet 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',
TIMEDIFF(out_time, in_time) as 'Working Hours'
FROM Attendance at";
return $query;
}
public function getWhereQuery($request){
if(($request['employee'] != "NULL" && !empty($request['employee']))){
$query = "where employee = ? and in_time >= ? and out_time <= ? group by employee;";
$params = array(
$request['employee'],
$request['date_start']." 00:00:00",
$request['date_end']." 23:59:59",
);
}else{
$query = "where in_time >= ? and out_time <= ? group by employee;";
$params = array(
$request['date_start']." 00:00:00",
$request['date_end']." 23:59:59",
);
}
return array($query, $params);
}}
now I canβt get the sum of this specific time period im getting the first day TIMEDIFF (out_time, in_time) value just not the amount of working time help me
EDit - Here I have two Employee and Attendance tables (id, employee (this is the identifier of the employee from the Employee table), in_time, out_time)
Edit: I strip DATE_FORMAT (in_time, '% Y-% m-% d') as "Date", I don't need this column