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);
}
}