Updates from pro v19

This commit is contained in:
Gamonoid
2016-11-25 17:21:30 +01:00
parent e6b4245334
commit ed739aa4e1
26 changed files with 1187 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
<?php
class OvertimeActionManager extends ApproveAdminActionManager{
public function getModelClass(){
return "EmployeeOvertime";
}
public function getItemName(){
return "Overtime Request";
}
public function getModuleName(){
return "Overtime Management";
}
public function getModuleTabUrl(){
return "g=modules&n=overtime&m=module_Time_Management#tabEmployeeOvertime";
}
public function getModuleSubordinateTabUrl(){
return "g=modules&n=overtime&m=module_Time_Management#tabSubordinateEmployeeOvertime";
}
public function getModuleApprovalTabUrl(){
return "g=modules&n=overtime&m=module_Time_Management#tabEmployeeOvertimeApproval";
}
}

View File

@@ -0,0 +1,123 @@
<?php
if (!class_exists('OvertimeAdminManager')) {
class OvertimeAdminManager extends AbstractModuleManager{
public function initializeUserClasses(){
if(defined('MODULE_TYPE') && MODULE_TYPE != 'admin'){
$this->addUserClass("EmployeeOvertime");
}
}
public function initializeFieldMappings(){
}
public function initializeDatabaseErrorMappings(){
}
public function setupModuleClassDefinitions(){
$this->addModelClass('OvertimeCategory');
$this->addModelClass('EmployeeOvertime');
$this->addModelClass('EmployeeOvertimeApproval');
}
}
}
if (!class_exists('OvertimeCategory')) {
class OvertimeCategory extends ICEHRM_Record {
var $_table = 'OvertimeCategories';
public function getAdminAccess(){
return array("get","element","save","delete");
}
public function getManagerAccess(){
return array("get","element","save","delete");
}
public function getUserAccess(){
return array("get");
}
public function getUserOnlyMeAccess(){
return array("get","element");
}
}
}
if (!class_exists('EmployeeOvertime')) {
class EmployeeOvertime extends ApproveModel
{
var $_table = 'EmployeeOvertime';
var $notificationModuleName = "Overtime Management";
var $notificationUnitName = "OvertimeRequest";
var $notificationUnitPrefix = "An";
var $notificationUnitAdminUrl = "g=modules&n=overtime&m=module_Time_Management#tabSubordinateEmployeeOvertime";
var $preApproveSettingName = "Attendance: Pre-Approve Overtime Request";
public function isMultiLevelApprovalsEnabled(){
return (SettingsManager::getInstance()->getSetting('Overtime: Enable Multi Level Approvals') == '1');
}
public function getAdminAccess()
{
return array("get", "element", "save", "delete");
}
public function getManagerAccess()
{
return array("get", "element", "save", "delete");
}
public function getUserAccess()
{
return array("get");
}
public function getUserOnlyMeAccess()
{
return array("element", "save", "delete");
}
public function fieldsNeedToBeApproved()
{
return array(
"start_time",
"end_time"
);
}
public function getType(){
return 'EmployeeOvertime';
}
public function allowIndirectMapping(){
if(SettingsManager::getInstance()->getSetting('Overtime: Allow Indirect Admins to Approve') == '1'){
return true;
}
return false;
}
}
}
if (!class_exists('EmployeeOvertimeApproval')) {
class EmployeeOvertimeApproval extends EmployeeOvertime
{
public function Find($whereOrderBy,$bindarr=false,$pkeysArr=false,$extra=array()){
return $this->findApprovals(new EmployeeOvertime(), $whereOrderBy,$bindarr,$pkeysArr,$extra);
}
}
}

View File

@@ -0,0 +1,42 @@
<?php
/*
This file is part of iCE Hrm.
iCE Hrm is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
iCE Hrm is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with iCE Hrm. If not, see <http://www.gnu.org/licenses/>.
------------------------------------------------------------------
Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd]
Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah)
*/
$moduleName = 'travel';
define('MODULE_PATH',dirname(__FILE__));
include APP_BASE_PATH.'header.php';
include APP_BASE_PATH.'modulejslibs.inc.php';
$options = array();
$options['setRemoteTable'] = 'true';
$moduleBuilder = new ModuleBuilder();
$moduleBuilder->addModuleOrGroup(new ModuleTab('OvertimeCategory','OvertimeCategory','Overtime Categories','OvertimeCategoryAdapter','','',true,$options));
$moduleBuilder->addModuleOrGroup(new ModuleTab('EmployeeOvertime','EmployeeOvertime','Overtime Requests','EmployeeOvertimeAdminAdapter','','',false,$options));
echo UIManager::getInstance()->renderModule($moduleBuilder);
$itemName = 'OvertimeRequest';
$moduleName = 'Time Management';
$itemNameLower = strtolower($itemName);
include APP_BASE_PATH.'footer.php';

99
ext/admin/overtime/lib.js Normal file
View File

@@ -0,0 +1,99 @@
/**
* Author: Thilina Hasantha
*/
/**
* OvertimeCategoryAdapter
*/
function OvertimeCategoryAdapter(endPoint) {
this.initAdapter(endPoint);
}
OvertimeCategoryAdapter.inherits(AdapterBase);
OvertimeCategoryAdapter.method('getDataMapping', function() {
return [
"id",
"name"
];
});
OvertimeCategoryAdapter.method('getHeaders', function() {
return [
{ "sTitle": "ID" ,"bVisible":false},
{ "sTitle": "Name" }
];
});
OvertimeCategoryAdapter.method('getFormFields', function() {
return [
[ "id", {"label":"ID","type":"hidden"}],
[ "name", {"label":"Name","type":"text","validation":""}]
];
});
/**
* EmployeeOvertimeAdminAdapter
*/
function EmployeeOvertimeAdminAdapter(endPoint,tab,filter,orderBy) {
this.initAdapter(endPoint,tab,filter,orderBy);
this.itemName = 'OvertimeRequest';
this.itemNameLower = 'overtimerequest';
this.modulePathName = 'overtime';
}
EmployeeOvertimeAdminAdapter.inherits(ApproveAdminAdapter);
EmployeeOvertimeAdminAdapter.method('getDataMapping', function() {
return [
"id",
"employee",
"category",
"start_time",
"end_time",
"project",
"status"
];
});
EmployeeOvertimeAdminAdapter.method('getHeaders', function() {
return [
{ "sTitle": "ID" ,"bVisible":false},
{ "sTitle": "Employee" },
{ "sTitle": "Category" },
{ "sTitle": "Start Time" },
{ "sTitle": "End Time"},
{ "sTitle": "Project"},
{ "sTitle": "Status"}
];
});
EmployeeOvertimeAdminAdapter.method('getFormFields', function() {
return [
["id", {"label": "ID", "type": "hidden"}],
["employee", {
"label": "Employee",
"type": "select2",
"sort": "none",
"allow-null": false,
"remote-source": ["Employee", "id", "first_name+last_name", "getActiveSubordinateEmployees"]
}],
["category", {"label": "Category", "type": "select2", "allow-null":false, "remote-source": ["OvertimeCategory", "id", "name"]}],
["start_time", {"label": "Start Time", "type": "datetime", "validation": ""}],
["end_time", {"label": "End Time", "type": "datetime", "validation": ""}],
["project", {"label": "Project", "type": "select2", "allow-null":true,"null=label":"none","remote-source": ["Project", "id", "name"]}],
["notes", {"label": "Notes", "type": "textarea", "validation": "none"}]
];
});

View File

@@ -0,0 +1,12 @@
{
"label":"Overtime Administration",
"menu":"Employees",
"order":"94",
"icon":"fa-align-center",
"user_levels":["Admin","Manager"],
"dashboardPosition":13,
"permissions":
{
}
}

View File

@@ -0,0 +1,66 @@
<?php
if(!class_exists('ReportBuilder')){
include_once APP_BASE_PATH.'admin/reports/reportClasses/ReportBuilder.php';
}
class OvertimeRequestReport extends CSVReportBuilder implements CSVReportBuilderInterface{
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',
(SELECT `name` from OvertimeCategories where id = at.category) as 'Category',
(SELECT `name` from Projects where id = at.project) as 'Project',
start_time as 'Start Time',
end_time as 'End Time',
notes as 'Notes',
status as 'Status'
FROM EmployeeOvertime 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 start_time >= ? and end_time <= ?";
$params = array(
$request['date_start']." 00:00:00",
$request['date_end']." 23:59:59",
);
}else{
$query = "where start_time >= ? and end_time <= ?";
$params = array(
$request['date_start']." 00:00:00",
$request['date_end']." 23:59:59",
);
}
if(!empty($request['category']) && $request['category'] != "NULL"){
$query.= " and category = ?";
$params[] = $request['category'];
}
if(!empty($request['project']) && $request['project'] != "NULL"){
$query.= " and project = ?";
$params[] = $request['project'];
}
$query.=" order by start_time desc;";
LogManager::getInstance()->info("Query:".$query);
LogManager::getInstance()->info("Params:".json_encode($params));
return array($query, $params);
}
}

View File

@@ -0,0 +1,19 @@
<?php
class OvertimeActionManager extends ApproveModuleActionManager{
public function getModelClass(){
return "EmployeeOvertime";
}
public function getItemName(){
return "Overtime Request";
}
public function getModuleName(){
return "Overtime Management";
}
public function getModuleTabUrl(){
return "g=modules&n=overtime&m=module_Time_Management#SubordinateEmployeeOvertime";
}
}

View File

@@ -0,0 +1,24 @@
<?php
if (!class_exists('OvertimeModulesManager')) {
class OvertimeModulesManager extends AbstractModuleManager{
public function initializeUserClasses(){
}
public function initializeFieldMappings(){
}
public function initializeDatabaseErrorMappings(){
}
public function setupModuleClassDefinitions(){
}
}
}

View File

@@ -0,0 +1,94 @@
<?php
/*
This file is part of iCE Hrm.
iCE Hrm is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
iCE Hrm is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with iCE Hrm. If not, see <http://www.gnu.org/licenses/>.
------------------------------------------------------------------
Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd]
Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah)
*/
$moduleName = 'overtime';
$moduleMainName = "EmployeeOvertime"; // for creating module js lib
$subModuleMainName = "SubordinateEmployeeOvertime";
$moduleItemName = "Overtime Request"; // For permissions
$itemName = $moduleItemName; // for status change popup
$itemNameLower = strtolower($moduleMainName); // for status change popup
$appModName = $moduleMainName.'Approval';
define('MODULE_PATH',dirname(__FILE__));
include APP_BASE_PATH.'header.php';
$additionalJs = array();
$additionalJs[] = BASE_URL.'admin/overtime/lib.js?v='.$jsVersion;
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="tab<?=$moduleMainName?>" href="#tabPage<?=$moduleMainName?>"><?=LanguageManager::tran('Overtime Requests')?></a></li>
<li class=""><a id="tab<?=$subModuleMainName?>" href="#tabPage<?=$subModuleMainName?>"><?=LanguageManager::tran('Subordinate Overtime Requests')?></a></li>
<li class=""><a id="tab<?=$appModName?>" href="#tabPage<?=$appModName?>"><?=LanguageManager::tran('Overtime Request Approval')?></a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tabPage<?=$moduleMainName?>">
<div id="<?=$moduleMainName?>" class="reviewBlock" data-content="List" style="padding-left:5px;">
</div>
<div id="<?=$moduleMainName?>Form" class="reviewBlock" data-content="Form" style="padding-left:5px;display:none;">
</div>
</div>
<div class="tab-pane" id="tabPage<?=$subModuleMainName?>">
<div id="<?=$subModuleMainName?>" class="reviewBlock" data-content="List" style="padding-left:5px;">
</div>
<div id="<?=$subModuleMainName?>Form" class="reviewBlock" data-content="Form" style="padding-left:5px;display:none;">
</div>
</div>
<div class="tab-pane" id="tabPage<?=$appModName?>">
<div id="<?=$appModName?>" class="reviewBlock" data-content="List" style="padding-left:5px;">
</div>
<div id="<?=$appModName?>Form" class="reviewBlock" data-content="Form" style="padding-left:5px;display:none;">
</div>
</div>
</div>
</div>
<script>
var modJsList = new Array();
modJsList['tab<?=$moduleMainName?>'] = new <?=$moduleMainName?>Adapter('<?=$moduleMainName?>','<?=$moduleMainName?>');
modJsList['tab<?=$appModName?>'] = new <?=$moduleMainName?>ApproverAdapter('<?=$appModName?>', '<?=$appModName?>');
modJsList['tab<?=$appModName?>'].setShowAddNew(false);
modJsList['tab<?=$appModName?>'].setShowDelete(false);
modJsList['tab<?=$appModName?>'].setShowEdit(false);
modJsList['tab<?=$subModuleMainName?>'] = new <?=$subModuleMainName?>Adapter('<?=$moduleMainName?>','<?=$subModuleMainName?>');
modJsList['tab<?=$subModuleMainName?>'].setRemoteTable(true);
modJsList['tab<?=$subModuleMainName?>'].setShowAddNew(false);
modJsList['tab<?=$subModuleMainName?>'].setShowDelete(false);
modJsList['tab<?=$subModuleMainName?>'].setShowEdit(true);
var modJs = modJsList['tab<?=$moduleMainName?>'];
</script>
<?php include APP_BASE_PATH.'footer.php';?>

120
ext/modules/overtime/lib.js Normal file
View File

@@ -0,0 +1,120 @@
/*
This file is part of iCE Hrm.
Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd]
Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah)
*/
function EmployeeOvertimeAdapter(endPoint) {
this.initAdapter(endPoint);
this.itemName = 'Overtime';
this.itemNameLower = 'employeeovertime';
this.modulePathName = 'overtime';
}
EmployeeOvertimeAdapter.inherits(ApproveModuleAdapter);
EmployeeOvertimeAdapter.method('getDataMapping', function() {
return [
"id",
"category",
"start_time",
"end_time",
"project",
"status"
];
});
EmployeeOvertimeAdapter.method('getHeaders', function() {
return [
{ "sTitle": "ID" ,"bVisible":false},
{ "sTitle": "Category" },
{ "sTitle": "Start Time" },
{ "sTitle": "End Time"},
{ "sTitle": "Project"},
{ "sTitle": "Status"}
];
});
EmployeeOvertimeAdapter.method('getFormFields', function() {
return [
["id", {"label": "ID", "type": "hidden"}],
["category", {"label": "Category", "type": "select2", "allow-null":false, "remote-source": ["OvertimeCategory", "id", "name"]}],
["start_time", {"label": "Start Time", "type": "datetime", "validation": ""}],
["end_time", {"label": "End Time", "type": "datetime", "validation": ""}],
["project", {"label": "Project", "type": "select2", "allow-null":true,"null=label":"none","remote-source": ["Project", "id", "name"]}],
["notes", {"label": "Notes", "type": "textarea", "validation": "none"}]
];
});
/*
EmployeeOvertimeApproverAdapter
*/
function EmployeeOvertimeApproverAdapter(endPoint) {
this.initAdapter(endPoint);
this.itemName = 'Overtime';
this.itemNameLower = 'employeeovertime';
this.modulePathName = 'overtime';
}
EmployeeOvertimeApproverAdapter.inherits(EmployeeOvertimeAdminAdapter);
EmployeeOvertimeApproverAdapter.method('getActionButtonsHtml', function(id,data) {
var statusChangeButton = '<img class="tableActionButton" src="_BASE_images/run.png" style="cursor:pointer;" rel="tooltip" title="Change Status" onclick="modJs.openStatus(_id_, \'_cstatus_\');return false;"></img>';
var viewLogsButton = '<img class="tableActionButton" src="_BASE_images/log.png" style="margin-left:15px;cursor:pointer;" rel="tooltip" title="View Logs" onclick="modJs.getLogs(_id_);return false;"></img>';
var html = '<div style="width:80px;">_status__logs_</div>';
html = html.replace('_logs_',viewLogsButton);
if(data[this.getStatusFieldPosition()] == 'Processing'){
html = html.replace('_status_',statusChangeButton);
}else{
html = html.replace('_status_','');
}
html = html.replace(/_id_/g,id);
html = html.replace(/_BASE_/g,this.baseUrl);
html = html.replace(/_cstatus_/g,data[this.getStatusFieldPosition()]);
return html;
});
EmployeeOvertimeApproverAdapter.method('getStatusOptionsData', function(currentStatus) {
var data = {};
if(currentStatus != 'Processing'){
}else{
data["Approved"] = "Approved";
data["Rejected"] = "Rejected";
}
return data;
});
EmployeeOvertimeApproverAdapter.method('getStatusOptions', function(currentStatus) {
return this.generateOptions(this.getStatusOptionsData(currentStatus));
});
/*
EmployeeOvertimeAdapter
*/
function SubordinateEmployeeOvertimeAdapter(endPoint,tab,filter,orderBy) {
this.initAdapter(endPoint,tab,filter,orderBy);
this.itemName = 'Overtime';
this.itemNameLower = 'employeeovertime';
this.modulePathName = 'overtime';
}
SubordinateEmployeeOvertimeAdapter.inherits(EmployeeOvertimeAdminAdapter);

View File

@@ -0,0 +1,12 @@
{
"label":"Overtime Requests",
"menu":"Time Management",
"order":"5",
"icon":"fa-align-center",
"user_levels":["Admin","Manager","Employee"],
"dashboardPosition":106,
"permissions":
{
}
}