Initial checkin v13.0

This commit is contained in:
Thilina Hasantha
2015-10-10 20:18:50 +05:30
parent 5fdd19b2c5
commit eb3439b29d
1396 changed files with 318492 additions and 0 deletions

View File

@@ -0,0 +1,137 @@
<?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)
*/
class AttendanceActionManager extends SubActionManager{
public function getPunch($req){
$date = $req->date;
$arr = explode(" ",$date);
$date = $arr[0];
$employee = $this->baseService->getElement('Employee',$this->getCurrentProfileId(),null,true);
//Find any open punch
$attendance = new Attendance();
$attendance->Load("employee = ? and DATE_FORMAT( in_time, '%Y-%m-%d' ) = ? and (out_time is NULL or out_time = '0000-00-00 00:00:00')",array($employee->id,$date));
if($attendance->employee == $employee->id){
//found an open punch
return new IceResponse(IceResponse::SUCCESS,$attendance);
}else{
return new IceResponse(IceResponse::SUCCESS,null);
}
}
public function savePunch($req){
$req->date = $req->time;
/*
if(strtotime($req->date) > strtotime($req->cdate)){
return new IceResponse(IceResponse::ERROR,"You are not allowed to punch a future time");
}
*/
//check if there is an open punch
$openPunch = $this->getPunch($req)->getData();
if(empty($openPunch)){
$openPunch = new Attendance();
}
$dateTime = $req->date;
$arr = explode(" ",$dateTime);
$date = $arr[0];
$currentDateTime = $req->cdate;
$arr = explode(" ",$currentDateTime);
$currentDate = $arr[0];
if($currentDate != $date){
return new IceResponse(IceResponse::ERROR,"You are not allowed to punch time for a previous date");
}
$employee = $this->baseService->getElement('Employee',$this->getCurrentProfileId(),null,true);
//check if dates are differnet
$arr = explode(" ",$openPunch->in_time);
$inDate = $arr[0];
if(!empty($openPunch->in_time) && $inDate != $date){
return new IceResponse(IceResponse::ERROR,"Attendance entry should be within a single day");
}
//compare dates
if(!empty($openPunch->in_time) && strtotime($dateTime) <= strtotime($openPunch->in_time)){
return new IceResponse(IceResponse::ERROR,"Punch-in time should be lesser than Punch-out time");
}
//Find all punches for the day
$attendance = new Attendance();
$attendanceList = $attendance->Find("employee = ? and DATE_FORMAT( in_time, '%Y-%m-%d' ) = ?",array($employee->id,$date));
foreach($attendanceList as $attendance){
if(!empty($openPunch->in_time)){
if($openPunch->id == $attendance->id){
continue;
}
if(strtotime($attendance->out_time) >= strtotime($dateTime) && strtotime($attendance->in_time) <= strtotime($dateTime)){
//-1---0---1---0 || ---0--1---1---0
return new IceResponse(IceResponse::ERROR,"Time entry is overlapping with an existing one 1");
}else if(strtotime($attendance->out_time) >= strtotime($openPunch->in_time) && strtotime($attendance->in_time) <= strtotime($openPunch->in_time)){
//---0---1---0---1 || ---0--1---1---0
return new IceResponse(IceResponse::ERROR,"Time entry is overlapping with an existing one 2");
}else if(strtotime($attendance->out_time) <= strtotime($dateTime) && strtotime($attendance->in_time) >= strtotime($openPunch->in_time)){
//--1--0---0--1--
return new IceResponse(IceResponse::ERROR,"Time entry is overlapping with an existing one 3 ".$attendance->id);
}
}else{
if(strtotime($attendance->out_time) >= strtotime($dateTime) && strtotime($attendance->in_time) <= strtotime($dateTime)){
//---0---1---0
return new IceResponse(IceResponse::ERROR,"Time entry is overlapping with an existing one 4");
}
}
}
if(!empty($openPunch->in_time)){
$openPunch->out_time = $dateTime;
$openPunch->note = $req->note;
$this->baseService->audit(IceConstants::AUDIT_ACTION, "Punch Out \ time:".$openPunch->out_time);
}else{
$openPunch->in_time = $dateTime;
$openPunch->out_time = '0000-00-00 00:00:00';
$openPunch->note = $req->note;
$openPunch->employee = $employee->id;
$this->baseService->audit(IceConstants::AUDIT_ACTION, "Punch In \ time:".$openPunch->in_time);
}
$ok = $openPunch->Save();
if(!$ok){
LogManager::getInstance()->info($openPunch->ErrorMsg());
return new IceResponse(IceResponse::ERROR,"Error occured while saving attendance");
}
return new IceResponse(IceResponse::SUCCESS,$openPunch);
}
}

View File

@@ -0,0 +1,24 @@
<?php
if (!class_exists('AttendanceModulesManager')) {
class AttendanceModulesManager extends AbstractModuleManager{
public function initializeUserClasses(){
if(defined('MODULE_TYPE') && MODULE_TYPE != 'admin'){
$this->addUserClass("Attendance");
}
}
public function initializeFieldMappings(){
}
public function initializeDatabaseErrorMappings(){
}
public function setupModuleClassDefinitions(){
}
}
}

View File

@@ -0,0 +1,70 @@
<?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 = 'attendance';
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="tabAttendance" href="#tabPageAttendance">Attendance</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tabPageAttendance">
<div id="Attendance" class="reviewBlock" data-content="List" style="padding-left:5px;">
</div>
</div>
</div>
</div>
<style>
#Attendance .dataTables_filter label{
float:left;
}
</style>
<script>
var modJsList = new Array();
modJsList['tabAttendance'] = new AttendanceAdapter('Attendance','Attendance','','in_time desc');
modJsList['tabAttendance'].setRemoteTable(true);
modJsList['tabAttendance'].updatePunchButton(true);
var modJs = modJsList['tabAttendance'];
</script>
<div class="modal" id="PunchModel" 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;">Punch Time</h3>
</div>
<div class="modal-body" style="max-height:530px;" id="AttendanceForm">
</div>
</div>
</div>
</div>
<?php include APP_BASE_PATH.'footer.php';?>

View File

@@ -0,0 +1,236 @@
/*
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)
*/
function AttendanceAdapter(endPoint,tab,filter,orderBy) {
this.initAdapter(endPoint,tab,filter,orderBy);
this.punch = null;
}
AttendanceAdapter.inherits(AdapterBase);
AttendanceAdapter.method('updatePunchButton', function() {
this.getPunch('changePunchButtonSuccessCallBack');
});
AttendanceAdapter.method('getDataMapping', function() {
return [
"id",
"in_time",
"out_time",
"note"
];
});
AttendanceAdapter.method('getHeaders', function() {
return [
{ "sTitle": "ID" ,"bVisible":false},
{ "sTitle": "Time-In" },
{ "sTitle": "Time-Out"},
{ "sTitle": "Note"}
];
});
AttendanceAdapter.method('getFormFields', function() {
return [
[ "id", {"label":"ID","type":"hidden"}],
[ "time", {"label":"Time","type":"datetime"}],
[ "note", {"label":"Note","type":"textarea","validation":"none"}]
];
});
AttendanceAdapter.method('getCustomTableParams', function() {
var that = this;
var dataTableParams = {
"aoColumnDefs": [
{
"fnRender": function(data, cell){
return that.preProcessRemoteTableData(data, cell, 1)
} ,
"aTargets": [1]
},
{
"fnRender": function(data, cell){
return that.preProcessRemoteTableData(data, cell, 2)
} ,
"aTargets": [2]
},
{
"fnRender": function(data, cell){
return that.preProcessRemoteTableData(data, cell, 3)
} ,
"aTargets": [3]
},
{
"fnRender": that.getActionButtons,
"aTargets": [that.getDataMapping().length]
}
]
};
return dataTableParams;
});
AttendanceAdapter.method('preProcessRemoteTableData', function(data, cell, id) {
if(id == 1){
if(cell == '0000-00-00 00:00:00' || cell == "" || cell == undefined || cell == null){
return "";
}
return Date.parse(cell).toString('yyyy MMM d <b>HH:mm</b>');
}else if(id == 2){
if(cell == '0000-00-00 00:00:00' || cell == "" || cell == undefined || cell == null){
return "";
}
return Date.parse(cell).toString('MMM d <b>HH:mm</b>');
}else if(id == 3){
if(cell != undefined && cell != null){
if(cell.length > 20){
return cell.substring(0,20)+"..";
}
}
return cell;
}
});
AttendanceAdapter.method('getActionButtonsHtml', function(id,data) {
/*
var html = '<div style="width:80px;"><img class="tableActionButton" src="_BASE_images/edit.png" style="cursor:pointer;" rel="tooltip" title="Edit" onclick="modJs.edit(_id_);return false;"></img><img class="tableActionButton" src="_BASE_images/download.png" style="margin-left:15px;cursor:pointer;" rel="tooltip" title="Download Document" onclick="download(\'_attachment_\');return false;"></img><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></div>';
html = html.replace(/_id_/g,id);
html = html.replace(/_attachment_/g,data[5]);
html = html.replace(/_BASE_/g,this.baseUrl);
return html;
*/
return "";
});
AttendanceAdapter.method('getTableTopButtonHtml', function() {
if(this.punch == null || this.punch == undefined){
return '<button id="punchButton" style="float:right;" onclick="modJs.showPunchDialog();return false;" class="btn btn-small">Punch-in <span class="icon-time"></span></button>';
}else{
return '<button id="punchButton" style="float:right;" onclick="modJs.showPunchDialog();return false;" class="btn btn-small">Punch-out <span class="icon-time"></span></button>';
}
});
AttendanceAdapter.method('save', function() {
var that = this;
var validator = new FormValidation(this.getTableName()+"_submit",true,{'ShowPopup':false,"LabelErrorClass":"error"});
if(validator.checkValues()){
var params = validator.getFormParameters();
params['cdate'] = this.getClientDate(new Date()).toISOString().slice(0, 19).replace('T', ' ');
var reqJson = JSON.stringify(params);
var callBackData = [];
callBackData['callBackData'] = [];
callBackData['callBackSuccess'] = 'saveSuccessCallback';
callBackData['callBackFail'] = 'getPunchFailCallBack';
this.customAction('savePunch','modules=attendance',reqJson,callBackData);
}
});
AttendanceAdapter.method('saveSuccessCallback', function(callBackData) {
this.punch = callBackData;
this.getPunch('changePunchButtonSuccessCallBack');
$('#PunchModel').modal('hide');
this.get([]);
});
AttendanceAdapter.method('cancel', function() {
$('#PunchModel').modal('hide');
});
AttendanceAdapter.method('showPunchDialog', function() {
this.getPunch('showPunchDialogShowPunchSuccessCallBack');
});
AttendanceAdapter.method('getPunch', function(successCallBack) {
var that = this;
var object = {};
object['date'] = this.getClientDate(new Date()).toISOString().slice(0, 19).replace('T', ' ');
object['offset'] = this.getClientGMTOffset();
var reqJson = JSON.stringify(object);
var callBackData = [];
callBackData['callBackData'] = [];
callBackData['callBackSuccess'] = successCallBack;
callBackData['callBackFail'] = 'getPunchFailCallBack';
this.customAction('getPunch','modules=attendance',reqJson,callBackData);
});
AttendanceAdapter.method('postRenderForm', function(object, $tempDomObj) {
$("#Attendance").show();
});
AttendanceAdapter.method('showPunchDialogShowPunchSuccessCallBack', function(callBackData) {
this.punch = callBackData;
$('#PunchModel').modal('show');
if(this.punch == null){
$('#PunchModel').find("h3").html("Punch Time-in");
modJs.renderForm();
}else{
$('#PunchModel').find("h3").html("Punch Time-out");
modJs.renderForm(this.punch);
}
var picker = $('#time_datetime').data('datetimepicker');
picker.setLocalDate(new Date());
});
AttendanceAdapter.method('changePunchButtonSuccessCallBack', function(callBackData) {
this.punch = callBackData;
if(this.punch == null){
$("#punchButton").html('Punch-in <span class="icon-time"></span>');
}else{
$("#punchButton").html('Punch-out <span class="icon-time"></span>');
}
});
AttendanceAdapter.method('getPunchFailCallBack', function(callBackData) {
this.showMessage("Error Occured while Time Punch", callBackData);
});
AttendanceAdapter.method('getClientDate', function (date) {
var offset = this.getClientGMTOffset();
var tzDate = date.addMinutes(offset*60);
return tzDate;
});
AttendanceAdapter.method('getClientGMTOffset', function () {
var rightNow = new Date();
var jan1 = new Date(rightNow.getFullYear(), 0, 1, 0, 0, 0, 0);
var temp = jan1.toGMTString();
var jan2 = new Date(temp.substring(0, temp.lastIndexOf(" ")-1));
var std_time_offset = (jan1 - jan2) / (1000 * 60 * 60);
return std_time_offset;
});

View File

@@ -0,0 +1,11 @@
{
"label":"Attendance",
"menu":"Time Management",
"order":"2",
"icon":"fa-clock-o",
"user_levels":["Admin","Manager","Employee"],
"permissions":
{
}
}

View File

@@ -0,0 +1,76 @@
<?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)
*/
include (APP_BASE_PATH."modules/leaves/api/LeavesActionManager.php");
class DashboardActionManager extends SubActionManager{
public function getPendingLeaves($req){
$lam = new LeavesActionManager();
$leavePeriod = $lam->getCurrentLeavePeriod(date("Y-m-d H:i:s"), date("Y-m-d H:i:s"));
$leave = new EmployeeLeave();
$pendingLeaves = $leave->Find("status = ? and employee = ?",array("Pending", $this->getCurrentProfileId()));
return new IceResponse(IceResponse::SUCCESS,count($pendingLeaves));
}
public function getLastTimeSheetHours($req){
$timeSheet = new EmployeeTimeSheet();
$timeSheet->Load("employee = ? order by date_end desc limit 1",array($this->getCurrentProfileId()));
if(empty($timeSheet->employee)){
return new IceResponse(IceResponse::SUCCESS,"0:00");
}
$timeSheetEntry = new EmployeeTimeEntry();
$list = $timeSheetEntry->Find("timesheet = ?",array($timeSheet->id));
$seconds = 0;
foreach($list as $entry){
$seconds += (strtotime($entry->date_end) - strtotime($entry->date_start));
}
$minutes = (int)($seconds/60);
$rem = $minutes % 60;
$hours = ($minutes - $rem)/60;
if($rem < 10){
$rem ="0".$rem;
}
return new IceResponse(IceResponse::SUCCESS,$hours.":".$rem);
}
public function getEmployeeActiveProjects($req){
$project = new EmployeeProject();
$projects = $project->Find("employee = ? and status =?",array($this->getCurrentProfileId(),'Current'));
return new IceResponse(IceResponse::SUCCESS,count($projects));
}
}

View File

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

View File

@@ -0,0 +1,122 @@
<?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 = 'dashboard';
define('MODULE_PATH',dirname(__FILE__));
include APP_BASE_PATH.'header.php';
include APP_BASE_PATH.'modulejslibs.inc.php';
?><div class="span9">
<div class="row">
<div class="col-lg-3 col-xs-6">
<!-- small box -->
<div class="small-box bg-aqua">
<div class="inner">
<h3 id="lastPunchTime">
..
</h3>
<p id="punchTimeText">
Waiting for Response..
</p>
</div>
<div class="icon">
<i class="ion ion-ios7-alarm-outline"></i>
</div>
<a href="#" class="small-box-footer" id="atteandanceLink">
Record Attendance <i class="fa fa-arrow-circle-right"></i>
</a>
</div>
</div><!-- ./col -->
<div class="col-lg-3 col-xs-6">
<!-- small box -->
<div class="small-box bg-green">
<div class="inner">
<h3 id="pendingLeaveCount">..</h3>
<p>
Pending Leaves
</p>
</div>
<div class="icon">
<i class="ion ion-calendar"></i>
</div>
<a href="#" class="small-box-footer" id="leavesLink">
Check Leave Status <i class="fa fa-arrow-circle-right"></i>
</a>
</div>
</div><!-- ./col -->
<div class="col-lg-3 col-xs-6">
<!-- small box -->
<div class="small-box bg-yellow">
<div class="inner">
<h3 id="timeSheetHoursWorked">..</h3>
<p>
Hours worked Last Week
</p>
</div>
<div class="icon">
<i class="ion ion-clock"></i>
</div>
<a href="#" class="small-box-footer" id="timesheetLink">
Update Time Sheet <i class="fa fa-arrow-circle-right"></i>
</a>
</div>
</div><!-- ./col -->
<div class="col-lg-3 col-xs-6">
<!-- small box -->
<div class="small-box bg-red">
<div class="inner">
<h3 id="numberOfProjects">..</h3>
<p>
Active Projects
</p>
</div>
<div class="icon">
<i class="ion ion-pie-graph"></i>
</div>
<a href="#" class="small-box-footer" id="projectsLink">
More info <i class="fa fa-arrow-circle-right"></i>
</a>
</div>
</div><!-- ./col -->
</div>
</div>
<script>
var modJsList = new Array();
modJsList['tabDashboard'] = new DashboardAdapter('Dashboard','Dashboard');
var modJs = modJsList['tabDashboard'];
$("#atteandanceLink").attr("href",modJs.getCustomUrl('?g=modules&n=attendance&m=module_Time_Management'));
$("#leavesLink").attr("href",modJs.getCustomUrl('?g=modules&n=leaves&m=module_Leaves'));
$("#timesheetLink").attr("href",modJs.getCustomUrl('?g=modules&n=time_sheets&m=module_Time_Management'));
$("#projectsLink").attr("href",modJs.getCustomUrl('?g=modules&n=projects&m=module_Personal_Information'));
modJs.getPunch();
modJs.getPendingLeaves();
modJs.getLastTimeSheetHours();
modJs.getEmployeeActiveProjects();
</script>
<?php include APP_BASE_PATH.'footer.php';?>

View File

@@ -0,0 +1,173 @@
/*
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)
*/
function DashboardAdapter(endPoint) {
this.initAdapter(endPoint);
}
DashboardAdapter.inherits(AdapterBase);
DashboardAdapter.method('getDataMapping', function() {
return [];
});
DashboardAdapter.method('getHeaders', function() {
return [];
});
DashboardAdapter.method('getFormFields', function() {
return [];
});
DashboardAdapter.method('get', function(callBackData) {
});
DashboardAdapter.method('getPunch', function() {
var that = this;
var object = {};
object['date'] = this.getClientDate(new Date()).toISOString().slice(0, 19).replace('T', ' ');
object['offset'] = this.getClientGMTOffset();
var reqJson = JSON.stringify(object);
var callBackData = [];
callBackData['callBackData'] = [];
callBackData['callBackSuccess'] = 'getPunchSuccessCallBack';
callBackData['callBackFail'] = 'getPunchFailCallBack';
this.customAction('getPunch','modules=attendance',reqJson,callBackData);
});
DashboardAdapter.method('getPunchSuccessCallBack', function(callBackData) {
var punch = callBackData;
if(punch == null){
$("#lastPunchTime").html("Not");
$("#punchTimeText").html("Punched In");
}else{
$("#lastPunchTime").html(Date.parse(punch.in_time).toString('h:mm tt'));
$("#punchTimeText").html("Punched In");
}
});
DashboardAdapter.method('getPunchFailCallBack', function(callBackData) {
});
DashboardAdapter.method('getPendingLeaves', function() {
var that = this;
var object = {};
var reqJson = JSON.stringify(object);
var callBackData = [];
callBackData['callBackData'] = [];
callBackData['callBackSuccess'] = 'getPendingLeavesSuccessCallBack';
callBackData['callBackFail'] = 'getPendingLeavesFailCallBack';
this.customAction('getPendingLeaves','modules=dashboard',reqJson,callBackData);
});
DashboardAdapter.method('getPendingLeavesSuccessCallBack', function(callBackData) {
var leaveCount = callBackData;
$("#pendingLeaveCount").html(leaveCount);
});
DashboardAdapter.method('getPendingLeavesFailCallBack', function(callBackData) {
});
DashboardAdapter.method('getLastTimeSheetHours', function() {
var that = this;
var object = {};
var reqJson = JSON.stringify(object);
var callBackData = [];
callBackData['callBackData'] = [];
callBackData['callBackSuccess'] = 'getLastTimeSheetHoursSuccessCallBack';
callBackData['callBackFail'] = 'getLastTimeSheetHoursFailCallBack';
this.customAction('getLastTimeSheetHours','modules=dashboard',reqJson,callBackData);
});
DashboardAdapter.method('getLastTimeSheetHoursSuccessCallBack', function(callBackData) {
var hours = callBackData;
$("#timeSheetHoursWorked").html(hours);
});
DashboardAdapter.method('getLastTimeSheetHoursFailCallBack', function(callBackData) {
});
DashboardAdapter.method('getEmployeeActiveProjects', function() {
var that = this;
var object = {};
var reqJson = JSON.stringify(object);
var callBackData = [];
callBackData['callBackData'] = [];
callBackData['callBackSuccess'] = 'getEmployeeActiveProjectsSuccessCallBack';
callBackData['callBackFail'] = 'getEmployeeActiveProjectsFailCallBack';
this.customAction('getEmployeeActiveProjects','modules=dashboard',reqJson,callBackData);
});
DashboardAdapter.method('getEmployeeActiveProjectsSuccessCallBack', function(callBackData) {
var hours = callBackData;
$("#numberOfProjects").html(hours);
});
DashboardAdapter.method('getEmployeeActiveProjectsFailCallBack', function(callBackData) {
});
DashboardAdapter.method('getClientDate', function (date) {
var offset = this.getClientGMTOffset();
var tzDate = date.addMinutes(offset*60);
return tzDate;
});
DashboardAdapter.method('getClientGMTOffset', function () {
var rightNow = new Date();
var jan1 = new Date(rightNow.getFullYear(), 0, 1, 0, 0, 0, 0);
var temp = jan1.toGMTString();
var jan2 = new Date(temp.substring(0, temp.lastIndexOf(" ")-1));
var std_time_offset = (jan1 - jan2) / (1000 * 60 * 60);
return std_time_offset;
});

View File

@@ -0,0 +1,11 @@
{
"label":"Dashboard",
"menu":"Personal Information",
"order":"1",
"icon":"fa-desktop",
"user_levels":["Admin","Manager","Employee"],
"permissions":
{
}
}

View File

@@ -0,0 +1,51 @@
<?php
if (!class_exists('DependentsModulesManager')) {
class DependentsModulesManager extends AbstractModuleManager{
public function initializeUserClasses(){
if(defined('MODULE_TYPE') && MODULE_TYPE != 'admin'){
$this->addUserClass("EmployeeDependent");
}
}
public function initializeFieldMappings(){
}
public function initializeDatabaseErrorMappings(){
}
public function setupModuleClassDefinitions(){
$this->addModelClass('EmployeeDependent');
}
}
}
if (!class_exists('EmployeeDependent')) {
class EmployeeDependent extends ICEHRM_Record {
var $_table = 'EmployeeDependents';
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");
}
}
}

View File

@@ -0,0 +1,63 @@
<?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 = 'emergency_contact';
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="tabEmployeeDependent" href="#tabPageEmployeeDependent">Dependents</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tabPageEmployeeDependent">
<div id="EmployeeDependent" class="reviewBlock" data-content="List" style="padding-left:5px;">
</div>
<div id="EmployeeDependentForm" class="reviewBlock" data-content="Form" style="padding-left:5px;display:none;">
</div>
</div>
</div>
</div>
<script>
var modJsList = new Array();
modJsList['tabEmployeeDependent'] = new EmployeeDependentAdapter('EmployeeDependent');
<?php if(isset($modulePermissions['perm']['Add Dependents']) && $modulePermissions['perm']['Add Dependents'] == "No"){?>
modJsList['tabEmployeeDependent'].setShowAddNew(false);
<?php }?>
<?php if(isset($modulePermissions['perm']['Delete Dependents']) && $modulePermissions['perm']['Delete Dependents'] == "No"){?>
modJsList['tabEmployeeDependent'].setShowDelete(false);
<?php }?>
<?php if(isset($modulePermissions['perm']['Edit Dependents']) && $modulePermissions['perm']['Edit Dependents'] == "No"){?>
modJsList['tabEmployeeDependent'].setShowEdit(false);
<?php }?>
var modJs = modJsList['tabEmployeeDependent'];
</script>
<?php include APP_BASE_PATH.'footer.php';?>

View File

@@ -0,0 +1,64 @@
/*
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)
*/
/**
* EmployeeDependentAdapter
*/
function EmployeeDependentAdapter(endPoint) {
this.initAdapter(endPoint);
}
EmployeeDependentAdapter.inherits(AdapterBase);
EmployeeDependentAdapter.method('getDataMapping', function() {
return [
"id",
"name",
"relationship",
"dob",
"id_number"
];
});
EmployeeDependentAdapter.method('getHeaders', function() {
return [
{ "sTitle": "ID" ,"bVisible":false},
{ "sTitle": "Name" },
{ "sTitle": "Relationship"},
{ "sTitle": "Date of Birth"},
{ "sTitle": "Id Number"}
];
});
EmployeeDependentAdapter.method('getFormFields', function() {
return [
[ "id", {"label":"ID","type":"hidden"}],
[ "name", {"label":"Name","type":"text","validation":""}],
[ "relationship", {"label":"Relationship","type":"select","source":[["Child","Child"],["Spouse","Spouse"],["Parent","Parent"],["Other","Other"]]}],
[ "dob", {"label":"Date of Birth","type":"date","validation":""}],
[ "id_number", {"label":"Id Number","type":"text","validation":"none"}]
];
});

View File

@@ -0,0 +1,22 @@
{
"label":"Dependents",
"menu":"Personal Information",
"order":"5",
"icon":"fa-sliders",
"user_levels":["Admin","Manager","Employee"],
"permissions":
{
"Manager":{
"Add Dependents":"Yes",
"Edit Dependents":"Yes",
"Delete Dependents":"Yes"
},
"Employee":{
"Add Dependents":"Yes",
"Edit Dependents":"Yes",
"Delete Dependents":"Yes"
}
}
}

View File

@@ -0,0 +1,25 @@
<?php
if (!class_exists('DocumentsModulesManager')) {
class DocumentsModulesManager extends AbstractModuleManager{
public function initializeUserClasses(){
if(defined('MODULE_TYPE') && MODULE_TYPE != 'admin'){
$this->addUserClass("EmployeeDocument");
}
}
public function initializeFieldMappings(){
}
public function initializeDatabaseErrorMappings(){
}
public function setupModuleClassDefinitions(){
}
}
}

View File

@@ -0,0 +1,64 @@
<?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 = 'documents';
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="tabEmployeeDocument" href="#tabPageEmployeeDocument">My Documents</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tabPageEmployeeDocument">
<div id="EmployeeDocument" class="reviewBlock" data-content="List" style="padding-left:5px;">
</div>
<div id="EmployeeDocumentForm" class="reviewBlock" data-content="Form" style="padding-left:5px;display:none;">
</div>
</div>
</div>
</div>
<script>
var modJsList = new Array();
modJsList['tabEmployeeDocument'] = new EmployeeDocumentAdapter('EmployeeDocument','EmployeeDocument');
<?php if(isset($modulePermissions['perm']['Add Documents']) && $modulePermissions['perm']['Add Documents'] == "No"){?>
modJsList['tabEmployeeDocument'].setShowAddNew(false);
<?php }?>
<?php if(isset($modulePermissions['perm']['Delete Documents']) && $modulePermissions['perm']['Delete Documents'] == "No"){?>
modJsList['tabEmployeeDocument'].setShowDelete(false);
<?php }?>
<?php if(isset($modulePermissions['perm']['Edit Documents']) && $modulePermissions['perm']['Edit Documents'] == "No"){?>
modJsList['tabEmployeeDocument'].setShowEdit(false);
<?php }?>
var modJs = modJsList['tabEmployeeDocument'];
</script>
<?php include APP_BASE_PATH.'footer.php';?>

View File

@@ -0,0 +1,90 @@
/*
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)
*/
function EmployeeDocumentAdapter(endPoint) {
this.initAdapter(endPoint);
}
EmployeeDocumentAdapter.inherits(AdapterBase);
EmployeeDocumentAdapter.method('getDataMapping', function() {
return [
"id",
"document",
"details",
"date_added",
"status",
"attachment"
];
});
EmployeeDocumentAdapter.method('getHeaders', function() {
return [
{ "sTitle": "ID" ,"bVisible":false},
{ "sTitle": "Document" },
{ "sTitle": "Details" },
{ "sTitle": "Date Added"},
{ "sTitle": "Status"},
{ "sTitle": "Attachment","bVisible":false}
];
});
EmployeeDocumentAdapter.method('getFormFields', function() {
return [
[ "id", {"label":"ID","type":"hidden"}],
[ "document", {"label":"Document","type":"select2","remote-source":["Document","id","name"]}],
//[ "date_added", {"label":"Date Added","type":"date","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"}],
[ "attachment", {"label":"Attachment","type":"fileupload","validation":"none"}]
];
});
EmployeeDocumentAdapter.method('getActionButtonsHtml', function(id,data) {
var downloadButton = '<img class="tableActionButton" src="_BASE_images/download.png" style="margin-left:15px;cursor:pointer;" rel="tooltip" title="Download Document" onclick="download(\'_attachment_\');return false;"></img>';
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 html = '<div style="width:80px;">_edit__download__delete_</div>';
html = html.replace('_download_',downloadButton);
if(this.showDelete){
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(/_attachment_/g,data[5]);
html = html.replace(/_BASE_/g,this.baseUrl);
return html;
});

View File

@@ -0,0 +1,22 @@
{
"label":"My Documents",
"menu":"Documents",
"order":"1",
"icon":"fa-files-o",
"user_levels":["Admin","Manager","Employee"],
"permissions":
{
"Manager":{
"Add Documents":"Yes",
"Edit Documents":"Yes",
"Delete Documents":"Yes"
},
"Employee":{
"Add Documents":"Yes",
"Edit Documents":"Yes",
"Delete Documents":"Yes"
}
}
}

View File

@@ -0,0 +1,49 @@
<?php
if (!class_exists('Emergency_contactModulesManager')) {
class Emergency_contactModulesManager extends AbstractModuleManager{
public function initializeUserClasses(){
if(defined('MODULE_TYPE') && MODULE_TYPE != 'admin'){
$this->addUserClass("EmergencyContact");
}
}
public function initializeFieldMappings(){
}
public function initializeDatabaseErrorMappings(){
}
public function setupModuleClassDefinitions(){
$this->addModelClass('EmergencyContact');
}
}
}
if (!class_exists('EmergencyContact')) {
class EmergencyContact extends ICEHRM_Record {
var $_table = 'EmergencyContacts';
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");
}
}
}

View File

@@ -0,0 +1,64 @@
<?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 = 'emergency_contact';
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="tabEmergencyContact" href="#tabPageEmergencyContact">Emergency Contacts</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tabPageEmergencyContact">
<div id="EmergencyContact" class="reviewBlock" data-content="List" style="padding-left:5px;">
</div>
<div id="EmergencyContactForm" class="reviewBlock" data-content="Form" style="padding-left:5px;display:none;">
</div>
</div>
</div>
</div>
<script>
var modJsList = new Array();
modJsList['tabEmergencyContact'] = new EmergencyContactAdapter('EmergencyContact');
<?php if(isset($modulePermissions['perm']['Add Emergency Contacts']) && $modulePermissions['perm']['Add Emergency Contacts'] == "No"){?>
modJsList['tabEmergencyContact'].setShowAddNew(false);
<?php }?>
<?php if(isset($modulePermissions['perm']['Delete Emergency Contacts']) && $modulePermissions['perm']['Delete Emergency Contacts'] == "No"){?>
modJsList['tabEmergencyContact'].setShowDelete(false);
<?php }?>
<?php if(isset($modulePermissions['perm']['Edit Emergency Contacts']) && $modulePermissions['perm']['Edit Emergency Contacts'] == "No"){?>
modJsList['tabEmergencyContact'].setShowEdit(false);
<?php }?>
var modJs = modJsList['tabEmergencyContact'];
</script>
<?php include APP_BASE_PATH.'footer.php';?>

View File

@@ -0,0 +1,63 @@
/*
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)
*/
function EmergencyContactAdapter(endPoint) {
this.initAdapter(endPoint);
}
EmergencyContactAdapter.inherits(AdapterBase);
EmergencyContactAdapter.method('getDataMapping', function() {
return [
"id",
"name",
"relationship",
"home_phone",
"work_phone",
"mobile_phone"
];
});
EmergencyContactAdapter.method('getHeaders', function() {
return [
{ "sTitle": "ID" ,"bVisible":false},
{ "sTitle": "Name" },
{ "sTitle": "Relationship"},
{ "sTitle": "Home Phone"},
{ "sTitle": "Work Phone"},
{ "sTitle": "Mobile Phone"}
];
});
EmergencyContactAdapter.method('getFormFields', function() {
return [
[ "id", {"label":"ID","type":"hidden"}],
[ "name", {"label":"Name","type":"text","validation":""}],
[ "relationship", {"label":"Relationship","type":"text","validation":"none"}],
[ "home_phone", {"label":"Home Phone","type":"text","validation":"none"}],
[ "work_phone", {"label":"Work Phone","type":"text","validation":"none"}],
[ "mobile_phone", {"label":"Mobile Phone","type":"text","validation":"none"}]
];
});

View File

@@ -0,0 +1,22 @@
{
"label":"Emergency Contacts",
"menu":"Personal Information",
"order":"6",
"icon":"fa-phone-square",
"user_levels":["Admin","Manager","Employee"],
"permissions":
{
"Manager":{
"Add Emergency Contacts":"Yes",
"Edit Emergency Contacts":"Yes",
"Delete Emergency Contacts":"Yes"
},
"Employee":{
"Add Emergency Contacts":"Yes",
"Edit Emergency Contacts":"Yes",
"Delete Emergency Contacts":"Yes"
}
}
}

View File

@@ -0,0 +1,80 @@
<?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)
*/
class EmployeesActionManager extends SubActionManager{
public function get($req){
$employee = $this->baseService->getElement('Employee',$this->getCurrentProfileId(),$req->map,true);
$subordinate = new Employee();
$subordinates = $subordinate->Find("supervisor = ?",array($employee->id));
$employee->subordinates = $subordinates;
$fs = FileService::getInstance();
$employee = $fs->updateProfileImage($employee);
if(!empty($employee->birthday)){
$employee->birthday = date("F jS, Y",strtotime($employee->birthday));
}
if(!empty($employee->driving_license_exp_date)){
$employee->driving_license_exp_date = date("F jS, Y",strtotime($employee->driving_license_exp_date));
}
if(!empty($employee->joined_date)){
$employee->joined_date = date("F jS, Y",strtotime($employee->joined_date));
}
if(empty($employee->id)){
return new IceResponse(IceResponse::ERROR,$employee);
}
return new IceResponse(IceResponse::SUCCESS,array($employee,$this->getCurrentProfileId(),$this->user->employee));
}
public function deleteProfileImage($req){
if($this->user->user_level == 'Admin' || $this->user->employee == $req->id){
$fs = FileService::getInstance();
$res = $fs->deleteProfileImage($req->id);
return new IceResponse(IceResponse::SUCCESS,$res);
}
}
public function changePassword($req){
if($this->getCurrentProfileId() != $this->user->employee || empty($this->user->employee)){
return new IceResponse(IceResponse::ERROR,"You are not allowed to change passwords of other employees");
}
$user = $this->baseService->getElement('User',$this->user->id);
if(empty($user->id)){
return new IceResponse(IceResponse::ERROR,"Error occured while changing password");
}
$user->password = md5($req->pwd);
$ok = $user->Save();
if(!$ok){
return new IceResponse(IceResponse::ERROR,$user->ErrorMsg());
}
return new IceResponse(IceResponse::SUCCESS,$user);
}
}

View File

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

View File

@@ -0,0 +1,203 @@
<div class="row-fluid">
<div class="col-xs-12 col-md-3">
<div class="row-fluid">
<div class="col-xs-12" style="text-align: center;">
<img id="profile_image__id_" src="" class="img-polaroid" style="max-width: 140px;max-height: 140px;">
</div>
</div>
</div>
<div class="col-xs-12 col-md-9">
<div class="row-fluid">
<div class="col-xs-12" style="font-size:18px;border-bottom: 1px solid #DDD;margin-bottom: 10px;padding-bottom: 10px;">
<span id="name"></span><br/>
<button id="employeeProfileEditInfo" class="btn btn-inverse btn-xs" onclick="modJs.editEmployee();" style="margin-right:10px;">Edit Info</button>
<button id="employeeUploadProfileImage" onclick="showUploadDialog('profile_image__id_','Upload Profile Image','profile_image',_id_,'profile_image__id_','src','url','image');return false;" class="btn btn-xs btn-inverse" type="button" style="margin-right:10px;">Upload Profile Image</button>
<button id="employeeDeleteProfileImage" onclick="modJs.deleteProfileImage(_id_);return false;" class="btn btn-xs btn-inverse" type="button">Delete Profile Image</button>
<button id="employeeUpdatePassword" onclick="modJs.changePassword();return false;" class="btn btn-xs btn-inverse" type="button">Change Password</button>
</div>
</div>
<div class="row-fluid" style="border-top: 1px;">
<div class="col-xs-6 col-md-4" style="font-size:16px;">
<label class="control-label col-xs-12" style="font-size:13px;font-size:13px;">Employee Id</label>
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="employee_id"></label>
</div>
<div class="col-xs-6 col-md-4" style="font-size:16px;">
<label class="control-label col-xs-12" style="font-size:13px;">NIC Number</label>
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="nic_num"></label>
</div>
<div class="col-xs-6 col-md-4" style="font-size:16px;">
<label class="control-label col-xs-12" style="font-size:13px;">EPF/CPF No</label>
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="ssn_num"></label>
</div>
</div>
</div>
</div>
<div class="row-fluid" style="margin-left:10px;">
<div class="col-xs-12">
<hr/>
<span class="label label-inverse" style="font-size:16px;background: #405A6A;">Personal Information</span><br/><br/>
<div class="row-fluid">
<div class="col-xs-6 col-md-3" style="font-size:16px;">
<label class="control-label col-xs-12" style="font-size:13px;">Driver's License Number</label>
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="driving_license"></label>
</div>
<div class="col-xs-6 col-md-3" style="font-size:16px;">
<label class="control-label col-xs-12" style="font-size:13px;">Other Id</label>
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="other_id"></label>
</div>
<div class="col-xs-6 col-md-3" style="font-size:16px;">
<label class="control-label col-xs-12" style="font-size:13px;">Birth Day</label>
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="birthday"></label>
</div>
<div class="col-xs-6 col-md-3" style="font-size:16px;">
<label class="control-label col-xs-12" style="font-size:13px;">Gender</label>
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="gender"></label>
</div>
</div>
<hr/>
<div class="row-fluid">
<div class="col-xs-6 col-md-3" style="font-size:16px;">
<label class="control-label col-xs-12" style="font-size:13px;">Nationality</label>
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="nationality_Name"></label>
</div>
<div class="col-xs-6 col-md-3" style="font-size:16px;">
<label class="control-label col-xs-12" style="font-size:13px;">Marital Status</label>
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="marital_status"></label>
</div>
<div class="col-xs-6 col-md-3" style="font-size:16px;">
<label class="control-label col-xs-12" style="font-size:13px;">Joined Date</label>
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="joined_date"></label>
</div>
</div>
</div>
</div>
<div class="row-fluid" style="margin-left:10px;margin-top:20px;">
<div class="col-xs-12">
<hr/>
<span class="label label-inverse" style="font-size:16px;background: #405A6A;">Contact Information</span><br/><br/>
<div class="row-fluid">
<div class="col-xs-6 col-md-3" style="font-size:16px;">
<label class="control-label col-xs-12" style="font-size:13px;">Address 1</label>
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="address1"></label>
</div>
<div class="col-xs-6 col-md-3" style="font-size:16px;">
<label class="control-label col-xs-12" style="font-size:13px;">Address 2</label>
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="address2"></label>
</div>
<div class="col-xs-6 col-md-3" style="font-size:16px;">
<label class="control-label col-xs-12" style="font-size:13px;">City</label>
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="city"></label>
</div>
<div class="col-xs-6 col-md-3" style="font-size:16px;">
<label class="control-label col-xs-12" style="font-size:13px;">Country</label>
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="country_Name"></label>
</div>
</div>
<hr/>
<div class="row-fluid">
<div class="col-xs-6 col-md-3" style="font-size:16px;">
<label class="control-label col-xs-12" style="font-size:13px;">Postal Code</label>
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="postal_code"></label>
</div>
<div class="col-xs-6 col-md-3" style="font-size:16px;">
<label class="control-label col-xs-12" style="font-size:13px;">Home Phone</label>
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="home_phone"></label>
</div>
<div class="col-xs-6 col-md-3" style="font-size:16px;">
<label class="control-label col-xs-12" style="font-size:13px;">Mobile Phone</label>
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="mobile_phone"></label>
</div>
<div class="col-xs-6 col-md-3" style="font-size:16px;">
<label class="control-label col-xs-12" style="font-size:13px;">Work Phone</label>
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="work_phone"></label>
</div>
</div>
<hr/>
<div class="row-fluid">
<div class="col-xs-6 col-md-3" style="font-size:16px;">
<label class="control-label col-xs-12" style="font-size:13px;">Work Email</label>
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="work_email"></label>
</div>
<div class="col-xs-6 col-md-3" style="font-size:16px;">
<label class="control-label col-xs-12" style="font-size:13px;">Private Email</label>
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="private_email"></label>
</div>
</div>
</div>
</div>
<div class="row-fluid" style="margin-left:10px;margin-top:20px;">
<div class="col-xs-12">
<hr/>
<span class="label label-inverse" style="font-size:16px;background: #405A6A;">Job Details</span><br/><br/>
<div class="row-fluid">
<div class="col-xs-6 col-md-3" style="font-size:16px;">
<label class="control-label col-xs-12" style="font-size:13px;">Job Title</label>
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="job_title_Name"></label>
</div>
<div class="col-xs-6 col-md-3" style="font-size:16px;">
<label class="control-label col-xs-12" style="font-size:13px;">Employment Status</label>
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="employment_status_Name"></label>
</div>
<div class="col-xs-6 col-md-3" style="font-size:16px;">
<label class="control-label col-xs-12" style="font-size:13px;">Supervisor</label>
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="supervisor_Name"></label>
</div>
<div class="col-xs-6 col-md-3" style="font-size:16px;">
<label class="control-label col-xs-12" style="font-size:13px;">Subordinates</label>
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="subordinates"></label>
</div>
</div>
<hr/>
<div class="row-fluid">
<div class="col-xs-6 col-md-3" style="font-size:16px;">
<label class="control-label col-xs-12" style="font-size:13px;">Department</label>
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="department_Name"></label>
</div>
</div>
</div>
</div>
<div class="modal" id="adminUsersModel" 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 User Password</h3>
</div>
<div class="modal-body">
<form id="adminUsersChangePwd">
<div class="control-group">
<div class="controls">
<span class="label label-warning" id="adminUsersChangePwd_error" style="display:none;"></span>
</div>
</div>
<div class="control-group" id="field_newpwd">
<label class="control-label" for="newpwd">New Password</label>
<div class="controls">
<input class="" type="password" id="newpwd" name="newpwd" value="" class="form-control"/>
<span class="help-inline" id="help_newpwd"></span>
</div>
</div>
<div class="control-group" id="field_conpwd">
<label class="control-label" for="conpwd">Confirm Password</label>
<div class="controls">
<input class="" type="password" id="conpwd" name="conpwd" value="" class="form-control"/>
<span class="help-inline" id="help_conpwd"></span>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button class="btn btn-primary" onclick="modJs.changePasswordConfirm();">Change Password</button>
<button class="btn" onclick="modJs.closeChangePassword();">Not Now</button>
</div>
</div>
</div>
</div>

View 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 = 'employees';
define('MODULE_PATH',dirname(__FILE__));
include APP_BASE_PATH.'header.php';
include APP_BASE_PATH.'modulejslibs.inc.php';
?>
<script type="text/javascript" src="<?=BASE_URL.'js/raphael-min.js?v='.$jsVersion?>"></script>
<script type="text/javascript" src="<?=BASE_URL.'js/graffle.js?v='.$jsVersion?>"></script>
<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="tabEmployee" href="#tabPageEmployee">My Details</a></li>
<li><a id="tabCompanyGraph" href="#tabPageCompanyGraph">Company</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tabPageEmployee">
<div id="Employee" class="container reviewBlock" data-content="List" style="padding-left:5px;">
</div>
<div id="EmployeeForm" class="reviewBlock" data-content="Form" style="padding-left:5px;display:none;">
</div>
</div>
<div class="tab-pane" id="tabPageCompanyGraph">
<div id="CompanyGraph" class="reviewBlock" data-content="List" style="padding-left:5px;">
</div>
<div id="CompanyGraphForm" class="reviewBlock" data-content="Form" style="padding-left:5px;display:none;">
</div>
</div>
</div>
</div>
<script>
var modJsList = new Array();
modJsList['tabEmployee'] = new EmployeeAdapter('Employee');
modJsList['tabCompanyGraph'] = new CompanyGraphAdapter('CompanyStructure');
var modJs = modJsList['tabEmployee'];
</script>
<?php include APP_BASE_PATH.'footer.php';?>

View File

@@ -0,0 +1,385 @@
/*
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)
*/
function EmployeeAdapter(endPoint) {
this.initAdapter(endPoint);
}
EmployeeAdapter.inherits(AdapterBase);
this.currentUserId = null;
EmployeeAdapter.method('getDataMapping', function() {
return [
"id",
"employee_id",
"first_name",
"last_name",
"mobile_phone",
"department",
"gender",
"supervisor"
];
});
EmployeeAdapter.method('getHeaders', function() {
return [
{ "sTitle": "ID" },
{ "sTitle": "Employee Number" },
{ "sTitle": "First Name" },
{ "sTitle": "Last Name"},
{ "sTitle": "Mobile"},
{ "sTitle": "Department"},
{ "sTitle": "Gender"},
{ "sTitle": "Supervisor"}
];
});
EmployeeAdapter.method('getFormFields', function() {
var employee_id, ssn_num, employment_status, job_title, pay_grade, joined_date, department, work_email, country;
if(this.checkPermission("Edit Employee Number") == "Yes"){
employee_id = [ "employee_id", {"label":"Employee Number","type":"text","validation":""}];
}else{
employee_id = [ "employee_id", {"label":"Employee Number","type":"placeholder","validation":""}];
}
if(this.checkPermission("Edit EPF/CPF Number") == "Yes"){
ssn_num = [ "ssn_num", {"label":"EPF/CPF/SS No","type":"text","validation":"none"}];
}else{
ssn_num = [ "ssn_num", {"label":"EPF/CPF/SS No","type":"placeholder","validation":"none"}];
}
if(this.checkPermission("Edit Employment Status") == "Yes"){
employment_status = [ "employment_status", {"label":"Employment Status","type":"select2","remote-source":["EmploymentStatus","id","name"]}];
}else{
employment_status = [ "employment_status", {"label":"Employment Status","type":"placeholder","remote-source":["EmploymentStatus","id","name"]}];
}
if(this.checkPermission("Edit Job Title") == "Yes"){
job_title = [ "job_title", {"label":"Job Title","type":"select2","remote-source":["JobTitle","id","name"]}];
}else{
job_title = [ "job_title", {"label":"Job Title","type":"placeholder","remote-source":["JobTitle","id","name"]}];
}
if(this.checkPermission("Edit Pay Grade") == "Yes"){
pay_grade = [ "pay_grade", {"label":"Pay Grade","type":"select2","allow-null":true,"remote-source":["PayGrade","id","name"]}];
}else{
pay_grade = [ "pay_grade", {"label":"Pay Grade","type":"placeholder","allow-null":true,"remote-source":["PayGrade","id","name"]}];
}
if(this.checkPermission("Edit Joined Date") == "Yes"){
joined_date = [ "joined_date", {"label":"Joined Date","type":"date","validation":""}];
}else{
joined_date = [ "joined_date", {"label":"Joined Date","type":"placeholder","validation":""}];
}
if(this.checkPermission("Edit Department") == "Yes"){
department = [ "department", {"label":"Department","type":"select2","remote-source":["CompanyStructure","id","title"]}];
}else{
department = [ "department", {"label":"Department","type":"placeholder","remote-source":["CompanyStructure","id","title"]}];
}
if(this.checkPermission("Edit Work Email") == "Yes"){
work_email = [ "work_email", {"label":"Work Email","type":"text","validation":"email"}];
}else{
work_email = [ "work_email", {"label":"Work Email","type":"placeholder","validation":"emailOrEmpty"}];
}
if(this.checkPermission("Edit Country") == "Yes"){
country = [ "country", {"label":"Country","type":"select2","remote-source":["Country","code","name"]}];
}else{
country = [ "country", {"label":"Country","type":"placeholder","remote-source":["Country","code","name"]}];
}
return [
[ "id", {"label":"ID","type":"hidden","validation":""}],
employee_id,
[ "first_name", {"label":"First Name","type":"text","validation":""}],
[ "middle_name", {"label":"Middle Name","type":"text","validation":"none"}],
[ "last_name", {"label":"Last Name","type":"text","validation":""}],
[ "nationality", {"label":"Nationality","type":"select2","remote-source":["Nationality","id","name"]}],
[ "birthday", {"label":"Date of Birth","type":"date","validation":""}],
[ "gender", {"label":"Gender","type":"select","source":[["Male","Male"],["Female","Female"]]}],
[ "marital_status", {"label":"Marital Status","type":"select","source":[["Married","Married"],["Single","Single"],["Divorced","Divorced"],["Widowed","Widowed"],["Other","Other"]]}],
ssn_num,
[ "nic_num", {"label":"NIC","type":"text","validation":"none"}],
[ "other_id", {"label":"Other ID","type":"text","validation":"none"}],
[ "driving_license", {"label":"Driving License No","type":"text","validation":"none"}],
employment_status,
job_title,
pay_grade,
[ "work_station_id", {"label":"Work Station Id","type":"text","validation":"none"}],
[ "address1", {"label":"Address Line 1","type":"text","validation":"none"}],
[ "address2", {"label":"Address Line 2","type":"text","validation":"none"}],
[ "city", {"label":"City","type":"text","validation":"none"}],
country,
[ "province", {"label":"Province","type":"select2","allow-null":true,"remote-source":["Province","id","name"]}],
[ "postal_code", {"label":"Postal/Zip Code","type":"text","validation":"none"}],
[ "home_phone", {"label":"Home Phone","type":"text","validation":"none"}],
[ "mobile_phone", {"label":"Mobile Phone","type":"text","validation":"none"}],
[ "work_phone", {"label":"Work Phone","type":"text","validation":"none"}],
work_email,
[ "private_email", {"label":"Private Email","type":"text","validation":"emailOrEmpty"}],
joined_date,
department
];
});
EmployeeAdapter.method('getSourceMapping' , function() {
var k = this.sourceMapping ;
k['supervisor'] = ["Employee","id","first_name+last_name"];
return k;
});
EmployeeAdapter.method('get', function() {
var that = this;
var sourceMappingJson = JSON.stringify(this.getSourceMapping());
var req = {"map":sourceMappingJson};
var reqJson = JSON.stringify(req);
var callBackData = [];
callBackData['callBackData'] = [];
callBackData['callBackSuccess'] = 'modEmployeeGetSuccessCallBack';
callBackData['callBackFail'] = 'modEmployeeGetFailCallBack';
this.customAction('get','modules=employees',reqJson,callBackData);
});
EmployeeAdapter.method('deleteProfileImage', function(empId) {
var that = this;
var req = {"id":empId};
var reqJson = JSON.stringify(req);
var callBackData = [];
callBackData['callBackData'] = [];
callBackData['callBackSuccess'] = 'modEmployeeDeleteProfileImageCallBack';
callBackData['callBackFail'] = 'modEmployeeDeleteProfileImageCallBack';
this.customAction('deleteProfileImage','modules=employees',reqJson,callBackData);
});
EmployeeAdapter.method('modEmployeeDeleteProfileImageCallBack', function(data) {
top.location.href = top.location.href;
});
EmployeeAdapter.method('modEmployeeGetSuccessCallBack' , function(data) {
var currentEmpId = data[1];
var userEmpId = data[2];
data = data[0];
var html = this.getCustomTemplate('myDetails.html');
html = html.replace(/_id_/g,data.id);
$("#"+this.getTableName()).html(html);
var fields = this.getFormFields();
for(var i=0;i<fields.length;i++) {
$("#"+this.getTableName()+" #" + fields[i][0]).html(data[fields[i][0]]);
}
var subordinates = "";
for(var i=0;i<data.subordinates.length;i++){
if(data.subordinates[i].first_name != undefined && data.subordinates[i].first_name != null){
subordinates += data.subordinates[i].first_name+" ";
}
+data.subordinates[i].middle_name
if(data.subordinates[i].middle_name != undefined && data.subordinates[i].middle_name != null && data.subordinates[i].middle_name != ""){
subordinates += data.subordinates[i].middle_name+" ";
}
if(data.subordinates[i].last_name != undefined && data.subordinates[i].last_name != null && data.subordinates[i].last_name != ""){
subordinates += data.subordinates[i].last_name;
}
subordinates += "<br/>";
}
$("#"+this.getTableName()+" #subordinates").html(subordinates);
$("#"+this.getTableName()+" #nationality_Name").html(data.nationality_Name);
$("#"+this.getTableName()+" #employment_status_Name").html(data.employment_status_Name);
$("#"+this.getTableName()+" #job_title_Name").html(data.job_title_Name);
$("#"+this.getTableName()+" #country_Name").html(data.country_Name);
$("#"+this.getTableName()+" #province_Name").html(data.province_Name);
$("#"+this.getTableName()+" #supervisor_Name").html(data.supervisor_Name);
$("#"+this.getTableName()+" #department_Name").html(data.department_Name);
$("#"+this.getTableName()+" #name").html(data.first_name + " " + data.last_name);
this.currentUserId = data.id;
$("#"+this.getTableName()+" #profile_image_"+data.id).attr('src',data.image);
if(this.checkPermission("Upload/Delete Profile Image") == "No"){
$("#employeeUploadProfileImage").remove();
$("#employeeDeleteProfileImage").remove();
}
if(this.checkPermission("Edit Employee Details") == "No"){
$("#employeeProfileEditInfo").remove();
}
if(currentEmpId != userEmpId){
$("#employeeUpdatePassword").remove();
}
this.cancel();
});
EmployeeAdapter.method('modEmployeeGetFailCallBack' , function(data) {
});
EmployeeAdapter.method('editEmployee' , function() {
this.edit(this.currentUserId);
});
EmployeeAdapter.method('changePassword', function() {
$('#adminUsersModel').modal('show');
$('#adminUsersChangePwd #newpwd').val('');
$('#adminUsersChangePwd #conpwd').val('');
});
EmployeeAdapter.method('changePasswordConfirm', function() {
$('#adminUsersChangePwd_error').hide();
var passwordValidation = function (str) {
var val = /^[a-zA-Z0-9]\w{6,}$/;
return str != null && val.test(str);
};
var password = $('#adminUsersChangePwd #newpwd').val();
if(!passwordValidation(password)){
$('#adminUsersChangePwd_error').html("Password may contain only letters, numbers and should be longer than 6 characters");
$('#adminUsersChangePwd_error').show();
return;
}
var conPassword = $('#adminUsersChangePwd #conpwd').val();
if(conPassword != password){
$('#adminUsersChangePwd_error').html("Passwords don't match");
$('#adminUsersChangePwd_error').show();
return;
}
var req = {"pwd":conPassword};
var reqJson = JSON.stringify(req);
var callBackData = [];
callBackData['callBackData'] = [];
callBackData['callBackSuccess'] = 'changePasswordSuccessCallBack';
callBackData['callBackFail'] = 'changePasswordFailCallBack';
this.customAction('changePassword','modules=employees',reqJson,callBackData);
});
EmployeeAdapter.method('closeChangePassword', function() {
$('#adminUsersModel').modal('hide');
});
EmployeeAdapter.method('changePasswordSuccessCallBack', function(callBackData,serverData) {
this.closeChangePassword();
this.showMessage("Password Change","Password changed successfully");
});
EmployeeAdapter.method('changePasswordFailCallBack', function(callBackData,serverData) {
this.closeChangePassword();
this.showMessage("Error",callBackData);
});
/*
* Company Graph
*/
function CompanyGraphAdapter(endPoint) {
this.initAdapter(endPoint);
}
CompanyGraphAdapter.inherits(AdapterBase);
CompanyGraphAdapter.method('getDataMapping', function() {
return [
"id",
"title",
"address",
"type",
"country",
"parent"
];
});
CompanyGraphAdapter.method('getHeaders', function() {
return [
{ "sTitle": "ID","bVisible":false },
{ "sTitle": "Name" },
{ "sTitle": "Address"},
{ "sTitle": "Type"},
{ "sTitle": "Country", "sClass": "center" },
{ "sTitle": "Parent Structure"}
];
});
CompanyGraphAdapter.method('getFormFields', function() {
return [
[ "id", {"label":"ID","type":"hidden","validation":""}],
[ "title", {"label":"Name","type":"text","validation":""}],
[ "description", {"label":"Details","type":"textarea","validation":""}],
[ "address", {"label":"Address","type":"textarea","validation":"none"}],
[ "type", {"label":"Type","type":"select","source":[["Company","Company"],["Head Office","Head Office"],["Regional Office","Regional Office"],["Department","Department"],["Unit","Unit"],["Sub Unit","Sub Unit"],["Other","Other"]]}],
[ "country", {"label":"Country","type":"select","remote-source":["Country","code","name"]}],
[ "parent", {"label":"Parent Structure","type":"select","allow-null":true,"remote-source":["CompanyStructure","id","title"]}]
];
});
CompanyGraphAdapter.method('createTable', function(elementId) {
var sourceData = this.sourceData;
if(modJs['r'] == undefined || modJs['r'] == null){
modJs['r'] = Raphael("CompanyGraph", 800, 1000);
}else{
return;
}
var r = modJs['r'];
for(var i=0; i< sourceData.length; i++){
sourceData[i].parent = sourceData[i]._original[6];
}
var hierarchy = new HierarchyJs();
var nodes = hierarchy.createNodes(sourceData);
hierarchy.createHierarchy(nodes, r);
});

View File

@@ -0,0 +1,38 @@
{
"label":"Basic Information",
"menu":"Personal Information",
"order":"2",
"icon":"fa-user",
"user_levels":["Admin","Manager","Employee"],
"permissions":
{
"Manager":{
"Edit Employee Number":"No",
"Edit EPF/CPF Number":"Yes",
"Edit Employment Status":"No",
"Edit Job Title":"Yes",
"Edit Pay Grade":"Yes",
"Edit Joined Date":"Yes",
"Edit Department":"Yes",
"Edit Work Email":"Yes",
"Edit Country":"Yes",
"Upload/Delete Profile Image":"Yes",
"Edit Employee Details":"Yes"
},
"Employee":{
"Edit Employee Number":"No",
"Edit EPF/CPF Number":"Yes",
"Edit Employment Status":"No",
"Edit Job Title":"No",
"Edit Pay Grade":"No",
"Edit Joined Date":"No",
"Edit Department":"No",
"Edit Work Email":"No",
"Edit Country":"No",
"Upload/Delete Profile Image":"Yes",
"Edit Employee Details":"Yes"
}
}
}

View File

@@ -0,0 +1,51 @@
<?php
if (!class_exists('LoansModulesManager')) {
class LoansModulesManager extends AbstractModuleManager{
public function initializeUserClasses(){
if(defined('MODULE_TYPE') && MODULE_TYPE != 'admin'){
$this->addUserClass("EmployeeCompanyLoan");
}
}
public function initializeFieldMappings(){
}
public function initializeDatabaseErrorMappings(){
}
public function setupModuleClassDefinitions(){
$this->addModelClass('EmployeeCompanyLoan');
}
}
}
if (!class_exists('EmployeeCompanyLoan')) {
class EmployeeCompanyLoan extends ICEHRM_Record {
var $_table = 'EmployeeCompanyLoans';
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");
}
}
}

View File

@@ -0,0 +1,58 @@
<?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 = 'loans';
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="tabEmployeeCompanyLoan" href="#tabPageEmployeeCompanyLoan">Loans Taken</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tabPageEmployeeCompanyLoan">
<div id="EmployeeCompanyLoan" class="reviewBlock" data-content="List" style="padding-left:5px;">
</div>
<div id="EmployeeCompanyLoanForm" class="reviewBlock" data-content="Form" style="padding-left:5px;display:none;">
</div>
</div>
</div>
</div>
<script>
var modJsList = new Array();
modJsList['tabEmployeeCompanyLoan'] = new EmployeeCompanyLoanAdapter('EmployeeCompanyLoan','EmployeeCompanyLoan');
modJsList['tabEmployeeCompanyLoan'].setShowAddNew(false);
modJsList['tabEmployeeCompanyLoan'].setShowSave(false);
modJsList['tabEmployeeCompanyLoan'].setShowDelete(false);
modJsList['tabEmployeeCompanyLoan'].setShowEdit(true);
var modJs = modJsList['tabEmployeeCompanyLoan'];
</script>
<?php include APP_BASE_PATH.'footer.php';?>

91
ext/modules/loans/lib.js Normal file
View File

@@ -0,0 +1,91 @@
/*
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)
*/
function EmployeeCompanyLoanAdapter(endPoint) {
this.initAdapter(endPoint);
}
EmployeeCompanyLoanAdapter.inherits(AdapterBase);
EmployeeCompanyLoanAdapter.method('getDataMapping', function() {
return [
"id",
"loan",
"start_date",
"period_months",
"currency",
"amount",
"status"
];
});
EmployeeCompanyLoanAdapter.method('getHeaders', function() {
return [
{ "sTitle": "ID" ,"bVisible":false},
{ "sTitle": "Loan Type" },
{ "sTitle": "Loan Start Date"},
{ "sTitle": "Loan Period (Months)"},
{ "sTitle": "Currency"},
{ "sTitle": "Amount"},
{ "sTitle": "Status"}
];
});
EmployeeCompanyLoanAdapter.method('getFormFields', function() {
return [
[ "id", {"label":"ID","type":"hidden"}],
[ "loan", {"label":"Loan Type","type":"placeholder","remote-source":["CompanyLoan","id","name"]}],
[ "start_date", {"label":"Loan Start Date","type":"placeholder","validation":""}],
[ "last_installment_date", {"label":"Last Installment Date","type":"placeholder","validation":"none"}],
[ "period_months", {"label":"Loan Period (Months)","type":"placeholder","validation":"number"}],
[ "currency", {"label":"Currency","type":"placeholder","remote-source":["CurrencyType","id","name"]}],
[ "amount", {"label":"Loan Amount","type":"placeholder","validation":"float"}],
[ "monthly_installment", {"label":"Monthly Installment","type":"placeholder","validation":"float"}],
[ "status", {"label":"Status","type":"placeholder","source":[["Approved","Approved"],["Paid","Paid"],["Suspended","Suspended"]]}],
[ "details", {"label":"Details","type":"placeholder","validation":"none"}]
];
});
EmployeeCompanyLoanAdapter.method('getActionButtonsHtml', function(id,data) {
var editButton = '<img class="tableActionButton" src="_BASE_images/view.png" style="cursor:pointer;" rel="tooltip" title="View" 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 html = '<div style="width:80px;">_edit__delete_</div>';
if(this.showDelete){
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;
});

View File

@@ -0,0 +1,11 @@
{
"label":"Loans",
"menu":"Loans",
"order":"1",
"icon":"fa-shield",
"user_levels":["Admin","Manager","Employee"],
"permissions":
{
}
}

9
ext/modules/meta.json Normal file
View File

@@ -0,0 +1,9 @@
{
"Personal Information":"fa-male",
"Subordinates":"fa-user",
"Leaves":"fa-calendar-o",
"Time Management":"fa-clock-o",
"Documents":"fa-files-o",
"Training":"fa-briefcase",
"Loans":"fa-list-alt"
}

View File

@@ -0,0 +1,51 @@
<?php
if (!class_exists('ProjectsModulesManager')) {
class ProjectsModulesManager extends AbstractModuleManager{
public function initializeUserClasses(){
if(defined('MODULE_TYPE') && MODULE_TYPE != 'admin'){
$this->addUserClass("EmployeeProject");
}
}
public function initializeFieldMappings(){
}
public function initializeDatabaseErrorMappings(){
}
public function setupModuleClassDefinitions(){
$this->addModelClass('EmployeeProject');
}
}
}
if (!class_exists('EmployeeProject')) {
class EmployeeProject extends ICEHRM_Record {
var $_table = 'EmployeeProjects';
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");
}
}
}

View File

@@ -0,0 +1,64 @@
<?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 = 'projects';
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="tabEmployeeProject" href="#tabPageEmployeeProject">My Projects</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tabPageEmployeeProject">
<div id="EmployeeProject" class="reviewBlock" data-content="List" style="padding-left:5px;">
</div>
<div id="EmployeeProjectForm" class="reviewBlock" data-content="Form" style="padding-left:5px;display:none;">
</div>
</div>
</div>
</div>
<script>
var modJsList = new Array();
modJsList['tabEmployeeProject'] = new EmployeeProjectAdapter('EmployeeProject','EmployeeProject');
<?php if(isset($modulePermissions['perm']['Add Projects']) && $modulePermissions['perm']['Add Projects'] == "No"){?>
modJsList['tabEmployeeProject'].setShowAddNew(false);
<?php }?>
<?php if(isset($modulePermissions['perm']['Delete Projects']) && $modulePermissions['perm']['Delete Projects'] == "No"){?>
modJsList['tabEmployeeProject'].setShowDelete(false);
<?php }?>
<?php if(isset($modulePermissions['perm']['Edit Projects']) && $modulePermissions['perm']['Edit Projects'] == "No"){?>
modJsList['tabEmployeeProject'].setShowEdit(false);
<?php }?>
var modJs = modJsList['tabEmployeeProject'];
</script>
<?php include APP_BASE_PATH.'footer.php';?>

View File

@@ -0,0 +1,54 @@
/*
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)
*/
function EmployeeProjectAdapter(endPoint) {
this.initAdapter(endPoint);
}
EmployeeProjectAdapter.inherits(AdapterBase);
EmployeeProjectAdapter.method('getDataMapping', function() {
return [
"id",
"project",
"status"
];
});
EmployeeProjectAdapter.method('getHeaders', function() {
return [
{ "sTitle": "ID" ,"bVisible":false},
{ "sTitle": "Project" },
{ "sTitle": "Status"}
];
});
EmployeeProjectAdapter.method('getFormFields', function() {
return [
[ "id", {"label":"ID","type":"hidden"}],
[ "project", {"label":"Project","type":"select2","remote-source":["Project","id","name"]}],
[ "status", {"label":"Status","type":"select","source":[["Current","Current"],["Inactive","Inactive"],["Completed","Completed"]]}],
[ "details", {"label":"Details","type":"textarea","validation":"none"}]
];
});

View File

@@ -0,0 +1,22 @@
{
"label":"Projects",
"menu":"Time Management",
"order":"1",
"icon":"fa-pencil-square",
"user_levels":["Admin","Manager","Employee"],
"permissions":
{
"Manager":{
"Add Projects":"Yes",
"Edit Projects":"Yes",
"Delete Projects":"Yes"
},
"Employee":{
"Add Projects":"No",
"Edit Projects":"No",
"Delete Projects":"No"
}
}
}

View File

@@ -0,0 +1,119 @@
<?php
if (!class_exists('QualificationsModulesManager')) {
class QualificationsModulesManager extends AbstractModuleManager{
public function initializeUserClasses(){
if(defined('MODULE_TYPE') && MODULE_TYPE != 'admin'){
$this->addUserClass("EmployeeSkill");
$this->addUserClass("EmployeeEducation");
$this->addUserClass("EmployeeCertification");
$this->addUserClass("EmployeeLanguage");
}
}
public function initializeFieldMappings(){
}
public function initializeDatabaseErrorMappings(){
}
public function setupModuleClassDefinitions(){
$this->addModelClass('EmployeeSkill');
$this->addModelClass('EmployeeEducation');
$this->addModelClass('EmployeeCertification');
$this->addModelClass('EmployeeLanguage');
}
}
}
if (!class_exists('EmployeeSkill')) {
class EmployeeSkill extends ICEHRM_Record {
var $_table = 'EmployeeSkills';
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");
}
}
class EmployeeEducation extends ICEHRM_Record {
var $_table = 'EmployeeEducations';
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");
}
}
class EmployeeCertification extends ICEHRM_Record {
var $_table = 'EmployeeCertifications';
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");
}
}
class EmployeeLanguage extends ICEHRM_Record {
var $_table = 'EmployeeLanguages';
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");
}
}
}

View File

@@ -0,0 +1,84 @@
<?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 = 'qualifications';
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="tabEmployeeSkill" href="#tabPageEmployeeSkill">Skills</a></li>
<li><a id="tabEmployeeEducation" href="#tabPageEmployeeEducation">Education</a></li>
<li><a id="tabEmployeeCertification" href="#tabPageEmployeeCertification">Certifications</a></li>
<li><a id="tabEmployeeLanguage" href="#tabPageEmployeeLanguage">Languages</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tabPageEmployeeSkill">
<div id="EmployeeSkill" class="reviewBlock" data-content="List" style="padding-left:5px;">
</div>
<div id="EmployeeSkillForm" class="reviewBlock" data-content="Form" style="padding-left:5px;display:none;">
</div>
</div>
<div class="tab-pane" id="tabPageEmployeeEducation">
<div id="EmployeeEducation" class="reviewBlock" data-content="List" style="padding-left:5px;">
</div>
<div id="EmployeeEducationForm" class="reviewBlock" data-content="Form" style="padding-left:5px;display:none;">
</div>
</div>
<div class="tab-pane" id="tabPageEmployeeCertification">
<div id="EmployeeCertification" class="reviewBlock" data-content="List" style="padding-left:5px;">
</div>
<div id="EmployeeCertificationForm" class="reviewBlock" data-content="Form" style="padding-left:5px;display:none;">
</div>
</div>
<div class="tab-pane" id="tabPageEmployeeLanguage">
<div id="EmployeeLanguage" class="reviewBlock" data-content="List" style="padding-left:5px;">
</div>
<div id="EmployeeLanguageForm" class="reviewBlock" data-content="Form" style="padding-left:5px;display:none;">
</div>
</div>
</div>
</div>
<script>
var modJsList = new Array();
modJsList['tabEmployeeSkill'] = new EmployeeSkillAdapter('EmployeeSkill');
modJsList['tabEmployeeEducation'] = new EmployeeEducationAdapter('EmployeeEducation');
modJsList['tabEmployeeCertification'] = new EmployeeCertificationAdapter('EmployeeCertification');
modJsList['tabEmployeeLanguage'] = new EmployeeLanguageAdapter('EmployeeLanguage');
var modJs = modJsList['tabEmployeeSkill'];
</script>
<?php include APP_BASE_PATH.'footer.php';?>

View File

@@ -0,0 +1,200 @@
/*
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)
*/
function EmployeeSkillAdapter(endPoint) {
this.initAdapter(endPoint);
}
EmployeeSkillAdapter.inherits(AdapterBase);
EmployeeSkillAdapter.method('getDataMapping', function() {
return [
"id",
"skill_id",
"details"
];
});
EmployeeSkillAdapter.method('getHeaders', function() {
return [
{ "sTitle": "ID" ,"bVisible":false},
{ "sTitle": "Skill" },
{ "sTitle": "Details"}
];
});
EmployeeSkillAdapter.method('getFormFields', function() {
return [
[ "id", {"label":"ID","type":"hidden"}],
[ "skill_id", {"label":"Skill","type":"select2","allow-null":true,"remote-source":["Skill","id","name"]}],
[ "details", {"label":"Details","type":"textarea","validation":""}]
];
});
/**
* EmployeeEducationAdapter
*/
function EmployeeEducationAdapter(endPoint) {
this.initAdapter(endPoint);
}
EmployeeEducationAdapter.inherits(AdapterBase);
EmployeeEducationAdapter.method('getDataMapping', function() {
return [
"id",
"education_id",
"institute",
"date_start",
"date_end"
];
});
EmployeeEducationAdapter.method('getHeaders', function() {
return [
{ "sTitle": "ID", "bVisible":false},
{ "sTitle": "Qualification" },
{ "sTitle": "Institute"},
{ "sTitle": "Start Date"},
{ "sTitle": "Completed On"},
];
});
EmployeeEducationAdapter.method('getFormFields', function() {
return [
[ "id", {"label":"ID","type":"hidden"}],
[ "education_id", {"label":"Qualification","type":"select2","allow-null":false,"remote-source":["Education","id","name"]}],
[ "institute", {"label":"Institute","type":"text","validation":""}],
[ "date_start", {"label":"Start Date","type":"date","validation":"none"}],
[ "date_end", {"label":"Completed On","type":"date","validation":"none"}]
];
});
/**
* EmployeeCertificationAdapter
*/
function EmployeeCertificationAdapter(endPoint) {
this.initAdapter(endPoint);
}
EmployeeCertificationAdapter.inherits(AdapterBase);
EmployeeCertificationAdapter.method('getDataMapping', function() {
return [
"id",
"certification_id",
"institute",
"date_start",
"date_start"
];
});
EmployeeCertificationAdapter.method('getHeaders', function() {
return [
{ "sTitle": "ID","bVisible":false},
{ "sTitle": "Certification" },
{ "sTitle": "Institute"},
{ "sTitle": "Granted On"},
{ "sTitle": "Valid Thru"},
];
});
EmployeeCertificationAdapter.method('getFormFields', function() {
return [
[ "id", {"label":"ID","type":"hidden"}],
[ "certification_id", {"label":"Certification","type":"select2","allow-null":false,"remote-source":["Certification","id","name"]}],
[ "institute", {"label":"Institute","type":"text","validation":""}],
[ "date_start", {"label":"Granted On","type":"date","validation":"none"}],
[ "date_end", {"label":"Valid Thru","type":"date","validation":"none"}]
];
});
/**
* EmployeeLanguageAdapter
*/
function EmployeeLanguageAdapter(endPoint) {
this.initAdapter(endPoint);
}
EmployeeLanguageAdapter.inherits(AdapterBase);
EmployeeLanguageAdapter.method('getDataMapping', function() {
return [
"id",
"language_id",
"reading",
"speaking",
"writing",
"understanding"
];
});
EmployeeLanguageAdapter.method('getHeaders', function() {
return [
{ "sTitle": "ID", "bVisible":false },
{ "sTitle": "Language" },
{ "sTitle": "Reading"},
{ "sTitle": "Speaking"},
{ "sTitle": "Writing"},
{ "sTitle": "Understanding"}
];
});
EmployeeLanguageAdapter.method('getFormFields', function() {
var compArray = [["Elementary Proficiency","Elementary Proficiency"],
["Limited Working Proficiency","Limited Working Proficiency"],
["Professional Working Proficiency","Professional Working Proficiency"],
["Full Professional Proficiency","Full Professional Proficiency"],
["Native or Bilingual Proficiency","Native or Bilingual Proficiency"]];
return [
[ "id", {"label":"ID","type":"hidden"}],
[ "language_id", {"label":"Language","type":"select2","allow-null":false,"remote-source":["Language","id","name"]}],
[ "reading", {"label":"Reading","type":"select","source":compArray}],
[ "speaking", {"label":"Speaking","type":"select","source":compArray}],
[ "writing", {"label":"Writing","type":"select","source":compArray}],
[ "understanding", {"label":"Understanding","type":"select","source":compArray}]
];
});

View File

@@ -0,0 +1,11 @@
{
"label":"Qualifications",
"menu":"Personal Information",
"order":"3",
"icon":"fa-graduation-cap",
"user_levels":["Admin","Manager","Employee"],
"permissions":
{
}
}

View File

@@ -0,0 +1,51 @@
<?php
if (!class_exists('SalaryModulesManager')) {
class SalaryModulesManager extends AbstractModuleManager{
public function initializeUserClasses(){
if(defined('MODULE_TYPE') && MODULE_TYPE != 'admin'){
$this->addUserClass("EmployeeSalary");
}
}
public function initializeFieldMappings(){
}
public function initializeDatabaseErrorMappings(){
}
public function setupModuleClassDefinitions(){
$this->addModelClass('EmployeeSalary');
}
}
}
if (!class_exists('EmployeeSalary')) {
class EmployeeSalary extends ICEHRM_Record {
var $_table = 'EmployeeSalary';
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");
}
}
}

View File

@@ -0,0 +1,64 @@
<?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 = 'salary';
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="tabEmployeeSalary" href="#tabPageEmployeeSalary">Salary</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tabPageEmployeeSalary">
<div id="EmployeeSalary" class="reviewBlock" data-content="List" style="padding-left:5px;">
</div>
<div id="EmployeeSalaryForm" class="reviewBlock" data-content="Form" style="padding-left:5px;display:none;">
</div>
</div>
</div>
</div>
<script>
var modJsList = new Array();
modJsList['tabEmployeeSalary'] = new EmployeeSalaryAdapter('EmployeeSalary');
<?php if(isset($modulePermissions['perm']['Add Salary']) && $modulePermissions['perm']['Add Salary'] == "No"){?>
modJsList['tabEmployeeSalary'].setShowAddNew(false);
<?php }?>
<?php if(isset($modulePermissions['perm']['Delete Salary']) && $modulePermissions['perm']['Delete Salary'] == "No"){?>
modJsList['tabEmployeeSalary'].setShowDelete(false);
<?php }?>
<?php if(isset($modulePermissions['perm']['Edit Salary']) && $modulePermissions['perm']['Edit Salary'] == "No"){?>
modJsList['tabEmployeeSalary'].setShowEdit(false);
<?php }?>
var modJs = modJsList['tabEmployeeSalary'];
</script>
<?php include APP_BASE_PATH.'footer.php';?>

62
ext/modules/salary/lib.js Normal file
View File

@@ -0,0 +1,62 @@
/*
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)
*/
function EmployeeSalaryAdapter(endPoint) {
this.initAdapter(endPoint);
}
EmployeeSalaryAdapter.inherits(AdapterBase);
EmployeeSalaryAdapter.method('getDataMapping', function() {
return [
"id",
"component",
"pay_frequency",
"currency",
"amount",
"details"
];
});
EmployeeSalaryAdapter.method('getHeaders', function() {
return [
{ "sTitle": "ID" ,"bVisible":false},
{ "sTitle": "Salary Component" },
{ "sTitle": "Pay Frequency"},
{ "sTitle": "Currency"},
{ "sTitle": "Amount"},
{ "sTitle": "Details"}
];
});
EmployeeSalaryAdapter.method('getFormFields', function() {
return [
[ "id", {"label":"ID","type":"hidden"}],
[ "component", {"label":"Salary Component","type":"select2","remote-source":["SalaryComponent","id","name"]}],
[ "pay_frequency", {"label":"Pay Frequency","type":"select","source":[["Hourly","Hourly"],["Daily","Daily"],["Bi Weekly","Bi Weekly"],["Weekly","Weekly"],["Semi Monthly","Semi Monthly"],["Monthly","Monthly"]]}],
[ "currency", {"label":"Currency","type":"select","remote-source":["CurrencyType","id","name"]}],
[ "amount", {"label":"Amount","type":"text","validation":"float"}],
[ "details", {"label":"Details","type":"textarea","validation":"none"}]
];
});

View File

@@ -0,0 +1,22 @@
{
"label":"Salary",
"menu":"Personal Information",
"order":"4",
"icon":"fa-calculator",
"user_levels":["Admin","Manager","Employee"],
"permissions":
{
"Manager":{
"Add Salary":"No",
"Edit Salary":"No",
"Delete Salary":"No"
},
"Employee":{
"Add Salary":"No",
"Edit Salary":"No",
"Delete Salary":"No"
}
}
}

View File

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

View File

@@ -0,0 +1,54 @@
<?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 = 'subordinates';
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="tabSubordinate" href="#tabPageSubordinate">Subordinates</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tabPageSubordinate">
<div id="Subordinate" class="reviewBlock" data-content="List" style="padding-left:5px;">
</div>
<div id="SubordinateForm" class="reviewBlock" data-content="Form" style="padding-left:5px;display:none;">
</div>
</div>
</div>
</div>
<script>
var modJsList = new Array();
modJsList['tabSubordinate'] = new SubordinateAdapter('Employee','Subordinate',{"supervisor":"__myid__"},'');
modJsList['tabSubordinate'].setShowAddNew(false);
modJsList['tabSubordinate'].setShowDelete(false);
var modJs = modJsList['tabSubordinate'];
</script>
<?php include APP_BASE_PATH.'footer.php';?>

View File

@@ -0,0 +1,83 @@
/**
* Author: Thilina Hasantha
*/
function SubordinateAdapter(endPoint,tab,filter,orderBy) {
this.initAdapter(endPoint,tab,filter,orderBy);
}
SubordinateAdapter.inherits(AdapterBase);
SubordinateAdapter.method('getDataMapping', function() {
return [
"id",
"employee_id",
"first_name",
"last_name",
"mobile_phone",
"department",
"gender",
"supervisor"
];
});
SubordinateAdapter.method('getHeaders', function() {
return [
{ "sTitle": "ID" },
{ "sTitle": "Employee Number" },
{ "sTitle": "First Name" },
{ "sTitle": "Last Name"},
{ "sTitle": "Mobile"},
{ "sTitle": "Department"},
{ "sTitle": "Gender"},
{ "sTitle": "Supervisor"}
];
});
SubordinateAdapter.method('getFormFields', function() {
return [
[ "id", {"label":"ID","type":"hidden","validation":""}],
[ "employee_id", {"label":"Employee Number","type":"text","validation":""}],
[ "first_name", {"label":"First Name","type":"text","validation":""}],
[ "middle_name", {"label":"Middle Name","type":"text","validation":"none"}],
[ "last_name", {"label":"Last Name","type":"text","validation":""}],
[ "nationality", {"label":"Nationality","type":"select2","remote-source":["Nationality","id","name"]}],
[ "birthday", {"label":"Date of Birth","type":"date","validation":""}],
[ "gender", {"label":"Gender","type":"select","source":[["Male","Male"],["Female","Female"]]}],
[ "marital_status", {"label":"Marital Status","type":"select","source":[["Married","Married"],["Single","Single"],["Divorced","Divorced"],["Widowed","Widowed"],["Other","Other"]]}],
[ "ssn_num", {"label":"SSN/NRIC","type":"text","validation":"none"}],
[ "nic_num", {"label":"NIC","type":"text","validation":"none"}],
[ "other_id", {"label":"Other ID","type":"text","validation":"none"}],
[ "driving_license", {"label":"Driving License No","type":"text","validation":"none"}],
/*[ "driving_license_exp_date", {"label":"License Exp Date","type":"date","validation":"none"}],*/
[ "employment_status", {"label":"Employment Status","type":"select2","remote-source":["EmploymentStatus","id","name"]}],
[ "job_title", {"label":"Job Title","type":"select2","remote-source":["JobTitle","id","name"]}],
[ "pay_grade", {"label":"Pay Grade","type":"select2","allow-null":true,"remote-source":["PayGrade","id","name"]}],
[ "work_station_id", {"label":"Work Station Id","type":"text","validation":"none"}],
[ "address1", {"label":"Address Line 1","type":"text","validation":"none"}],
[ "address2", {"label":"Address Line 2","type":"text","validation":"none"}],
[ "city", {"label":"City","type":"text","validation":"none"}],
[ "country", {"label":"Country","type":"select2","remote-source":["Country","code","name"]}],
[ "province", {"label":"Province","type":"select2","allow-null":true,"remote-source":["Province","id","name"]}],
[ "postal_code", {"label":"Postal/Zip Code","type":"text","validation":"none"}],
[ "home_phone", {"label":"Home Phone","type":"text","validation":"none"}],
[ "mobile_phone", {"label":"Mobile Phone","type":"text","validation":"none"}],
[ "work_phone", {"label":"Work Phone","type":"text","validation":"none"}],
[ "work_email", {"label":"Work Email","type":"text","validation":"email"}],
[ "private_email", {"label":"Private Email","type":"text","validation":"email"}],
[ "joined_date", {"label":"Joined Date","type":"date","validation":"none"}],
[ "confirmation_date", {"label":"Confirmation Date","type":"date","validation":"none"}],
[ "department", {"label":"Department","type":"select2","remote-source":["CompanyStructure","id","title"]}],
[ "supervisor", {"label":"Supervisor","type":"select2","allow-null":true,"remote-source":["Employee","id","first_name+last_name"]}]
];
});
SubordinateAdapter.method('getActionButtonsHtml', function(id) {
var html = '<div style="width:110px;"><img class="tableActionButton" src="_BASE_images/user.png" style="cursor:pointer;" rel="tooltip" title="Login as this Employee" onclick="modJs.setAdminEmployee(_id_);return false;"></img><img class="tableActionButton" src="_BASE_images/edit.png" style="cursor:pointer;margin-left:15px;" rel="tooltip" title="Edit" onclick="modJs.edit(_id_);return false;"></img><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></div>';
html = html.replace(/_id_/g,id);
html = html.replace(/_BASE_/g,this.baseUrl);
return html;
});

View File

@@ -0,0 +1,11 @@
{
"label":"Subordinates",
"menu":"Subordinates",
"order":"1",
"icon":"fa-users",
"user_levels":["Admin","Manager"],
"permissions":
{
}
}

View File

@@ -0,0 +1,165 @@
<?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)
*/
class Time_sheetsActionManager extends SubActionManager{
public function getTimeEntries($req){
$employee = $this->baseService->getElement('Employee',$this->getCurrentProfileId(),null,true);
$timeSheetEntry = new EmployeeTimeEntry();
$list = $timeSheetEntry->Find("timesheet = ? order by date_start",array($req->id));
$mappingStr = $req->sm;
$map = json_decode($mappingStr);
if(!$list){
LogManager::getInstance()->info($timeSheetEntry->ErrorMsg());
}
if(!empty($mappingStr)){
$list = $this->baseService->populateMapping($list,$map);
}
return new IceResponse(IceResponse::SUCCESS,$list);
}
public function changeTimeSheetStatus($req){
$employee = $this->baseService->getElement('Employee',$this->getCurrentProfileId(),null,true);
$subordinate = new Employee();
$subordinates = $subordinate->Find("supervisor = ?",array($employee->id));
$subordinatesIds = array();
foreach($subordinates as $sub){
$subordinatesIds[] = $sub->id;
}
$timeSheet = new EmployeeTimeSheet();
$timeSheet->Load("id = ?",array($req->id));
if($timeSheet->id != $req->id){
return new IceResponse(IceResponse::ERROR,"Timesheet not found");
}
if($req->status == 'Submitted' && $employee->id == $timeSheet->employee){
}else if(!in_array($timeSheet->employee, $subordinatesIds) && $this->user->user_level != 'Admin'){
return new IceResponse(IceResponse::ERROR,"This Timesheet does not belong to any of your subordinates");
}
$oldStatus = $timeSheet->status;
$timeSheet->status = $req->status;
if($oldStatus == $req->status){
return new IceResponse(IceResponse::SUCCESS,"");
}
$ok = $timeSheet->Save();
if(!$ok){
LogManager::getInstance()->info($timeSheet->ErrorMsg());
}
$timeSheetEmployee = $this->baseService->getElement('Employee',$timeSheet->employee,null,true);
$this->baseService->audit(IceConstants::AUDIT_ACTION, "Timesheet [".$timeSheetEmployee->first_name." ".$timeSheetEmployee->last_name." - ".date("M d, Y (l)",strtotime($timeSheet->date_start))." to ".date("M d, Y (l)",strtotime($timeSheet->date_end))."] status changed from:".$oldStatus." to:".$req->status);
if($timeSheet->status == "Submitted" && $employee->id == $timeSheet->employee){
$notificationMsg = $employee->first_name." ".$employee->last_name." submitted timesheet from ".date("M d, Y (l)",strtotime($timeSheet->date_start))." to ".date("M d, Y (l)",strtotime($timeSheet->date_end));
$this->baseService->notificationManager->addNotification($employee->supervisor,$notificationMsg,'{"type":"url","url":"g=modules&n=time_sheets&m=module_Time_Management#tabSubEmployeeTimeSheetAll"}',IceConstants::NOTIFICATION_TIMESHEET);
}else if($timeSheet->status == "Approved" || $timeSheet->status == "Rejected"){
$notificationMsg = $employee->first_name." ".$employee->last_name." ".$timeSheet->status." timesheet from ".date("M d, Y (l)",strtotime($timeSheet->date_start))." to ".date("M d, Y (l)",strtotime($timeSheet->date_end));
$this->baseService->notificationManager->addNotification($timeSheet->employee,$notificationMsg,'{"type":"url","url":"g=modules&n=time_sheets&m=module_Time_Management#tabEmployeeTimeSheetApproved"}',IceConstants::NOTIFICATION_TIMESHEET);
}
return new IceResponse(IceResponse::SUCCESS,"");
}
public function createPreviousTimesheet($req){
$employee = $this->baseService->getElement('Employee',$this->getCurrentProfileId(),null,true);
$timeSheet = new EmployeeTimeSheet();
$timeSheet->Load("id = ?",array($req->id));
if($timeSheet->id != $req->id){
return new IceResponse(IceResponse::ERROR,"Timesheet not found");
}
if($timeSheet->employee != $employee->id){
return new IceResponse(IceResponse::ERROR,"You don't have permissions to add this Timesheet");
}
$end = date("Y-m-d", strtotime("last Saturday", strtotime($timeSheet->date_start)));
$start = date("Y-m-d", strtotime("last Sunday", strtotime($end)));
$tempTimeSheet = new EmployeeTimeSheet();
$tempTimeSheet->Load("employee = ? and date_start = ?",array($employee->id, $start));
if($employee->id == $tempTimeSheet->employee){
return new IceResponse(IceResponse::ERROR,"Timesheet already exists");
}
$newTimeSheet = new EmployeeTimeSheet();
$newTimeSheet->employee = $employee->id;
$newTimeSheet->date_start = $start;
$newTimeSheet->date_end = $end;
$newTimeSheet->status = "Pending";
$ok = $newTimeSheet->Save();
if(!$ok){
LogManager::getInstance()->info("Error creating time sheet : ".$newTimeSheet->ErrorMsg());
return new IceResponse(IceResponse::ERROR,"Error creating Timesheet");
}
return new IceResponse(IceResponse::SUCCESS,"");
}
public function getSubEmployeeTimeSheets($req){
$employee = $this->baseService->getElement('Employee',$this->getCurrentProfileId(),null,true);
$subordinate = new Employee();
$subordinates = $subordinate->Find("supervisor = ?",array($employee->id));
$subordinatesIds = "";
foreach($subordinates as $sub){
if($subordinatesIds != ""){
$subordinatesIds.=",";
}
$subordinatesIds.=$sub->id;
}
$subordinatesIds.="";
$mappingStr = $req->sm;
$map = json_decode($mappingStr);
$timeSheet = new EmployeeTimeSheet();
$list = $timeSheet->Find("employee in (".$subordinatesIds.")",array());
if(!$list){
LogManager::getInstance()->info($timeSheet->ErrorMsg());
}
if(!empty($mappingStr)){
$list = $this->baseService->populateMapping($list,$map);
}
return new IceResponse(IceResponse::SUCCESS,$list);
}
}

View File

@@ -0,0 +1,67 @@
<?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)
*/
class Time_sheetsInitialize extends AbstractInitialize{
public function init(){
//Add Employee time sheets if it is not already created for current week
$empId = $this->getCurrentProfileId();
if(date('w', strtotime("now")) == 0) {
$start = date("Y-m-d", strtotime("now"));
}else{
$start = date("Y-m-d", strtotime("last Sunday"));
}
if(date('w', strtotime("now")) == 6) {
$end = date("Y-m-d", strtotime("now"));
}else{
$end = date("Y-m-d", strtotime("next Saturday"));
}
$timeSheet = new EmployeeTimeSheet();
$timeSheet->Load("employee = ? and date_start = ? and date_end = ?",array($empId,$start,$end));
if($timeSheet->date_start == $start && $timeSheet->employee == $empId){
}else{
if(!empty($empId)){
$timeSheet->employee = $empId;
$timeSheet->date_start = $start;
$timeSheet->date_end = $end;
$timeSheet->status = "Pending";
$ok = $timeSheet->Save();
if(!$ok){
LogManager::getInstance()->info("Error creating time sheet : ".$timeSheet->ErrorMsg());
}
}
}
//Generate missing timesheets
}
}

View File

@@ -0,0 +1,82 @@
<?php
if (!class_exists('Time_sheetsModulesManager')) {
class Time_sheetsModulesManager extends AbstractModuleManager{
public function initializeUserClasses(){
$this->addUserClass("EmployeeTimeSheet");
$this->addUserClass("EmployeeTimeEntry");
}
public function initializeFieldMappings(){
}
public function initializeDatabaseErrorMappings(){
}
public function setupModuleClassDefinitions(){
$this->addModelClass('EmployeeTimeSheet');
$this->addModelClass('EmployeeTimeEntry');
}
}
}
if (!class_exists('EmployeeTimeSheet')) {
class EmployeeTimeSheet extends ICEHRM_Record {
var $_table = 'EmployeeTimeSheets';
public function getAdminAccess(){
return array("get","element","save","delete");
}
public function getManagerAccess(){
return array("get","element","save","delete");
}
public function getUserAccess(){
return array("get","element");
}
public function getUserOnlyMeAccess(){
return array("element","save","delete");
}
}
class EmployeeTimeEntry extends ICEHRM_Record {
var $_table = 'EmployeeTimeEntry';
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 validateSave($obj){
if(SettingsManager::getInstance()->getSetting("Attendance: Time-sheet Cross Check") == "1"){
$attendance = new Attendance();
$list = $attendance->Find("employee = ? and in_time <= ? and out_time >= ?",array($obj->employee,$obj->date_start,$obj->date_end));
if(empty($list) || count($list) == 0){
return new IceResponse(IceResponse::ERROR,"The time entry can not be added since you have not marked attendance for selected period");
}
}
return new IceResponse(IceResponse::SUCCESS,"");
}
}
}

View File

@@ -0,0 +1,19 @@
<form class="form-horizontal" id="_id_" role="form">
<div class="box-body">
<div class="control-group">
<div class="controls">
<span class="label label-warning" id="_id__error" style="display:none;"></span>
</div>
</div>
_fields_
<div class="control-group row">
<div class="controls col-sm-9">
<button onclick="try{modJs.save()}catch(e){};return false;" class="saveBtn btn btn-primary pull-right"><i class="fa fa-save"></i> Save</button>
<button onclick="modJs.cancel();return false;" class="cancelBtn btn pull-right" style="margin-right:5px;"><i class="fa fa-times-circle-o"></i> Cancel</button>
</div>
<div class="controls col-sm-3">
</div>
</div>
</div>
</form>

View File

@@ -0,0 +1,163 @@
<?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 = 'employee_TimeSheet';
define('MODULE_PATH',dirname(__FILE__));
include APP_BASE_PATH.'header.php';
include APP_BASE_PATH.'modulejslibs.inc.php';
//custom code
$employeeProjects = array();
$allowAllProjects = $settingsManager->getSetting("Projects: Make All Projects Available to Employees");
if($allowAllProjects == 0){
$employeeProjects = array();
$employeeProjectsTemp = $baseService->get("EmployeeProject");
foreach($employeeProjectsTemp as $p){
$project = new Project();
$project->Load("id = ?",$p->project);
$p->name = $project->name;
$employeeProjects[] = $p;
}
}else{
$employeeProjects = $baseService->get("Project");
}
?><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="tabEmployeeTimeSheetAll" href="#tabPageEmployeeTimeSheetAll">All My TimeSheets</a></li>
<li class=""><a id="tabEmployeeTimeSheetApproved" href="#tabPageEmployeeTimeSheetApproved">Approved TimeSheets</a></li>
<li class=""><a id="tabEmployeeTimeSheetPending" href="#tabPageEmployeeTimeSheetPending">Pending TimeSheets</a></li>
<li class=""><a id="tabSubEmployeeTimeSheetAll" href="#tabPageSubEmployeeTimeSheetAll">Subordinate TimeSheets</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tabPageEmployeeTimeSheetAll">
<div id="EmployeeTimeSheetAll" class="reviewBlock" data-content="List" style="padding-left:5px;">
</div>
<div id="EmployeeTimeSheetAllForm" class="reviewBlock" data-content="Form" style="padding-left:5px;display:none;">
</div>
</div>
<div class="tab-pane" id="tabPageEmployeeTimeSheetApproved">
<div id="EmployeeTimeSheetApproved" class="reviewBlock" data-content="List" style="padding-left:5px;">
</div>
<div id="EmployeeTimeSheetApprovedForm" class="reviewBlock" data-content="Form" style="padding-left:5px;display:none;">
</div>
</div>
<div class="tab-pane" id="tabPageEmployeeTimeSheetPending">
<div id="EmployeeTimeSheetPending" class="reviewBlock" data-content="List" style="padding-left:5px;">
</div>
<div id="EmployeeTimeSheetPendingForm" class="reviewBlock" data-content="Form" style="padding-left:5px;display:none;">
</div>
</div>
<div class="tab-pane" id="tabPageSubEmployeeTimeSheetAll">
<div id="SubEmployeeTimeSheetAll" class="reviewBlock" data-content="List" style="padding-left:5px;">
</div>
<div id="SubEmployeeTimeSheetAllForm" class="reviewBlock" data-content="Form" style="padding-left:5px;display:none;">
</div>
</div>
</div>
</div>
<script>
var modJsList = new Array();
modJsList['tabEmployeeTimeSheetAll'] = new EmployeeTimeSheetAdapter('EmployeeTimeSheet','EmployeeTimeSheetAll','','date_start desc');
modJsList['tabEmployeeTimeSheetAll'].setShowAddNew(false);
modJsList['tabEmployeeTimeSheetAll'].setRemoteTable(true);
modJsList['tabEmployeeTimeSheetApproved'] = new EmployeeTimeSheetAdapter('EmployeeTimeSheet','EmployeeTimeSheetApproved',{"status":"Approved"});
modJsList['tabEmployeeTimeSheetApproved'].setShowAddNew(false);
modJsList['tabEmployeeTimeSheetApproved'].setRemoteTable(true);
modJsList['tabEmployeeTimeSheetPending'] = new EmployeeTimeSheetAdapter('EmployeeTimeSheet','EmployeeTimeSheetPending',{"status":"Pending"});
modJsList['tabEmployeeTimeSheetPending'].setShowAddNew(false);
modJsList['tabEmployeeTimeSheetPending'].setRemoteTable(true);
modJsList['tabSubEmployeeTimeSheetAll'] = new SubEmployeeTimeSheetAdapter('EmployeeTimeSheet','SubEmployeeTimeSheetAll','','date_start desc');
modJsList['tabSubEmployeeTimeSheetAll'].setShowAddNew(false);
modJsList['tabSubEmployeeTimeSheetAll'].setRemoteTable(true);
modJsList['tabEmployeeTimeEntry'] = new EmployeeTimeEntryAdapter('EmployeeTimeEntry','EmployeeTimeEntry','','');
modJsList['tabEmployeeTimeEntry'].setShowAddNew(false);
modJsList['tabEmployeeTimeEntry'].setAllProjectsAllowed(<?=$allowAllProjects?>);
modJsList['tabEmployeeTimeEntry'].setEmployeeProjects(<?=json_encode($employeeProjects)?>);
var modJs = modJsList['tabEmployeeTimeSheetAll'];
</script>
<div class="modal" id="TimeSheetStatusModel" 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 Timesheet Status</h3>
</div>
<div class="modal-body">
<form id="TimeSheetStatusForm">
<div class="control-group">
<label class="control-label" for="timesheet_status">Timesheet Status</label>
<div class="controls">
<select class="" type="text" id="timesheet_status" name="timesheet_status">
<option value="Approved">Approved</option>
<option value="Pending">Pending</option>
<option value="Rejected">Rejected</option>
<option value="Submitted">Submitted</option>
</select>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button class="btn btn-primary" onclick="modJs.changeTimeSheetStatus();">Change Status</button>
<button class="btn" onclick="modJs.closeTimeSheetStatus();">Not Now</button>
</div>
</div>
</div>
</div>
<div class="modal" id="TimeEntryModel" 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;">Time Entry</h3>
</div>
<div class="modal-body" style="max-height:530px;" id="EmployeeTimeEntryForm">
</div>
</div>
</div>
</div>
<?php include APP_BASE_PATH.'footer.php';?>

View File

@@ -0,0 +1,696 @@
/*
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)
*/
function EmployeeTimeSheetAdapter(endPoint,tab,filter,orderBy) {
this.initAdapter(endPoint,tab,filter,orderBy);
}
EmployeeTimeSheetAdapter.inherits(AdapterBase);
this.currentTimesheetId = null;
this.currentTimesheet = null;
EmployeeTimeSheetAdapter.method('getDataMapping', function() {
return [
"id",
"date_start",
"date_end",
"status"
];
});
EmployeeTimeSheetAdapter.method('getHeaders', function() {
return [
{ "sTitle": "ID" ,"bVisible":false},
{ "sTitle": "Start Date"},
{ "sTitle": "End Date"},
{ "sTitle": "Status"}
];
});
EmployeeTimeSheetAdapter.method('getFormFields', function() {
return [
[ "id", {"label":"ID","type":"hidden"}],
[ "date_start", {"label":"TimeSheet Start Date","type":"date","validation":""}],
[ "date_end", {"label":"TimeSheet End Date","type":"date","validation":""}],
[ "details", {"label":"Reason","type":"textarea","validation":"none"}]
];
});
EmployeeTimeSheetAdapter.method('preProcessTableData', function(row) {
row[1] = Date.parse(row[1]).toString('MMM d, yyyy (dddd)');
row[2] = Date.parse(row[2]).toString('MMM d, yyyy (dddd)');
return row;
});
EmployeeTimeSheetAdapter.method('renderForm', function(object) {
var formHtml = this.templates['formTemplate'];
var html = "";
$("#"+this.getTableName()+'Form').html(formHtml);
$("#"+this.getTableName()+'Form').show();
$("#"+this.getTableName()).hide();
$('#timesheet_start').html(Date.parse(object.date_start).toString('MMM d, yyyy (dddd)'));
$('#timesheet_end').html(Date.parse(object.date_end).toString('MMM d, yyyy (dddd)'));
this.currentTimesheet = object;
this.getTimeEntries();
});
EmployeeTimeSheetAdapter.method('openTimeEntryDialog', function() {
this.currentTimesheetId = this.currentId;
var obj = modJsList['tabEmployeeTimeEntry'];
$('#TimeEntryModel').modal({
backdrop: 'static',
keyboard: false
});
obj.currentTimesheet = this.currentTimesheet;
obj.renderForm();
obj.timesheetId = this.currentId;
});
EmployeeTimeSheetAdapter.method('closeTimeEntryDialog', function() {
$('#TimeEntryModel').modal('hide');
});
EmployeeTimeSheetAdapter.method('getTimeEntries', function() {
timesheetId = this.currentId;
var sourceMappingJson = JSON.stringify(modJsList['tabEmployeeTimeEntry'].getSourceMapping());
object = {"id":timesheetId,"sm":sourceMappingJson};
var reqJson = JSON.stringify(object);
var callBackData = [];
callBackData['callBackData'] = [];
callBackData['callBackSuccess'] = 'getTimeEntriesSuccessCallBack';
callBackData['callBackFail'] = 'getTimeEntriesFailCallBack';
this.customAction('getTimeEntries','modules=time_sheets',reqJson,callBackData);
});
EmployeeTimeSheetAdapter.method('getTimeEntriesSuccessCallBack', function(callBackData) {
var entries = callBackData;
var html = "";
var temp = '<tr><td><img class="tableActionButton" src="_BASE_images/delete.png" style="cursor:pointer;" rel="tooltip" title="Delete" onclick="modJsList[\'tabEmployeeTimeEntry\'].deleteRow(_id_);return false;"></img></td><td>_start_</td><td>_end_</td><td>_duration_</td><td>_project_</td><td>_details_</td>';
for(var i=0;i<entries.length;i++){
try{
var t = temp;
t = t.replace(/_start_/g,Date.parse(entries[i].date_start).toString('MMM d, yyyy [hh:mm tt]'));
t = t.replace(/_end_/g,Date.parse(entries[i].date_end).toString('MMM d, yyyy [hh:mm tt]'));
var mili = Date.parse(entries[i].date_end) - Date.parse(entries[i].date_start);
var minutes = Math.round(mili/60000);
var hourMinutes = (minutes % 60);
var hours = (minutes-hourMinutes)/60;
t = t.replace(/_duration_/g,"Hours ("+hours+") - Min ("+hourMinutes+")");
if(entries[i].project == 'null' || entries[i].project == null || entries[i].project == undefined){
t = t.replace(/_project_/g,"None");
}else{
t = t.replace(/_project_/g,entries[i].project);
}
t = t.replace(/_project_/g,entries[i].project);
t = t.replace(/_details_/g,entries[i].details);
t = t.replace(/_id_/g,entries[i].id);
t = t.replace(/_BASE_/g,this.baseUrl);
html += t;
}catch(e){}
}
$('.timesheet_entries_table_body').html(html);
if(modJs.getTableName() == 'SubEmployeeTimeSheetAll'){
$('#submit_sheet').hide();
$('#add_time_sheet_entry').hide();
}else{
if(this.currentElement.status == 'Approved'){
$('#submit_sheet').hide();
$('#add_time_sheet_entry').hide();
}else{
$('#submit_sheet').show();
$('#add_time_sheet_entry').show();
}
}
});
EmployeeTimeSheetAdapter.method('getTimeEntriesFailCallBack', function(callBackData) {
this.showMessage("Error", "Error occured while getting timesheet entries");
});
EmployeeTimeSheetAdapter.method('createPreviousTimesheet', function(id) {
object = {"id":id};
var reqJson = JSON.stringify(object);
var callBackData = [];
callBackData['callBackData'] = [];
callBackData['callBackSuccess'] = 'createPreviousTimesheetSuccessCallBack';
callBackData['callBackFail'] = 'createPreviousTimesheetFailCallBack';
this.customAction('createPreviousTimesheet','modules=time_sheets',reqJson,callBackData);
});
EmployeeTimeSheetAdapter.method('createPreviousTimesheetSuccessCallBack', function(callBackData) {
$('.tooltip').css("display","none");
$('.tooltip').remove();
//this.showMessage("Success", "Previous Timesheet created");
this.get([]);
});
EmployeeTimeSheetAdapter.method('createPreviousTimesheetFailCallBack', function(callBackData) {
this.showMessage("Error", callBackData);
});
EmployeeTimeSheetAdapter.method('changeTimeSheetStatusWithId', function(id, status) {
if(status == "" || status ==null || status == undefined){
this.showMessage("Status Error","Please select a status");
return;
}
object = {"id":id,"status":status};
var reqJson = JSON.stringify(object);
var callBackData = [];
callBackData['callBackData'] = [];
callBackData['callBackSuccess'] = 'changeTimeSheetStatusSuccessCallBack';
callBackData['callBackFail'] = 'changeTimeSheetStatusFailCallBack';
this.customAction('changeTimeSheetStatus','modules=time_sheets',reqJson,callBackData);
});
EmployeeTimeSheetAdapter.method('changeTimeSheetStatusSuccessCallBack', function(callBackData) {
this.showMessage("Successful", "Timesheet status changed successfully");
this.get([]);
});
EmployeeTimeSheetAdapter.method('changeTimeSheetStatusFailCallBack', function(callBackData) {
this.showMessage("Error", "Error occured while changing Timesheet status");
});
EmployeeTimeSheetAdapter.method('getActionButtonsHtml', function(id,data) {
var html = '';
if(this.getTableName() == "EmployeeTimeSheetAll"){
html = '<div style="width:80px;"><img class="tableActionButton" src="_BASE_images/edit.png" style="cursor:pointer;" rel="tooltip" title="Edit Timesheet Entries" onclick="modJs.edit(_id_);return false;"></img><img class="tableActionButton" src="_BASE_images/redo.png" style="cursor:pointer;margin-left:15px;" rel="tooltip" title="Create previous time sheet" onclick="modJs.createPreviousTimesheet(_id_);return false;"></img></div>';
}else{
html = '<div style="width:80px;"><img class="tableActionButton" src="_BASE_images/edit.png" style="cursor:pointer;" rel="tooltip" title="Edit Timesheet Entries" onclick="modJs.edit(_id_);return false;"></img></div>';
}
html = html.replace(/_id_/g,id);
html = html.replace(/_BASE_/g,this.baseUrl);
return html;
});
EmployeeTimeSheetAdapter.method('getCustomTableParams', function() {
var that = this;
var dataTableParams = {
"aoColumnDefs": [
{
"fnRender": function(data, cell){
return that.preProcessRemoteTableData(data, cell, 1)
} ,
"aTargets": [1]
},
{
"fnRender": function(data, cell){
return that.preProcessRemoteTableData(data, cell, 2)
} ,
"aTargets": [2]
},
{
"fnRender": that.getActionButtons,
"aTargets": [that.getDataMapping().length]
}
]
};
return dataTableParams;
});
EmployeeTimeSheetAdapter.method('preProcessRemoteTableData', function(data, cell, id) {
return Date.parse(cell).toString('MMM d, yyyy (dddd)');
});
/*
* Subordinate TimeSheets
*/
function SubEmployeeTimeSheetAdapter(endPoint,tab,filter,orderBy) {
this.initAdapter(endPoint,tab,filter,orderBy);
}
this.timeSheetStatusChangeId = null;
SubEmployeeTimeSheetAdapter.inherits(EmployeeTimeSheetAdapter);
SubEmployeeTimeSheetAdapter.method('getDataMapping', function() {
return [
"id",
"employee",
"date_start",
"date_end",
"status"
];
});
SubEmployeeTimeSheetAdapter.method('getHeaders', function() {
return [
{ "sTitle": "ID" ,"bVisible":false},
{ "sTitle": "Employee","bSearchable":true},
{ "sTitle": "Start Date","bSearchable":true},
{ "sTitle": "End Date","bSearchable":true},
{ "sTitle": "Status"}
];
});
SubEmployeeTimeSheetAdapter.method('getFormFields', function() {
return [
[ "id", {"label":"ID","type":"hidden"}],
[ "employee", {"label":"Employee","type":"select","allow-null":false,"remote-source":["Employee","id","first_name+last_name"]}],
[ "date_start", {"label":"TimeSheet Start Date","type":"date","validation":""}],
[ "date_end", {"label":"TimeSheet Start Date","type":"date","validation":""}],
[ "details", {"label":"Reason","type":"textarea","validation":"none"}]
];
});
/*
SubEmployeeTimeSheetAdapter.method('get', function(callBackData) {
var that = this;
var sourceMappingJson = JSON.stringify(this.getSourceMapping());
var filterJson = "";
if(this.getFilter() != null){
filterJson = JSON.stringify(this.getFilter());
}
var orderBy = "";
if(this.getOrderBy() != null){
orderBy = this.getOrderBy();
}
var object = {'sm':sourceMappingJson,'ft':filterJson,'ob':orderBy};
var reqJson = JSON.stringify(object);
var callBackData = [];
callBackData['callBackData'] = [];
callBackData['callBackSuccess'] = 'getCustomSuccessCallBack';
callBackData['callBackFail'] = 'getFailCallBack';
this.customAction('getSubEmployeeTimeSheets','modules=time_sheets',reqJson,callBackData);
});
*/
SubEmployeeTimeSheetAdapter.method('isSubProfileTable', function() {
return true;
});
SubEmployeeTimeSheetAdapter.method('getCustomSuccessCallBack', function(serverData) {
var data = [];
var mapping = this.getDataMapping();
for(var i=0;i<serverData.length;i++){
var row = [];
for(var j=0;j<mapping.length;j++){
row[j] = serverData[i][mapping[j]];
}
data.push(this.preProcessTableData(row));
}
this.tableData = data;
this.createTable(this.getTableName());
$("#"+this.getTableName()+'Form').hide();
$("#"+this.getTableName()).show();
});
SubEmployeeTimeSheetAdapter.method('preProcessTableData', function(row) {
row[2] = Date.parse(row[2]).toString('MMM d, yyyy (dddd)');
row[3] = Date.parse(row[3]).toString('MMM d, yyyy (dddd)');
return row;
});
SubEmployeeTimeSheetAdapter.method('openTimeSheetStatus', function(timeSheetId,status) {
this.currentTimesheetId = timeSheetId;
$('#TimeSheetStatusModel').modal('show');
$('#timesheet_status').val(status);
this.timeSheetStatusChangeId = timeSheetId;
});
SubEmployeeTimeSheetAdapter.method('closeTimeSheetStatus', function() {
$('#TimeSheetStatusModel').modal('hide');
});
SubEmployeeTimeSheetAdapter.method('changeTimeSheetStatus', function() {
var timeSheetStatus = $('#timesheet_status').val();
this.changeTimeSheetStatusWithId(this.timeSheetStatusChangeId,timeSheetStatus);
this.closeTimeSheetStatus();
this.timeSheetStatusChangeId = null;
});
SubEmployeeTimeSheetAdapter.method('getActionButtonsHtml', function(id,data) {
var html;
html = '<div style="width:80px;"><img class="tableActionButton" src="_BASE_images/edit.png" style="cursor:pointer;" rel="tooltip" title="Edit Timesheet Entries" onclick="modJs.edit(_id_);return false;"></img><img class="tableActionButton" src="_BASE_images/run.png" style="cursor:pointer;margin-left:15px;" rel="tooltip" title="Change TimeSheet Status" onclick="modJs.openTimeSheetStatus(_id_,\'_status_\');return false;"></img></div>';
html = html.replace(/_id_/g,id);
html = html.replace(/_BASE_/g,this.baseUrl);
html = html.replace(/_status_/g,data[3]);
return html;
});
SubEmployeeTimeSheetAdapter.method('getCustomTableParams', function() {
var that = this;
var dataTableParams = {
"aoColumnDefs": [
{
"fnRender": function(data, cell){
return that.preProcessRemoteTableData(data, cell, 2)
} ,
"aTargets": [2]
},
{
"fnRender": function(data, cell){
return that.preProcessRemoteTableData(data, cell, 3)
} ,
"aTargets": [3]
},
{
"fnRender": that.getActionButtons,
"aTargets": [that.getDataMapping().length]
}
]
};
return dataTableParams;
});
/**
* EmployeeTimeEntryAdapter
*/
function EmployeeTimeEntryAdapter(endPoint,tab,filter,orderBy) {
this.initAdapter(endPoint,tab,filter,orderBy);
}
EmployeeTimeEntryAdapter.inherits(AdapterBase);
this.timesheetId = null;
this.currentTimesheet = null;
this.allProjectsAllowed = 1;
this.employeeProjects = [];
EmployeeTimeEntryAdapter.method('getDataMapping', function() {
return [
"id",
"project",
"date_start",
"time_start",
"date_end",
"time_end",
"details"
];
});
EmployeeTimeEntryAdapter.method('getHeaders', function() {
return [
{ "sTitle": "ID" ,"bVisible":false},
{ "sTitle": "Project"},
{ "sTitle": "Start Date"},
{ "sTitle": "Start Time"},
{ "sTitle": "End Date"},
{ "sTitle": "End Time"},
{ "sTitle": "Details"}
];
});
EmployeeTimeEntryAdapter.method('getFormFields', function() {
return [
[ "id", {"label":"ID","type":"hidden"}],
[ "project", {"label":"Project","type":"select2","allow-null":true,"remote-source":["Project","id","name"]}],
//[ "project", {"label":"Project","type":"select","source":[]}],
[ "date_select", {"label":"Date","type":"select","source":[]}],
[ "date_start", {"label":"Start Time","type":"time","validation":""}],
/*[ "time_start", {"label":"Start Time","type":"time"}],*/
[ "date_end", {"label":"End Time","type":"time","validation":""}],
/*[ "time_end", {"label":"End Time","type":"time"}],*/
[ "details", {"label":"Details","type":"textarea","validation":""}]
];
});
/*
EmployeeTimeEntryAdapter.method('renderForm', function(object) {
var formHtml = this.templates['orig_formTemplate'];
formHtml = formHtml.replace(/modJs/g,"modJsList['tabEmployeeTimeEntry']");
var html = "";
var fields = this.getFormFields();
for(var i=0;i<fields.length;i++){
html += this.renderFormField(fields[i]);
}
formHtml = formHtml.replace(/_id_/g,this.getTableName()+"_submit");
formHtml = formHtml.replace(/_fields_/g,html);
$("#"+this.getTableName()+'Form').html(formHtml);
$("#"+this.getTableName()+'Form').show();
$("#"+this.getTableName()+'Form .datefield').datepicker({'viewMode':2});
$("#"+this.getTableName()+'Form .timefield').timepicker({ 'step': 15 });
if(object != undefined && object != null){
this.fillForm(object);
}
});
*/
EmployeeTimeEntryAdapter.method('getDates', function(startDate, stopDate) {
var dateArray = new Array();
var currentDate = startDate;
while (currentDate <= stopDate) {
dateArray.push( new Date (currentDate) );
currentDate = currentDate.add({ days: 1 });
}
return dateArray;
});
EmployeeTimeEntryAdapter.method('renderForm', function(object) {
var formHtml = this.getCustomTemplate('time_entry_form.html');
formHtml = formHtml.replace(/modJs/g,"modJsList['tabEmployeeTimeEntry']");
var html = "";
var fields = this.getFormFields();
for(var i=0;i<fields.length;i++){
var metaField = this.getMetaFieldForRendering(fields[i][0]);
if(metaField == "" || metaField == undefined){
html += this.renderFormField(fields[i]);
}else{
var metaVal = object[metaField];
if(metaVal != '' && metaVal != null && metaVal != undefined && metaVal.trim() != ''){
html += this.renderFormField(JSON.parse(metaVal));
}else{
html += this.renderFormField(fields[i]);
}
}
}
//append dates
var dateStart = new Date(this.currentTimesheet.date_start.replace(" ","T"));
var dateStop = new Date(this.currentTimesheet.date_end.replace(" ","T"));
var datesArray = this.getDates(dateStart, dateStop);
var optionList = "";
for(var i=0; i<datesArray.length; i++){
optionList += '<option value="'+datesArray[i].toString("yyyy-MM-dd")+'">'+datesArray[i].toString("d-MMM-yyyy")+'</option>';
}
formHtml = formHtml.replace(/_id_/g,this.getTableName()+"_submit");
formHtml = formHtml.replace(/_fields_/g,html);
$("#"+this.getTableName()+'Form').html(formHtml);
$("#"+this.getTableName()+'Form').show();
$("#"+this.getTableName()).hide();
$("#"+this.getTableName()+'Form .datefield').datepicker({'viewMode':2});
$("#"+this.getTableName()+'Form .datetimefield').datetimepicker({
language: 'en'
});
$("#"+this.getTableName()+'Form .timefield').datetimepicker({
language: 'en',
pickDate: false
});
$("#"+this.getTableName()+'Form .select2Field').select2();
$("#date_select").html(optionList);
var projectOptionList = "";
projectOptionList += '<option value="NULL">None</option>';
if(this.allProjectsAllowed == 0){
for(var i=0;i<this.employeeProjects.length;i++){
projectOptionList += '<option value="'+this.employeeProjects[i].project+'">'+this.employeeProjects[i].name+'</option>';
}
}else{
for(var i=0;i<this.employeeProjects.length;i++){
projectOptionList += '<option value="'+this.employeeProjects[i].id+'">'+this.employeeProjects[i].name+'</option>';
}
}
$("#project").html(projectOptionList);
if(object != undefined && object != null){
this.fillForm(object);
}
});
EmployeeTimeEntryAdapter.method('cancel', function() {
$('#TimeEntryModel').modal('hide');
});
EmployeeTimeEntryAdapter.method('setAllProjectsAllowed', function(allProjectsAllowed) {
this.allProjectsAllowed = allProjectsAllowed;
});
EmployeeTimeEntryAdapter.method('setEmployeeProjects', function(employeeProjects) {
this.employeeProjects = employeeProjects;
});
/*
EmployeeTimeEntryAdapter.method('save', function() {
var validator = new FormValidation(this.getTableName()+"_submit",true,{'ShowPopup':false,"LabelErrorClass":"error"});
if(validator.checkValues()){
var params = validator.getFormParameters();
params.date_end = params.date_start;
$(params).attr('timesheet',this.timesheetId);
if(params.time_start.indexOf("am") != -1 && params.time_start.indexOf("12:") != -1){
params.time_start = params.time_start.replace("12:","00:");
}
if(params.time_end.indexOf("am") != -1 && params.time_end.indexOf("12:") != -1){
params.time_end = params.time_end.replace("12:","00:");
}
params.date_start = Date.parse(params.date_start+" "+params.time_start.replace('am',' AM').replace('pm',' PM')).toString("yyyy-MM-dd HH:mm:ss");
params.date_end = Date.parse(params.date_end+" "+params.time_end.replace('am',' AM').replace('pm',' PM')).toString("yyyy-MM-dd HH:mm:ss");
var msg = this.doCustomValidation(params);
if(msg == null){
var id = $('#'+this.getTableName()+"_submit #id").val();
if(id != null && id != undefined && id != ""){
$(params).attr('id',id);
}
this.add(params,[]);
this.cancel();
}else{
$("#"+this.getTableName()+'Form .label').html(msg);
$("#"+this.getTableName()+'Form .label').show();
}
}
});
*/
EmployeeTimeEntryAdapter.method('save', function() {
var validator = new FormValidation(this.getTableName()+"_submit",true,{'ShowPopup':false,"LabelErrorClass":"error"});
if(validator.checkValues()){
var params = validator.getFormParameters();
$(params).attr('timesheet',this.timesheetId);
params.time_start = params.date_start;
params.time_end = params.date_end;
params.date_start = params.date_select+" "+params.date_start;
params.date_end = params.date_select+" "+params.date_end;
var msg = this.doCustomValidation(params);
if(msg == null){
var id = $('#'+this.getTableName()+"_submit #id").val();
if(id != null && id != undefined && id != ""){
$(params).attr('id',id);
}
this.add(params,[]);
this.cancel();
}else{
$("#"+this.getTableName()+'Form .label').html(msg);
$("#"+this.getTableName()+'Form .label').show();
}
}
});
EmployeeTimeEntryAdapter.method('doCustomValidation', function(params) {
var st = Date.parse(params.date_start.replace(" ","T"));
var et = Date.parse(params.date_end.replace(" ","T"));
if(st.compareTo(et) != -1){
return "Start time should be less than End time";
}
/*
var sd = Date.parse(this.currentTimesheet.date_start);
var ed = Date.parse(this.currentTimesheet.date_end).addDays(1);
if(sd.compareTo(et) != -1 || sd.compareTo(st) > 0 || st.compareTo(ed) != -1 || et.compareTo(ed) != -1){
return "Start time and end time shoud be with in " + sd.toString('MMM d, yyyy (dddd)') + " and " + ed.toString('MMM d, yyyy (dddd)');
}
*/
return null;
});
EmployeeTimeEntryAdapter.method('addSuccessCallBack', function(callBackData,serverData) {
this.get(callBackData);
modJs.getTimeEntries();
});
EmployeeTimeEntryAdapter.method('deleteRow', function(id) {
this.deleteObj(id,[]);
});
EmployeeTimeEntryAdapter.method('deleteSuccessCallBack', function(callBackData,serverData) {
modJs.getTimeEntries();
});

View File

@@ -0,0 +1,11 @@
{
"label":"Time Sheets",
"menu":"Time Management",
"order":"3",
"icon":"fa-check-circle-o",
"user_levels":["Admin","Manager","Employee"],
"permissions":
{
}
}

View File

@@ -0,0 +1,23 @@
<form class="form-horizontal" id="timesheet_entries_cont">
<span style="font-size:15px;font-weight:bold;color:#999;margin-left:10px;">
Timesheet From <span id="timesheet_start"></span> to <span id="timesheet_end"></span>
</span>
<table class="table table-condensed table-bordered table-striped" id="timesheet_entries" style="width:100%;font-size:12px;margin-left:5px;">
<thead>
<tr>
<th></th>
<th>Start</th>
<th>End</th>
<th>Duration</th>
<th>Project</th>
<th>Details</th>
</tr>
</thead>
<tbody id="timesheet_entries_table_body" class="timesheet_entries_table_body">
</tbody>
</table>
<div class="control-group">
<button id="add_time_sheet_entry" style="margin-left:5px;display:none;" onclick="try{modJs.openTimeEntryDialog()}catch(e){};return false;" class="btn"><span class="icon-plus-sign"></span> Add Time Entry</button>
<button id="submit_sheet" onclick="modJs.changeTimeSheetStatusWithId(modJs.currentId,'Submitted');return false;" class="btn" style="display:none;"><span class="icon-ok"></span> Submit Timesheet</button>
</div>
</form>