Upgrade to v15.0.OS

This commit is contained in:
Thilina Hasantha
2016-02-08 04:25:58 +05:30
parent b99b6f6f77
commit 078396d5d7
91 changed files with 3332 additions and 1720 deletions

View File

@@ -0,0 +1,17 @@
<div class="col-lg-3 col-xs-12">
<div class="small-box bg-teal">
<div class="inner">
<h3>Reports</h3>
<p>
View / Download Reports
</p>
</div>
<div class="icon">
<i class="ion ion-document-text"></i>
</div>
<a href="#_moduleLink_#" class="small-box-footer" id="reportsLink">
Create a Report <i class="fa fa-arrow-circle-right"></i>
</a>
</div>
</div>

View File

@@ -19,14 +19,21 @@ include APP_BASE_PATH.'modulejslibs.inc.php';
</div>
</div>
</div>
</div>
<script>
var modJsList = new Array();
modJsList['tabReport'] = new ReportAdapter('Report','Report');
modJsList['tabReport'] = new ReportAdapter('Report','Report','','report_group');
modJsList['tabReport'].setShowAddNew(false);
modJsList['tabReport'].setRemoteTable(true);
/*
modJsList['tabReport'] = new ReportGenAdapter('File','File','{"file_group":"Report"}','group');
modJsList['tabReport'].setShowAddNew(false);
*/
var modJs = modJsList['tabReport'];

View File

@@ -7,8 +7,9 @@
* ReportAdapter
*/
function ReportAdapter(endPoint) {
this.initAdapter(endPoint);
function ReportAdapter(endPoint,tab,filter,orderBy) {
this.initAdapter(endPoint,tab,filter,orderBy);
this._formFileds = [
[ "id", {"label":"ID","type":"hidden"}],
[ "name", {"label":"Name","type":"label","validation":""}],
@@ -162,3 +163,42 @@ ReportAdapter.method('fillForm', function(object) {
}
});
function ReportGenAdapter(endPoint) {
this.initAdapter(endPoint);
}
ReportGenAdapter.inherits(AdapterBase);
ReportGenAdapter.method('getDataMapping', function() {
return [
"id",
"name",
];
});
ReportGenAdapter.method('getHeaders', function() {
return [
{ "sTitle": "ID" ,"bVisible":false},
{ "sTitle": "Name" }
];
});
ReportGenAdapter.method('getFormFields', function() {
return [
];
});
ReportGenAdapter.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="download(_name_);return false;"></img></div>';
html = html.replace(/_id_/g,id);
html = html.replace(/_name_/g,data[1]);
html = html.replace(/_BASE_/g,this.baseUrl);
return html;
});

View File

@@ -1,11 +1,11 @@
{
"label":"Reports",
"menu":"Reports",
"order":"1",
"icon":"fa-file-o",
"user_levels":["Admin","Manager"],
"permissions":
{
}
"label":"Reports",
"menu":"Reports",
"order":"1",
"icon":"fa-file-o",
"user_levels":["Admin","Manager"],
"dashboardPosition":7,
"permissions":
{
}
}

View File

@@ -1,6 +1,6 @@
<?php
if(!class_exists('ReportBuilder')){
include_once MODULE_PATH.'/reportClasses/ReportBuilder.php';
include_once APP_BASE_PATH.'admin/reports/reportClasses/ReportBuilder.php';
}
class ActiveEmployeeReport extends ReportBuilder{

View File

@@ -1,6 +1,6 @@
<?php
if(!class_exists('ReportBuilder')){
include_once MODULE_PATH.'/reportClasses/ReportBuilder.php';
include_once APP_BASE_PATH.'admin/reports/reportClasses/ReportBuilder.php';
}
class EmployeeAttendanceReport extends ReportBuilder{

View File

@@ -0,0 +1,53 @@
<?php
if(!interface_exists('ReportBuilderInterface')){
include_once APP_BASE_PATH.'admin/reports/reportClasses/ReportBuilderInterface.php';
}
if(!class_exists('LeavesActionManager')){
include_once APP_BASE_PATH.'modules/leaves/api/LeavesActionManager.php';
}
class EmployeeLeaveEntitlementReport implements ReportBuilderInterface{
public function getData($report,$req){
$leaveActionManager = new LeavesActionManager();
$department = $req['department'];
$employeeId = $req['employee'];
if(($employeeId == "NULL" || empty($employeeId)) && ($department == "NULL" || empty($department))){
$emp = new Employee();
$employees = $emp->Find("status = 'Active'",array());
}else if($employeeId != "NULL" && !empty($employeeId)){
$emp = new Employee();
$employees = $emp->Find("id = ?",array($employeeId));
}else{
$emp = new Employee();
$employees = $emp->Find("department = ? and status = 'Active'",array($department));
}
$reportData = array();
$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();
foreach($leaveEntitlements as $leaveEntitlement){
$reportData[] = array(
$employee->employee_id,
$employee->first_name." ".$employee->last_name,
$leaveEntitlement['name'],
$leaveEntitlement['pendingLeaves'],
$leaveEntitlement['approvedLeaves'],
$leaveEntitlement['rejectedLeaves'],
$leaveEntitlement['cancelRequestedLeaves'],
$leaveEntitlement['availableLeaves'],
$leaveEntitlement['tobeAccrued'],
$leaveEntitlement['carriedForward']
);
}
}
return $reportData;
}
}

View File

@@ -0,0 +1,70 @@
<?php
if(!class_exists('ReportBuilder')){
include_once APP_BASE_PATH.'admin/reports/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_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'
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);
}
}

View File

@@ -0,0 +1,67 @@
<?php
if(!interface_exists('ReportBuilderInterface')){
include_once APP_BASE_PATH.'admin/reports/reportClasses/ReportBuilderInterface.php';
}
class EmployeeTimeSheetData implements ReportBuilderInterface{
public function getData($report,$request){
$employeeCache = array();
$employeeList = array();
if(!empty($request['employee'])){
$employeeList = json_decode($request['employee'],true);
}
if(in_array("NULL", $employeeList) ){
$employeeList = array();
}
$employee_query = "";
if(!empty($employeeList)){
$employee_query = "employee in (".implode(",", $employeeList).") and ";
}
$timeSheet = new EmployeeTimeSheet();
if($request['status'] != "NULL"){
$timeSheets = $timeSheet->Find($employee_query."status = ? and date_start >= ? and date_end <= ?",
array($request['status'],$request['date_start'],$request['date_end']));
}else{
$timeSheets = $timeSheet->Find($employee_query."date_start >= ? and date_end <= ?",
array($request['date_start'],$request['date_end']));
}
if(!$timeSheets){
LogManager::getInstance()->info($timeSheet->ErrorMsg());
}
$reportData = array();
$reportData[] = array("Employee ID","Employee","Time Sheet","Total Time","Status");
foreach($timeSheets as $ts){
$employee = $employeeCache[$ts->employee];
if(empty($employee)){
$employee = new Employee();
$employee->Load("id = ?",array($ts->employee));
if(empty($employee->id)){
continue;
}
$employeeCache[$employee->id] = $employee;
}
$reportData[] = array(
$employee->employee_id,
$employee->first_name." ".$employee->last_name,
$ts->name,
$ts->getTotalTime(),
$ts->status
);
}
return $reportData;
}
}

View File

@@ -1,6 +1,6 @@
<?php
if(!interface_exists('ReportBuilderInterface')){
include_once MODULE_PATH.'/reportClasses/ReportBuilderInterface.php';
include_once APP_BASE_PATH.'admin/reports/reportClasses/ReportBuilderInterface.php';
}
class EmployeeTimeTrackReport implements ReportBuilderInterface{
public function getData($report,$req){

View File

@@ -1,6 +1,6 @@
<?php
if(!class_exists('ReportBuilder')){
include_once MODULE_PATH.'/reportClasses/ReportBuilder.php';
include_once APP_BASE_PATH.'admin/reports/reportClasses/ReportBuilder.php';
}
class EmployeeTimesheetReport extends ReportBuilder{

View File

@@ -0,0 +1,68 @@
<?php
if(!class_exists('ReportBuilder')){
include_once APP_BASE_PATH.'admin/reports/reportClasses/ReportBuilder.php';
}
class ExpenseReport extends ReportBuilder{
public function getMainQuery(){
$query = "SELECT
(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',
payee as 'Payee',
(SELECT name from ExpensesCategories where id = category) as 'Category',
notes as 'Notes',
concat(`amount`,' ',`currency`) as 'Amount',
status as 'Status',
created as 'Created',
updated as 'Updated'
from EmployeeExpenses";
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(expense_date) >= ? and date(expense_date) <= ? and status = ?;";
$params = array(
$request['date_start'],
$request['date_end'],
$request['status']
);
}else if(!empty($employeeList)){
$query = "where employee in (".implode(",", $employeeList).") and date(expense_date) >= ? and date(expense_date) <= ?;";
$params = array(
$request['date_start'],
$request['date_end']
);
}else if(($request['status'] != "NULL" && !empty($request['status']))){
$query = "where status = ? and date(expense_date) >= ? and date(expense_date) <= ?;";
$params = array(
$request['status'],
$request['date_start'],
$request['date_end']
);
}else{
$query = "where date(expense_date) >= ? and date(expense_date) <= ?;";
$params = array(
$request['date_start'],
$request['date_end']
);
}
return array($query, $params);
}
}

View File

@@ -1,6 +1,6 @@
<?php
if(!class_exists('ActiveEmployeeReport')){
include_once MODULE_PATH.'/reportClasses/ActiveEmployeeReport.php';
include_once APP_BASE_PATH.'admin/reports/reportClasses/ActiveEmployeeReport.php';
}
class NewHiresEmployeeReport extends ActiveEmployeeReport{

View File

@@ -1,6 +1,6 @@
<?php
if(!interface_exists('ReportBuilderInterface')){
include_once MODULE_PATH.'/reportClasses/ReportBuilderInterface.php';
include_once APP_BASE_PATH.'admin/reports/reportClasses/ReportBuilderInterface.php';
}
abstract class ReportBuilder implements ReportBuilderInterface{

View File

@@ -1,6 +1,6 @@
<?php
if(!class_exists('ActiveEmployeeReport')){
include_once MODULE_PATH.'/reportClasses/ActiveEmployeeReport.php';
include_once APP_BASE_PATH.'admin/reports/reportClasses/ActiveEmployeeReport.php';
}
class TerminatedEmployeeReport extends ActiveEmployeeReport{

View File

@@ -0,0 +1,69 @@
<?php
if(!class_exists('ReportBuilder')){
include_once APP_BASE_PATH.'admin/reports/reportClasses/ReportBuilder.php';
}
class TravelRequestReport extends ReportBuilder{
public function getMainQuery(){
$query = "SELECT
(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',
travel_to as 'Travel To',
travel_date as 'Travel Date',
return_date as 'Return Date',
details as 'Other Details',
concat(`funding`,' ',`currency`) as 'Funding',
status as 'Status',
created as 'Created',
updated as 'Updated'
from EmployeeTravelRecords";
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(travel_date) >= ? and date(return_date) <= ? and status = ?;";
$params = array(
$request['date_start'],
$request['date_end'],
$request['status']
);
}else if(!empty($employeeList)){
$query = "where employee in (".implode(",", $employeeList).") and date(travel_date) >= ? and date(return_date) <= ?;";
$params = array(
$request['date_start'],
$request['date_end']
);
}else if(($request['status'] != "NULL" && !empty($request['status']))){
$query = "where status = ? and date(travel_date) >= ? and date(return_date) <= ?;";
$params = array(
$request['status'],
$request['date_start'],
$request['date_end']
);
}else{
$query = "where date(travel_date) >= ? and date(return_date) <= ?;";
$params = array(
$request['date_start'],
$request['date_end']
);
}
return array($query, $params);
}
}