Adding travel module
This commit is contained in:
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"
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
19
ext/admin/travel/dashboard.html
Normal file
19
ext/admin/travel/dashboard.html
Normal file
@@ -0,0 +1,19 @@
|
||||
<div class="col-lg-3 col-xs-12">
|
||||
|
||||
<div class="small-box bg-red">
|
||||
<div class="inner">
|
||||
<h3>
|
||||
Travel
|
||||
</h3>
|
||||
<p id="numberOfTravel">
|
||||
Requests
|
||||
</p>
|
||||
</div>
|
||||
<div class="icon">
|
||||
<i class="ion ion-plane"></i>
|
||||
</div>
|
||||
<a href="#_moduleLink_#" class="small-box-footer" id="travelLink">
|
||||
Manage Travel <i class="fa fa-arrow-circle-right"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
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"}]
|
||||
];
|
||||
});
|
||||
|
||||
12
ext/admin/travel/meta.json
Normal file
12
ext/admin/travel/meta.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"label":"Travel Administration",
|
||||
"menu":"Employees",
|
||||
"order":"6",
|
||||
"icon":"fa-plane",
|
||||
"user_levels":["Admin","Manager"],
|
||||
"dashboardPosition":12,
|
||||
|
||||
"permissions":
|
||||
{
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user