Initial checkin v13.0
This commit is contained in:
23
ext/admin/reports/api/ReportsAdminManager.php
Normal file
23
ext/admin/reports/api/ReportsAdminManager.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
if (!class_exists('ReportsAdminManager')) {
|
||||
class ReportsAdminManager extends AbstractModuleManager{
|
||||
|
||||
public function initializeUserClasses(){
|
||||
|
||||
}
|
||||
|
||||
public function initializeFieldMappings(){
|
||||
|
||||
}
|
||||
|
||||
public function initializeDatabaseErrorMappings(){
|
||||
|
||||
}
|
||||
|
||||
public function setupModuleClassDefinitions(){
|
||||
|
||||
//This is a fixed module, store model classes in models.inc.php
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
34
ext/admin/reports/index.php
Normal file
34
ext/admin/reports/index.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
$moduleName = 'Reports';
|
||||
define('MODULE_PATH',dirname(__FILE__));
|
||||
include APP_BASE_PATH.'header.php';
|
||||
include APP_BASE_PATH.'modulejslibs.inc.php';
|
||||
?><div class="span9">
|
||||
|
||||
<ul class="nav nav-tabs" id="modTab" style="margin-bottom:0px;margin-left:5px;border-bottom: none;">
|
||||
<li class="active"><a id="tabReport" href="#tabPageReport">Reports</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active" id="tabPageReport">
|
||||
<div id="Report" class="reviewBlock" data-content="List" style="padding-left:5px;">
|
||||
|
||||
</div>
|
||||
<div id="ReportForm" class="reviewBlock" data-content="Form" style="padding-left:5px;display:none;">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<script>
|
||||
var modJsList = new Array();
|
||||
|
||||
modJsList['tabReport'] = new ReportAdapter('Report','Report');
|
||||
modJsList['tabReport'].setShowAddNew(false);
|
||||
|
||||
var modJs = modJsList['tabReport'];
|
||||
|
||||
</script>
|
||||
<?php include APP_BASE_PATH.'footer.php';?>
|
||||
167
ext/admin/reports/lib.js
Normal file
167
ext/admin/reports/lib.js
Normal file
@@ -0,0 +1,167 @@
|
||||
/**
|
||||
* Author: Thilina Hasantha
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* ReportAdapter
|
||||
*/
|
||||
|
||||
function ReportAdapter(endPoint) {
|
||||
this.initAdapter(endPoint);
|
||||
this._formFileds = [
|
||||
[ "id", {"label":"ID","type":"hidden"}],
|
||||
[ "name", {"label":"Name","type":"label","validation":""}],
|
||||
[ "parameters", {"label":"Parameters","type":"fieldset","validation":"none"}]
|
||||
];
|
||||
}
|
||||
|
||||
ReportAdapter.inherits(AdapterBase);
|
||||
|
||||
ReportAdapter.method('_initLocalFormFields', function() {
|
||||
this._formFileds = [
|
||||
[ "id", {"label":"ID","type":"hidden"}],
|
||||
[ "name", {"label":"Name","type":"label","validation":""}],
|
||||
[ "parameters", {"label":"Parameters","type":"fieldset","validation":"none"}]
|
||||
];
|
||||
});
|
||||
|
||||
ReportAdapter.method('getDataMapping', function() {
|
||||
return [
|
||||
"id",
|
||||
"name",
|
||||
"details",
|
||||
"parameters"
|
||||
];
|
||||
});
|
||||
|
||||
ReportAdapter.method('getHeaders', function() {
|
||||
return [
|
||||
{ "sTitle": "ID" ,"bVisible":false},
|
||||
{ "sTitle": "Name" },
|
||||
{ "sTitle": "Details"},
|
||||
{ "sTitle": "Parameters","bVisible":false},
|
||||
];
|
||||
});
|
||||
|
||||
ReportAdapter.method('getFormFields', function() {
|
||||
return this._formFileds;
|
||||
});
|
||||
|
||||
ReportAdapter.method('processFormFieldsWithObject', function(object) {
|
||||
var that = this;
|
||||
this._initLocalFormFields();
|
||||
var len = this._formFileds.length;
|
||||
var fieldIDsToDelete = [];
|
||||
var fieldsToDelete = [];
|
||||
for(var i=0;i<len;i++){
|
||||
if(this._formFileds[i][1]['type']=="fieldset"){
|
||||
var newFields = JSON.parse(object[this._formFileds[i][0]]);
|
||||
fieldsToDelete.push(this._formFileds[i][0]);
|
||||
newFields.forEach(function(entry) {
|
||||
that._formFileds.push(entry);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
var tempArray = [];
|
||||
that._formFileds.forEach(function(entry) {
|
||||
if(jQuery.inArray(entry[0], fieldsToDelete) < 0){
|
||||
tempArray.push(entry);
|
||||
}
|
||||
});
|
||||
|
||||
that._formFileds = tempArray;
|
||||
});
|
||||
|
||||
ReportAdapter.method('renderForm', function(object) {
|
||||
var that = this;
|
||||
this.processFormFieldsWithObject(object);
|
||||
var cb = function(){
|
||||
that.uber('renderForm',object);
|
||||
};
|
||||
this.initFieldMasterData(cb);
|
||||
|
||||
});
|
||||
|
||||
ReportAdapter.method('getActionButtonsHtml', function(id,data) {
|
||||
var html = '<div style="width:80px;"><img class="tableActionButton" src="_BASE_images/download.png" style="cursor:pointer;" rel="tooltip" title="Download" onclick="modJs.edit(_id_);return false;"></img></div>';
|
||||
html = html.replace(/_id_/g,id);
|
||||
html = html.replace(/_BASE_/g,this.baseUrl);
|
||||
return html;
|
||||
});
|
||||
|
||||
ReportAdapter.method('addSuccessCallBack', function(callBackData,serverData) {
|
||||
//var link = '<a href="'+this.getCustomActionUrl("download",{'file':serverData})+'" target="_blank">Download Report <i class="icon-download-alt"></i> </a>';
|
||||
//this.showMessage("Download Report",link);
|
||||
|
||||
var fileName = serverData[0];
|
||||
var link;
|
||||
|
||||
if(fileName.indexOf("https:") == 0){
|
||||
link = '<a href="'+fileName+'" target="_blank" style="font-size:14px;font-weight:bold;">Download Report <img src="_BASE_images/download.png"></img> </a>';
|
||||
}else{
|
||||
link = '<a href="'+modJs.getCustomActionUrl("download",{'file':fileName})+'" target="_blank" style="font-size:14px;font-weight:bold;">Download Report <img src="_BASE_images/download.png"></img> </a>';
|
||||
}
|
||||
link = link.replace(/_BASE_/g,this.baseUrl);
|
||||
|
||||
var tableHtml = link+'<br/><br/><div class="box-body table-responsive" style="overflow-x:scroll;padding: 5px;border: solid 1px #DDD;"><table id="tempReportTable" cellpadding="0" cellspacing="0" border="0" class="table table-bordered table-striped"></table></div>';
|
||||
|
||||
//Delete existing temp report table
|
||||
$("#tempReportTable").remove();
|
||||
|
||||
//this.showMessage("Report",tableHtml);
|
||||
|
||||
$("#Report").html(tableHtml);
|
||||
$("#Report").show();
|
||||
$("#ReportForm").hide();
|
||||
|
||||
//Prepare headers
|
||||
var headers = [];
|
||||
for(title in serverData[1]){
|
||||
headers.push({ "sTitle": serverData[1][title]});
|
||||
}
|
||||
|
||||
var data = serverData[2];
|
||||
|
||||
|
||||
var dataTableParams = {
|
||||
"oLanguage": {
|
||||
"sLengthMenu": "_MENU_ records per page"
|
||||
},
|
||||
"aaData": data,
|
||||
"aoColumns": headers,
|
||||
"bSort": false,
|
||||
"iDisplayLength": 15,
|
||||
"iDisplayStart": 0
|
||||
};
|
||||
|
||||
$("#tempReportTable").dataTable( dataTableParams );
|
||||
|
||||
$(".dataTables_paginate ul").addClass("pagination");
|
||||
$(".dataTables_length").hide();
|
||||
$(".dataTables_filter input").addClass("form-control");
|
||||
$(".dataTables_filter input").attr("placeholder","Search");
|
||||
$(".dataTables_filter label").contents().filter(function(){
|
||||
return (this.nodeType == 3);
|
||||
}).remove();
|
||||
$('.tableActionButton').tooltip();
|
||||
});
|
||||
|
||||
|
||||
ReportAdapter.method('fillForm', function(object) {
|
||||
var fields = this.getFormFields();
|
||||
for(var i=0;i<fields.length;i++) {
|
||||
if(fields[i][1].type == 'label'){
|
||||
$("#"+this.getTableName()+'Form #'+fields[i][0]).html(object[fields[i][0]]);
|
||||
}else{
|
||||
$("#"+this.getTableName()+'Form #'+fields[i][0]).val(object[fields[i][0]]);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
ReportAdapter.method('getHelpLink', function () {
|
||||
return 'http://blog.icehrm.com/?page_id=118';
|
||||
});
|
||||
11
ext/admin/reports/meta.json
Normal file
11
ext/admin/reports/meta.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"label":"Reports",
|
||||
"menu":"Reports",
|
||||
"order":"1",
|
||||
"icon":"fa-file-o",
|
||||
"user_levels":["Admin","Manager"],
|
||||
|
||||
"permissions":
|
||||
{
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
18
ext/admin/reports/scripts/reports.sql
Normal file
18
ext/admin/reports/scripts/reports.sql
Normal file
@@ -0,0 +1,18 @@
|
||||
INSERT INTO `Reports` (`name`, `details`, `parameters`, `query`, `paramOrder`, `type`) VALUES
|
||||
('Active Employee Report', 'This report list employees who are currently active based on joined date and termination date ',
|
||||
'[\r\n[ "department", {"label":"Department","type":"select2","remote-source":["CompanyStructure","id","title"],"allow-null":true}]\r\n]',
|
||||
'ActiveEmployeeReport',
|
||||
'["department"]', 'Class');
|
||||
|
||||
|
||||
INSERT INTO `Reports` (`name`, `details`, `parameters`, `query`, `paramOrder`, `type`) VALUES
|
||||
('New Hires Employee Report', 'This report list employees who are joined between given two dates ',
|
||||
'[[ "department", {"label":"Department","type":"select2","remote-source":["CompanyStructure","id","title"],"allow-null":true}],\r\n[ "date_start", {"label":"Start Date","type":"date"}],\r\n[ "date_end", {"label":"End Date","type":"date"}]\r\n]',
|
||||
'NewHiresEmployeeReport',
|
||||
'["department","date_start","date_end"]', 'Class');
|
||||
|
||||
INSERT INTO `Reports` (`name`, `details`, `parameters`, `query`, `paramOrder`, `type`) VALUES
|
||||
('Terminated Employee Report', 'This report list employees who are terminated between given two dates ',
|
||||
'[[ "department", {"label":"Department","type":"select2","remote-source":["CompanyStructure","id","title"],"allow-null":true}],\r\n[ "date_start", {"label":"Start Date","type":"date"}],\r\n[ "date_end", {"label":"End Date","type":"date"}]\r\n]',
|
||||
'TerminatedEmployeeReport',
|
||||
'["department","date_start","date_end"]', 'Class');
|
||||
6
ext/admin/reports/templates/fields/label.html
Normal file
6
ext/admin/reports/templates/fields/label.html
Normal file
@@ -0,0 +1,6 @@
|
||||
<div class="control-group" id="field__id_">
|
||||
<div class="controls">
|
||||
<label id="_id_" name="_id_" style="font-weight:bold"></label>
|
||||
<hr/>
|
||||
</div>
|
||||
</div>
|
||||
14
ext/admin/reports/templates/form_template.html
Normal file
14
ext/admin/reports/templates/form_template.html
Normal file
@@ -0,0 +1,14 @@
|
||||
<form class="form-horizontal" id="_id_">
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<span class="label label-warning" id="_id__error" style="display:none;"></span>
|
||||
</div>
|
||||
</div>
|
||||
_fields_
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<button onclick="try{modJs.save()}catch(e){};return false;" class="btn">Download</button>
|
||||
<button onclick="modJs.cancel();return false;" class="btn">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
Reference in New Issue
Block a user