Adding travel module
This commit is contained in:
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(){
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
17
ext/modules/travel/dashboard.html
Normal file
17
ext/modules/travel/dashboard.html
Normal file
@@ -0,0 +1,17 @@
|
||||
<div class="col-lg-3 col-xs-12">
|
||||
<!-- small box -->
|
||||
<div class="small-box bg-aqua">
|
||||
<div class="inner">
|
||||
<h3>My Travel</h3>
|
||||
<p>
|
||||
Management
|
||||
</p>
|
||||
</div>
|
||||
<div class="icon">
|
||||
<i class="ion ion-plane"></i>
|
||||
</div>
|
||||
<a href="#_moduleLink_#" class="small-box-footer" id="mytravelLink">
|
||||
Travel Management <i class="fa fa-arrow-circle-right"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
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"],
|
||||
"dashboardPosition":107,
|
||||
"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