Improve dashboards
This commit is contained in:
@@ -1,70 +0,0 @@
|
|||||||
<?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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
19
ext/admin/travel/api/TravelActionManager.php
Normal file
19
ext/admin/travel/api/TravelActionManager.php
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
class TravelActionManager extends ApproveAdminActionManager{
|
||||||
|
|
||||||
|
public function getModelClass(){
|
||||||
|
return "EmployeeTravelRecord";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getItemName(){
|
||||||
|
return "TravelRequest";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getModuleName(){
|
||||||
|
return "Travel Management";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getModuleTabUrl(){
|
||||||
|
return "g=modules&n=travel&m=module_Travel_Management";
|
||||||
|
}
|
||||||
|
}
|
||||||
128
ext/admin/travel/api/TravelAdminManager.php
Normal file
128
ext/admin/travel/api/TravelAdminManager.php
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
<?php
|
||||||
|
if (!class_exists('TravelAdminManager')) {
|
||||||
|
|
||||||
|
class TravelAdminManager extends AbstractModuleManager{
|
||||||
|
|
||||||
|
public function initializeUserClasses(){
|
||||||
|
if(defined('MODULE_TYPE') && MODULE_TYPE != 'admin'){
|
||||||
|
$this->addUserClass("EmployeeImmigration");
|
||||||
|
$this->addUserClass("EmployeeTravelRecord");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function initializeFieldMappings(){
|
||||||
|
$this->addFileFieldMapping('EmployeeImmigration', 'attachment1', 'name');
|
||||||
|
$this->addFileFieldMapping('EmployeeImmigration', 'attachment2', 'name');
|
||||||
|
$this->addFileFieldMapping('EmployeeImmigration', 'attachment3', 'name');
|
||||||
|
|
||||||
|
$this->addFileFieldMapping('EmployeeTravelRecord', 'attachment1', 'name');
|
||||||
|
$this->addFileFieldMapping('EmployeeTravelRecord', 'attachment2', 'name');
|
||||||
|
$this->addFileFieldMapping('EmployeeTravelRecord', 'attachment3', 'name');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function initializeDatabaseErrorMappings(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setupModuleClassDefinitions(){
|
||||||
|
|
||||||
|
$this->addModelClass('ImmigrationDocument');
|
||||||
|
$this->addModelClass('EmployeeImmigration');
|
||||||
|
$this->addModelClass('EmployeeTravelRecord');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!class_exists('ImmigrationDocument')) {
|
||||||
|
class ImmigrationDocument extends ICEHRM_Record {
|
||||||
|
var $_table = 'ImmigrationDocuments';
|
||||||
|
|
||||||
|
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('EmployeeImmigration')) {
|
||||||
|
class EmployeeImmigration extends ICEHRM_Record {
|
||||||
|
var $_table = 'EmployeeImmigrations';
|
||||||
|
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!class_exists('EmployeeTravelRecord')) {
|
||||||
|
class EmployeeTravelRecord extends ApproveModel
|
||||||
|
{
|
||||||
|
var $_table = 'EmployeeTravelRecords';
|
||||||
|
|
||||||
|
var $notificationModuleName = "Travel Management";
|
||||||
|
var $notificationUnitName = "TravelRequest";
|
||||||
|
var $notificationUnitPrefix = "A";
|
||||||
|
var $notificationUnitAdminUrl = "g=admin&n=travel&m=admin_Employees";
|
||||||
|
var $preApproveSettingName = "Travel: Pre-Approve Travel Request";
|
||||||
|
|
||||||
|
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(
|
||||||
|
"travel_from",
|
||||||
|
"travel_to",
|
||||||
|
"travel_date",
|
||||||
|
"return_date",
|
||||||
|
"funding",
|
||||||
|
"currency"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
78
ext/admin/travel/index.php
Normal file
78
ext/admin/travel/index.php
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
<?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('EmployeeTravelRecord','EmployeeTravelRecord','Travel Requests','EmployeeTravelRecordAdapter','','',true,$options));
|
||||||
|
echo UIManager::getInstance()->renderModule($moduleBuilder);
|
||||||
|
|
||||||
|
|
||||||
|
$itemName = 'TravelRequest';
|
||||||
|
$moduleName = 'Travel Management';
|
||||||
|
$itemNameLower = strtolower($itemName);
|
||||||
|
|
||||||
|
$statuses = array("Approved","Pending","Rejected","Cancelled");
|
||||||
|
|
||||||
|
?><div class="modal" id="<?=$itemNameLower?>StatusModel" tabindex="-1" role="dialog" aria-labelledby="messageModelLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><li class="fa fa-times"/></button>
|
||||||
|
<h3 style="font-size: 17px;">Change <?=$itemName?> Status</h3>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<form id="expenseStatusForm">
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label" for="expense_status"><?=$itemName?> Status</label>
|
||||||
|
<div class="controls">
|
||||||
|
<select type="text" id="<?=$itemNameLower?>_status" class="form-control" name="<?=$itemNameLower?>_status" value="">
|
||||||
|
<?php foreach($statuses as $status){?>
|
||||||
|
<option value="<?=$status?>"><?=$status?></option>
|
||||||
|
<?php }?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label" for="expense_status">Status Change Note</label>
|
||||||
|
<div class="controls">
|
||||||
|
<textarea id="<?=$itemNameLower?>_reason" class="form-control" name="<?=$itemNameLower?>_reason" maxlength="500"></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button class="btn btn-primary" onclick="modJs.changeStatus();">Change <?=$itemName?> Status</button>
|
||||||
|
<button class="btn" onclick="modJs.closeDialog();">Not Now</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
include APP_BASE_PATH.'footer.php';
|
||||||
182
ext/admin/travel/lib.js
Normal file
182
ext/admin/travel/lib.js
Normal file
@@ -0,0 +1,182 @@
|
|||||||
|
/**
|
||||||
|
* Author: Thilina Hasantha
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ImmigrationDocumentAdapter
|
||||||
|
*/
|
||||||
|
|
||||||
|
function ImmigrationDocumentAdapter(endPoint) {
|
||||||
|
this.initAdapter(endPoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
ImmigrationDocumentAdapter.inherits(AdapterBase);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ImmigrationDocumentAdapter.method('getDataMapping', function() {
|
||||||
|
return [
|
||||||
|
"id",
|
||||||
|
"name",
|
||||||
|
"details",
|
||||||
|
"required",
|
||||||
|
"alert_on_missing",
|
||||||
|
"alert_before_expiry"
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
ImmigrationDocumentAdapter.method('getHeaders', function() {
|
||||||
|
return [
|
||||||
|
{ "sTitle": "ID" ,"bVisible":false},
|
||||||
|
{ "sTitle": "Name" },
|
||||||
|
{ "sTitle": "Details"},
|
||||||
|
{ "sTitle": "Compulsory"},
|
||||||
|
{ "sTitle": "Alert If Not Found"},
|
||||||
|
{ "sTitle": "Alert Before Expiry"}
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
ImmigrationDocumentAdapter.method('getFormFields', function() {
|
||||||
|
return [
|
||||||
|
[ "id", {"label":"ID","type":"hidden"}],
|
||||||
|
[ "name", {"label":"Name","type":"text","validation":""}],
|
||||||
|
[ "details", {"label":"Details","type":"textarea","validation":"none"}],
|
||||||
|
[ "required", {"label":"Compulsory","type":"select","source":[["No","No"],["Yes","Yes"]]}],
|
||||||
|
[ "alert_on_missing", {"label":"Alert If Not Found","type":"select","source":[["No","No"],["Yes","Yes"]]}],
|
||||||
|
[ "alert_before_expiry", {"label":"Alert Before Expiry","type":"select","source":[["No","No"],["Yes","Yes"]]}],
|
||||||
|
[ "alert_before_day_number", {"label":"Days for Expiry Alert","type":"text","validation":""}]
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EmployeeImmigrationAdapter
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
function EmployeeImmigrationAdapter(endPoint) {
|
||||||
|
this.initAdapter(endPoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
EmployeeImmigrationAdapter.inherits(AdapterBase);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
EmployeeImmigrationAdapter.method('getDataMapping', function() {
|
||||||
|
return [
|
||||||
|
"id",
|
||||||
|
"employee",
|
||||||
|
"document",
|
||||||
|
"documentname",
|
||||||
|
"valid_until",
|
||||||
|
"status"
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
EmployeeImmigrationAdapter.method('getHeaders', function() {
|
||||||
|
return [
|
||||||
|
{ "sTitle": "ID" ,"bVisible":false},
|
||||||
|
{ "sTitle": "Employee" },
|
||||||
|
{ "sTitle": "Document" },
|
||||||
|
{ "sTitle": "Document Id" },
|
||||||
|
{ "sTitle": "Valid Until"},
|
||||||
|
{ "sTitle": "Status"}
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
EmployeeImmigrationAdapter.method('getFormFields', function() {
|
||||||
|
return [
|
||||||
|
[ "id", {"label":"ID","type":"hidden"}],
|
||||||
|
[ "employee", {"label":"Employee","type":"select2","remote-source":["Employee","id","first_name+last_name"]}],
|
||||||
|
[ "document", {"label":"Document","type":"select2","remote-source":["ImmigrationDocument","id","name"]}],
|
||||||
|
[ "documentname", {"label":"Document Id","type":"text","validation":""}],
|
||||||
|
[ "valid_until", {"label":"Valid Until","type":"date","validation":"none"}],
|
||||||
|
[ "status", {"label":"Status","type":"select","source":[["Active","Active"],["Inactive","Inactive"],["Draft","Draft"]]}],
|
||||||
|
[ "details", {"label":"Details","type":"textarea","validation":"none"}],
|
||||||
|
[ "attachment1", {"label":"Attachment 1","type":"fileupload","validation":"none"}],
|
||||||
|
[ "attachment2", {"label":"Attachment 2","type":"fileupload","validation":"none"}],
|
||||||
|
[ "attachment3", {"label":"Attachment 3","type":"fileupload","validation":"none"}]
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
EmployeeImmigrationAdapter.method('getFilters', function() {
|
||||||
|
return [
|
||||||
|
[ "employee", {"label":"Employee","type":"select2","remote-source":["Employee","id","first_name+last_name"]}]
|
||||||
|
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EmployeeTravelRecordAdapter
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
function EmployeeTravelRecordAdapter(endPoint,tab,filter,orderBy) {
|
||||||
|
this.initAdapter(endPoint,tab,filter,orderBy);
|
||||||
|
this.itemName = 'TravelRequest';
|
||||||
|
this.itemNameLower = 'travelrequest';
|
||||||
|
this.modulePathName = 'travel';
|
||||||
|
}
|
||||||
|
|
||||||
|
EmployeeTravelRecordAdapter.inherits(ApproveAdminAdapter);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
EmployeeTravelRecordAdapter.method('getDataMapping', function() {
|
||||||
|
return [
|
||||||
|
"id",
|
||||||
|
"employee",
|
||||||
|
"type",
|
||||||
|
"purpose",
|
||||||
|
"travel_from",
|
||||||
|
"travel_to",
|
||||||
|
"travel_date",
|
||||||
|
"status"
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
EmployeeTravelRecordAdapter.method('getHeaders', function() {
|
||||||
|
return [
|
||||||
|
{ "sTitle": "ID" ,"bVisible":false},
|
||||||
|
{ "sTitle": "Employee" },
|
||||||
|
{ "sTitle": "Travel Type" },
|
||||||
|
{ "sTitle": "Purpose" },
|
||||||
|
{ "sTitle": "From"},
|
||||||
|
{ "sTitle": "To"},
|
||||||
|
{ "sTitle": "Travel Date"},
|
||||||
|
{ "sTitle": "Status"}
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
EmployeeTravelRecordAdapter.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"]
|
||||||
|
}],
|
||||||
|
["type", {
|
||||||
|
"label": "Travel Type",
|
||||||
|
"type": "select",
|
||||||
|
"source": [["Local", "Local"], ["International", "International"]]
|
||||||
|
}],
|
||||||
|
["purpose", {"label": "Purpose of Travel", "type": "textarea", "validation": ""}],
|
||||||
|
["travel_from", {"label": "Travel From", "type": "text", "validation": ""}],
|
||||||
|
["travel_to", {"label": "Travel To", "type": "text", "validation": ""}],
|
||||||
|
["travel_date", {"label": "Travel Date", "type": "datetime", "validation": ""}],
|
||||||
|
["return_date", {"label": "Return Date", "type": "datetime", "validation": ""}],
|
||||||
|
["details", {"label": "Notes", "type": "textarea", "validation": "none"}],
|
||||||
|
["currency", {"label": "Currency", "type": "select2", "allow-null":false, "remote-source": ["CurrencyType", "id", "code"]}],
|
||||||
|
["funding", {"label": "Total Funding Proposed", "type": "text", "validation": "float"}],
|
||||||
|
["attachment1", {"label": "Itinerary / Cab Receipt", "type": "fileupload", "validation": "none"}],
|
||||||
|
["attachment2", {"label": "Other Attachment 1", "type": "fileupload", "validation": "none"}],
|
||||||
|
["attachment3", {"label": "Other Attachment 2", "type": "fileupload", "validation": "none"}]
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
11
ext/admin/travel/meta.json
Normal file
11
ext/admin/travel/meta.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"label":"Travel Administration",
|
||||||
|
"menu":"Employees",
|
||||||
|
"order":"6",
|
||||||
|
"icon":"fa-plane",
|
||||||
|
"user_levels":["Admin","Manager"],
|
||||||
|
|
||||||
|
"permissions":
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
59
ext/modules/travel/api/TravelActionManager.php
Normal file
59
ext/modules/travel/api/TravelActionManager.php
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
class TravelActionManager extends ApproveModuleActionManager{
|
||||||
|
|
||||||
|
public function getModelClass(){
|
||||||
|
return "EmployeeTravelRecord";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getItemName(){
|
||||||
|
return "TravelRequest";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getModuleName(){
|
||||||
|
return "Travel Management";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getModuleTabUrl(){
|
||||||
|
return "g=admin&n=travel&m=admin_Employees#tabEmployeeTravelRecord";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
class TravelActionManager extends SubActionManager{
|
||||||
|
public function cancelTravel($req){
|
||||||
|
|
||||||
|
$employee = $this->baseService->getElement('Employee',$this->getCurrentProfileId(),null,true);
|
||||||
|
|
||||||
|
$employeeTravel = new EmployeeTravelRecord();
|
||||||
|
$employeeTravel->Load("id = ?",array($req->id));
|
||||||
|
if($employeeTravel->id != $req->id){
|
||||||
|
return new IceResponse(IceResponse::ERROR,"Travel record not found");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if($this->user->user_level != 'Admin' && $this->getCurrentProfileId() != $employeeTravel->employee){
|
||||||
|
return new IceResponse(IceResponse::ERROR,"Only an admin or owner of the travel request can do this");
|
||||||
|
}
|
||||||
|
|
||||||
|
if($employeeTravel->status != 'Approved'){
|
||||||
|
return new IceResponse(IceResponse::ERROR,"Only an approved travel request can be cancelled");
|
||||||
|
}
|
||||||
|
|
||||||
|
$employeeTravel->status = 'Cancellation Requested';
|
||||||
|
$ok = $employeeTravel->Save();
|
||||||
|
if(!$ok){
|
||||||
|
LogManager::getInstance()->error("Error occured while cancelling the travel:".$employeeTravel->ErrorMsg());
|
||||||
|
return new IceResponse(IceResponse::ERROR,"Error occurred while cancelling the travel request. Please contact admin.");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$this->baseService->audit(IceConstants::AUDIT_ACTION, "Travel cancellation \ start:".$employeeTravel->date_start."\ end:".$employeeTravel->date_end);
|
||||||
|
$notificationMsg = $employee->first_name." ".$employee->last_name." cancelled a travel. Visit travel management module to approve";
|
||||||
|
|
||||||
|
$this->baseService->notificationManager->addNotification($employee->supervisor,$notificationMsg,'{"type":"url","url":"g=admin&n=travel&m=admin_Employees#tabEmployeeTravelRecord"}',
|
||||||
|
"Travel Module", null, false, true);
|
||||||
|
return new IceResponse(IceResponse::SUCCESS,$employeeTravel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
24
ext/modules/travel/api/TravelModulesManager.php
Normal file
24
ext/modules/travel/api/TravelModulesManager.php
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
if (!class_exists('TravelModulesManager')) {
|
||||||
|
|
||||||
|
class TravelModulesManager extends AbstractModuleManager{
|
||||||
|
|
||||||
|
public function initializeUserClasses(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function initializeFieldMappings(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function initializeDatabaseErrorMappings(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setupModuleClassDefinitions(){
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
66
ext/modules/travel/index.php
Normal file
66
ext/modules/travel/index.php
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
<?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';
|
||||||
|
$moduleMainName = "EmployeeTravelRecord";
|
||||||
|
$moduleItemName = "Travel Request";
|
||||||
|
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="tab<?=$moduleMainName?>" href="#tabPage<?=$moduleMainName?>">Travel Requests</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>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
var modJsList = new Array();
|
||||||
|
|
||||||
|
modJsList['tab<?=$moduleMainName?>'] = new <?=$moduleMainName?>Adapter('<?=$moduleMainName?>','<?=$moduleMainName?>');
|
||||||
|
|
||||||
|
<?php if(isset($modulePermissions['perm']['Add '.$moduleItemName]) && $modulePermissions['perm']['Add '.$moduleItemName] == "No"){?>
|
||||||
|
modJsList['tab<?=$moduleMainName?>'].setShowAddNew(false);
|
||||||
|
<?php }?>
|
||||||
|
<?php if(isset($modulePermissions['perm']['Delete '.$moduleItemName]) && $modulePermissions['perm']['Delete '.$moduleItemName] == "No"){?>
|
||||||
|
modJsList['tab<?=$moduleMainName?>'].setShowDelete(false);
|
||||||
|
<?php }?>
|
||||||
|
<?php if(isset($modulePermissions['perm']['Edit '.$moduleItemName]) && $modulePermissions['perm']['Edit '.$moduleItemName] == "No"){?>
|
||||||
|
modJsList['tab<?=$moduleMainName?>'].setShowEdit(false);
|
||||||
|
<?php }?>
|
||||||
|
|
||||||
|
var modJs = modJsList['tab<?=$moduleMainName?>'];
|
||||||
|
|
||||||
|
</script>
|
||||||
|
<?php include APP_BASE_PATH.'footer.php';?>
|
||||||
158
ext/modules/travel/lib.js
Normal file
158
ext/modules/travel/lib.js
Normal file
@@ -0,0 +1,158 @@
|
|||||||
|
/*
|
||||||
|
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 EmployeeImmigrationAdapter(endPoint) {
|
||||||
|
this.initAdapter(endPoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
EmployeeImmigrationAdapter.inherits(AdapterBase);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
EmployeeImmigrationAdapter.method('getDataMapping', function() {
|
||||||
|
return [
|
||||||
|
"id",
|
||||||
|
"document",
|
||||||
|
"documentname",
|
||||||
|
"valid_until",
|
||||||
|
"status"
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
EmployeeImmigrationAdapter.method('getHeaders', function() {
|
||||||
|
return [
|
||||||
|
{ "sTitle": "ID" ,"bVisible":false},
|
||||||
|
{ "sTitle": "Document" },
|
||||||
|
{ "sTitle": "Document Id" },
|
||||||
|
{ "sTitle": "Valid Until"},
|
||||||
|
{ "sTitle": "Status"}
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
EmployeeImmigrationAdapter.method('getFormFields', function() {
|
||||||
|
return [
|
||||||
|
[ "id", {"label":"ID","type":"hidden"}],
|
||||||
|
[ "document", {"label":"Document","type":"select2","remote-source":["ImmigrationDocument","id","name"]}],
|
||||||
|
[ "documentname", {"label":"Document Id","type":"text","validation":""}],
|
||||||
|
[ "valid_until", {"label":"Valid Until","type":"date","validation":"none"}],
|
||||||
|
[ "status", {"label":"Status","type":"select","source":[["Active","Active"],["Inactive","Inactive"],["Draft","Draft"]]}],
|
||||||
|
[ "details", {"label":"Details","type":"textarea","validation":"none"}],
|
||||||
|
[ "attachment1", {"label":"Attachment 1","type":"fileupload","validation":"none"}],
|
||||||
|
[ "attachment2", {"label":"Attachment 2","type":"fileupload","validation":"none"}],
|
||||||
|
[ "attachment3", {"label":"Attachment 3","type":"fileupload","validation":"none"}]
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function EmployeeTravelRecordAdapter(endPoint) {
|
||||||
|
this.initAdapter(endPoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
EmployeeTravelRecordAdapter.inherits(AdapterBase);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
EmployeeTravelRecordAdapter.method('getDataMapping', function() {
|
||||||
|
return [
|
||||||
|
"id",
|
||||||
|
"type",
|
||||||
|
"purpose",
|
||||||
|
"travel_from",
|
||||||
|
"travel_to",
|
||||||
|
"travel_date",
|
||||||
|
"return_date",
|
||||||
|
"status"
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
EmployeeTravelRecordAdapter.method('getHeaders', function() {
|
||||||
|
return [
|
||||||
|
{ "sTitle": "ID" ,"bVisible":false},
|
||||||
|
{ "sTitle": "Travel Type" },
|
||||||
|
{ "sTitle": "Purpose" },
|
||||||
|
{ "sTitle": "From"},
|
||||||
|
{ "sTitle": "To"},
|
||||||
|
{ "sTitle": "Travel Date"},
|
||||||
|
{ "sTitle": "Return Date"},
|
||||||
|
{ "sTitle": "Status"}
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
EmployeeTravelRecordAdapter.method('getFormFields', function() {
|
||||||
|
return [
|
||||||
|
[ "id", {"label":"ID","type":"hidden"}],
|
||||||
|
[ "type", {"label":"Travel Type","type":"select","source":[["Local","Local"],["International","International"]]}],
|
||||||
|
[ "purpose", {"label":"Purpose of Travel","type":"textarea","validation":""}],
|
||||||
|
[ "travel_from", {"label":"Travel From","type":"text","validation":""}],
|
||||||
|
[ "travel_to", {"label":"Travel To","type":"text","validation":""}],
|
||||||
|
[ "travel_date", {"label":"Travel Date","type":"datetime","validation":""}],
|
||||||
|
[ "return_date", {"label":"Return Date","type":"datetime","validation":""}],
|
||||||
|
[ "details", {"label":"Notes","type":"textarea","validation":"none"}],
|
||||||
|
[ "currency", {"label":"Currency","type":"select2","allow-null":false,"remote-source":["CurrencyType","id","code"]}],
|
||||||
|
[ "funding", {"label":"Total Funding Proposed","type":"text","validation":"float"}],
|
||||||
|
[ "attachment1", {"label":"Itinerary / Cab Receipt","type":"fileupload","validation":"none"}],
|
||||||
|
[ "attachment2", {"label":"Other Attachment 1","type":"fileupload","validation":"none"}],
|
||||||
|
[ "attachment3", {"label":"Other Attachment 2","type":"fileupload","validation":"none"}]
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
EmployeeTravelRecordAdapter.method('getActionButtonsHtml', function(id,data) {
|
||||||
|
var editButton = '<img class="tableActionButton" src="_BASE_images/edit.png" style="cursor:pointer;" rel="tooltip" title="Edit" onclick="modJs.edit(_id_);return false;"></img>';
|
||||||
|
var deleteButton = '<img class="tableActionButton" src="_BASE_images/delete.png" style="margin-left:15px;cursor:pointer;" rel="tooltip" title="Delete" onclick="modJs.deleteRow(_id_);return false;"></img>';
|
||||||
|
var requestCancellationButton = '<img class="tableActionButton" src="_BASE_images/delete.png" style="margin-left:15px;cursor:pointer;" rel="tooltip" title="Cancel Travel Request" onclick="modJs.cancelTravel(_id_);return false;"></img>';
|
||||||
|
|
||||||
|
var html = '<div style="width:80px;">_edit__delete_</div>';
|
||||||
|
|
||||||
|
if(this.showDelete){
|
||||||
|
if(data[7] == "Approved"){
|
||||||
|
html = html.replace('_delete_',requestCancellationButton);
|
||||||
|
}else{
|
||||||
|
html = html.replace('_delete_',deleteButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
html = html.replace('_delete_','');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.showEdit){
|
||||||
|
html = html.replace('_edit_',editButton);
|
||||||
|
}else{
|
||||||
|
html = html.replace('_edit_','');
|
||||||
|
}
|
||||||
|
|
||||||
|
html = html.replace(/_id_/g,id);
|
||||||
|
html = html.replace(/_BASE_/g,this.baseUrl);
|
||||||
|
return html;
|
||||||
|
});
|
||||||
|
|
||||||
|
EmployeeTravelRecordAdapter.method('cancelTravel', function(id) {
|
||||||
|
var that = this;
|
||||||
|
var object = {};
|
||||||
|
object['id'] = id;
|
||||||
|
|
||||||
|
var reqJson = JSON.stringify(object);
|
||||||
|
|
||||||
|
var callBackData = [];
|
||||||
|
callBackData['callBackData'] = [];
|
||||||
|
callBackData['callBackSuccess'] = 'cancelSuccessCallBack';
|
||||||
|
callBackData['callBackFail'] = 'cancelFailCallBack';
|
||||||
|
|
||||||
|
this.customAction('cancelTravel','modules=travel',reqJson,callBackData);
|
||||||
|
});
|
||||||
|
|
||||||
|
EmployeeTravelRecordAdapter.method('cancelSuccessCallBack', function(callBackData) {
|
||||||
|
this.showMessage("Successful", "Travel request cancellation request sent");
|
||||||
|
this.get([]);
|
||||||
|
});
|
||||||
|
|
||||||
|
EmployeeTravelRecordAdapter.method('cancelFailCallBack', function(callBackData) {
|
||||||
|
this.showMessage("Error Occurred while cancelling Travel request", callBackData);
|
||||||
|
});
|
||||||
|
|
||||||
23
ext/modules/travel/meta.json
Normal file
23
ext/modules/travel/meta.json
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"label":"Travel",
|
||||||
|
"menu":"Travel Management",
|
||||||
|
"order":"1",
|
||||||
|
"icon":"fa-plane",
|
||||||
|
"user_levels":["Admin","Manager","Employee"],
|
||||||
|
|
||||||
|
"permissions":
|
||||||
|
{
|
||||||
|
"Manager":{
|
||||||
|
"Add Travel Request":"Yes",
|
||||||
|
"Edit Travel Request":"Yes",
|
||||||
|
"Delete Travel Request":"Yes"
|
||||||
|
},
|
||||||
|
|
||||||
|
"Employee":{
|
||||||
|
"Add Travel Request":"Yes",
|
||||||
|
"Edit Travel Request":"Yes",
|
||||||
|
"Delete Travel Request":"Yes"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user