Compare commits

...

3 Commits

Author SHA1 Message Date
Thilina Hasantha
31bb455d6f Release note v16.0
------------------
### Features
 * Advanced Employee Management Module is now included in IceHrm Open Source Edition
 * LDAP Module which was only available in IceHrm Enterprise is now included in open source also
 * Initial implementation of icehrm REST Api for reading employee details
 * Improvements to data filtering
 * Multiple tabs for settings module
 * Overtime reports - now its possible to calculate overtime for employees.compatible with US overtime rules
 * Logout the user if tried accessing an unauthorized module
 * Setting for updating module names

### Fixes
 * Fix issue: classes should be loaded even the module is disabled
 * Deleting the only Admin user is not allowed
 * Fixes for handling non UTF-8
 * Fix for non-mandatory select boxes are shown as mandatory
2016-04-15 20:24:39 +05:30
Thilina Hasantha
301ea64832 Changes to open source dashboard 2016-04-15 19:52:49 +05:30
Thilina Hasantha
6fd9ba20c8 Release note v15.3
------------------
### Fixes
 * Fix issue: classes should be loaded even the module is disabled
 * Deleting the only Admin user is not allowed
 * Fixes for handling non UTF-8
 * Fix for non-mandatory select boxes are shown as mandatory
2016-04-15 15:53:14 +05:30
90 changed files with 8792 additions and 2870 deletions

View File

@@ -0,0 +1,82 @@
<?php
class LDAPManager {
private static $me = null;
private function __construct(){
}
public static function getInstance(){
if(empty(self::$me)){
self::$me = new LDAPManager();
}
return self::$me;
}
public function checkLDAPLogin($user, $password){
$ldap_host = SettingsManager::getInstance()->getSetting("LDAP: Server");
$ldap_port = SettingsManager::getInstance()->getSetting("LDAP: Port");
$ldap_dn = SettingsManager::getInstance()->getSetting("LDAP: Root DN");
$managerDN = SettingsManager::getInstance()->getSetting("LDAP: Manager DN");
$managerPassword = SettingsManager::getInstance()->getSetting("LDAP: Manager Password");
// connect to active directory
if(empty($ldap_port)){
$ldap_port = 389;
}
$ldap = ldap_connect($ldap_host, intval($ldap_port));
if(!$ldap){
return new IceResponse(IceResponse::ERROR,"Could not connect to LDAP Server");
}
LogManager::getInstance()->debug("LDAP Connect Result:".print_r($ldap,true));
if(SettingsManager::getInstance()->getSetting("LDAP: Version 3") == "1"){
ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
}
ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0);
// verify user and password
$bind = @ldap_bind($ldap, $managerDN, $managerPassword);
LogManager::getInstance()->debug("LDAP Manager Bind:".print_r($bind,true));
if($bind) {
$userFilterStr = SettingsManager::getInstance()->getSetting("LDAP: User Filter");
$filter = str_replace("{}", $user, $userFilterStr); //"(uid=" . $user . ")";
$result = ldap_search($ldap, $ldap_dn, $filter);
LogManager::getInstance()->debug("LDAP Search Result:".print_r($result,true));
if(!$result){
exit("Unable to search LDAP server");
}
$entries = ldap_get_entries($ldap, $result);
LogManager::getInstance()->debug("LDAP Search Entries:".print_r($entries,true));
if(empty($entries) || !isset($entries[0]) || !isset($entries[0]['dn'])){
return new IceResponse(IceResponse::ERROR,"Invalid user");
}
$bind = @ldap_bind($ldap,$entries[0]['dn'], $password);
ldap_unbind($ldap);
if($bind){
return new IceResponse(IceResponse::SUCCESS, $entries[0]);
}else{
return new IceResponse(IceResponse::ERROR,"Invalid user");
}
} else {
return new IceResponse(IceResponse::ERROR,"Invalid manager user");
}
}
}

View File

@@ -9,9 +9,9 @@ define('HOME_LINK_ADMIN', CLIENT_BASE_URL."?g=admin&n=dashboard&m=admin_Admin");
define('HOME_LINK_OTHERS', CLIENT_BASE_URL."?g=modules&n=dashboard&m=module_Personal_Information");
//Version
define('VERSION', '15.2.OS');
define('CACHE_VALUE', '15.2.OS');
define('VERSION_DATE', '12/03/2016');
define('VERSION', '16.0.OS');
define('CACHE_VALUE', '16.0.OS');
define('VERSION_DATE', '14/04/2016');
if(!defined('CONTACT_EMAIL')){define('CONTACT_EMAIL','icehrm@gamonoid.com');}
if(!defined('KEY_PREFIX')){define('KEY_PREFIX','IceHrm');}

View File

@@ -0,0 +1,187 @@
ALTER TABLE `Users` ADD COLUMN `login_hash` varchar(64) default null;
ALTER TABLE `Users` ADD INDEX login_hash_index (`login_hash`);
INSERT INTO `ImmigrationStatus` VALUES
(1,'Citizen'),
(2,'Permanent Resident'),
(3,'Work Permit Holder'),
(4,'Dependant Pass Holder');
INSERT INTO `Ethnicity` VALUES
(1,'White American'),
(2,'Black or African American'),
(3,'Native American'),
(4,'Alaska Native'),
(5,'Asian American'),
(6,'Native Hawaiian'),
(7,'Pacific Islander');
REPLACE INTO `Settings` (`name`, `value`, `description`, `meta`) VALUES
('Attendance: Overtime Calculation Class', 'BasicOvertimeCalculator', 'Set the method used to calculate overtime','["value", {"label":"Value","type":"select","source":[["BasicOvertimeCalculator","BasicOvertimeCalculator"],["CaliforniaOvertimeCalculator","CaliforniaOvertimeCalculator"]]}]');
REPLACE INTO `Settings` (`name`, `value`, `description`, `meta`) VALUES
('Attendance: Work Week Start Day', '0', 'Set the starting day of the work week','["value", {"label":"Value","type":"select","source":[["0","Sunday"],["1","Monday"],["2","Tuesday"],["3","Wednesday"],["4","Thursday"],["5","Friday"],["6","Saturday"]]}]');
REPLACE INTO `Settings` (`name`, `value`, `description`, `meta`) VALUES
('System: Reset Module Names', '1', 'Select this to reset module names in Database','["value", {"label":"Value","type":"select","source":[["1","Yes"],["0","No"]]}]');
REPLACE INTO `Settings` (`name`, `value`, `description`, `meta`) VALUES
('Attendance: Overtime Start Hour', '8', 'Overtime calculation will start after an employee work this number of hours per day, 0 to indicate no overtime', ''),
('Attendance: Double time Start Hour', '12', 'Double time calculation will start after an employee work this number of hours per day, 0 to indicate no double time', ''),
('Api: REST Api Enabled', '1', '','["value", {"label":"Value","type":"select","source":[["0","No"],["1","Yes"]]}]'),
('Api: REST Api Token', 'Click on edit icon', '','["value", {"label":"Value","type":"placeholder"}]');
REPLACE INTO `Settings` (`name`, `value`, `description`, `meta`) VALUES
('System: Allowed Countries', '0', 'Only these countries will be allowed in select boxes','["value", {"label":"Value","type":"select2multi","remote-source":["Country","id","name"]}]');
REPLACE INTO `Settings` (`name`, `value`, `description`, `meta`) VALUES
('System: Allowed Currencies', '0', 'Only these currencies will be allowed in select boxes','["value", {"label":"Value","type":"select2multi","remote-source":["CurrencyType","id","code+name"]}]');
INSERT INTO `Settings` (`name`, `value`, `description`, `meta`) VALUES
('System: Allowed Nationality', '', 'Only these nationalities will be allowed in select boxes','["value", {"label":"Value","type":"select2multi","remote-source":["Nationality","id","name"]}]');
REPLACE INTO `Reports` (`name`, `details`, `parameters`, `query`, `paramOrder`, `type`,`report_group`) VALUES
('Overtime Report', 'This report list all employee attendance entries by employee with overtime calculations', '[\r\n[ "employee", {"label":"Employee","type":"select2multi","allow-null":true,"null-label":"All Employees","remote-source":["Employee","id","first_name+last_name"]}],\r\n[ "date_start", {"label":"Start Date","type":"date"}],\r\n[ "date_end", {"label":"End Date","type":"date"}]\r\n]', 'OvertimeReport', '["employee","date_start","date_end"]', 'Class','Time Management');
REPLACE INTO `Reports` (`name`, `details`, `parameters`, `query`, `paramOrder`, `type`,`report_group`) VALUES
('Overtime Summary Report', 'This report list all employee attendance entries by employee with overtime calculation summary', '[\r\n[ "employee", {"label":"Employee","type":"select2multi","allow-null":true,"null-label":"All Employees","remote-source":["Employee","id","first_name+last_name"]}],\r\n[ "date_start", {"label":"Start Date","type":"date"}],\r\n[ "date_end", {"label":"End Date","type":"date"}]\r\n]', 'OvertimeSummaryReport', '["employee","date_start","date_end"]', 'Class','Time Management');
create table `EmployeeDataHistory` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`type` varchar(100) not null,
`employee` bigint(20) NOT NULL,
`field` varchar(100) not null,
`old_value` varchar(500) default null,
`new_value` varchar(500) default null,
`description` varchar(800) default null,
`user` bigint(20) NULL,
`updated` timestamp default '0000-00-00 00:00:00',
`created` timestamp default '0000-00-00 00:00:00',
CONSTRAINT `Fk_EmployeeDataHistory_Employee` FOREIGN KEY (`employee`) REFERENCES `Employees` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `Fk_EmployeeDataHistory_Users` FOREIGN KEY (`user`) REFERENCES `Users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
primary key (`id`)
) engine=innodb default charset=utf8;
REPLACE INTO `FieldNameMappings` (`type`, `name`, `textOrig`, `textMapped`, `display`) VALUES
('Employee', 'indirect_supervisors', 'Indirect Supervisors', 'Indirect Supervisors', 'Form');
Update Crons set time = (FLOOR( 1 + RAND( ) *58 )), type = 'Hourly' where name = 'Document Expire Alert';
CREATE TABLE `PayFrequency` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(200) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB default charset=utf8;
INSERT INTO `PayFrequency` VALUES
(1,'Bi Weekly'),
(2,'Weekly'),
(3,'Semi Monthly'),
(4,'Monthly'),
(5,'Yearly');
CREATE TABLE `PayrollColumnTemplates` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`name` varchar(50) DEFAULT NULL,
`columns` varchar(500) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB default charset=utf8;
create table `Payroll` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`name` varchar(200) NULL,
`pay_period` bigint(20) NOT NULL,
`department` bigint(20) NOT NULL,
`column_template` bigint(20) NOT NULL,
`columns` varchar(500) DEFAULT NULL,
`date_start` DATE NULL default '0000-00-00',
`date_end` DATE NULL default '0000-00-00',
`status` enum('Draft','Completed','Processing') default 'Draft',
primary key (`id`)
) engine=innodb default charset=utf8;
CREATE TABLE `PayrollData` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`payroll` bigint(20) NOT NULL,
`employee` bigint(20) NOT NULL,
`payroll_item` int(11) NOT NULL,
`amount` varchar(25) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `PayrollDataUniqueKey` (`payroll`,`employee`,`payroll_item`),
CONSTRAINT `Fk_PayrollData_Payroll` FOREIGN KEY (`payroll`) REFERENCES `Payroll` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB default charset=utf8;
CREATE TABLE `PayrollColumns` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) DEFAULT NULL,
`calculation_hook` varchar(200) DEFAULT NULL,
`salary_components` varchar(500) DEFAULT NULL,
`deductions` varchar(500) DEFAULT NULL,
`add_columns` varchar(500) DEFAULT NULL,
`sub_columns` varchar(500) DEFAULT NULL,
`colorder` int(11) DEFAULT NULL,
`editable` enum('Yes','No') default 'Yes',
`enabled` enum('Yes','No') default 'Yes',
`default_value` varchar(25) DEFAULT NULL,
`calculation_columns` varchar(500) DEFAULT NULL,
`calculation_function` varchar(100) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB default charset=utf8;
INSERT INTO `PayrollColumns` (`id`,`name`,`calculation_hook`,`salary_components`,`deductions`,`add_columns`,`sub_columns`,`editable`) VALUES
(1,'Total Hours','AttendanceUtil_getTimeWorkedHours','','','','','No'),
(2,'Regular Hours','AttendanceUtil_getRegularWorkedHours','','','','','No'),
(3,'Overtime Hours','AttendanceUtil_getOverTimeWorkedHours','','','','','No'),
(4,'Leave Hours','LeaveUtil_getLeaveHours','','','','','No');
create table `PayrollEmployees` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`employee` bigint(20) NOT NULL,
`pay_frequency` int(11) default null,
`currency` bigint(20) NULL,
`deduction_exemptions` varchar(250) default null,
`deduction_allowed` varchar(250) default null,
CONSTRAINT `Fk_PayrollEmployee_Employee` FOREIGN KEY (`employee`) REFERENCES `Employees` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
primary key (`id`),
unique key `PayrollEmployees_employee` (`employee`)
) engine=innodb default charset=utf8;
create table `DeductionGroup` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
`description` varchar(100) NOT NULL,
primary key (`id`)
) engine=innodb default charset=utf8;
drop table `DeductionRules`;
drop table `Deductions`;
create table `Deductions` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
`componentType` varchar(250) NULL,
`component` varchar(250) NULL,
`payrollColumn` int(11) DEFAULT NULL,
`rangeAmounts` text default null,
`deduction_group` bigint(20) NULL,
CONSTRAINT `Fk_Deductions_DeductionGroup` FOREIGN KEY (`deduction_group`) REFERENCES `DeductionGroup` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
primary key (`id`)
) engine=innodb default charset=utf8;
Update Reports set parameters = '[\r\n[ "department", {"label":"Department (Company)","type":"select2","remote-source":["CompanyStructure","id","title"],"allow-null":true}],\r\n[ "employee", {"label":"Employee","type":"select2multi","allow-null":true,"null-label":"All Employees","remote-source":["Employee","id","first_name+last_name"]}],\r\n[ "date_start", {"label":"Start Date","type":"date"}],\r\n[ "date_end", {"label":"End Date","type":"date"}],\r\n[ "status", {"label":"Leave Status","type":"select","source":[["NULL","All Statuses"],["Approved","Approved"],["Pending","Pending"],["Rejected","Rejected"],["Cancellation Requested","Cancellation Requested"],["Cancelled","Cancelled"]]}]\r\n]' where name = "Employee Leaves Report";
Delete from `Settings` where name = 'System: Default Country';

View File

@@ -0,0 +1,27 @@
Before using please install php5-ldap module
sudo apt-get install php5-ldap
For using php ldap on windows please refer
http://stackoverflow.com/questions/16864306/fatal-error-call-to-undefined-function-ldap-connect
The user "admin" will always login with local db username and password (even LDAP is enabled)
Use following config to test LDAP connection with following test LDAP server
http://www.forumsys.com/tutorials/integration-how-to/ldap/online-ldap-test-server/
Change configs as follows under System->Settings
LDAP: Enabled = Yes
LDAP: Server = ldap.forumsys.com
LDAP: Port = 389
LDAP: Root DN = dc=example,dc=com
LDAP: Manager DN = cn=read-only-admin,dc=example,dc=com
LDAP: Manager Password = password
LDAP: Version 3 = Yes
LDAP: User Filter = uid={}
Then create a user with username "riemann" under System->Users
Logout and try login with riemann/password

View File

@@ -0,0 +1,2 @@
<?php
//Nothing here

View File

@@ -3,17 +3,66 @@ define('CLIENT_PATH',dirname(__FILE__));
include ("config.base.php");
include ("include.common.php");
include("server.includes.inc.php");
error_log(print_r($_REQUEST,true));
if(empty($user)){
if(!isset($_REQUEST['f']) && isset($_COOKIE['icehrmLF']) && $_REQUEST['login'] != 'no' && !isset($_REQUEST['username'])){
$tempUser = new User();
$tempUser->Load("login_hash = ?",array($_COOKIE['icehrmLF']));
if(!empty($tempUser->id) &&
sha1($tempUser->email."_".$tempUser->password) == $_COOKIE['icehrmLF']){
$_REQUEST['username'] = $tempUser->username;
$_REQUEST['password'] = $tempUser->password;
$_REQUEST['hashedPwd'] = $tempUser->password;
}
}
if(!empty($_REQUEST['username']) && !empty($_REQUEST['password'])){
$suser = null;
$ssoUserLoaded = false;
if(empty($suser)){
$suser = new User();
$suser->Load("(username = ? or email = ?) and password = ?",array($_REQUEST['username'],$_REQUEST['username'],md5($_REQUEST['password'])));
if($_REQUEST['username'] != "admin") {
LogManager::getInstance()->debug("LDAP: Enabled :" . SettingsManager::getInstance()->getSetting("LDAP: Enabled"));
if (SettingsManager::getInstance()->getSetting("LDAP: Enabled") == "1") {
$ldapResp = LDAPManager::getInstance()->checkLDAPLogin($_REQUEST['username'], $_REQUEST['password']);
LogManager::getInstance()->debug("LDAP Response :" . json_encode($ldapResp));
if ($ldapResp->getStatus() == IceResponse::ERROR) {
header("Location:" . CLIENT_BASE_URL . "login.php?f=1");
exit();
} else {
$suser = new User();
$suser->Load("username = ?", array($_REQUEST['username']));
if (empty($suser)) {
header("Location:" . CLIENT_BASE_URL . "login.php?f=1");
exit();
}
$ssoUserLoaded = true;
}
}
}
if($suser->password == md5($_REQUEST['password']) || $ssoUserLoaded){
if(!isset($_REQUEST['hashedPwd'])){
$_REQUEST['hashedPwd'] = md5($_REQUEST['password']);
}
$suser = null;
$ssoUserLoaded = false;
include 'login.com.inc.php';
if(empty($suser)){
$suser = new User();
$suser->Load("(username = ? or email = ?) and password = ?",array($_REQUEST['username'],$_REQUEST['username'],$_REQUEST['hashedPwd']));
}
if($suser->password == $_REQUEST['hashedPwd'] || $ssoUserLoaded){
$user = $suser;
SessionUtils::saveSessionObject('user', $user);
$suser->last_login = date("Y-m-d H:i:s");
@@ -24,12 +73,29 @@ if(empty($user)){
BaseService::getInstance()->audit(IceConstants::AUDIT_AUTHENTICATION, "User Login");
}
if(!$ssoUserLoaded && isset($_REQUEST['remember'])){
//Add cookie
$suser->login_hash = sha1($suser->email."_".$suser->password);
$suser->Save();
setcookie('icehrmLF',$suser->login_hash);
}
if(!isset($_REQUEST['remember'])){
setcookie('icehrmLF');
}
$redirectUrl = SessionUtils::getSessionObject('loginRedirect');
if(!empty($redirectUrl)){
header("Location:".$redirectUrl);
}else{
if($user->user_level == "Admin"){
header("Location:".HOME_LINK_ADMIN);
if(SessionUtils::getSessionObject('account_locked') == "1"){
header("Location:".CLIENT_BASE_URL."?g=admin&n=billing&m=admin_System");
}else{
header("Location:".HOME_LINK_ADMIN);
}
}else{
if(empty($user->default_module)){
header("Location:".HOME_LINK_OTHERS);
@@ -39,12 +105,13 @@ if(empty($user)){
if($defaultModule->mod_group == "user"){
$defaultModule->mod_group = "modules";
}
$homeLink = CLIENT_BASE_URL."?g=".$defaultModule->mod_group."&n=".$defaultModule->name.
$homeLink = CLIENT_BASE_URL."?g=".$defaultModule->mod_group."&&n=".$defaultModule->name.
"&m=".$defaultModule->mod_group."_".str_replace(" ","_",$defaultModule->menu);
header("Location:".$homeLink);
}
}
}
}else{
header("Location:".CLIENT_BASE_URL."login.php?f=1");
}
@@ -70,27 +137,25 @@ if(empty($user)){
}
$tuser = SessionUtils::getSessionObject('user');
//check user
$logoFileUrl = UIManager::getInstance()->getCompanyLogoUrl();
?><!DOCTYPE html>
<html lang="en">
<head>
<head>
<meta charset="utf-8">
<title><?=APP_NAME?> Login v<?=VERSION?> &copy; http://icehrm.com</title>
<title><?=APP_NAME?> Login</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="A Powerful But Simple Way to Manage Your Company and People. http://icehrm.com">
<meta name="author" content="http://gamonoid.com">
<meta name="description" content="">
<meta name="author" content="">
<!-- Le styles -->
<link href="<?=BASE_URL?>bootstrap/css/bootstrap.css" rel="stylesheet">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.js"></script>
<script type="text/javascript" src="<?=BASE_URL?>js/jquery-1.8.1.js"></script>
<script src="<?=BASE_URL?>bootstrap/js/bootstrap.js"></script>
<script src="<?=BASE_URL?>js/jquery.placeholder.js"></script>
<script src="<?=BASE_URL?>js/jquery.dataTables.js"></script>
<script src="<?=BASE_URL?>js/bootstrap-datepicker.js"></script>
<script src="<?=BASE_URL?>js/jquery.placeholder.js"></script>
<script src="<?=BASE_URL?>js/jquery.dataTables.js"></script>
<script src="<?=BASE_URL?>js/bootstrap-datepicker.js"></script>
<link href="<?=BASE_URL?>bootstrap/css/bootstrap-responsive.css" rel="stylesheet">
<link href="<?=BASE_URL?>css/DT_bootstrap.css?v=0.4" rel="stylesheet">
<link href="<?=BASE_URL?>css/datepicker.css" rel="stylesheet">
@@ -98,7 +163,7 @@ $logoFileUrl = UIManager::getInstance()->getCompanyLogoUrl();
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<script src="<?=BASE_URL?>js/html5.js"></script>
<![endif]-->
<style type="text/css">
@@ -113,29 +178,29 @@ $logoFileUrl = UIManager::getInstance()->getCompanyLogoUrl();
width: 300px;
}
/* The white background content wrapper */
.container > .content {
min-height: 0px !important;
background-color: #fff;
padding: 20px;
margin: 0 -20px;
-webkit-border-radius:0px;
-moz-border-radius:0px;
border-radius: 0px;
-webkit-box-shadow: 0 1px 2px rgba(0,0,0,.15);
-moz-box-shadow: 0 1px 2px rgba(0,0,0,.15);
box-shadow: 0 1px 2px rgba(0,0,0,.15);
}
/* The white background content wrapper */
.container > .content {
min-height: 0px !important;
background-color: #fff;
padding: 20px;
margin: 0 -20px;
-webkit-border-radius:0px;
-moz-border-radius:0px;
border-radius: 0px;
-webkit-box-shadow: 0 1px 2px rgba(0,0,0,.15);
-moz-box-shadow: 0 1px 2px rgba(0,0,0,.15);
box-shadow: 0 1px 2px rgba(0,0,0,.15);
}
.login-form {
margin-left: 65px;
}
.login-form {
margin-left: 65px;
}
legend {
margin-right: -50px;
font-weight: bold;
color: #404040;
}
legend {
margin-right: -50px;
font-weight: bold;
color: #404040;
}
.add-on{
-webkit-border-radius:0px;
@@ -143,212 +208,203 @@ $logoFileUrl = UIManager::getInstance()->getCompanyLogoUrl();
border-radius: 0px;
}
input{
-webkit-border-radius:0px;
-moz-border-radius:0px;
border-radius: 0px;
}
input{
-webkit-border-radius:0px;
-moz-border-radius:0px;
border-radius: 0px;
}
</style>
</head>
<body>
<div itemscope itemtype="http://schema.org/WebApplication" style="display: none;">
<span itemprop="name">IceHrm Pro</span> -
<body>
REQUIRES <span itemprop="operatingSystem">Windows, OSX, Linux</span>
<link itemprop="applicationCategory" href="http://icehrm.com"/>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
RATING:
<div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
<span itemprop="ratingValue">4.5</span> (
<span itemprop="ratingCount">12</span> ratings )
</div>
ga('create', '<?=BaseService::getInstance()->getGAKey()?>', 'gamonoid.com');
ga('send', 'pageview');
<div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
Price: $<span itemprop="price">199.99</span>
<meta itemprop="priceCurrency" content="USD" />
</div>
</div>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
</script>
ga('create', '<?=BaseService::getInstance()->getGAKey()?>', 'gamonoid.com');
ga('send', 'pageview');
<script type="text/javascript">
var key = "";
<?php if(isset($_REQUEST['key'])){?>
key = '<?=$_REQUEST['key']?>';
key = key.replace(/ /g,"+");
<?php }?>
</script>
$(document).ready(function() {
$(window).keydown(function(event){
if(event.keyCode == 13) {
event.preventDefault();
return false;
}
});
<script type="text/javascript">
var key = "";
<?php if(isset($_REQUEST['key'])){?>
key = '<?=$_REQUEST['key']?>';
key = key.replace(/ /g,"+");
<?php }?>
$("#password").keydown(function(event){
if(event.keyCode == 13) {
submitLogin();
return false;
}
});
});
$(document).ready(function() {
$(window).keydown(function(event){
if(event.keyCode == 13) {
event.preventDefault();
return false;
}
});
function showForgotPassword(){
$("#loginForm").hide();
$("#requestPasswordChangeForm").show();
}
$("#password").keydown(function(event){
if(event.keyCode == 13) {
submitLogin();
return false;
}
});
});
function requestPasswordChange(){
$("#requestPasswordChangeFormAlert").hide();
var id = $("#usernameChange").val();
$.post("service.php", {'a':'rpc','id':id}, function(data) {
if(data.status == "SUCCESS"){
$("#requestPasswordChangeFormAlert").show();
$("#requestPasswordChangeFormAlert").html(data.message);
}else{
$("#requestPasswordChangeFormAlert").show();
$("#requestPasswordChangeFormAlert").html(data.message);
}
},"json");
}
function showForgotPassword(){
$("#loginForm").hide();
$("#requestPasswordChangeForm").show();
}
function changePassword(){
$("#newPasswordFormAlert").hide();
var password = $("#password").val();
function requestPasswordChange(){
$("#requestPasswordChangeFormAlert").hide();
var id = $("#usernameChange").val();
$.post("service.php", {'a':'rpc','id':id}, function(data) {
if(data.status == "SUCCESS"){
$("#requestPasswordChangeFormAlert").show();
$("#requestPasswordChangeFormAlert").html(data.message);
}else{
$("#requestPasswordChangeFormAlert").show();
$("#requestPasswordChangeFormAlert").html(data.message);
}
},"json");
}
function changePassword(){
$("#newPasswordFormAlert").hide();
var password = $("#password").val();
var passwordValidation = function (str) {
var val = /^[a-zA-Z0-9]\w{6,}$/;
return str != null && val.test(str);
};
var passwordValidation = function (str) {
var val = /^[a-zA-Z0-9]\w{6,}$/;
return str != null && val.test(str);
};
if(!passwordValidation(password)){
$("#newPasswordFormAlert").show();
$("#newPasswordFormAlert").html("Password may contain only letters, numbers and should be longer than 6 characters");
return;
}
if(!passwordValidation(password)){
$("#newPasswordFormAlert").show();
$("#newPasswordFormAlert").html("Password may contain only letters, numbers and should be longer than 6 characters");
return;
}
$.post("service.php", {'a':'rsp','key':key,'pwd':password,"now":"1"}, function(data) {
if(data.status == "SUCCESS"){
top.location.href = "login.php?c=1";
}else{
$("#newPasswordFormAlert").show();
$("#newPasswordFormAlert").html(data.message);
}
},"json");
}
$.post("service.php", {'a':'rsp','key':key,'pwd':password,"now":"1"}, function(data) {
if(data.status == "SUCCESS"){
top.location.href = "login.php?c=1";
}else{
$("#newPasswordFormAlert").show();
$("#newPasswordFormAlert").html(data.message);
}
},"json");
}
function submitLogin(){
$("#loginForm").submit();
}
function submitLogin(){
try{
localStorage.clear();
}catch(e){}
$("#loginForm").submit();
}
</script>
<div class="container">
<?php if(defined('DEMO_MODE')){?>
<div class="content" style="top: 30px;
</script>
<div class="container">
<?php if(defined('DEMO_MODE')){?>
<div class="content" style="top: 30px;
position: absolute;
left: 50px;
width: 380px;
height: 100px;">
<ul class="list-group" style="font-size:12px;">
<li style="padding-bottom:3px;" class="list-group-item">Admin: (Username = admin/ Password = admin)</li>
<li style="padding-bottom:3px;" class="list-group-item">Manager: (Username = manager/ Password = demouserpwd)</li>
<li style="padding-bottom:3px;" class="list-group-item">User: (Username = user1/ Password = demouserpwd)</li>
<li style="padding-bottom:3px;" class="list-group-item">User: (Username = user2/ Password = demouserpwd)</li>
</ul>
</div>
<?php }?>
<div class="content" style="margin-top:100px;">
<div class="row">
<div class="login-form">
<h2><img src="<?=$logoFileUrl?>"/></h2>
<?php if(!isset($_REQUEST['cp'])){?>
<form id="loginForm" action="login.php" method="POST">
<fieldset>
<div class="clearfix">
<div class="input-prepend">
<span class="add-on"><i class="icon-user"></i></span>
<input class="span2" type="text" id="username" name="username" placeholder="Username">
</div>
</div>
<div class="clearfix">
<div class="input-prepend">
<span class="add-on"><i class="icon-lock"></i></span>
<input class="span2" type="password" id="password" name="password" placeholder="Password">
</div>
</div>
<?php if(isset($_REQUEST['f'])){?>
<div class="clearfix alert alert-error" style="font-size:11px;width:147px;margin-bottom: 5px;">
Login failed
<?php if(isset($_REQUEST['fm'])){
echo $_REQUEST['fm'];
}?>
</div>
<?php } ?>
<?php if(isset($_REQUEST['c'])){?>
<div class="clearfix alert alert-info" style="font-size:11px;width:147px;margin-bottom: 5px;">
Password changed successfully
</div>
<?php } ?>
<button class="btn" style="margin-top: 5px;" type="button" onclick="submitLogin();return false;">Sign in&nbsp;&nbsp;<span class="icon-arrow-right"></span></button>
</fieldset>
<div class="clearfix">
<a href="" onclick="showForgotPassword();return false;" style="float:left;margin-top: 10px;">Forgot password</a>
<a href="<?=TWITTER_URL?>" target="_blank" style="float:right;"><img src="<?=BASE_URL?>images/32x32-Circle-53-TW.png"/></a>
<a href="<?=FB_URL?>" target="_blank" style="float:right;margin-right: 7px;"><img src="<?=BASE_URL?>images/32x32-Circle-54-FB.png"/></a>
</div>
<ul class="list-group" style="font-size:12px;">
<li style="padding-bottom:3px;" class="list-group-item">Admin: (Username = admin/ Password = admin)</li>
<li style="padding-bottom:3px;" class="list-group-item">Manager: (Username = manager/ Password = demouserpwd)</li>
<li style="padding-bottom:3px;" class="list-group-item">User: (Username = user1/ Password = demouserpwd)</li>
<li style="padding-bottom:3px;" class="list-group-item">User: (Username = user2/ Password = demouserpwd)</li>
</ul>
</div>
<?php }?>
<div class="content" style="margin-top:100px;">
<div class="row">
<div class="login-form">
<h2><img src="<?=$logoFileUrl?>"/></h2>
<?php if(!isset($_REQUEST['cp'])){?>
<form id="loginForm" action="login.php" method="POST">
<fieldset>
<div class="clearfix">
<div class="input-prepend">
<span class="add-on"><i class="icon-user"></i></span>
<input class="span2" type="text" id="username" name="username" placeholder="Username">
</div>
</div>
<div class="clearfix">
<div class="input-prepend">
<span class="add-on"><i class="icon-lock"></i></span>
<input class="span2" type="password" id="password" name="password" placeholder="Password">
</div>
</div>
<div class="clearfix">
<div class="checkbox">
<label><input id="remember" name="remember" type="checkbox" value="remember" checked>Remember me</label>
</div>
</div>
<?php if(isset($_REQUEST['f'])){?>
<div class="clearfix alert alert-error" style="font-size:11px;width:147px;margin-bottom: 5px;">
Login failed
<?php if(isset($_REQUEST['fm'])){
echo $_REQUEST['fm'];
}?>
</div>
<?php } ?>
<?php if(isset($_REQUEST['c'])){?>
<div class="clearfix alert alert-info" style="font-size:11px;width:147px;margin-bottom: 5px;">
Password changed successfully
</div>
<?php } ?>
<button class="btn" style="margin-top: 5px;" type="button" onclick="submitLogin();return false;">Sign in&nbsp;&nbsp;<span class="icon-arrow-right"></span></button>
</fieldset>
<div class="clearfix">
<span style="font-size:9px;">&copy; <a href="http://icehrm.com" target="_blank">IceHrm - v<?=VERSION?></a> Developed by <a href="http://gamonoid.com" target="_blank">Gamonoid (Pvt) Ltd.</a></span>
<a href="" onclick="showForgotPassword();return false;" style="float:left;margin-top: 10px;">Forgot password</a>
<!--
<a href="<?=TWITTER_URL?>" target="_blank" style="float:right;"><img src="<?=BASE_URL?>images/32x32-Circle-53-TW.png"/></a>
<a href="<?=FB_URL?>" target="_blank" style="float:right;margin-right: 7px;"><img src="<?=BASE_URL?>images/32x32-Circle-54-FB.png"/></a>
-->
</div>
</form>
<form id="requestPasswordChangeForm" style="display:none;" action="">
<fieldset>
<div class="clearfix">
<div class="input-prepend">
<span class="add-on"><i class="icon-user"></i></span>
<input class="span2" type="text" id="usernameChange" name="usernameChange" placeholder="Username or Email">
</div>
</div>
<div id="requestPasswordChangeFormAlert" class="clearfix alert alert-info" style="font-size:11px;width:147px;margin-bottom: 5px;display:none;">
</form>
<form id="requestPasswordChangeForm" style="display:none;" action="">
<fieldset>
<div class="clearfix">
<div class="input-prepend">
<span class="add-on"><i class="icon-user"></i></span>
<input class="span2" type="text" id="usernameChange" name="usernameChange" placeholder="Username or Email">
</div>
</div>
<div id="requestPasswordChangeFormAlert" class="clearfix alert alert-info" style="font-size:11px;width:147px;margin-bottom: 5px;display:none;">
</div>
<button class="btn" style="margin-top: 5px;" type="button" onclick="requestPasswordChange();return false;">Request Password Change&nbsp;&nbsp;<span class="icon-arrow-right"></span></button>
</fieldset>
</form>
<?php }else{?>
<form id="newPasswordForm" action="">
<fieldset>
<div class="clearfix">
<div class="input-prepend">
<span class="add-on"><i class="icon-lock"></i></span>
<input class="span2" type="password" id="password" name="password" placeholder="New Password">
</div>
</div>
<div id="newPasswordFormAlert" class="clearfix alert alert-error" style="font-size:11px;width:147px;margin-bottom: 5px;display:none;">
</div>
<button class="btn" style="margin-top: 5px;" type="button" onclick="requestPasswordChange();return false;">Request Password Change&nbsp;&nbsp;<span class="icon-arrow-right"></span></button>
</fieldset>
</form>
<?php }else{?>
<form id="newPasswordForm" action="">
<fieldset>
<div class="clearfix">
<div class="input-prepend">
<span class="add-on"><i class="icon-lock"></i></span>
<input class="span2" type="password" id="password" name="password" placeholder="New Password">
</div>
</div>
<div id="newPasswordFormAlert" class="clearfix alert alert-error" style="font-size:11px;width:147px;margin-bottom: 5px;display:none;">
</div>
<button class="btn" style="margin-top: 5px;" type="button" onclick="changePassword();return false;">Change Password&nbsp;&nbsp;<span class="icon-arrow-right"></span></button>
</fieldset>
</form>
<?php }?>
</div>
</div>
</div>
</div> <!-- /container -->
</div>
<button class="btn" style="margin-top: 5px;" type="button" onclick="changePassword();return false;">Change Password&nbsp;&nbsp;<span class="icon-arrow-right"></span></button>
</fieldset>
</form>
<?php }?>
</div>
</div>
</div>
</div> <!-- /container -->
</body>
</html>

View File

@@ -5,9 +5,9 @@ class ICEHRM_Record extends ADOdb_Active_Record{
return array("get","element","save","delete");
}
public function getOtherAccess(){
return array("get","element","save","delete");
}
public function getOtherAccess(){
return array("get","element","save","delete");
}
public function getManagerAccess(){
return array("get","element");
@@ -57,20 +57,24 @@ class ICEHRM_Record extends ADOdb_Active_Record{
}
public function postProcessGetData($obj){
return $obj;
}
public function postProcessGetData($obj){
return $obj;
}
public function getDefaultAccessLevel(){
return array("get","element","save","delete");
}
public function postProcessGetElement($obj){
return $obj;
}
public function getVirtualFields(){
return array(
);
}
public function getDefaultAccessLevel(){
return array("get","element","save","delete");
}
public function allowIndirectMapping(){
return false;
}
public function getVirtualFields(){
return array(
);
}
public function allowIndirectMapping(){
return false;
}
}

View File

@@ -1,54 +1,54 @@
<!-- Delete Modal -->
<div class="modal fade" id="deleteModel" tabindex="-1" role="dialog" aria-labelledby="deleteModelLabel" 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 id="deleteModelLabel" style="font-size: 17px;"></h3>
</div>
<div class="modal-body">
<p id="deleteModelBody"></p>
</div>
<div class="modal-footer">
<button class="btn" onclick="modJs.cancelDelete();">Cancel</button>
<button class="btn btn-primary" onclick="modJs.confirmDelete();">Delete</button>
</div>
</div>
</div>
<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 id="deleteModelLabel" style="font-size: 17px;"></h3>
</div>
<div class="modal-body">
<p id="deleteModelBody"></p>
</div>
<div class="modal-footer">
<button class="btn" onclick="modJs.cancelDelete();">Cancel</button>
<button class="btn btn-primary" onclick="modJs.confirmDelete();">Delete</button>
</div>
</div>
</div>
</div>
<!-- Delete Modal -->
<!-- Message Modal -->
<div class="modal fade" id="messageModel" 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 id="messageModelLabel" style="font-size: 17px;"></h3>
</div>
<div class="modal-body">
<p id="messageModelBody"></p>
</div>
<div class="modal-footer">
<button class="btn" onclick="modJs.closeMessage();">Ok</button>
</div>
</div>
</div>
<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 id="messageModelLabel" style="font-size: 17px;"></h3>
</div>
<div class="modal-body">
<p id="messageModelBody"></p>
</div>
<div class="modal-footer">
<button class="btn" onclick="modJs.closeMessage();">Ok</button>
</div>
</div>
</div>
</div>
<!-- Message Modal -->
<!-- Plain Message Modal -->
<div class="modal fade" id="plainMessageModel" tabindex="-1" role="dialog" aria-labelledby="plainMessageModelLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header" style="border-bottom:none;/*background-color: #3c8dbc;*/">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="margin-top:-10px;"><li class="fa fa-times"/></button>
</div>
<div class="modal-body">
<p id="plainMessageModelBody"></p>
</div>
</div>
</div>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header" style="border-bottom:none;/*background-color: #3c8dbc;*/">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="margin-top:-10px;"><li class="fa fa-times"/></button>
</div>
<div class="modal-body">
<p id="plainMessageModelBody"></p>
</div>
</div>
</div>
</div>
<!-- Plain Message Modal -->
@@ -89,98 +89,98 @@
<!-- Upload Modal -->
<div class="modal fade" id="uploadModel" tabindex="-1" role="dialog" 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 id="uploadModelLabel" style="font-size: 17px;"></h3>
</div>
<div class="modal-body">
<p id="uploadModelBody"></p>
</div>
<div class="modal-footer">
<button class="btn" onclick="$('#uploadModel').modal('hide');">Cancel</button>
</div>
</div>
</div>
<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 id="uploadModelLabel" style="font-size: 17px;"></h3>
</div>
<div class="modal-body">
<p id="uploadModelBody"></p>
</div>
<div class="modal-footer">
<button class="btn" onclick="$('#uploadModel').modal('hide');">Cancel</button>
</div>
</div>
</div>
</div>
<!-- Upload Modal -->
<!-- Message Modal -->
<div class="modal fade" id="verifyModel" tabindex="-1" role="dialog" aria-labelledby="verifyModelLabel" 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 id="verifyModelLabel" style="font-size: 17px;"></h3>
</div>
<div class="modal-body">
<p id="verifyModelBody">
<b>Step 1:</b><br/>
Please get your Instance Key from here:<br/>
<a target="_blank" href="http://icehrm.com/generateInstanceKey.php?id=<?=$baseService->getInstanceId()?>">
http://icehrm.com/generateInstanceKey.php?id=<?=$baseService->getInstanceId()?>
</a>
<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 id="verifyModelLabel" style="font-size: 17px;"></h3>
</div>
<div class="modal-body">
<p id="verifyModelBody">
<b>Step 1:</b><br/>
Please get your Instance Key from here:<br/>
<a target="_blank" href="http://icehrm.com/generateInstanceKey.php?id=<?=$baseService->getInstanceId()?>">
http://icehrm.com/generateInstanceKey.php?id=<?=$baseService->getInstanceId()?>
</a>
<br/><b>Step 2:</b><br/>
Enter the key you generated in step 1 here and click "Verify"<br/>
<form role="form">
<div class="row">
<label class="col-sm-12 control-label" for="verificationKey">Verification Key</label>
<div class="controls col-sm-12">
<input class="form-control" type="text" id="verificationKey" name="verificationKey" value=""/>
</div>
</div>
<br/><br/>
<div class="control-group row">
<div class="controls col-sm-12">
<button onclick="try{verifyInstance($('#verificationKey').val());}catch(e){};return false;" class="saveBtn btn btn-primary pull-right"><i class="fa fa-save"></i> Verify</button>
<button onclick="$('#verifyModel').modal('hide');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>
</p>
</div>
</div>
<br/><b>Step 2:</b><br/>
Enter the key you generated in step 1 here and click "Verify"<br/>
<form role="form">
<div class="row">
<label class="col-sm-12 control-label" for="verificationKey">Verification Key</label>
<div class="controls col-sm-12">
<input class="form-control" type="text" id="verificationKey" name="verificationKey" value=""/>
</div>
</div>
<br/><br/>
<div class="control-group row">
<div class="controls col-sm-12">
<button onclick="try{verifyInstance($('#verificationKey').val());}catch(e){};return false;" class="saveBtn btn btn-primary pull-right"><i class="fa fa-save"></i> Verify</button>
<button onclick="$('#verifyModel').modal('hide');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>
</p>
</div>
</div>
</div>
</div>
<!-- Message Modal -->
<?php if($user->user_level == 'Admin'){?>
<!-- Modal -->
<div class="modal fade" id="profileSwitchModal" tabindex="-1" role="dialog" 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 id="myModalLabel">Switch Employee</h3>
</div>
<div class="modal-body">
<p>Select the employee to Edit</p>
<div style="border: solid 1px #EEE;">
<select id="switch_emp" style="width:100%;">
<!--
<option value="-1">No Employee</option>
-->
<?php
$employees = $baseService->get('Employee');
foreach($employees as $empTemp){
?>
<option value="<?=$empTemp->id?>"><?=$empTemp->first_name." ".$empTemp->last_name?></option>
<?php }?>
</select>
</div>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
<button class="btn btn-primary" onclick="modJs.setAdminProfile($('#switch_emp').val());return false;">Switch</button>
</div>
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="profileSwitchModal" tabindex="-1" role="dialog" 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 id="myModalLabel">Switch Employee</h3>
</div>
<div class="modal-body">
<p>Select the employee to Edit</p>
<div style="border: solid 1px #EEE;">
<select id="switch_emp" style="width:100%;">
<!--
<option value="-1">No Employee</option>
-->
<?php
$employees = $baseService->get('Employee');
foreach($employees as $empTemp){
?>
<option value="<?=$empTemp->id?>"><?=$empTemp->first_name." ".$empTemp->last_name?></option>
<?php }?>
</select>
</div>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
<button class="btn btn-primary" onclick="modJs.setAdminProfile($('#switch_emp').val());return false;">Switch</button>
</div>
</div>
<!-- Modal -->
<?php }?>
</div>
</div>
<!-- Modal -->
<?php }?>

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,19 @@
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
DELIMITER $$
CREATE FUNCTION generate_fname () RETURNS varchar(255)
BEGIN
RETURN ELT(FLOOR(1 + (RAND() * (100-1))), "James","Mary","John","Patricia","Robert","Linda","Michael","Barbara","William","Elizabeth","David","Jennifer","Richard","Maria","Charles","Susan","Joseph","Margaret","Thomas","Dorothy","Christopher","Lisa","Daniel","Nancy","Paul","Karen","Mark","Betty","Donald","Helen","George","Sandra","Kenneth","Donna","Steven","Carol","Edward","Ruth","Brian","Sharon","Ronald","Michelle","Anthony","Laura","Kevin","Sarah","Jason","Kimberly","Matthew","Deborah","Gary","Jessica","Timothy","Shirley","Jose","Cynthia","Larry","Angela","Jeffrey","Melissa","Frank","Brenda","Scott","Amy","Eric","Anna","Stephen","Rebecca","Andrew","Virginia","Raymond","Kathleen","Gregory","Pamela","Joshua","Martha","Jerry","Debra","Dennis","Amanda","Walter","Stephanie","Patrick","Carolyn","Peter","Christine","Harold","Marie","Douglas","Janet","Henry","Catherine","Carl","Frances","Arthur","Ann","Ryan","Joyce","Roger","Diane");
END$$
DELIMITER ;
DELIMITER $$
CREATE FUNCTION generate_lname () RETURNS varchar(255)
BEGIN
RETURN ELT(FLOOR(1 + (RAND() * (100-1))), "Smith","Johnson","Williams","Jones","Brown","Davis","Miller","Wilson","Moore","Taylor","Anderson","Thomas","Jackson","White","Harris","Martin","Thompson","Garcia","Martinez","Robinson","Clark","Rodriguez","Lewis","Lee","Walker","Hall","Allen","Young","Hernandez","King","Wright","Lopez","Hill","Scott","Green","Adams","Baker","Gonzalez","Nelson","Carter","Mitchell","Perez","Roberts","Turner","Phillips","Campbell","Parker","Evans","Edwards","Collins","Stewart","Sanchez","Morris","Rogers","Reed","Cook","Morgan","Bell","Murphy","Bailey","Rivera","Cooper","Richardson","Cox","Howard","Ward","Torres","Peterson","Gray","Ramirez","James","Watson","Brooks","Kelly","Sanders","Price","Bennett","Wood","Barnes","Ross","Henderson","Coleman","Jenkins","Perry","Powell","Long","Patterson","Hughes","Flores","Washington","Butler","Simmons","Foster","Gonzales","Bryant","Alexander","Russell","Griffin","Diaz","Hayes");
END$$
DELIMITER ;
INSERT INTO `CompanyStructures` (`id`, `title`, `description`, `address`, `type`, `country`, `parent`) VALUES
(4, 'Development Center', 'Development Center', 'PO Box 001002\nSample Road, Sample Town', 'Regional Office', 'SG', 1),
@@ -10,11 +24,23 @@ INSERT INTO `CompanyStructures` (`id`, `title`, `description`, `address`, `type`
(9, 'Administration & HR', 'Administration and Human Resource', '', 'Department', 'SG', 4);
INSERT INTO `Employees` (`id`, `employee_id`, `first_name`, `middle_name`, `last_name`, `nationality`, `birthday`, `gender`, `marital_status`, `ssn_num`, `nic_num`, `other_id`, `driving_license`, `driving_license_exp_date`, `employment_status`, `job_title`, `pay_grade`, `work_station_id`, `address1`, `address2`, `city`, `country`, `province`, `postal_code`, `home_phone`, `mobile_phone`, `work_phone`, `work_email`, `private_email`, `joined_date`, `confirmation_date`, `supervisor`, `department`, `custom1`, `custom2`, `custom3`, `custom4`, `custom5`, `custom6`, `custom7`, `custom8`, `custom9`, `custom10`) VALUES
(2, 'EMP002', 'Lala', 'Nadila ', 'Lamees', 175, '1984-03-12 18:30:00', 'Female', 'Single', '', '4594567WE3', '4595567WE3', '349-066-YUO', '2012-03-01', 1, 8, 2, 'W001', 'Green War Rd, 00123', '', 'Istanbul', 'TR', NULL, '909066', '+960112345', '+960112345', '+960112345', 'icehrm+manager@web-stalk.com', 'icehrm+manager@web-stalk.com', '2011-03-07 18:30:00', '2012-02-14 18:30:00', 1, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(3, 'EMP003', 'Sofia', '', 'O''Sullivan', 4, '1975-08-28 18:30:00', 'Female', 'Married', '', '768-20-4394', '768-20-4394', '', NULL, 3, 10, 2, '', '2792 Trails End Road', 'Fort Lauderdale', 'Fort Lauderdale', 'US', 12, '33308', '954-388-3340', '954-388-3340', '954-388-3340', 'icehrm+user1@web-stalk.com', 'icehrm+user1@web-stalk.com', '2010-02-08 18:30:00', '0000-00-00 00:00:00', 2, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(4, 'EMP004', 'Taylor', '', 'Holmes', 10, '1979-07-15 18:30:00', 'Male', 'Single', '158-06-2292', '158-06-2292', '', '', NULL, 1, 5, 2, '', '1164', 'Walnut Avenue', 'Rochelle Park', 'US', 35, '7662', '201-474-8048', '201-474-8048', '201-474-8048', 'icehrm+user2@web-stalk.com', 'icehrm+user2@web-stalk.com', '2006-07-12 18:30:00', '0000-00-00 00:00:00', 2, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
INSERT INTO `Employees` (`id`, `employee_id`, `first_name`, `middle_name`, `last_name`, `nationality`, `birthday`, `gender`, `marital_status`, `ssn_num`, `nic_num`, `other_id`, `driving_license`, `driving_license_exp_date`, `employment_status`, `job_title`, `pay_grade`, `work_station_id`, `address1`, `address2`, `city`, `country`, `province`, `postal_code`, `home_phone`, `mobile_phone`, `work_phone`, `work_email`, `private_email`, `joined_date`, `confirmation_date`, `supervisor`, `department`, `custom1`, `custom2`, `custom3`, `custom4`, `custom5`, `custom6`, `custom7`, `custom8`, `custom9`, `custom10`,`indirect_supervisors`) VALUES
(2, 'EMP002', 'Lala', 'Nadila ', 'Lamees', 175, '1984-03-12 18:30:00', 'Female', 'Single', '', '4594567WE3', '4595567WE3', '349-066-YUO', '2012-03-01', 1, 8, 2, 'W001', 'Green War Rd, 00123', '', 'Istanbul', 'TR', NULL, '909066', '+960112345', '+960112345', '+960112345', 'icehrm+manager@web-stalk.com', 'icehrm+manager@web-stalk.com', '2011-03-07 18:30:00', '2012-02-14 18:30:00', 1, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,NULL),
(3, 'EMP003', 'Sofia', '', 'O''Sullivan', 4, '1975-08-28 18:30:00', 'Female', 'Married', '', '768-20-4394', '768-20-4394', '', NULL, 3, 10, 2, '', '2792 Trails End Road', 'Fort Lauderdale', 'Fort Lauderdale', 'US', 12, '33308', '954-388-3340', '954-388-3340', '954-388-3340', 'icehrm+user1@web-stalk.com', 'icehrm+user1@web-stalk.com', '2010-02-08 18:30:00', '0000-00-00 00:00:00', 2, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,'[\"1\"]'),
(4, 'EMP004', 'Taylor', '', 'Holmes', 10, '1979-07-15 18:30:00', 'Male', 'Single', '158-06-2292', '158-06-2292', '', '', NULL, 1, 5, 2, '', '1164', 'Walnut Avenue', 'Rochelle Park', 'US', 35, '7662', '201-474-8048', '201-474-8048', '201-474-8048', 'icehrm+user2@web-stalk.com', 'icehrm+user2@web-stalk.com', '2006-07-12 18:30:00', '0000-00-00 00:00:00', 2, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,NULL);
INSERT INTO `Employees` (`id`, `employee_id`, `first_name`, `middle_name`, `last_name`, `nationality`, `birthday`, `gender`, `marital_status`, `ssn_num`, `nic_num`, `other_id`, `driving_license`, `driving_license_exp_date`, `employment_status`, `job_title`, `pay_grade`, `work_station_id`, `address1`, `address2`, `city`, `country`, `province`, `postal_code`, `home_phone`, `mobile_phone`, `work_phone`, `work_email`, `private_email`, `joined_date`, `confirmation_date`, `supervisor`, `department`, `custom1`, `custom2`, `custom3`, `custom4`, `custom5`, `custom6`, `custom7`, `custom8`, `custom9`, `custom10`) VALUES
(5, CONCAT('EMP', RAND()), generate_fname(), '', generate_fname(), 10, '1979-07-15 18:30:00', 'Male', 'Single', '158-06-2292', '158-06-2292', '', '', NULL, 1, 5, 2, '', '1164', 'Walnut Avenue', 'Rochelle Park', 'US', 35, '7662', '201-474-8048', '201-474-8048', '201-474-8048', 'icehrm+user2@web-stalk.com', 'icehrm+user2@web-stalk.com', '2006-07-12 18:30:00', '0000-00-00 00:00:00', 2, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(6, CONCAT('EMP', RAND()), generate_fname(), '', generate_fname(), 10, '1979-07-15 18:30:00', 'Male', 'Single', '158-06-2292', '158-06-2292', '', '', NULL, 1, 5, 2, '', '1164', 'Walnut Avenue', 'Rochelle Park', 'US', 35, '7662', '201-474-8048', '201-474-8048', '201-474-8048', 'icehrm+user2@web-stalk.com', 'icehrm+user2@web-stalk.com', '2006-07-12 18:30:00', '0000-00-00 00:00:00', 2, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(7, CONCAT('EMP', RAND()), generate_fname(), '', generate_fname(), 10, '1979-07-15 18:30:00', 'Male', 'Single', '158-06-2292', '158-06-2292', '', '', NULL, 1, 5, 2, '', '1164', 'Walnut Avenue', 'Rochelle Park', 'US', 35, '7662', '201-474-8048', '201-474-8048', '201-474-8048', 'icehrm+user2@web-stalk.com', 'icehrm+user2@web-stalk.com', '2006-07-12 18:30:00', '0000-00-00 00:00:00', 2, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(8, CONCAT('EMP', RAND()), generate_fname(), '', generate_fname(), 10, '1979-07-15 18:30:00', 'Male', 'Single', '158-06-2292', '158-06-2292', '', '', NULL, 1, 5, 2, '', '1164', 'Walnut Avenue', 'Rochelle Park', 'US', 35, '7662', '201-474-8048', '201-474-8048', '201-474-8048', 'icehrm+user2@web-stalk.com', 'icehrm+user2@web-stalk.com', '2006-07-12 18:30:00', '0000-00-00 00:00:00', 2, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(9, CONCAT('EMP', RAND()), generate_fname(), '', generate_fname(), 10, '1979-07-15 18:30:00', 'Male', 'Single', '158-06-2292', '158-06-2292', '', '', NULL, 1, 5, 2, '', '1164', 'Walnut Avenue', 'Rochelle Park', 'US', 35, '7662', '201-474-8048', '201-474-8048', '201-474-8048', 'icehrm+user2@web-stalk.com', 'icehrm+user2@web-stalk.com', '2006-07-12 18:30:00', '0000-00-00 00:00:00', 2, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(10, CONCAT('EMP', RAND()), generate_fname(), '', generate_fname(), 10, '1979-07-15 18:30:00', 'Female', 'Single', '158-06-2292', '158-06-2292', '', '', NULL, 1, 5, 2, '', '1164', 'Walnut Avenue', 'Rochelle Park', 'US', 35, '7662', '201-474-8048', '201-474-8048', '201-474-8048', 'icehrm+user2@web-stalk.com', 'icehrm+user2@web-stalk.com', '2006-07-12 18:30:00', '0000-00-00 00:00:00', 2, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(11, CONCAT('EMP', RAND()), generate_fname(), '', generate_fname(), 10, '1979-07-15 18:30:00', 'Female', 'Single', '158-06-2292', '158-06-2292', '', '', NULL, 1, 5, 2, '', '1164', 'Walnut Avenue', 'Rochelle Park', 'US', 35, '7662', '201-474-8048', '201-474-8048', '201-474-8048', 'icehrm+user2@web-stalk.com', 'icehrm+user2@web-stalk.com', '2006-07-12 18:30:00', '0000-00-00 00:00:00', 2, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(12, CONCAT('EMP', RAND()), generate_fname(), '', generate_fname(), 10, '1979-07-15 18:30:00', 'Female', 'Single', '158-06-2292', '158-06-2292', '', '', NULL, 1, 5, 2, '', '1164', 'Walnut Avenue', 'Rochelle Park', 'US', 35, '7662', '201-474-8048', '201-474-8048', '201-474-8048', 'icehrm+user2@web-stalk.com', 'icehrm+user2@web-stalk.com', '2006-07-12 18:30:00', '0000-00-00 00:00:00', 2, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(13, CONCAT('EMP', RAND()), generate_fname(), '', generate_fname(), 10, '1979-07-15 18:30:00', 'Female', 'Single', '158-06-2292', '158-06-2292', '', '', NULL, 1, 5, 2, '', '1164', 'Walnut Avenue', 'Rochelle Park', 'US', 35, '7662', '201-474-8048', '201-474-8048', '201-474-8048', 'icehrm+user2@web-stalk.com', 'icehrm+user2@web-stalk.com', '2006-07-12 18:30:00', '0000-00-00 00:00:00', 2, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(14, CONCAT('EMP', RAND()), generate_fname(), '', generate_fname(), 10, '1979-07-15 18:30:00', 'Female', 'Single', '158-06-2292', '158-06-2292', '', '', NULL, 1, 5, 2, '', '1164', 'Walnut Avenue', 'Rochelle Park', 'US', 35, '7662', '201-474-8048', '201-474-8048', '201-474-8048', 'icehrm+user2@web-stalk.com', 'icehrm+user2@web-stalk.com', '2006-07-12 18:30:00', '0000-00-00 00:00:00', 2, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(15, CONCAT('EMP', RAND()), generate_fname(), '', generate_fname(), 10, '1979-07-15 18:30:00', 'Female', 'Single', '158-06-2292', '158-06-2292', '', '', NULL, 1, 5, 2, '', '1164', 'Walnut Avenue', 'Rochelle Park', 'US', 35, '7662', '201-474-8048', '201-474-8048', '201-474-8048', 'icehrm+user2@web-stalk.com', 'icehrm+user2@web-stalk.com', '2006-07-12 18:30:00', '0000-00-00 00:00:00', 2, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
INSERT INTO `EmergencyContacts` (`id`, `employee`, `name`, `relationship`, `home_phone`, `work_phone`, `mobile_phone`) VALUES
@@ -36,9 +62,6 @@ INSERT INTO `EmployeeDependents` (`id`, `employee`, `name`, `relationship`, `dob
(2, 1, 'Mica Singroo', 'Other', '2000-06-13', '');
INSERT INTO `EmployeeEducations` (`id`, `education_id`, `employee`, `institute`, `date_start`, `date_end`) VALUES
(1, 1, 1, 'National University of Turky', '2004-02-03', '2006-06-13'),
(2, 1, 2, 'MIT', '1995-02-21', '1999-10-12');
@@ -56,12 +79,38 @@ INSERT INTO `EmployeeProjects` (`id`, `employee`, `project`, `date_start`, `date
(5, 2, 3, '2013-02-24', '0000-00-00', 'Current', '');
INSERT INTO `EmployeeSalary` (`employee`, `component`,`amount`, `details`) VALUES
(1, 1,'50000.00', ''),
(1, 2,'20000.00', ''),
(1, 3,'30000.00', ''),
(1, 4,'2000.00', ''),
INSERT INTO `EmployeeSalary` (`id`, `employee`, `component`, `pay_frequency`, `currency`, `amount`, `details`) VALUES
(1, 1, 1, 'Monthly', 131, '2700.00', ''),
(2, 2, 2, 'Monthly', 151, '12000.00', ''),
(3, 2, 3, 'Monthly', 131, '5000.00', '');
(2, 1,'90500.00', ''),
(2, 2,'40000.00', ''),
(2, 3,'50000.00', ''),
(3, 1,'131409.00', ''),
(3, 2,'143471.00', ''),
(3, 3,'50000.00', ''),
(3, 4,'30000.00', ''),
(4, 5,'1432.00', ''),
(4, 6,'2100.00', ''),
(5, 5,'1200.00', ''),
(5, 6,'1500.00', ''),
(5, 7,'2000.00', ''),
(5, 1,round(rand() * 100000 + rand() * 20000 - rand() * 20000, 2), ''),
(6, 1,round(rand() * 100000 + rand() * 20000 - rand() * 20000, 2), ''),
(7, 1,round(rand() * 100000 + rand() * 20000 - rand() * 20000, 2), ''),
(8, 1,round(rand() * 100000 + rand() * 20000 - rand() * 20000, 2), ''),
(9, 1,round(rand() * 100000 + rand() * 20000 - rand() * 20000, 2), ''),
(10, 1,round(rand() * 100000 + rand() * 20000 - rand() * 20000, 2), ''),
(11, 1,round(rand() * 100000 + rand() * 20000 - rand() * 20000, 2), ''),
(12, 1,round(rand() * 100000 + rand() * 20000 - rand() * 20000, 2), ''),
(13, 1,round(rand() * 100000 + rand() * 20000 - rand() * 20000, 2), ''),
(14, 1,round(rand() * 100000 + rand() * 20000 - rand() * 20000, 2), '');
INSERT INTO `EmployeeSkills` (`id`, `skill_id`, `employee`, `details`) VALUES
(1, 9, 1, 'Creating web sites'),
@@ -69,10 +118,37 @@ INSERT INTO `EmployeeSkills` (`id`, `skill_id`, `employee`, `details`) VALUES
INSERT INTO `Users` (`id`, `username`, `email`, `password`, `employee`, `user_level`, `last_login`, `last_update`, `created`) VALUES
(2, 'manager', 'icehrm+manager@web-stalk.com', '4048bb914a704a0728549a26b92d8550', 2, 'Manager', '2013-01-03 02:47:37', '2013-01-03 02:47:37', '2013-01-03 02:47:37'),
(3, 'user1', 'icehrm+user1@web-stalk.com', '4048bb914a704a0728549a26b92d8550', 3, 'Employee', '2013-01-03 02:48:32', '2013-01-03 02:48:32', '2013-01-03 02:48:32'),
(4, 'user2', 'icehrm+user2@web-stalk.com', '4048bb914a704a0728549a26b92d8550', 4, 'Employee', '2013-01-03 02:58:55', '2013-01-03 02:58:55', '2013-01-03 02:58:55');
INSERT INTO `LeaveRules` (`id`, `leave_type`, `job_title`, `employment_status`, `employee`, `supervisor_leave_assign`, `employee_can_apply`, `apply_beyond_current`, `leave_accrue`, `carried_forward`, `default_per_year`) VALUES
(1, 1, 11, NULL, NULL, 'No', 'Yes', 'Yes', 'No', 'No', 25),
(2, 2, NULL, NULL, 2, 'No', 'Yes', 'Yes', 'No', 'No', 10);
INSERT INTO `Users` (`id`, `username`, `email`, `password`, `employee`,`default_module`, `user_level`,`user_roles`, `last_login`, `last_update`, `created`) VALUES
(2, 'manager', 'icehrm+manager@web-stalk.com', '4048bb914a704a0728549a26b92d8550', 2,NULL, 'Manager','', '2013-01-03 02:47:37', '2013-01-03 02:47:37', '2013-01-03 02:47:37'),
(3, 'user1', 'icehrm+user1@web-stalk.com', '4048bb914a704a0728549a26b92d8550', 3,NULL, 'Employee','', '2013-01-03 02:48:32', '2013-01-03 02:48:32', '2013-01-03 02:48:32'),
(4, 'user2', 'icehrm+user2@web-stalk.com', '4048bb914a704a0728549a26b92d8550', 4,NULL, 'Employee','', '2013-01-03 02:58:55', '2013-01-03 02:58:55', '2013-01-03 02:58:55'),
(5, 'user3', 'icehrm+user3@web-stalk.com', '4048bb914a704a0728549a26b92d8550', NULL,NULL, 'Other','["1"]', '2013-01-03 02:58:55', '2013-01-03 02:58:55', '2013-01-03 02:58:55');
INSERT INTO `Job` VALUES
(1,'Software Engineer','More than 375,000 users world-wide rely on our software for their daily business as it makes creating graphical presentations so much easier, faster and more enjoyable. Among our customers are many renowned consulting companies and large international corporations.','More than 375,000 users world-wide rely on our software for their daily business as it makes creating graphical presentations so much easier, faster and more enjoyable. Among our customers are many renowned consulting companies and large international corporations.\n\nWe follow our own strategy and do not have to make compromises with regard to code quality and beauty, because think-cell is profitable and has no outside investors. We are flourishing without program managers, meetings, and marketing-driven deadlines. Our code quality is extraordinarily high because we only release software when it is ready. We are willing to do the leg work of developing sophisticated algorithms and refining our user interface, which makes working with think-cell’s software so satisfying.','Challenging C++ coding with high personal responsibility\nWork with a competent and creative team in a modern loft office in Berlin\nFamily-friendly working hours, no deadlines\nAbove-average salary (we offer our developers EUR 120,000 annually after one year of employment)\nFree supply of drinks, fruits, sweets and snacks\nFlat hierarchies and plenty of room for your ideas\nA full-time company nanny who is available for free when children are sick, or when you just feel like spending an evening out','[\"Health plan\",\"Paid vacations\"]',226,2,NULL,'JC001',1,NULL,7,14,9,151,'Yes',3500,5500,'job, engineer','Active','0000-00-00 00:00:00',NULL,'Text Only',1),
(2,'QA Senior Test Automation Engineer','As a QA Senior Test Automation Engineer at Rocket you will help us launch the most successful startup companies around the world.','As a QA Senior Test Automation Engineer at Rocket you will help us launch the most successful startup companies around the world.','Responsibilities:\n\nAutomated testing of web and mobile applications\nDevelop automated scenarios/scripts using Cucumber (for web applications) and Calabash (for mobile applications)\nOptimize existing test cases to get more stability and efficiency\nRun automated functional tests as well as performance and load tests\nAnalyze automated test results and report bugs to responsible employees\nSupport the test automation team during the whole development process (starting from the analysis of requirements up to the integration of automated test cases into the CI system (Jenkins)\n\n\nRequirements:\n\nSeveral years of experience as a Test Automation Engineer ( 5+ years )\nExperience with automated solutions such as Cucumber/Calabash, Gherkin, Selenium or similar tools/frameworks\nExperience with Ruby, Python, PHP, JAVA or similar programming languages\nExperience with source code controls like SVN, GIT, CVS\nFamiliarity with Continuous Integration and Delivery\nExperience in Agile Methodologies like Scrum and Kanban or extreme programming\nFluency in speaking & writing English skills\nISTQB certification\n Technology stack we use:\n\nTools: GitHub, Jira, Confluence, Bamboo, Jenkins, Testlink\nScrum, Kanban\nCucumber, Calabash, Capybara, JMeter','[\"Life insurance\"]',80,3,NULL,'JC002',3,NULL,5,14,6,151,'Yes',4000,4500,'','Active','0000-00-00 00:00:00',NULL,'Text Only',1),
(3,'Online Editor','Online Editors required for a reputed news agency','Online Editors required for a reputed news agency','','[]',129,NULL,NULL,'J0003',1,NULL,7,23,9,103,'No',0,0,'','Active','0001-01-01 00:00:00','attachment_BI5XQCYFxZO12W1447383181684','Image and Full Text',1);
INSERT INTO `Candidates` VALUES
(1,'Jhon','Doe',4,NULL,'Male',NULL,NULL,NULL,'New York','US',NULL,NULL,'icehrm+jhon@web-stalk.com','+1 455565656',NULL,'Software Engineer','cv_rYwHphV7xD5dOe1444302569136',NULL,NULL,NULL,'','','','','','',NULL,NULL,NULL,NULL,NULL,NULL,'2015-10-08 16:59:20','2015-10-08 16:59:20',0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'663fd20d1859344585f678a0f87b23522b8f9fce8c67c5290a609ce342b81442',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
INSERT INTO `Files` VALUES
(6,'attachment_BI5XQCYFxZO12W1447383181684','attachment_BI5XQCYFxZO12W1447383181684.png',1,'Job');
INSERT INTO `EmployeeDocuments` (`id`,`employee`, `document`, `date_added`, `valid_until`, `status`, `details`, `attachment`, `expire_notification_last`) VALUES
(1, 1, 1, CURDATE(), DATE_ADD(CURDATE(), INTERVAL 30 DAY), 'Active', '', NULL, -1),
(2, 1, 2, CURDATE(), DATE_ADD(CURDATE(), INTERVAL 7 DAY), 'Active', '', NULL, -1),
(3, 1, 3, CURDATE(), DATE_ADD(CURDATE(), INTERVAL 1 DAY), 'Active', '', NULL, -1);
INSERT INTO `Attendance` (`employee`,`in_time`,`out_time`,`note`) VALUES
(1, FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 30 DAY))) + FLOOR(28800 + (RAND() * 3600)),'%Y-%m-%d %T'), FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 30 DAY))) + FLOOR(57600 + (RAND() * 21600)),'%Y-%m-%d %T'), ''),
@@ -116,6 +192,90 @@ INSERT INTO `Attendance` (`employee`,`in_time`,`out_time`,`note`) VALUES
(3, FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 22 DAY))) + FLOOR(28800 + (RAND() * 3600)),'%Y-%m-%d %T'), FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 22 DAY))) + FLOOR(57600 + (RAND() * 21600)),'%Y-%m-%d %T'), '');
INSERT INTO `Payroll` VALUES
(1,'2016-03',4,1,1,'[\"5\",\"8\",\"9\",\"10\",\"6\",\"7\",\"4\",\"3\",\"2\",\"1\",\"11\",\"12\",\"13\",\"14\",\"15\",\"16\"]','2016-03-01','2016-03-31','Draft'),
(2,'2016-03-Weekly',2,1,2,'[\"1\",\"2\",\"3\"]','2016-03-01','2016-03-31','Draft');
INSERT INTO `PayrollColumns` VALUES
(5,'Basic Salary',NULL,'[\"1\"]','[]','[]','[]',5,'No','Yes','0.00',NULL,NULL),
(6,'Fixed Allowance',NULL,'[\"2\"]','[]','[]','[]',6,'No','Yes','0.00',NULL,NULL),
(7,'Gross Pay',NULL,'[]','[]','[\"5\",\"6\"]','[]',7,'No','Yes','0.00',NULL,NULL),
(8,'EPF Employee Contribution',NULL,'[]','[\"1\"]','[]','[]',8,'No','Yes','0.00',NULL,NULL),
(9,'EPF Employer Contribution',NULL,'[]','[\"2\"]','[]','[]',9,'No','Yes','0.00',NULL,NULL),
(10,'ETF Employee Contribution',NULL,'[]','[\"3\"]','[]','[]',10,'No','Yes','0.00',NULL,NULL),
(11,'Total EPF 20%',NULL,'[]','[]','[\"8\",\"9\"]','[]',11,'No','Yes','0.00',NULL,NULL),
(12,'Total for PAYE',NULL,'[]','[]','[\"7\"]','[]',12,'No','Yes','0.00',NULL,NULL),
(13,'PAYE Tax',NULL,'[]','[\"4\"]','[]','[]',13,'No','Yes','0.00',NULL,NULL),
(14,'Stamp Duty',NULL,'[]','[\"5\"]','[]','[]',14,'No','Yes','0.00',NULL,NULL),
(15,'Total Deductions',NULL,'[]','[]','[\"8\",\"13\",\"14\"]','[]',15,'No','Yes','0.00',NULL,NULL),
(16,'Salary to Bank',NULL,'[]','[]','[\"7\"]','[\"15\"]',16,'No','Yes','0.00',NULL,NULL);
INSERT INTO `DeductionGroup` VALUES
(1,'Sri Lanka Payroll Calculation',''),
(2,'Singapore Payroll Calculation','');
INSERT INTO `Deductions` VALUES
(1,'EPF Employee Contribution','[]','[]',7,'[{\"lowerCondition\":\"No Lower Limit\",\"lowerLimit\":\"0\",\"upperCondition\":\"No Upper Limit\",\"upperLimit\":\"0\",\"amount\":\"X*0.08\",\"id\":\"rangeAmounts_1\"}]',1),
(2,'EPF Employer Contribution','[]','[]',7,'[{\"lowerCondition\":\"No Lower Limit\",\"lowerLimit\":\"0\",\"upperCondition\":\"No Upper Limit\",\"upperLimit\":\"0\",\"amount\":\"X*0.12\",\"id\":\"rangeAmounts_1\"}]',1),
(3,'ETF Employee Contribution','[]','[]',7,'[{\"lowerCondition\":\"No Lower Limit\",\"lowerLimit\":\"0\",\"upperCondition\":\"No Upper Limit\",\"upperLimit\":\"0\",\"amount\":\"X*0.03\",\"id\":\"rangeAmounts_1\"}]',1),
(4,'PAYE Tax','[]','[]',12,'[{\"lowerCondition\":\"No Lower Limit\",\"lowerLimit\":\"0\",\"upperCondition\":\"lte\",\"upperLimit\":\"62500\",\"amount\":\"0\",\"id\":\"rangeAmounts_1\"},{\"lowerCondition\":\"gt\",\"lowerLimit\":\"62500\",\"upperCondition\":\"lte\",\"upperLimit\":\"104167\",\"amount\":\"X*0.04 - 2500\",\"id\":\"rangeAmounts_2\"},{\"lowerCondition\":\"gt\",\"lowerLimit\":\"104167\",\"upperCondition\":\"lte\",\"upperLimit\":\"145833\",\"amount\":\"X*0.08 - 6667\",\"id\":\"rangeAmounts_3\"},{\"lowerCondition\":\"gt\",\"lowerLimit\":\"145833\",\"upperCondition\":\"lte\",\"upperLimit\":\"187500\",\"amount\":\"X*0.12-12500\",\"id\":\"rangeAmounts_4\"},{\"lowerCondition\":\"gt\",\"lowerLimit\":\"187500\",\"upperCondition\":\"No Upper Limit\",\"upperLimit\":\"0\",\"amount\":\"X*0.16 - 20000\",\"id\":\"rangeAmounts_5\"}]',1),
(5,'Stamp Duty','[]','[]',12,'[{\"lowerCondition\":\"No Lower Limit\",\"lowerLimit\":\"0\",\"upperCondition\":\"lte\",\"upperLimit\":\"25000\",\"amount\":\"0\",\"id\":\"rangeAmounts_1\"},{\"lowerCondition\":\"gt\",\"lowerLimit\":\"25000\",\"upperCondition\":\"No Upper Limit\",\"upperLimit\":\"0\",\"amount\":\"25\",\"id\":\"rangeAmounts_2\"}]',1);
INSERT INTO `PayrollEmployees` VALUES
(1,1,4,151,'[]','[]',1),
(2,2,4,151,'[]','[]',1),
(3,3,4,151,'[]','[]',1),
(4,4,2,151,'[]','[]',1),
(5,5,2,151,'[]','[]',1),
(6,6,4,151,'[]','[]',1),
(7,7,4,151,'[]','[]',1),
(8,8,4,151,'[]','[]',1),
(9,9,4,151,'[]','[]',1),
(10,10,4,151,'[]','[]',1);
INSERT INTO `EmployeeLeaves` VALUES
(1,1,1,4,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 3 DAY))),'%Y-%m-%d'),FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 3 DAY))),'%Y-%m-%d'),'Test Reason 1','Pending',''),
(2,1,1,4,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 4 DAY))),'%Y-%m-%d'),FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 4 DAY))),'%Y-%m-%d'),'Test Reason 2','Approved',''),
(3,2,1,4,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 3 DAY))),'%Y-%m-%d'),FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 3 DAY))),'%Y-%m-%d'),'Test Reason 3','Approved',''),
(4,3,1,4,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 8 DAY))),'%Y-%m-%d'),FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 8 DAY))),'%Y-%m-%d'),'Test Reason 4','Pending',''),
(5,3,1,4,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 9 DAY))),'%Y-%m-%d'),FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 9 DAY))),'%Y-%m-%d'),'Test Reason 4','Pending',''),
(6,3,1,4,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 10 DAY))),'%Y-%m-%d'),FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 10 DAY))),'%Y-%m-%d'),'Test Reason 4','Pending',''),
(7,3,1,4,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 11 DAY))),'%Y-%m-%d'),FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 11 DAY))),'%Y-%m-%d'),'Test Reason 4','Pending',''),
(8,3,1,4,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 12 DAY))),'%Y-%m-%d'),FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 12 DAY))),'%Y-%m-%d'),'Test Reason 4','Pending',''),
(9,3,1,4,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 13 DAY))),'%Y-%m-%d'),FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 13 DAY))),'%Y-%m-%d'),'Test Reason 4','Pending',''),
(10,3,1,4,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 14 DAY))),'%Y-%m-%d'),FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 14 DAY))),'%Y-%m-%d'),'Test Reason 4','Pending',''),
(11,3,1,4,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 15 DAY))),'%Y-%m-%d'),FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 15 DAY))),'%Y-%m-%d'),'Test Reason 4','Pending',''),
(12,3,1,4,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 16 DAY))),'%Y-%m-%d'),FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 16 DAY))),'%Y-%m-%d'),'Test Reason 4','Pending',''),
(13,3,1,4,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 17 DAY))),'%Y-%m-%d'),FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 17 DAY))),'%Y-%m-%d'),'Test Reason 4','Pending',''),
(14,3,1,4,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 18 DAY))),'%Y-%m-%d'),FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 18 DAY))),'%Y-%m-%d'),'Test Reason 4','Pending',''),
(15,3,1,4,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 19 DAY))),'%Y-%m-%d'),FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 19 DAY))),'%Y-%m-%d'),'Test Reason 4','Pending',''),
(16,3,1,4,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 20 DAY))),'%Y-%m-%d'),FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 20 DAY))),'%Y-%m-%d'),'Test Reason 4','Pending',''),
(17,3,1,4,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 21 DAY))),'%Y-%m-%d'),FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 21 DAY))),'%Y-%m-%d'),'Test Reason 4','Pending',''),
(18,3,1,4,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 22 DAY))),'%Y-%m-%d'),FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 22 DAY))),'%Y-%m-%d'),'Test Reason 22','Pending','');
INSERT INTO `EmployeeLeaveDays` VALUES
(1,1,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 3 DAY))),'%Y-%m-%d'),'Full Day'),
(2,1,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 4 DAY))),'%Y-%m-%d'),'Half Day - Morning'),
(3,2,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 3 DAY))),'%Y-%m-%d'),'Half Day - Morning'),
(4,3,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 8 DAY))),'%Y-%m-%d'),'3 Hours - Morning'),
(5,3,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 9 DAY))),'%Y-%m-%d'),'Full Day'),
(6,3,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 10 DAY))),'%Y-%m-%d'),'Full Day'),
(7,3,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 11 DAY))),'%Y-%m-%d'),'Full Day'),
(8,3,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 12 DAY))),'%Y-%m-%d'),'Full Day'),
(9,3,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 13 DAY))),'%Y-%m-%d'),'Full Day'),
(10,3,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 14 DAY))),'%Y-%m-%d'),'Full Day'),
(11,3,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 15 DAY))),'%Y-%m-%d'),'Full Day'),
(12,3,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 16 DAY))),'%Y-%m-%d'),'Full Day'),
(13,3,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 17 DAY))),'%Y-%m-%d'),'Full Day'),
(14,3,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 18 DAY))),'%Y-%m-%d'),'Full Day'),
(15,3,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 19 DAY))),'%Y-%m-%d'),'Full Day'),
(16,3,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 20 DAY))),'%Y-%m-%d'),'Full Day'),
(17,3,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 21 DAY))),'%Y-%m-%d'),'Full Day'),
(18,3,FROM_UNIXTIME((UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 22 DAY))),'%Y-%m-%d'),'Full Day');
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
@@ -125,11 +285,3 @@ INSERT INTO `Attendance` (`employee`,`in_time`,`out_time`,`note`) VALUES

File diff suppressed because it is too large Load Diff

View File

@@ -34,6 +34,12 @@ if (!class_exists('AttendanceAdminManager')) {
UIManager::getInstance()->addQuickAccessMenuItem("Clocked In Employees","fa-clock-o",CLIENT_BASE_URL."?g=admin&n=attendance&m=admin_Employees#tabAttendanceStatus",array("Admin","Manager"));
}
public function initCalculationHooks(){
$this->addCalculationHook('AttendanceUtil_getTimeWorkedHours','Total Hours from Attendance','AttendanceUtil','getTimeWorkedHours');
$this->addCalculationHook('AttendanceUtil_getRegularWorkedHours','Total Regular Hours from Attendance','AttendanceUtil','getRegularWorkedHours');
$this->addCalculationHook('AttendanceUtil_getOverTimeWorkedHours','Total Overtime Hours from Attendance','AttendanceUtil','getOverTimeWorkedHours');
}
}
}
@@ -213,6 +219,39 @@ if (!class_exists('AttendanceStatus')) {
}
}
if (!class_exists('AttendanceUtil')) {
class AttendanceUtil{
public function getAttendanceSummary($employeeId, $startDate, $endDate){
$startTime = $startDate." 00:00:00";
$endTime = $endDate." 23:59:59";
$attendance = new Attendance();
$atts = $attendance->Find("employee = ? and in_time >= ? and out_time <= ?",array($employeeId, $startTime, $endTime));
$atCalClassName = SettingsManager::getInstance()->getSetting('Attendance: Overtime Calculation Class');
$atCal = new $atCalClassName();
$atSum = $atCal->getDataSeconds($atts, $startDate, true);
return $atSum;
}
public function getTimeWorkedHours($employeeId, $startDate, $endDate){
$atSum = $this->getAttendanceSummary($employeeId, $startDate, $endDate);
return round(($atSum['t']/60)/60,2);
}
public function getRegularWorkedHours($employeeId, $startDate, $endDate){
$atSum = $this->getAttendanceSummary($employeeId, $startDate, $endDate);
return round(($atSum['r']/60)/60,2);
}
public function getOverTimeWorkedHours($employeeId, $startDate, $endDate){
$atSum = $this->getAttendanceSummary($employeeId, $startDate, $endDate);
return round(($atSum['o']/60)/60,2);
}
}
}
if (!class_exists('BasicOvertimeCalculator')) {
@@ -305,6 +344,18 @@ if (!class_exists('BasicOvertimeCalculator')) {
}
public function getDataSeconds($atts, $actualStartDate, $aggregate = false){
$atSummary = $this->createAttendanceSummary($atts);
$overtime = $this->calculateOvertime($this->removeAdditionalDays($atSummary, $actualStartDate));
if($aggregate){
$overtime = $this->aggregateData($overtime);
return $overtime;
}else{
return $overtime;
}
}
public function convertToHours($overtime){

View File

@@ -0,0 +1,156 @@
<?php
if (!class_exists('ChartsActionManager')) {
class ChartsActionManager extends SubActionManager{
public function getTimeUtilization($req){
if(empty($req->start)){
$req->start = date("Y-m-01");
}
if(empty($req->end)){
$req->end = date("Y-m-t",strtotime($req->start));
}
//Find Time Entries
$employeeTimeEntry = new EmployeeTimeEntry();
if(empty($req->employee)){
$timeEntryList = $employeeTimeEntry->Find("date(date_start) >= ? and date(date_end) <= ?",array($req->start, $req->end));
}else{
$timeEntryList = $employeeTimeEntry->Find("employee = ? and date(date_start) >= ? and date(date_end) <= ?",array($req->employee, $req->start, $req->end));
}
$seconds = 0;
$graphTimeArray = array();
foreach($timeEntryList as $entry){
$seconds = (strtotime($entry->date_end) - strtotime($entry->date_start));
$key = date("Y-m-d",strtotime($entry->date_end));
if(isset($graphTimeArray[$key])){
$graphTimeArray[$key] += $seconds;
}else{
$graphTimeArray[$key] = $seconds;
}
}
//$minutes = (int)($seconds/60);
//Find Attendance Entries
$attendance = new Attendance();
if(empty($req->employee)){
$atteandanceList = $attendance->Find("date(in_time) >= ? and date(out_time) <= ? and in_time < out_time",array($req->start, $req->end));
}else{
$atteandanceList = $attendance->Find("employee = ? and date(in_time) >= ? and date(out_time) <= ? and in_time < out_time",array($req->employee, $req->start, $req->end));
}
$seconds = 0;
$graphAttendanceArray = array();
foreach($atteandanceList as $entry){
$seconds = (strtotime($entry->out_time) - strtotime($entry->in_time));
$key = date("Y-m-d",strtotime($entry->in_time));
if(isset($graphAttendanceArray[$key])){
$graphAttendanceArray[$key] += $seconds;
}else{
$graphAttendanceArray[$key] = $seconds;
}
}
$data = array();
$data[] = array("key"=>"Hours in Attendance", "values"=>array());
$data[] = array("key"=>"Hours Worked", "values"=>array());
//Iterate date range
$interval = DateInterval::createFromDateString('1 day');
$period = new DatePeriod(new DateTime($req->start), $interval, new DateTime($req->end));
foreach ( $period as $dt ){
$key = $dt->format("Y-m-d");
if(isset($graphAttendanceArray[$key])){
$data[0]['values'][] = array("x"=>$key, "y"=>round(($graphAttendanceArray[$key]/3600),2));
}else{
$data[0]['values'][] = array("x"=>$key, "y"=>0);
}
if(isset($graphTimeArray[$key])){
$data[1]['values'][] = array("x"=>$key, "y"=>round(($graphTimeArray[$key]/3600),2));
}else{
$data[1]['values'][] = array("x"=>$key, "y"=>0);
}
}
/*
//Test data
for($i = 1; $i<31; $i++){
$data[0]['values'][] = array("x"=>$i, "y"=>rand(2,9));
$data[1]['values'][] = array("x"=>$i, "y"=>rand(2,8));
}
*/
return new IceResponse(IceResponse::SUCCESS,$data);
}
public function getAttendance($req){
if(empty($req->start)){
$req->start = date("Y-m-01");
}
if(empty($req->end)){
$req->end = date("Y-m-t",strtotime($req->start));
}
//Find Attendance Entries
$attendance = new Attendance();
if(empty($req->employee)){
$atteandanceList = $attendance->Find("date(in_time) >= ? and date(out_time) <= ? and in_time < out_time",array($req->start, $req->end));
}else{
$atteandanceList = $attendance->Find("employee = ? and date(in_time) >= ? and date(out_time) <= ? and in_time < out_time",array($req->employee, $req->start, $req->end));
}
$seconds = 0;
$graphAttendanceArray = array();
foreach($atteandanceList as $entry){
$seconds = (strtotime($entry->out_time) - strtotime($entry->in_time));
$key = date("Y-m-d",strtotime($entry->in_time));
if(isset($graphAttendanceArray[$key])){
$graphAttendanceArray[$key] += $seconds;
}else{
$graphAttendanceArray[$key] = $seconds;
}
}
$data[0] = array();
$data[0] = array("key"=>"Attendance", "values"=>array());
//Iterate date range
$interval = DateInterval::createFromDateString('1 day');
$period = new DatePeriod(new DateTime($req->start), $interval, new DateTime($req->end));
foreach ( $period as $dt ){
$key = $dt->format("Y-m-d");
if(isset($graphAttendanceArray[$key])){
$data[0]['values'][] = array("x"=>$key, "y"=>round(($graphAttendanceArray[$key]/3600),2));
}else{
$data[0]['values'][] = array("x"=>$key, "y"=>0);
}
}
return new IceResponse(IceResponse::SUCCESS,$data);
}
}
}

View File

@@ -1,7 +1,6 @@
<?php
if (!class_exists('TravelModulesManager')) {
class TravelModulesManager extends AbstractModuleManager{
if (!class_exists('ChartsAdminManager')) {
class ChartsAdminManager extends AbstractModuleManager{
public function initializeUserClasses(){
@@ -17,7 +16,6 @@ if (!class_exists('TravelModulesManager')) {
public function setupModuleClassDefinitions(){
}
}

View File

@@ -0,0 +1,56 @@
<?php
$moduleName = 'company_structure';
define('MODULE_PATH',dirname(__FILE__));
include APP_BASE_PATH.'header.php';
include APP_BASE_PATH.'modulejslibs.inc.php';
?>
<link href="<?=BASE_URL.'js/nvd3/src/nv.d3.css?v='.$jsVersion?>" rel="stylesheet" type="text/css">
<script src="<?=BASE_URL.'js/nvd3/lib/d3.v3.js?v='.$jsVersion?>"></script>
<script src="<?=BASE_URL.'js/nvd3/nv.d3.js?v='.$jsVersion?>"></script>
<script src="<?=BASE_URL.'js/nvd3/src/tooltip.js?v='.$jsVersion?>"></script>
<script src="<?=BASE_URL.'js/nvd3/src/utils.js?v='.$jsVersion?>"></script>
<script src="<?=BASE_URL.'js/nvd3/src/models/legend.js?v='.$jsVersion?>"></script>
<script src="<?=BASE_URL.'js/nvd3/src/models/axis.js?v='.$jsVersion?>"></script>
<script src="<?=BASE_URL.'js/nvd3/src/models/multiBar.js?v='.$jsVersion?>"></script>
<script src="<?=BASE_URL.'js/nvd3/src/models/discreteBar.js?v='.$jsVersion?>"></script>
<script src="<?=BASE_URL.'js/nvd3/src/models/discreteBarChart.js?v='.$jsVersion?>"></script>
<script src="<?=BASE_URL.'js/nvd3/stream_layers.js?v='.$jsVersion?>"></script>
<style type="text/css">
svg .tooltip { opacity: 1; }
</style>
<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="tabAttendanceGraph" href="#tabPageAttendanceGraph">Attendance Graph</a></li>
<li><a id="tabTimeUtilizationGraph" href="#tabPageTimeUtilizationGraph">Hours in Office vs Hours Worked Graph</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active reviewBlock with-3d-shadow with-transitions" id="tabPageAttendanceGraph" style="height: 500px;position: relative;">
<svg></svg>
</div>
<div class="tab-pane reviewBlock with-3d-shadow with-transitions" id="tabPageTimeUtilizationGraph" style="height: 500px;position: relative;">
<svg></svg>
</div>
</div>
</div>
<script>
var modJsList = new Array();
modJsList['tabAttendanceGraph'] = new AttendanceGraphAdapter('AttendanceGraph');
modJsList['tabAttendanceGraph'].setShowAddNew(false);
modJsList['tabTimeUtilizationGraph'] = new TimeUtilizationGraphAdapter('TimeUtilizationGraph');
modJsList['tabTimeUtilizationGraph'].setShowAddNew(false);
var modJs = modJsList['tabAttendanceGraph'];
</script>
<?php include APP_BASE_PATH.'footer.php';?>

284
ext/admin/charts/lib.js Normal file
View File

@@ -0,0 +1,284 @@
/**
* Author: Thilina Hasantha
*/
function BaseGraphAdapter(endPoint) {
this.initAdapter(endPoint);
}
BaseGraphAdapter.inherits(AdapterBase);
BaseGraphAdapter.method('getDataMapping', function() {
return [];
});
BaseGraphAdapter.method('getHeaders', function() {
return [];
});
BaseGraphAdapter.method('getFormFields', function() {
return [];
});
BaseGraphAdapter.method('createTable', function(elementId) {
});
/*
* TimeUtilizationGraphAdapter
*/
function AttendanceGraphAdapter(endPoint) {
this.initAdapter(endPoint);
}
AttendanceGraphAdapter.inherits(BaseGraphAdapter);
AttendanceGraphAdapter.method('getFormFields', function() {
return [];
});
AttendanceGraphAdapter.method('getFilters', function() {
return [
[ "employee", {"label":"Employee","type":"select2","allow-null":true,"null-label":"All Employees","remote-source":["Employee","id","first_name+last_name"]}],
[ "start", {"label":"Start Date","type":"date","validation":""}],
[ "end", {"label":"End Date","type":"date","validation":""}]
];
});
AttendanceGraphAdapter.method('get', function() {
this.initFieldMasterData();
this.getTimeUtilization();
});
AttendanceGraphAdapter.method('doCustomFilterValidation', function(params) {
$("#"+this.table+"_filter_error").html("");
$("#"+this.table+"_filter_error").hide();
if(Date.parse(params.start).getTime() > Date.parse(params.end).getTime()){
$("#"+this.table+"_filter_error").html("End date should be a later date than start date");
$("#"+this.table+"_filter_error").show();
return false;
}
var dateDiff = (Date.parse(params.end).getTime() - Date.parse(params.start).getTime())/(1000*60*60*24);
if(dateDiff > 45 && (params['employee'] == undefined || params['employee'] == null || params['employee'] == "NULL")){
$("#"+this.table+"_filter_error").html("Differance between start and end dates should not be more than 45 days, when creating chart for all employees");
$("#"+this.table+"_filter_error").show();
return false;
}else if(dateDiff > 90){
$("#"+this.table+"_filter_error").html("Differance between start and end dates should not be more than 90 days");
$("#"+this.table+"_filter_error").show();
return false;
}
return true;
});
AttendanceGraphAdapter.method('getTimeUtilization', function(object,callBackData) {
var that = this;
object = {};
if(this.filter != null && this.filter != undefined){
if(this.filter.employee != "NULL"){
object['employee'] = this.filter.employee;
}
object['start'] = this.filter.start;
object['end'] = this.filter.end;
}
var reqJson = JSON.stringify(object);
var callBackData = [];
callBackData['callBackData'] = [];
callBackData['callBackSuccess'] = 'getAttendanceSuccessCallBack';
callBackData['callBackFail'] = 'getAttendanceFailCallBack';
this.customAction('getAttendance','admin=charts',reqJson,callBackData);
});
AttendanceGraphAdapter.method('getAttendanceFailCallBack', function(callBackData) {
this.showMessage("Error Occured while getting data for chart", callBackData);
});
AttendanceGraphAdapter.method('getAttendanceSuccessCallBack', function(callBackData) {
var that = this;
var chart;
var filterHtml = that.getTableTopButtonHtml();
$("#tabPageAttendanceGraph svg").remove();
$("#tabPageAttendanceGraph div").remove();
$("#tabPageAttendanceGraph").html("");
$("#tabPageAttendanceGraph").html(filterHtml+"<svg></svg>");
nv.addGraph(function() {
var chart = nv.models.multiBarChart()
.margin({bottom: 200})
.transitionDuration(0)
.reduceXTicks(true) //If 'false', every single x-axis tick label will be rendered.
.rotateLabels(45) //Angle to rotate x-axis labels.
.showControls(false) //Allow user to switch between 'Grouped' and 'Stacked' mode.
.groupSpacing(0.1) //Distance between each group of bars.
;
chart.yAxis
.tickFormat(d3.format(',.1f'));
chart.dispatch.on('stateChange', function(e) { nv.log('New State:', JSON.stringify(e)); });
chart.tooltip(function (key, x, y, e, graph) {
return '<p><strong>' + key + '</strong></p>' +
'<p>' + y + ' on ' + x + '</p>';
});
d3.select('#tabPageAttendanceGraph svg')
.datum(callBackData)
.call(chart);
return chart;
});
});
/*
* TimeUtilizationGraphAdapter
*/
function TimeUtilizationGraphAdapter(endPoint) {
this.initAdapter(endPoint);
}
TimeUtilizationGraphAdapter.inherits(BaseGraphAdapter);
TimeUtilizationGraphAdapter.method('getFormFields', function() {
return [];
});
TimeUtilizationGraphAdapter.method('getFilters', function() {
return [
[ "employee", {"label":"Employee","type":"select2","allow-null":true,"null-label":"All Employees","remote-source":["Employee","id","first_name+last_name"]}],
[ "start", {"label":"Start Date","type":"date","validation":""}],
[ "end", {"label":"End Date","type":"date","validation":""}]
];
});
TimeUtilizationGraphAdapter.method('get', function() {
this.initFieldMasterData();
this.getTimeUtilization();
});
TimeUtilizationGraphAdapter.method('doCustomFilterValidation', function(params) {
$("#"+this.table+"_filter_error").html("");
$("#"+this.table+"_filter_error").hide();
if(Date.parse(params.start).getTime() > Date.parse(params.end).getTime()){
$("#"+this.table+"_filter_error").html("End date should be a later date than start date");
$("#"+this.table+"_filter_error").show();
return false;
}
var dateDiff = (Date.parse(params.end).getTime() - Date.parse(params.start).getTime())/(1000*60*60*24);
if(dateDiff > 45 && (params['employee'] == undefined || params['employee'] == null || params['employee'] == "NULL")){
$("#"+this.table+"_filter_error").html("Differance between start and end dates should not be more than 45 days, when creating chart for all employees");
$("#"+this.table+"_filter_error").show();
return false;
}else if(dateDiff > 90){
$("#"+this.table+"_filter_error").html("Differance between start and end dates should not be more than 90 days");
$("#"+this.table+"_filter_error").show();
return false;
}
return true;
});
TimeUtilizationGraphAdapter.method('getTimeUtilization', function(object,callBackData) {
var that = this;
object = {};
if(this.filter != null && this.filter != undefined){
if(this.filter.employee != "NULL"){
object['employee'] = this.filter.employee;
}
object['start'] = this.filter.start;
object['end'] = this.filter.end;
}
var reqJson = JSON.stringify(object);
var callBackData = [];
callBackData['callBackData'] = [];
callBackData['callBackSuccess'] = 'getTimeUtilizationSuccessCallBack';
callBackData['callBackFail'] = 'getTimeUtilizationFailCallBack';
this.customAction('getTimeUtilization','admin=charts',reqJson,callBackData);
});
TimeUtilizationGraphAdapter.method('getTimeUtilizationFailCallBack', function(callBackData) {
this.showMessage("Error Occured while getting data for chart", callBackData);
});
TimeUtilizationGraphAdapter.method('getTimeUtilizationSuccessCallBack', function(callBackData) {
var that = this;
var chart;
var filterHtml = that.getTableTopButtonHtml();
$("#tabPageTimeUtilizationGraph svg").remove();
$("#tabPageTimeUtilizationGraph div").remove();
$("#tabPageTimeUtilizationGraph").html("");
$("#tabPageTimeUtilizationGraph").html(filterHtml+"<svg></svg>");
nv.addGraph(function() {
var chart = nv.models.multiBarChart()
.margin({bottom: 200})
.transitionDuration(0)
.reduceXTicks(true) //If 'false', every single x-axis tick label will be rendered.
.rotateLabels(45) //Angle to rotate x-axis labels.
.showControls(true) //Allow user to switch between 'Grouped' and 'Stacked' mode.
.groupSpacing(0.1) //Distance between each group of bars.
;
chart.yAxis
.tickFormat(d3.format(',.1f'));
d3.select('#tabPageTimeUtilizationGraph svg')
.datum(callBackData)
.call(chart);
chart.dispatch.on('stateChange', function(e) { nv.log('New State:', JSON.stringify(e)); });
chart.tooltip(function (key, x, y, e, graph) {
return '<p><strong>' + key + '</strong></p>' +
'<p>' + y + ' on ' + x + '</p>';
});
return chart;
});
});

View File

@@ -0,0 +1,11 @@
{
"label":"Performance Charts",
"menu":"Employees",
"order":"93",
"icon":"fa-bar-chart-o",
"user_levels":["Admin","Manager"],
"permissions":
{
}
}

View File

@@ -56,6 +56,37 @@ if (!class_exists('CompanyStructure')) {
return new IceResponse(IceResponse::SUCCESS,"");
}
public static function getAllChildCompanyStructures($companyStructureId){
$structures = array();
$companyStructure = new CompanyStructure();
$companyStructure->Load("id = ?",array($companyStructureId));
if($companyStructure->id != $companyStructureId || empty($companyStructure->id)){
return new IceResponse(IceResponse::ERROR, array());
}
self::getChildCompanyStructures($companyStructure, $structures);
$structures[$companyStructure->id] = $companyStructure;
return new IceResponse(IceResponse::SUCCESS, array_values($structures));
}
private static function getChildCompanyStructures($companyStructure, &$structures){
$child = new CompanyStructure();
$children = $child->Find("parent = ?",array($companyStructure->id));
if(!empty($children)){
foreach($children as $c){
if(isset($structures[$c->id])){
continue;
}
$structures[$c->id] = $c;
self::getChildCompanyStructures($c, $structures);
}
}
}
}
}

View File

@@ -58,7 +58,21 @@ include APP_BASE_PATH.'modulejslibs.inc.php';
}
?>
</div>
<div id="iceannon">
<div class="callout callout-danger lead" style="font-size: 14px;font-weight: bold;">
<h4>Why not upgrade to IceHrm Pro Version</h4>
<p>
IceHrm Pro is the feature rich upgrade to IceHrm open source version. It comes with improved modules for
employee management, leave management and number of other features over open source version.
Hit this <a href="http://icehrm.com/#compare" class="btn btn-primary btn-xs target="_blank">link</a> to do a full one to one comparison.
Also you can learn more about IceHrm Pro <a href="http://blog.icehrm.com/docs/icehrm-pro/" class="btn btn-primary btn-xs" target="_blank">here</a>
<br/>
<br/>
<a href="http://icehrm.com/modules.php" class="btn btn-success btm-xs" target="_blank"><i class="fa fa-checkout"></i> Buy IceHrm Pro</a>
</p>
</div>
</div>
</div>
<script>
@@ -68,5 +82,17 @@ include APP_BASE_PATH.'modulejslibs.inc.php';
var modJs = modJsList['tabDashboard'];
$(document).ready(function() {
try {
$.ajax({
url: "https://icehrm-public.s3.amazonaws.com/icehrmnews.html",
success: function (result) {
$('#iceannon').html(result);
}
});
} catch (e) {
}
}
</script>
<?php include APP_BASE_PATH.'footer.php';?>

View File

@@ -0,0 +1,44 @@
ICEHRM END USER LICENSE AGREEMENT
NOTICE TO ALL USERS: BY PURCHASING THE MODULE, YOU (EITHER AN INDIVIDUAL OR A SINGLE ENTITY) CONSENT TO BE BOUND BY AND BECOME A PARTY TO THIS AGREEMENT.
All references to "Software" herein shall be deemed to include the software license with which you will be provided by Gamonoid Media Pvt Ltd, as part of the Software.
1. LICENSE GRANT. Subject to the payment of the applicable licence fees, and subject to the terms and conditions of this Agreement, ICEHRM hereby grants to you a non-exclusive, non-transferable right to use one copy of the specified version of the Software and the accompanying documentation (the "Documentation") for the term of this Agreement solely for your own internal business purposes. You may install one copy of the Software for production use.
.
2. USE. The Software is licensed as a single product; it may not be used on more than one ICEHRM Server at a time. The Software is "in use" on a Server when its installed on a Server. You shall not, nor permit any third party to copy (other than as expressly permitted herein). You shall not rent, lease or lend the Software to any other person, nor transfer or sub-licence your licence rights to any other person.
3. TERM. This Agreement is effective until terminated as set forth herein. This Agreement will terminate automatically if you fail to comply with any of the conditions, limitations or other requirements described herein. Upon any termination of this Agreement, you must immediately destroy all copies of the Software and the Documentation. You may terminate this Agreement at any point by destroying all copies of the Software and the Documentation.
4. SUPPORT. Gamonoid Media Pvt Ltd will provide you support according to the support agreement subscribed by the company.
5. OWNERSHIP RIGHTS. The Software is protected by copyright laws. ICEHRM and Gamonoid Media Pvt Ltd own and retain all right, title and interest in and to the Software, including all copyrights, patents, trademarks and other intellectual property rights therein. Your possession, installation, or use of the Software does not transfer to you any title to the intellectual property in the Software, and you will not acquire any rights to the Software except as expressly set forth in this Agreement.
6. LIMITED WARRANTY. You may not rent, lease, loan or resell the Software. You may not permit third parties to benefit from the use or functionality of the Software via a timesharing, service bureau or other arrangement, except to the extent such use is specified in the applicable list price or product packaging for the Software. You may not transfer any of the rights granted to you under this Agreement. You may not modify, or create derivative works based upon, the Software in whole or in part. You may not copy the Software or Documentation except as expressly permitted in Section 1 above. You may not remove any proprietary notices or labels on the Software. All rights not expressly set forth hereunder are reserved by ICEHRM. ICEHRM reserves the right to periodically conduct audits upon advance written notice to verify compliance with the terms of this Agreement.
7. WARRANTY and DISCLAIMER.
(i) Gamonoid Media Pvt Ltd. warrants that for 30 days from first download or installation the Software will perform substantially in accordance with the functionality described in the Documentation (http://blog.icehrm.com) when operated properly and in the manner specified in the Documentation.
(ii) You accept all responsibility for the selection of this Software to meet your requirements.
(iii) Gamonoid Media Pvt Ltd. does not warrant that the Software and/or the Documentation will be suitable for such requirements nor that any use will be uninterrupted and error free.
(iv) The warranty in (i) shall not apply if you (a) make or cause to be made any modifications to this Software, (b) use the Software in a manner for which it was not intended or (c) use the Software other than as permitted under this Agreement.
(vii) The warranties and conditions stated in this Agreement are in lieu of all other conditions, warranties or other terms concerning the supply or purported supply of, failure to supply or delay in supplying the Software or the Documentation which might but for this paragraph (vii) have effect between the ICEHRM and you or would otherwise be implied into or incorporated into this Agreement or any collateral contract, whether by statute, common law or otherwise, all of which are hereby excluded (including, without limitation, the implied conditions, warranties or other terms as to satisfactory quality, fitness for purpose or as to the use of reasonable skill and care).
8. LIMITATION of LIABILITY. Gamonoid Media Pvt Ltd. shall have no liability (whether in contract, tort, restitution or otherwise) for any of the following losses or damage (whether such losses or damage were foreseen, foreseeable, known or otherwise):
- Loss of revenue;
- Loss of actual or anticipated profits (including for loss of profits on contracts);
- Loss of the use of money;
- Loss of anticipated savings;
- Loss of business;
- Loss of opportunity;
- Loss of goodwill;
- Loss of reputation;
- Loss of, damage to or corruption of data;
or
Any indirect or consequential loss or damage howsoever caused (including, for the avoidance of doubt, where such loss or damage is of the type specified in paragraph (ii), (a) to (ii), (i).
The ICEHRM liability (whether in contract, tort, restitution or otherwise) arising out of or in connection with the supply of the Software shall in no circumstances exceed a sum equal to the amount equally paid by you for the Software.
The construction and interpretation of this Agreement shall be governed in accordance with the laws of Sri Lanka. The parties hereby submit to the jurisdiction of the courts of Sri Lanka save that ICEHRM as claimant shall be entitled to initiate proceedings in any court of competent jurisdiction.
This Agreement contains the entire understanding of the parties with respect to the subject matter hereof and supersedes all and any prior understandings, undertakings and promises between you and ICEHRM, whether oral or in writing, which have been given or may be implied from anything written or said in negotiations between us or our representatives prior to this Agreement and all prior agreements between the parties relating to the matters aforesaid shall cease to have effect as from the Effective Date.

View File

@@ -0,0 +1,7 @@
This module is licensed under IceHrm Commercial License, which can be found in LICENSE.txt.
You are allowed to make any modification required to these module, but only allowed to use
the module in one production server (even with modifications).
Installation
------------
Copy this module into <icehrm path>/admin/ directory

View File

@@ -0,0 +1,164 @@
<?php
class EmployeesActionManager extends SubActionManager{
public function terminateEmployee($req){
$employee = new Employee();
$employee->Load("id = ?",array($req->id));
if(empty($employee->id)){
return new IceResponse(IceResponse::ERROR, "Employee Not Found");
}
$employee->termination_date = date('Y-m-d H:i:s');
$employee->status = 'Terminated';
$ok = $employee->Save();
if(!$ok){
return new IceResponse(IceResponse::ERROR, "Error occured while terminating employee");
}
return new IceResponse(IceResponse::SUCCESS, $employee);
//$user = BaseService::getInstance()->getUserFromProfileId($employee->id);
}
public function activateEmployee($req){
$employee = new Employee();
$employee->Load("id = ?",array($req->id));
if(empty($employee->id)){
return new IceResponse(IceResponse::ERROR, "Employee Not Found");
}
$employee->termination_date = NULL;
$employee->status = 'Active';
$ok = $employee->Save();
if(!$ok){
return new IceResponse(IceResponse::ERROR, "Error occured while activating employee");
}
return new IceResponse(IceResponse::SUCCESS, $employee);
//$user = BaseService::getInstance()->getUserFromProfileId($employee->id);
}
public function deleteEmployee($req){
$employee = new Employee();
$employee->Load("id = ?",array($req->id));
if(empty($employee->id)){
return new IceResponse(IceResponse::ERROR, "Employee Not Found");
}
$archived = new ArchivedEmployee();
$archived->ref_id = $employee->id;
$archived->employee_id = $employee->employee_id;
$archived->first_name = $employee->first_name;
$archived->last_name = $employee->last_name;
$archived->gender = $employee->gender;
$archived->ssn_num = $employee->ssn_num;
$archived->nic_num = $employee->nic_num;
$archived->other_id = $employee->other_id;
$archived->work_email = $employee->work_email;
$archived->joined_date = $employee->joined_date;
$archived->confirmation_date = $employee->confirmation_date;
$archived->supervisor = $employee->supervisor;
$archived->department = $employee->department;
$archived->termination_date = $employee->termination_date;
$archived->notes = $employee->notes;
//$archived = BaseService::getInstance()->cleanUpAdoDB($archived);
$mapping = '{"nationality":["Nationality","id","name"],"employment_status":["EmploymentStatus","id","name"],"job_title":["JobTitle","id","name"],"pay_grade":["PayGrade","id","name"],"country":["Country","code","name"],"province":["Province","id","name"],"department":["CompanyStructure","id","title"],"supervisor":["Employee","id","first_name+last_name"]}';
$employeeEnriched = BaseService::getInstance()->getElement('Employee',$employee->id,$mapping,true);
$employeeEnriched = BaseService::getInstance()->cleanUpAdoDB($employeeEnriched);
$data = new stdClass();
$data->enrichedEmployee = $employeeEnriched;
$data->timesheets = $this->getEmployeeData($employee->id, new EmployeeTimeSheet());
$data->timesheetEntries = $this->getEmployeeData($employee->id, new EmployeeTimeEntry());
$data->attendance = $this->getEmployeeData($employee->id, new Attendance());
$data->documents = $this->getEmployeeData($employee->id, new EmployeeDocument());
if(class_exists('EmployeeTrainingSession')){
$data->trainingSessions = $this->getEmployeeData($employee->id, new EmployeeTrainingSession());
}
$data->travelRecords = $this->getEmployeeData($employee->id, new EmployeeTravelRecord());
$data->qualificationSkills = $this->getEmployeeData($employee->id, new EmployeeSkill());
$data->qualificationEducation = $this->getEmployeeData($employee->id, new EmployeeEducation());
$data->qualificationCertifications = $this->getEmployeeData($employee->id, new EmployeeCertification());
$data->qualificationLanguages = $this->getEmployeeData($employee->id, new EmployeeLanguage());
$data->salary = $this->getEmployeeData($employee->id, new EmployeeSalary());
$data->dependants = $this->getEmployeeData($employee->id, new EmployeeDependent());
$data->emergencyContacts = $this->getEmployeeData($employee->id, new EmergencyContact());
$data->projects = $this->getEmployeeData($employee->id, new EmployeeProject());
$data->leaves = $this->getEmployeeData($employee->id, new EmployeeLeave());
$data->leaveDays = $this->getEmployeeData($employee->id, new EmployeeLeaveDay());
$archived->data = json_encode($data, JSON_PRETTY_PRINT);
$ok = $archived->Save();
if(!$ok){
return new IceResponse(IceResponse::ERROR, "Error occured while archiving employee");
}
$ok = $employee->Delete();
if(!$ok){
return new IceResponse(IceResponse::ERROR, "Error occured while deleting employee");
}
return new IceResponse(IceResponse::SUCCESS, $archived);
}
public function downloadArchivedEmployee($req){
if($this->baseService->currentUser->user_level != 'Admin'){
echo "Error: Permission denied";
exit();
}
$employee = new ArchivedEmployee();
$employee->Load("id = ?",array($req->id));
if(empty($employee->id)){
return new IceResponse(IceResponse::ERROR, "Employee Not Found");
}
$employee->data = json_decode($employee->data);
$employee = $this->baseService->cleanUpAdoDB($employee);
$str = json_encode($employee, JSON_PRETTY_PRINT);
$filename = uniqid();
$file = fopen("/tmp/".$filename,"w");
fwrite($file,$str);
fclose($file);
$downloadFileName = "employee_".$employee->id."_".str_replace(" ", "_", $employee->first_name)."_".str_replace(" ", "_", $employee->last_name).".txt";
header("Pragma: public"); // required
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Description: File Transfer");
header("Content-Type: image/jpg");
header('Content-Disposition: attachment; filename="'.$downloadFileName.'"');
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize("/tmp/".$filename));
readfile("/tmp/".$filename);
exit();
}
private function getEmployeeData($id, $obj){
$data = array();
$objs = $obj->Find("employee = ?",array($id));
foreach($objs as $entry){
$data[] = BaseService::getInstance()->cleanUpAdoDB($entry);
}
return $data;
}
}

View File

@@ -10,6 +10,18 @@ if (!class_exists('EmployeesAdminManager')) {
}
public function setupRestEndPoints(){
\NoahBuscher\Macaw\Macaw::get(REST_API_PATH.'employee/(:any)', function($pathParams) {
$empRestEndPoint = new EmployeeRestEndPoint();
$empRestEndPoint->process('get',$pathParams);
});
\NoahBuscher\Macaw\Macaw::get(REST_API_PATH.'employees', function() {
$empRestEndPoint = new EmployeesRestEndPoint();
$empRestEndPoint->process('get',NULL);
});
}
public function initializeDatabaseErrorMappings(){
$this->addDatabaseErrorMapping('CONSTRAINT `Fk_User_Employee` FOREIGN KEY',"Can not delete Employee, please delete the User for this employee first.");
$this->addDatabaseErrorMapping("Duplicate entry|for key 'employee'","A duplicate entry found");
@@ -41,6 +53,43 @@ if (!class_exists('EmployeesAdminManager')) {
if (!class_exists('Employee')) {
class Employee extends ICEHRM_Record {
var $oldObj = null;
var $oldObjOrig = null;
var $historyUpdateList = array();
var $historyFieldsToTrack = array(
"employee_id"=>"employee_id",
"first_name"=>"first_name",
"middle_name"=>"middle_name",
"last_name"=>"last_name",
"nationality"=>"nationality_Name",
"birthday"=>"birthday",
"gender"=>"gender",
"marital_status"=>"marital_status",
"ssn_num"=>"ssn_num",
"nic_num"=>"nic_num",
"other_id"=>"other_id",
"employment_status"=>"employment_status_Name",
"job_title"=>"job_title_Name",
"pay_grade"=>"pay_grade_Name",
"work_station_id"=>"work_station_id",
"address1"=>"address1",
"address2"=>"address2",
"city"=>"city_Name",
"country"=>"country_Name",
"province"=>"province_Name",
"postal_code"=>"postal_code",
"home_phone"=>"home_phone",
"mobile_phone"=>"mobile_phone",
"work_phone"=>"work_phone",
"work_email"=>"work_email",
"private_email"=>"private_email",
"joined_date"=>"joined_date",
"confirmation_date"=>"confirmation_date",
"supervisor"=>"supervisor_Name",
"indirect_supervisors"=>"indirect_supervisors",
"department"=>"department_Name"
);
public function getAdminAccess(){
return array("get","element","save","delete");
}
@@ -61,10 +110,165 @@ if (!class_exists('Employee')) {
return "id";
}
private function initHistory($obj){
$oldObjOrig = new Employee();
$oldObjOrig->Load("id = ?",array($obj->id));
$this->oldObjOrig = $oldObjOrig;
$mapping = '{"nationality":["Nationality","id","name"],"employment_status":["EmploymentStatus","id","name"],"job_title":["JobTitle","id","name"],"pay_grade":["PayGrade","id","name"],"country":["Country","code","name"],"province":["Province","id","name"],"department":["CompanyStructure","id","title"],"supervisor":["Employee","id","first_name+last_name"]}';
$this->oldObj = BaseService::getInstance()->getElement('Employee',$obj->id,$mapping,true);
}
private function saveHistory($obj){
$oldObj = $this->oldObj;
$oldObjOrig = $this->oldObjOrig;
$mapping = '{"nationality":["Nationality","id","name"],"employment_status":["EmploymentStatus","id","name"],"job_title":["JobTitle","id","name"],"pay_grade":["PayGrade","id","name"],"country":["Country","code","name"],"province":["Province","id","name"],"department":["CompanyStructure","id","title"],"supervisor":["Employee","id","first_name+last_name"]}';
$objEnriched = BaseService::getInstance()->getElement('Employee',$obj->id,$mapping,true);
foreach($this->historyFieldsToTrack as $k => $v){
if(empty($oldObjOrig->$k) && $obj->$k = '[]'){
continue;
}
if(empty($obj->$k) && $oldObjOrig->$k = '0000-00-00'){
continue;
}
if($oldObjOrig->$k != $obj->$k){
$enrichNewVal = '';
$enrichOldVal = '';
if($k == 'indirect_supervisors'){
if(!empty($obj->$k) && $obj->$k != '[]'){
$newIndeirectSupervisorIds = json_decode($obj->$k);
foreach($newIndeirectSupervisorIds as $id){
$item = BaseService::getInstance()->getItemFromCache("Employee", $id);
if($enrichNewVal != ""){
$enrichNewVal .= ", ";
}
$enrichNewVal .= $item->first_name." ".$item->last_name;
}
}
if(!empty($oldObjOrig->$k) && $oldObjOrig->$k != '[]'){
$oldIndeirectSupervisorIds = json_decode($oldObjOrig->$k);
foreach($oldIndeirectSupervisorIds as $id){
$item = BaseService::getInstance()->getItemFromCache("Employee", $id);
if($enrichOldVal != ""){
$enrichOldVal .= ", ";
}
$enrichOldVal .= $item->first_name." ".$item->last_name;
}
}
}else{
$enrichOldVal = $oldObj->$v;
$enrichNewVal = $objEnriched->$v;
}
$this->historyUpdateList[] = array($obj->id,$k,$enrichOldVal,$enrichNewVal);
}
}
while(count($this->historyUpdateList)){
$ele = array_pop($this->historyUpdateList);
BaseService::getInstance()->addHistoryItem("Employee","Employee",$ele[0],$ele[1],$ele[2],$ele[3]);
}
}
public function executePreSaveActions($obj){
if(empty($obj->status)){
$obj->status = 'Active';
}
return new IceResponse(IceResponse::SUCCESS,$obj);
}
public function executePreUpdateActions($obj){
$this->initHistory($obj);
return new IceResponse(IceResponse::SUCCESS,$obj);
}
public function executePostUpdateActions($obj){
$this->saveHistory($obj);
}
public function postProcessGetData($obj){
$obj = FileService::getInstance()->updateSmallProfileImage($obj);
return $obj;
}
public function getVirtualFields(){
return array(
"image"
);
}
public function getActiveEmployees(){
$employee = new Employee();
$list = $employee->Find("status = ?",array('Active'));
return $list;
}
public function getActiveSubordinateEmployees(){
$employee = new Employee();
if(BaseService::getInstance()->currentUser->user_level != 'Admin'){
$cemp = BaseService::getInstance()->getCurrentProfileId();
$list = $employee->Find("status = ? and supervisor = ?",array('Active', $cemp));
}else{
$list = $employee->Find("status = ?",array('Active'));
}
return $list;
}
public static function cleanEmployeeData($obj){
unset($obj->historyFieldsToTrack);
unset($obj->historyUpdateList);
unset($obj->oldObjOrig);
unset($obj->oldObj);
unset($obj->oldObj);
return $obj;
}
var $_table = 'Employees';
}
}
if (!class_exists('ArchivedEmployee')) {
class ArchivedEmployee extends ICEHRM_Record {
public function getAdminAccess(){
return array("get","element","save","delete");
}
public function getManagerAccess(){
return array("get","element","save");
}
public function getUserAccess(){
return array("get");
}
public function getUserOnlyMeAccess(){
return array("element","save");
}
public function getUserOnlyMeAccessField(){
return "id";
}
var $_table = 'ArchivedEmployees';
}
}
if (!class_exists('EmploymentStatus')) {
class EmploymentStatus extends ICEHRM_Record {
@@ -84,3 +288,52 @@ if (!class_exists('EmploymentStatus')) {
}
}
if (!class_exists('EmployeeRestEndPoint')) {
class EmployeeRestEndPoint extends RestEndPoint{
public function get($parameter){
if(empty($parameter)){
return new IceResponse(IceResponse::ERROR, "Employee ID not provided");
}
$accessTokenValidation = $this->validateAccessToken();
if($accessTokenValidation->getStatus() == IceResponse::ERROR){
return $accessTokenValidation;
}
$mapping = '{"nationality":["Nationality","id","name"],"ethnicity":["Ethnicity","id","name"],"immigration_status":["ImmigrationStatus","id","name"],"employment_status":["EmploymentStatus","id","name"],"job_title":["JobTitle","id","name"],"pay_grade":["PayGrade","id","name"],"country":["Country","code","name"],"province":["Province","id","name"],"department":["CompanyStructure","id","title"],"supervisor":["Employee","id","first_name+last_name"]}';
$employeeResp = BaseService::getInstance()->getElement('Employee',$parameter,$mapping,true);
if($employeeResp->getStatus() == IceResponse::SUCCESS){
$emp = $employeeResp->getObject();
$emp = Employee::cleanEmployeeData($emp);
return new IceResponse(IceResponse::SUCCESS,$emp);
}
return $employeeResp;
}
}
}
if (!class_exists('EmployeesRestEndPoint')) {
class EmployeesRestEndPoint extends RestEndPoint{
public function get($parameter){
$accessTokenValidation = $this->validateAccessToken();
if($accessTokenValidation->getStatus() == IceResponse::ERROR){
return $accessTokenValidation;
}
$emp = new Employee();
$emps = $emp->Find("1=1");
$newEmps = array();
foreach($emps as $emp){
$newEmps[] = Employee::cleanEmployeeData($emp);
}
return new IceResponse(IceResponse::SUCCESS, $newEmps);
}
}
}

View File

@@ -0,0 +1,248 @@
<div class="row">
<div class="col-xs-12 col-md-2">
<div class="row-fluid">
<div class="col-xs-12" style="text-align: center;">
<img id="profile_image__id_" src="" class="img-polaroid img-thumbnail" style="max-width: 140px;max-height: 140px;">
</div>
</div>
</div>
<div class="col-xs-12 col-md-10">
<div class="row-fluid">
<div class="col-md-12"><h2 id="name"></h2></div>
</div>
<div class="row-fluid">
<div class="col-md-12">
<p>
<i class="fa fa-phone"></i> <span id="mobile_phone"></span>&nbsp;&nbsp;
<i class="fa fa-envelope"></i> <span id="work_email"></span>
</p>
</div>
</div>
<div class="row-fluid">
<div class="col-xs-12" style="font-size:18px;border-bottom: 1px solid #DDD;margin-bottom: 10px;padding-bottom: 10px;">
<button id="employeeProfileEditInfo" class="btn btn-small btn-success" onclick="modJs.edit(_id_);" style="margin-right:10px;"><i class="fa fa-edit"></i> 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-small btn-primary" type="button" style="margin-right:10px;"><i class="fa fa-upload"></i> Upload Profile Image</button>
<button id="employeeDeleteProfileImage" onclick="modJs.deleteProfileImage(_id_);return false;" class="btn btn-small btn-warning" type="button" style="margin-right:10px;"><i class="fa fa-times"></i> Delete Profile Image</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;">#_label_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;">#_label_nic_num_#</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;">#_label_ssn_num_#</label>
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="ssn_num"></label>
</div>
</div>
</div>
</div>
<ul class="nav nav-tabs" id="subModTab" style="margin-bottom:0px;margin-left:5px;border-bottom: none;">
<li class="active"><a id="tabBasic" href="#tabPageBasic">Basic Information</a></li>
<li class=""><a id="tabQualifications" href="#tabPageQualifications">Qualifications</a></li>
<li class=""><a id="tabDocuments" href="#tabPageDocuments">Documents</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tabPageBasic" style="border:1px solid #DDD;">
<div class="row" style="margin-left:10px;margin-top:20px;">
<div class="panel panel-default" style="width:97.5%;">
<div class="panel-heading"><h4>Personal Information</h4></div>
<div class="panel-body">
<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;">#_label_driving_license_#</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;">#_label_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;">#_label_birthday_#</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;">#_label_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;">#_label_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;">#_label_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;">#_label_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>
<div class="row" style="margin-left:10px;margin-top:20px;">
<div class="panel panel-default" style="width:97.5%;">
<div class="panel-heading"><h4>Contact Information</h4></div>
<div class="panel-body">
<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;">#_label_address1_#</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;">#_label_address2_#</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;">#_label_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;">#_label_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;">#_label_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;">#_label_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;">#_label_work_phone_#</label>
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="work_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;">#_label_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>
<div class="row" style="margin-left:10px;margin-top:20px;">
<div class="panel panel-default" style="width:97.5%;">
<div class="panel-heading"><h4>Job Details</h4></div>
<div class="panel-body">
<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;">#_label_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;">#_label_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;">#_label_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;">Direct Reports</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;">#_label_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>
<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>
</div><!-- End tabPageBasic -->
<div class="tab-pane" id="tabPageQualifications" style="border:1px solid #DDD;">
<div class="row" style="margin-top:20px;">
<div class="col-md-3">
<div id="EmployeeSkillSubTab" class="" data-content="List" style="padding-left:5px;">
</div>
</div>
<div class="col-md-3">
<div id="EmployeeEducationSubTab" class="" data-content="List" style="padding-left:5px;">
</div>
</div>
<div class="col-md-3">
<div id="EmployeeCertificationSubTab" class="" data-content="List" style="padding-left:5px;">
</div>
</div>
<div class="col-md-3">
<div id="EmployeeLanguageSubTab" class="" data-content="List" style="padding-left:5px;">
</div>
</div>
</div><!-- End tabPageQualifications -->
</div>
<div class="tab-pane" id="tabPageDocuments" style="border:1px solid #DDD;">
<div class="row" style="margin-top:20px;">
<div class="col-md-12">
<div id="EmployeeDocumentSubTab" class="" data-content="List" style="padding-left:5px;">
</div>
</div>
</div><!-- End tabPageQualifications -->
</div>
</div><!-- End tab-content -->

View File

@@ -0,0 +1,108 @@
ALTER TABLE Employees ADD COLUMN `status` enum('Active','Terminated') default 'Active';
create table `ArchivedEmployees` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`ref_id` bigint(20) NOT NULL,
`employee_id` varchar(50) default null,
`first_name` varchar(100) default '' not null,
`last_name` varchar(100) default '' not null,
`gender` enum('Male','Female') default NULL,
`ssn_num` varchar(100) default '',
`nic_num` varchar(100) default '',
`other_id` varchar(100) default '',
`work_email` varchar(100) default null,
`joined_date` DATETIME default '0000-00-00 00:00:00',
`confirmation_date` DATETIME default '0000-00-00 00:00:00',
`supervisor` bigint(20) default null,
`department` bigint(20) default null,
`termination_date` DATETIME default '0000-00-00 00:00:00',
`notes` text default null,
`data` longtext default null,
primary key (`id`)
) engine=innodb default charset=utf8;
create table `FieldNameMappings` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`type` varchar(20) NOT NULL,
`name` varchar(20) NOT NULL,
`textOrig` varchar(200) default null,
`textMapped` varchar(200) default null,
`display` enum('Form','Table and Form','Hidden') default 'Form',
`created` DATETIME default '0000-00-00 00:00:00',
`updated` DATETIME default '0000-00-00 00:00:00',
primary key (`id`)
) engine=innodb default charset=utf8;
INSERT INTO `FieldNameMappings` (`type`, `name`, `textOrig`, `textMapped`, `display`) VALUES
('Employee', 'employee_id', 'Employee Number', 'Employee Number', 'Table and Form'),
('Employee', 'first_name', 'First Name', 'First Name', 'Table and Form'),
('Employee', 'middle_name', 'Middle Name', 'Middle Name', 'Form'),
('Employee', 'last_name', 'Last Name', 'Last Name', 'Table and Form'),
('Employee', 'nationality', 'Nationality', 'Nationality', 'Form'),
('Employee', 'birthday', 'Date of Birth', 'Date of Birth', 'Form'),
('Employee', 'gender', 'Gender', 'Gender', 'Form'),
('Employee', 'marital_status', 'Marital Status', 'Marital Status', 'Form'),
('Employee', 'ssn_num', 'SSN/NRIC', 'SSN/NRIC', 'Form'),
('Employee', 'nic_num', 'NIC', 'NIC', 'Form'),
('Employee', 'other_id', 'Other ID', 'Other ID', 'Form'),
('Employee', 'driving_license', 'Driving License No', 'Driving License No', 'Form'),
('Employee', 'employment_status', 'Employment Status', 'Employment Status', 'Form'),
('Employee', 'job_title', 'Job Title', 'Job Title', 'Form'),
('Employee', 'pay_grade', 'Pay Grade', 'Pay Grade', 'Form'),
('Employee', 'work_station_id', 'Work Station Id', 'Work Station Id', 'Form'),
('Employee', 'address1', 'Address Line 1', 'Address Line 1', 'Form'),
('Employee', 'address2', 'Address Line 2', 'Address Line 2', 'Form'),
('Employee', 'city', 'City', 'City', 'Form'),
('Employee', 'country', 'Country', 'Country', 'Form'),
('Employee', 'province', 'Province', 'Province', 'Form'),
('Employee', 'postal_code', 'Postal/Zip Code', 'Postal/Zip Code', 'Form'),
('Employee', 'home_phone', 'Home Phone', 'Home Phone', 'Form'),
('Employee', 'mobile_phone', 'Mobile Phone', 'Mobile Phone', 'Table and Form'),
('Employee', 'work_phone', 'Work Phone', 'Work Phone', 'Form'),
('Employee', 'work_email', 'Work Email', 'Work Email', 'Form'),
('Employee', 'private_email', 'Private Email', 'Private Email', 'Form'),
('Employee', 'joined_date', 'Joined Date', 'Joined Date', 'Form'),
('Employee', 'confirmation_date', 'Confirmation Date', 'Confirmation Date', 'Form'),
('Employee', 'termination_date', 'Termination Date', 'Termination Date', 'Form'),
('Employee', 'supervisor', 'Supervisor', 'Supervisor', 'Table and Form'),
('Employee', 'department', 'Department', 'Department', 'Table and Form'),
('Employee', 'notes', 'Notes', 'Notes', 'Form');
create table `CustomFields` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`type` varchar(20) NOT NULL,
`name` varchar(20) NOT NULL,
`data` text default null,
`display` enum('Form','Table and Form','Hidden') default 'Form',
`created` DATETIME default '0000-00-00 00:00:00',
`updated` DATETIME default '0000-00-00 00:00:00',
primary key (`id`)
) engine=innodb default charset=utf8;
INSERT INTO `CustomFields` (`type`, `name`, `data`,`display`) VALUES
('Employee', 'custom1', '', 'Hidden'),
('Employee', 'custom2', '', 'Hidden'),
('Employee', 'custom3', '', 'Hidden'),
('Employee', 'custom4', '', 'Hidden'),
('Employee', 'custom5', '', 'Hidden'),
('Employee', 'custom6', '', 'Hidden'),
('Employee', 'custom7', '', 'Hidden'),
('Employee', 'custom8', '', 'Hidden'),
('Employee', 'custom9', '', 'Hidden'),
('Employee', 'custom10', '', 'Hidden');
Alter table `Employees` MODIFY COLUMN `middle_name` varchar(100) default null;
Alter table `Employees` MODIFY COLUMN `last_name` varchar(100) default null;
Alter table `Employees` MODIFY COLUMN `ssn_num` varchar(100) default NULL;
Alter table `Employees` MODIFY COLUMN `nic_num` varchar(100) default NULL;
Alter table `Employees` MODIFY COLUMN `other_id` varchar(100) default NULL;
Alter table `Employees` MODIFY COLUMN `driving_license` varchar(100) default NULL;
Alter table `Employees` MODIFY COLUMN `work_station_id` varchar(100) default NULL;
Alter table `Employees` MODIFY COLUMN `address1` varchar(100) default NULL;
Alter table `Employees` MODIFY COLUMN `address2` varchar(100) default NULL;
Alter table `Employees` MODIFY COLUMN `city` varchar(150) default NULL;

View File

@@ -4,10 +4,41 @@ $moduleName = 'employees';
define('MODULE_PATH',dirname(__FILE__));
include APP_BASE_PATH.'header.php';
include APP_BASE_PATH.'modulejslibs.inc.php';
$fieldNameMap = BaseService::getInstance()->getFieldNameMappings("Employee");
$customFields = BaseService::getInstance()->getCustomFields("Employee");
?><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">Employees</a></li>
<?php if($user->user_level != "Admin"){
?>
<li class="active"><a id="tabEmployee" href="#tabPageEmployee">Employees (Direct Reports)</a></li>
<?php }else{ ?>
<li class="active"><a id="tabEmployee" href="#tabPageEmployee">Employees</a></li>
<?php }?>
<?php if($user->user_level == "Admin"){
?>
<li><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>
<li><a id="tabEmployeeDependent" href="#tabPageEmployeeDependent">Dependents</a></li>
<li><a id="tabEmergencyContact" href="#tabPageEmergencyContact">Emergency Contacts</a></li>
<?php if (!class_exists('DocumentsAdminManager')) {?>
<li><a id="tabEmployeeDocument" href="#tabPageEmployeeDocument">Documents</a></li>
<?php } ?>
<?php }?>
<?php if($user->user_level == "Admin"){
?>
<li class="dropdown">
<a href="#" id="terminatedEmployeeMenu" class="dropdown-toggle" data-toggle="dropdown" aria-controls="terminatedEmployeeMenu-contents">Suspended Employees <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu" aria-labelledby="terminatedEmployeeMenu" id="terminatedEmployeeMenu-contents">
<li><a id="tabTerminatedEmployee" href="#tabPageTerminatedEmployee">Temporarily Suspended Employees</a></li>
<li><a id="tabArchivedEmployee" href="#tabPageArchivedEmployee">Terminated Employee Data</a></li>
</ul>
</li>
<?php }?>
</ul>
<div class="tab-content">
@@ -19,16 +50,161 @@ include APP_BASE_PATH.'modulejslibs.inc.php';
</div>
</div>
<div class="tab-pane" 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 class="tab-pane" 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 class="tab-pane" 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 class="tab-pane" id="tabPageArchivedEmployee">
<div id="ArchivedEmployee" class="reviewBlock" data-content="List" style="padding-left:5px;">
</div>
<div id="ArchivedEmployeeForm" class="reviewBlock" data-content="Form" style="padding-left:5px;display:none;">
</div>
</div>
<div class="tab-pane" id="tabPageTerminatedEmployee">
<div id="TerminatedEmployee" class="reviewBlock" data-content="List" style="padding-left:5px;">
</div>
<div id="TerminatedEmployeeForm" class="reviewBlock" data-content="Form" style="padding-left:5px;display:none;">
</div>
</div>
<?php if (!class_exists('DocumentsAdminManager')) {?>
<div class="tab-pane" 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>
<?php } ?>
</div>
</div>
<script>
var modJsList = new Array();
modJsList['tabEmployee'] = new EmployeeAdapter('Employee');
<?php if($user->user_level != "Admin"){
?>
modJsList['tabEmployee'] = new EmployeeAdapter('Employee','Employee',{"status":"Active", "supervisor":"__myid__"});
modJsList['tabEmployee'].setShowAddNew(false);
<?php
}else{
?>
modJsList['tabEmployee'] = new EmployeeAdapter('Employee','Employee',{"status":"Active"});
<?php
}
?>
modJsList['tabEmployee'].setRemoteTable(true);
modJsList['tabEmployee'].setFieldNameMap(<?=json_encode($fieldNameMap)?>);
modJsList['tabEmployee'].setCustomFields(<?=json_encode($customFields)?>);
modJsList['tabEmployeeSkill'] = new EmployeeSkillAdapter('EmployeeSkill');
modJsList['tabEmployeeSkill'].setRemoteTable(true);
modJsList['tabEmployeeEducation'] = new EmployeeEducationAdapter('EmployeeEducation');
modJsList['tabEmployeeEducation'].setRemoteTable(true);
modJsList['tabEmployeeCertification'] = new EmployeeCertificationAdapter('EmployeeCertification');
modJsList['tabEmployeeCertification'].setRemoteTable(true);
modJsList['tabEmployeeLanguage'] = new EmployeeLanguageAdapter('EmployeeLanguage');
modJsList['tabEmployeeLanguage'].setRemoteTable(true);
modJsList['tabEmployeeDependent'] = new EmployeeDependentAdapter('EmployeeDependent');
modJsList['tabEmployeeDependent'].setRemoteTable(true);
modJsList['tabEmergencyContact'] = new EmergencyContactAdapter('EmergencyContact');
modJsList['tabEmergencyContact'].setRemoteTable(true);
modJsList['tabEmployeeImmigration'] = new EmployeeImmigrationAdapter('EmployeeImmigration');
modJsList['tabEmployeeImmigration'].setRemoteTable(true);
modJsList['tabArchivedEmployee'] = new ArchivedEmployeeAdapter('ArchivedEmployee');
modJsList['tabArchivedEmployee'].setRemoteTable(true);
modJsList['tabArchivedEmployee'].setShowAddNew(false);
modJsList['tabTerminatedEmployee'] = new TerminatedEmployeeAdapter('Employee','TerminatedEmployee',{"status":"Terminated"});
modJsList['tabTerminatedEmployee'].setRemoteTable(true);
modJsList['tabTerminatedEmployee'].setShowAddNew(false);
<?php if (!class_exists('DocumentsAdminManager')) {?>
modJsList['tabEmployeeDocument'] = new EmployeeDocumentAdapter('EmployeeDocument','EmployeeDocument');
modJsList['tabTerminatedEmployee'].setRemoteTable(true);
<?php } ?>
var modJs = modJsList['tabEmployee'];
</script>
<div class="modal" id="createUserModel" 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;">Employee Saved Successfully</h3>
</div>
<div class="modal-body">
Employee needs a User to login to IceHrm. Do you want to create a user for this employee now? <br/><br/>You can do this later through Users module if required.
</div>
<div class="modal-footer">
<button class="btn btn-primary" onclick="modJs.createUser();">Yes</button>
<button class="btn" onclick="modJs.closeCreateUser();">No</button>
</div>
</div>
</div>
</div>
<?php include APP_BASE_PATH.'footer.php';?>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,57 @@
<?php
if (!class_exists('FieldnamesAdminManager')) {
class FieldnamesAdminManager extends AbstractModuleManager{
public function initializeUserClasses(){
}
public function initializeFieldMappings(){
}
public function initializeDatabaseErrorMappings(){
}
public function setupModuleClassDefinitions(){
$this->addModelClass('FieldNameMapping');
$this->addModelClass('CustomField');
}
}
}
if (!class_exists('FieldNameMapping')) {
class FieldNameMapping extends ICEHRM_Record {
var $_table = 'FieldNameMappings';
public function getAdminAccess(){
return array("get","element","save","delete");
}
public function getUserAccess(){
return array();
}
public function getAnonymousAccess(){
return array("get","element");
}
}
}
if (!class_exists('CustomField')) {
class CustomField extends ICEHRM_Record {
var $_table = 'CustomFields';
public function getAdminAccess(){
return array("get","element","save","delete");
}
public function getUserAccess(){
return array();
}
public function getAnonymousAccess(){
return array("get","element");
}
}
}

View File

@@ -0,0 +1,62 @@
<?php
/*
This file is part of Ice Framework.
------------------------------------------------------------------
Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd]
Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah)
*/
$moduleName = 'fieldnames';
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="dropdown">
<a href="#" id="settingsEmployeeMenu" class="dropdown-toggle" data-toggle="dropdown" aria-controls="settingsEmployeeMenu-contents">Employee Fields <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu" aria-labelledby="settingsEmployeeMenu" id="settingsEmployeeMenu-contents">
<li><a id="tabEmployeeFieldName" href="#tabPageEmployeeFieldName">Employee Field Name Mapping</a></li>
<li><a id="tabEmployeeCustomField" href="#tabPageEmployeeCustomField">Employee Custom Fields</a></li>
</ul>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tabPageEmployeeFieldName">
<div id="EmployeeFieldName" class="reviewBlock" data-content="List" style="padding-left:5px;">
</div>
<div id="EmployeeFieldNameForm" class="reviewBlock" data-content="Form" style="padding-left:5px;display:none;">
</div>
</div>
<div class="tab-pane" id="tabPageEmployeeCustomField">
<div id="EmployeeCustomField" class="reviewBlock" data-content="List" style="padding-left:5px;">
</div>
<div id="EmployeeCustomFieldForm" class="reviewBlock" data-content="Form" style="padding-left:5px;display:none;">
</div>
</div>
</div>
</div>
<script>
var modJsList = new Array();
modJsList['tabEmployeeFieldName'] = new FieldNameAdapter('FieldNameMapping','EmployeeFieldName',{"type":"Employee"});
modJsList['tabEmployeeFieldName'].setRemoteTable(true);
modJsList['tabEmployeeFieldName'].setShowAddNew(false);
modJsList['tabEmployeeCustomField'] = new CustomFieldAdapter('CustomField','EmployeeCustomField',{"type":"Employee"});
modJsList['tabEmployeeCustomField'].setRemoteTable(true);
modJsList['tabEmployeeCustomField'].setShowAddNew(false);
var modJs = modJsList['tabEmployeeFieldName'];
</script>
<?php include APP_BASE_PATH.'footer.php';?>

View File

@@ -0,0 +1,86 @@
/**
* Author: Thilina Hasantha
*/
/**
* FieldNameAdapter
*/
function FieldNameAdapter(endPoint,tab,filter,orderBy) {
this.initAdapter(endPoint,tab,filter,orderBy);
}
FieldNameAdapter.inherits(AdapterBase);
FieldNameAdapter.method('getDataMapping', function() {
return [
"id",
"name",
"textOrig",
"textMapped",
"display"
];
});
FieldNameAdapter.method('getHeaders', function() {
return [
{ "sTitle": "ID" ,"bVisible":false},
{ "sTitle": "Name" },
{ "sTitle": "Original Text"},
{ "sTitle": "Mapped Text"},
{ "sTitle": "Display Status"}
];
});
FieldNameAdapter.method('getFormFields', function() {
return [
[ "id", {"label":"ID","type":"hidden"}],
[ "type", {"label":"Type","type":"placeholder","validation":""}],
[ "name", {"label":"Name","type":"placeholder","validation":""}],
[ "textOrig", {"label":"Original Text","type":"placeholder","validation":""}],
[ "textMapped", {"label":"Mapped Text","type":"text","validation":""}],
[ "display", {"label":"Display Status","type":"select","source":[["Form","Form"],["Table and Form","Table and Form"],["Hidden","Hidden"]]}]
];
});
/*
*
*/
function CustomFieldAdapter(endPoint,tab,filter,orderBy) {
this.initAdapter(endPoint,tab,filter,orderBy);
}
CustomFieldAdapter.inherits(AdapterBase);
CustomFieldAdapter.method('getDataMapping', function() {
return [
"id",
"name",
"display"
];
});
CustomFieldAdapter.method('getHeaders', function() {
return [
{ "sTitle": "ID" ,"bVisible":false},
{ "sTitle": "Name" },
{ "sTitle": "Display Status"}
];
});
CustomFieldAdapter.method('getFormFields', function() {
return [
[ "id", {"label":"ID","type":"hidden"}],
[ "type", {"label":"Type","type":"placeholder","validation":""}],
[ "name", {"label":"Name","type":"placeholder","validation":""}],
[ "data", {"label":"Data","type":"textarea","validation":""}],
[ "display", {"label":"Display Status","type":"select","source":[["Form","Form"],["Table and Form","Table and Form"],["Hidden","Hidden"]]}]
];
});

View File

@@ -0,0 +1,11 @@
{
"label":"Field Names Setup",
"menu":"System",
"order":"7",
"icon":"fa-sort-alpha-asc",
"user_levels":["Admin"],
"permissions":
{
}
}

View File

@@ -3,5 +3,5 @@
"Employees":"fa-users",
"Reports":"fa-file-text",
"System":"fa-cogs",
"Salary Details":"fa-money"
"Payroll":"fa-money"
}

View File

@@ -22,6 +22,7 @@ if (!class_exists('MetadataAdminManager')) {
$this->addModelClass('Nationality');
$this->addModelClass('ImmigrationStatus');
$this->addModelClass('Ethnicity');
$this->addModelClass('CalculationHook');
}
}
@@ -42,6 +43,20 @@ if (!class_exists('Country')) {
public function getAnonymousAccess(){
return array("get","element");
}
function Find($whereOrderBy,$bindarr=false,$pkeysArr=false,$extra=array()){
$allowedCountriesStr = SettingsManager::getInstance()->getSetting('System: Allowed Countries');
$allowedCountries = array();
if(!empty($allowedCountriesStr)){
$allowedCountries = json_decode($allowedCountriesStr,true);
}
if(!empty($allowedCountries)){
return parent::Find("id in (".implode(",",$allowedCountries).")" , array());
}
return parent::Find($whereOrderBy, $bindarr, $pkeysArr, $extra);
}
}
}
@@ -79,6 +94,20 @@ if (!class_exists('CurrencyType')) {
public function getAnonymousAccess(){
return array("get","element");
}
function Find($whereOrderBy,$bindarr=false,$pkeysArr=false,$extra=array()){
$allowedCountriesStr = SettingsManager::getInstance()->getSetting('System: Allowed Currencies');
$allowedCountries = array();
if(!empty($allowedCountriesStr)){
$allowedCountries = json_decode($allowedCountriesStr,true);
}
if(!empty($allowedCountries)){
return parent::Find("id in (".implode(",",$allowedCountries).")" , array());
}
return parent::Find($whereOrderBy, $bindarr, $pkeysArr, $extra);
}
}
}
@@ -98,6 +127,22 @@ if (!class_exists('Nationality')) {
public function getAnonymousAccess(){
return array("get","element");
}
function Find($whereOrderBy,$bindarr=false,$pkeysArr=false,$extra=array()){
$allowedCountriesStr = SettingsManager::getInstance()->getSetting('System: Allowed Nationality');
$allowedCountries = array();
if(!empty($allowedCountriesStr)){
$allowedCountries = json_decode($allowedCountriesStr,true);
}
if(!empty($allowedCountries)){
return parent::Find("id in (".implode(",",$allowedCountries).")" , array());
}
return parent::Find($whereOrderBy, $bindarr, $pkeysArr, $extra);
}
}
}
@@ -139,6 +184,32 @@ if (!class_exists('Ethnicity')) {
}
}
if (!class_exists('CalculationHook')) {
class CalculationHook extends ICEHRM_Record {
var $_table = 'CalculationHooks';
public function getAdminAccess(){
return array("get","element","save","delete");
}
public function getUserAccess(){
return array();
}
public function getAnonymousAccess(){
return array("get","element");
}
function Find($whereOrderBy,$bindarr=false,$pkeysArr=false,$extra=array()){
return BaseService::getInstance()->getCalculationHooks();
}
function Load($where=null,$bindarr=false){
return BaseService::getInstance()->getCalculationHook($bindarr[0]);
}
}
}

View File

@@ -32,7 +32,6 @@ $moduleBuilder->addModuleOrGroup(new ModuleTab('Country','Country','Countries','
$moduleBuilder->addModuleOrGroup(new ModuleTab('Province','Province','Provinces','ProvinceAdapter','',''));
$moduleBuilder->addModuleOrGroup(new ModuleTab('CurrencyType','CurrencyType','Currency Types','CurrencyTypeAdapter','',''));
$moduleBuilder->addModuleOrGroup(new ModuleTab('Nationality','Nationality','Nationality','NationalityAdapter','',''));
$moduleBuilder->addModuleOrGroup(new ModuleTab('Nationality','Nationality','Nationality','NationalityAdapter','',''));
$moduleBuilder->addModuleOrGroup(new ModuleTab('Ethnicity','Ethnicity','Ethnicity','EthnicityAdapter','',''));
$moduleBuilder->addModuleOrGroup(new ModuleTab('ImmigrationStatus','ImmigrationStatus','Immigration Status','ImmigrationStatusAdapter','',''));

View File

@@ -46,9 +46,9 @@ include APP_BASE_PATH.'modulejslibs.inc.php';
<script>
var modJsList = new Array();
modJsList['moduleModule'] = new ModuleAdapter('Module','Module');
modJsList['moduleModule'].setShowAddNew(false);
var modJs = modJsList['moduleModule'];
modJsList['tabModule'] = new ModuleAdapter('Module','Module');
modJsList['tabModule'].setShowAddNew(false);
var modJs = modJsList['tabModule'];
</script>
<?php include APP_BASE_PATH.'footer.php';?>

View File

@@ -58,7 +58,7 @@ ModuleAdapter.method('getActionButtonsHtml', function(id,data) {
var nonEditableFields = {};
nonEditableFields["admin_Company Structure"] = 1;
nonEditableFields["admin_Employees"] = 1;
nonEditableFields["admin_Jobs"] = 1;
nonEditableFields["admin_Job Details Setup"] = 1;
nonEditableFields["admin_Leaves"] = 1;
nonEditableFields["admin_Manage Modules"] = 1;
nonEditableFields["admin_Projects"] = 1;
@@ -66,9 +66,10 @@ ModuleAdapter.method('getActionButtonsHtml', function(id,data) {
nonEditableFields["admin_Settings"] = 1;
nonEditableFields["admin_Users"] = 1;
nonEditableFields["admin_Upgrade"] = 1;
nonEditableFields["admin_Upgrade"] = 1;
nonEditableFields["admin_Dashboard"] = 1;
nonEditableFields["user_Basic Information"] = 1;
nonEditableFields["user_Dashboard"] = 1;
if(nonEditableFields[data[3]+"_"+data[1]] == 1){
return "";

View File

@@ -1,11 +0,0 @@
{
"label":"Setup",
"menu":"Salary Details",
"order":"6",
"icon":"fa-cogs",
"user_levels":["Admin"],
"permissions":
{
}
}

View File

@@ -33,32 +33,48 @@ from EmployeeLeaves lv";
$employeeList = array();
}
if($request['department'] != "NULL" && empty($employeeList)){
$empTmp = new Employee();
$empTemps = $empTmp->Find("department = ? and status = Active",array($request['department']));
foreach($empTemps as $empTmp){
$employeeList[] = $empTmp->id;
}
}
if(!empty($employeeList) && ($request['status'] != "NULL" && !empty($request['status']))){
$query = "where employee in (".implode(",", $employeeList).") and date_start >= ? and date_end <= ? and status = ?;";
$query = "where employee in (".implode(",", $employeeList).") and ((date_start >= ? and date_start <= ?) or (date_end >= ? and date_end <= ?)) and status = ?;";
$params = array(
$request['date_start'],
$request['date_end'],
$request['date_start'],
$request['date_end'],
$request['status']
);
}else if(!empty($employeeList)){
$query = "where employee in (".implode(",", $employeeList).") and date_start >= ? and date_end <= ?;";
$query = "where employee in (".implode(",", $employeeList).") and ((date_start >= ? and date_start <= ?) or (date_end >= ? and date_end <= ?));";
$params = array(
$request['date_start'],
$request['date_end'],
$request['date_start'],
$request['date_end']
);
}else if(($request['status'] != "NULL" && !empty($request['status']))){
$query = "where status = ? and date_start >= ? and date_end <= ?;";
$query = "where status = ? and ((date_start >= ? and date_start <= ?) or (date_end >= ? and date_end <= ?));";
$params = array(
$request['status'],
$request['date_start'],
$request['date_end']
$request['date_end'],
$request['date_start'],
$request['date_end']
);
}else{
$query = "where date_start >= ? and date_end <= ?;";
$query = "where ((date_start >= ? and date_start <= ?) or (date_end >= ? and date_end <= ?));";
$params = array(
$request['date_start'],
$request['date_end']
$request['date_end'],
$request['date_start'],
$request['date_end']
);
}

View File

@@ -0,0 +1,44 @@
ICEHRM END USER LICENSE AGREEMENT
NOTICE TO ALL USERS: BY PURCHASING THE MODULE, YOU (EITHER AN INDIVIDUAL OR A SINGLE ENTITY) CONSENT TO BE BOUND BY AND BECOME A PARTY TO THIS AGREEMENT.
All references to "Software" herein shall be deemed to include the software license with which you will be provided by Gamonoid Media Pvt Ltd, as part of the Software.
1. LICENSE GRANT. Subject to the payment of the applicable licence fees, and subject to the terms and conditions of this Agreement, ICEHRM hereby grants to you a non-exclusive, non-transferable right to use one copy of the specified version of the Software and the accompanying documentation (the "Documentation") for the term of this Agreement solely for your own internal business purposes. You may install one copy of the Software for production use.
.
2. USE. The Software is licensed as a single product; it may not be used on more than one ICEHRM Server at a time. The Software is "in use" on a Server when its installed on a Server. You shall not, nor permit any third party to copy (other than as expressly permitted herein). You shall not rent, lease or lend the Software to any other person, nor transfer or sub-licence your licence rights to any other person.
3. TERM. This Agreement is effective until terminated as set forth herein. This Agreement will terminate automatically if you fail to comply with any of the conditions, limitations or other requirements described herein. Upon any termination of this Agreement, you must immediately destroy all copies of the Software and the Documentation. You may terminate this Agreement at any point by destroying all copies of the Software and the Documentation.
4. SUPPORT. Gamonoid Media Pvt Ltd will provide you support according to the support agreement subscribed by the company.
5. OWNERSHIP RIGHTS. The Software is protected by copyright laws. ICEHRM and Gamonoid Media Pvt Ltd own and retain all right, title and interest in and to the Software, including all copyrights, patents, trademarks and other intellectual property rights therein. Your possession, installation, or use of the Software does not transfer to you any title to the intellectual property in the Software, and you will not acquire any rights to the Software except as expressly set forth in this Agreement.
6. LIMITED WARRANTY. You may not rent, lease, loan or resell the Software. You may not permit third parties to benefit from the use or functionality of the Software via a timesharing, service bureau or other arrangement, except to the extent such use is specified in the applicable list price or product packaging for the Software. You may not transfer any of the rights granted to you under this Agreement. You may not modify, or create derivative works based upon, the Software in whole or in part. You may not copy the Software or Documentation except as expressly permitted in Section 1 above. You may not remove any proprietary notices or labels on the Software. All rights not expressly set forth hereunder are reserved by ICEHRM. ICEHRM reserves the right to periodically conduct audits upon advance written notice to verify compliance with the terms of this Agreement.
7. WARRANTY and DISCLAIMER.
(i) Gamonoid Media Pvt Ltd. warrants that for 30 days from first download or installation the Software will perform substantially in accordance with the functionality described in the Documentation (http://blog.icehrm.com) when operated properly and in the manner specified in the Documentation.
(ii) You accept all responsibility for the selection of this Software to meet your requirements.
(iii) Gamonoid Media Pvt Ltd. does not warrant that the Software and/or the Documentation will be suitable for such requirements nor that any use will be uninterrupted and error free.
(iv) The warranty in (i) shall not apply if you (a) make or cause to be made any modifications to this Software, (b) use the Software in a manner for which it was not intended or (c) use the Software other than as permitted under this Agreement.
(vii) The warranties and conditions stated in this Agreement are in lieu of all other conditions, warranties or other terms concerning the supply or purported supply of, failure to supply or delay in supplying the Software or the Documentation which might but for this paragraph (vii) have effect between the ICEHRM and you or would otherwise be implied into or incorporated into this Agreement or any collateral contract, whether by statute, common law or otherwise, all of which are hereby excluded (including, without limitation, the implied conditions, warranties or other terms as to satisfactory quality, fitness for purpose or as to the use of reasonable skill and care).
8. LIMITATION of LIABILITY. Gamonoid Media Pvt Ltd. shall have no liability (whether in contract, tort, restitution or otherwise) for any of the following losses or damage (whether such losses or damage were foreseen, foreseeable, known or otherwise):
- Loss of revenue;
- Loss of actual or anticipated profits (including for loss of profits on contracts);
- Loss of the use of money;
- Loss of anticipated savings;
- Loss of business;
- Loss of opportunity;
- Loss of goodwill;
- Loss of reputation;
- Loss of, damage to or corruption of data;
or
Any indirect or consequential loss or damage howsoever caused (including, for the avoidance of doubt, where such loss or damage is of the type specified in paragraph (ii), (a) to (ii), (i).
The ICEHRM liability (whether in contract, tort, restitution or otherwise) arising out of or in connection with the supply of the Software shall in no circumstances exceed a sum equal to the amount equally paid by you for the Software.
The construction and interpretation of this Agreement shall be governed in accordance with the laws of Sri Lanka. The parties hereby submit to the jurisdiction of the courts of Sri Lanka save that ICEHRM as claimant shall be entitled to initiate proceedings in any court of competent jurisdiction.
This Agreement contains the entire understanding of the parties with respect to the subject matter hereof and supersedes all and any prior understandings, undertakings and promises between you and ICEHRM, whether oral or in writing, which have been given or may be implied from anything written or said in negotiations between us or our representatives prior to this Agreement and all prior agreements between the parties relating to the matters aforesaid shall cease to have effect as from the Effective Date.

View File

@@ -0,0 +1,7 @@
This module is licensed under IceHrm Commercial License, which can be found in LICENSE.txt.
You are allowed to make any modification required to these module, but only allowed to use
the module in one production server (even with modifications).
Installation
------------
Copy this module into <icehrm path>/admin/ directory

View File

@@ -1,6 +1,6 @@
<?php
if (!class_exists('PayrollAdminManager')) {
class PayrollAdminManager extends AbstractModuleManager{
if (!class_exists('SalaryAdminManager')) {
class SalaryAdminManager extends AbstractModuleManager{
public function initializeUserClasses(){
@@ -18,7 +18,6 @@ if (!class_exists('PayrollAdminManager')) {
$this->addModelClass('SalaryComponentType');
$this->addModelClass('SalaryComponent');
$this->addModelClass('Deduction');
}
}
@@ -66,4 +65,31 @@ if (!class_exists('Deduction')) {
}
}
if (!class_exists('DeductionGroup')) {
class DeductionGroup extends ICEHRM_Record {
var $_table = 'DeductionGroup';
public function getAdminAccess(){
return array("get","element","save","delete");
}
public function getUserAccess(){
return array("get","element");
}
}
}
if (!class_exists('PayrollEmployee')) {
class PayrollEmployee extends ICEHRM_Record {
var $_table = 'PayrollEmployees';
public function getAdminAccess(){
return array("get","element","save","delete");
}
public function getUserAccess(){
return array("get","element");
}
}
}

View File

@@ -1,15 +1,18 @@
<?php
$moduleName = 'metadata';
$moduleName = 'salary';
define('MODULE_PATH',dirname(__FILE__));
include APP_BASE_PATH.'header.php';
include APP_BASE_PATH.'modulejslibs.inc.php';
include APP_BASE_PATH.'mod-houlejslibs.inc.php';
$moduleBuilder = new ModuleBuilder();
$moduleBuilder->addModuleOrGroup(new ModuleTab('SalaryComponentType','SalaryComponentType','Salary Component Types','SalaryComponentTypeAdapter','','',true));
$moduleBuilder->addModuleOrGroup(new ModuleTab('SalaryComponent','SalaryComponent','Salary Components','SalaryComponentAdapter','',''));
$moduleBuilder->addModuleOrGroup(new ModuleTab('EmployeeSalary','EmployeeSalary','Employee Salary','EmployeeSalaryAdapter','','',false,array("setRemoteTable"=>"true")));
$moduleBuilder->addModuleOrGroup(new ModuleTab('DeductionGroup','DeductionGroup','Calculation Groups','DeductionGroupAdapter','',''));
$moduleBuilder->addModuleOrGroup(new ModuleTab('Deduction','Deduction','Calculation Methods','DeductionAdapter','',''));
$moduleBuilder->addModuleOrGroup(new ModuleTab('EmployeeSalary','EmployeeSalary','Employee Salary Components','EmployeeSalaryAdapter','','',false,array("setRemoteTable"=>"true")));
echo UIManager::getInstance()->renderModule($moduleBuilder);

View File

@@ -2,7 +2,6 @@
* Author: Thilina Hasantha
*/
/**
* SalaryComponentTypeAdapter
*/
@@ -16,27 +15,27 @@ SalaryComponentTypeAdapter.inherits(AdapterBase);
SalaryComponentTypeAdapter.method('getDataMapping', function() {
return [
"id",
"code",
"name"
];
return [
"id",
"code",
"name"
];
});
SalaryComponentTypeAdapter.method('getHeaders', function() {
return [
{ "sTitle": "ID" ,"bVisible":false},
{ "sTitle": "Code" },
{ "sTitle": "Name"}
];
return [
{ "sTitle": "ID" ,"bVisible":false},
{ "sTitle": "Code" },
{ "sTitle": "Name"}
];
});
SalaryComponentTypeAdapter.method('getFormFields', function() {
return [
[ "id", {"label":"ID","type":"hidden"}],
[ "code", {"label":"Code","type":"text","validation":""}],
[ "name", {"label":"Name","type":"text","validation":""}]
];
return [
[ "id", {"label":"ID","type":"hidden"}],
[ "code", {"label":"Code","type":"text","validation":""}],
[ "name", {"label":"Name","type":"text","validation":""}]
];
});
@@ -53,30 +52,30 @@ SalaryComponentAdapter.inherits(AdapterBase);
SalaryComponentAdapter.method('getDataMapping', function() {
return [
"id",
"name",
"componentType",
"details"
];
return [
"id",
"name",
"componentType",
"details"
];
});
SalaryComponentAdapter.method('getHeaders', function() {
return [
{ "sTitle": "ID" ,"bVisible":false},
{ "sTitle": "Name" },
{ "sTitle": "Salary Component Type" },
{ "sTitle": "Details"}
];
return [
{ "sTitle": "ID" ,"bVisible":false},
{ "sTitle": "Name" },
{ "sTitle": "Salary Component Type" },
{ "sTitle": "Details"}
];
});
SalaryComponentAdapter.method('getFormFields', function() {
return [
[ "id", {"label":"ID","type":"hidden"}],
[ "name", {"label":"Name","type":"text","validation":""}],
[ "componentType", {"label":"Salary Component Type","type":"select2","remote-source":["SalaryComponentType","id","name"]}],
[ "details", {"label":"Details","type":"textarea","validation":"none"}]
];
return [
[ "id", {"label":"ID","type":"hidden"}],
[ "name", {"label":"Name","type":"text","validation":""}],
[ "componentType", {"label":"Salary Component Type","type":"select2","remote-source":["SalaryComponentType","id","name"]}],
[ "details", {"label":"Details","type":"textarea","validation":"none"}]
];
});
@@ -96,8 +95,7 @@ DeductionAdapter.method('getDataMapping', function() {
return [
"id",
"name",
"contributor",
"type",
"deduction_group"
];
});
@@ -105,32 +103,52 @@ DeductionAdapter.method('getHeaders', function() {
return [
{ "sTitle": "ID" ,"bVisible":false},
{ "sTitle": "Name" },
{ "sTitle": "Contributor"},
{ "sTitle": "Deduction Type"}
{ "sTitle": "Calculation Group"}
];
});
DeductionAdapter.method('getFormFields', function() {
var rangeAmounts = [ "rangeAmounts", {"label":"Deduction Amounts","type":"datagroup",
var rangeAmounts = [ "rangeAmounts", {"label":"Calculation Process","type":"datagroup",
"form":[
[ "lowerCondition", {"label":"Lower Limit Condition","type":"select","source":[["No Lower Limit","No Lower Limit"],[">","Greater than"],[">=","Greater than or Equal"]]}],
[ "lowerLimit", {"label":"Lower Limit","type":"text","validation":"none"}],
[ "upperCondition", {"label":"Upper Limit Condition","type":"select","source":[["No Upper Limit","No Upper Limit"],["<","Less than"],["<=","Less than or Equal"]]}],
[ "upperLimit", {"label":"Upper Limit","type":"text","validation":"none"}],
[ "amount", {"label":"Value","type":"text","validation":"float"}]
[ "lowerCondition", {"label":"Lower Limit Condition","type":"select","source":[["No Lower Limit","No Lower Limit"],["gt","Greater than"],["gte","Greater than or Equal"]]}],
[ "lowerLimit", {"label":"Lower Limit","type":"text","validation":"float"}],
[ "upperCondition", {"label":"Upper Limit Condition","type":"select","source":[["No Upper Limit","No Upper Limit"],["lt","Less than"],["lte","Less than or Equal"]]}],
[ "upperLimit", {"label":"Upper Limit","type":"text","validation":"float"}],
[ "amount", {"label":"Value","type":"text","validation":""}]
],
"html":'<div id="#_id_#" class="panel panel-default">#_delete_##_edit_#<div class="panel-body">#_renderFunction_#</div></div>',
"validation":"none",
"custom-validate-function":function (data){
var res = {};
res['valid'] = true;
if(lowerCondition != 'No Lower Limit'){
data.lowerLimit = 0;
}
if(upperCondition != 'No Upper Limit'){
data.upperLimit = 0;
}
res['params'] = data;
return res;
},
"render":function(item){
var output = "";
var getSymbol = function(text){
var map = {};
map['gt'] = '>';
map['gte'] = '>=';
map['lt'] = '<';
map['lte'] = '<=';
return map[text];
}
if(item.lowerCondition != "No Lower Limit"){
output += item.lowerLimit + " " + item.lowerCondition + " ";
output += " and ";
output += item.lowerLimit + " " + getSymbol(item.lowerCondition) + " ";
}
if(item.upperCondition != "No Upper Limit"){
output += item.upperCondition + " " + item.upperLimit + " ";
output += " and ";
output += getSymbol(item.upperCondition) + " " + item.upperLimit + " ";
}
if(output == ""){
return "Deduction is "+item.amount + " for all ranges";
@@ -148,17 +166,16 @@ DeductionAdapter.method('getFormFields', function() {
return [
[ "id", {"label":"ID","type":"hidden"}],
[ "name", {"label":"Name","type":"text","validation":""}],
[ "contributor", {"label":"Contributor","type":"select","source":[["Employee","Employee"],["Employer","Employer"]]}],
[ "type", {"label":"Deduction Type","type":"select","source":[["Fixed","Fixed"],["Percentage","Percentage"]]}],
[ "percentage_type", {"label":"Percentage Type","type":"select","source":[["On Component","On Component"],["On Component Type","On Component Type"]]}],
[ "componentType", {"label":"Salary Component Type","type":"select2","allow-null":true,"null-label":"N/A","remote-source":["SalaryComponentType","id","name"]}],
[ "component", {"label":"Salary Component","type":"select2","allow-null":true,"null-label":"N/A","remote-source":["SalaryComponent","id","name"]}],
[ "componentType", {"label":"Salary Component Type","type":"select2multi","allow-null":true,"remote-source":["SalaryComponentType","id","name"]}],
[ "component", {"label":"Salary Component","type":"select2multi","allow-null":true,"remote-source":["SalaryComponent","id","name"]}],
[ "payrollColumn", {"label":"Payroll Report Column","type":"select2","allow-null":true,"remote-source":["PayrollColumn","id","name"]}],
rangeAmounts,
[ "country", {"label":"Country","type":"select2","remote-source":["Country","id","name"]}]
[ "deduction_group", {"label":"Calculation Group","type":"select2","allow-null":true,"null-label":"None","remote-source":["DeductionGroup","id","name"]}]
];
});
/*
DeductionAdapter.method('doCustomValidation', function(params) {
if(params.type == "Fixed"){
return null;
@@ -177,7 +194,8 @@ DeductionAdapter.method('doCustomValidation', function(params) {
return null;
});
*/
/*
DeductionAdapter.method('postRenderForm', function(object, $tempDomObj) {
$tempDomObj.find("#field_componentType").hide();
@@ -213,6 +231,10 @@ DeductionAdapter.method('postRenderForm', function(object, $tempDomObj) {
}
});
});
*/
/*
@@ -232,8 +254,6 @@ EmployeeSalaryAdapter.method('getDataMapping', function() {
"id",
"employee",
"component",
"pay_frequency",
"currency",
"amount",
"details"
];
@@ -244,8 +264,6 @@ EmployeeSalaryAdapter.method('getHeaders', function() {
{ "sTitle": "ID" ,"bVisible":false},
{ "sTitle": "Employee" },
{ "sTitle": "Salary Component" },
{ "sTitle": "Pay Frequency"},
{ "sTitle": "Currency"},
{ "sTitle": "Amount"},
{ "sTitle": "Details"}
];
@@ -256,8 +274,6 @@ EmployeeSalaryAdapter.method('getFormFields', function() {
[ "id", {"label":"ID","type":"hidden"}],
[ "employee", {"label":"Employee","type":"select2","remote-source":["Employee","id","first_name+last_name"]}],
[ "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":"select2","remote-source":["CurrencyType","id","name"]}],
[ "amount", {"label":"Amount","type":"text","validation":"float"}],
[ "details", {"label":"Details","type":"textarea","validation":"none"}]
];
@@ -272,3 +288,43 @@ EmployeeSalaryAdapter.method('getFilters', function() {
/*
* DeductionGroupAdapter
*/
function DeductionGroupAdapter(endPoint,tab,filter,orderBy) {
this.initAdapter(endPoint,tab,filter,orderBy);
}
DeductionGroupAdapter.inherits(AdapterBase);
DeductionGroupAdapter.method('getDataMapping', function() {
return [
"id",
"name",
"description"
];
});
DeductionGroupAdapter.method('getHeaders', function() {
return [
{ "sTitle": "ID" ,"bVisible":false},
{ "sTitle": "Name" },
{ "sTitle": "Details" }
];
});
DeductionGroupAdapter.method('getFormFields', function() {
return [
[ "id", {"label":"ID","type":"hidden"}],
[ "name", {"label":"Name","type":"text","validation":""}],
[ "description", {"label":"Details","type":"textarea","validation":"none"}]
];
});

View File

@@ -0,0 +1,11 @@
{
"label":"Salary",
"menu":"Payroll",
"order":"1",
"icon":"fa-money",
"user_levels":["Admin"],
"permissions":
{
}
}

View File

@@ -30,7 +30,7 @@ class SettingsInitialize extends AbstractInitialize{
$dbUser->Load("id = ?",array($user->id));
$resp = RestApiManager::getInstance()->getAccessTokenForUser($dbUser);
if($resp->getStatus() != IceResponse::SUCCESS){
LogManager::getInstance()->error("Error occured while creating REST Api acces token for ".$user->username);
LogManager::getInstance()->error("Error occurred while creating REST Api access token for ".$user->username);
}
}

View File

@@ -25,37 +25,26 @@ $moduleName = 'settings';
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="tabSetting" href="#tabPageSetting">Settings</a></li>
</ul>
$moduleBuilder = new ModuleBuilder();
<div class="tab-content">
<div class="tab-pane active" id="tabPageSetting">
<div id="Setting" class="reviewBlock" data-content="List" style="padding-left:5px;">
</div>
<div id="SettingForm" class="reviewBlock" data-content="Form" style="padding-left:5px;display:none;">
</div>
</div>
</div>
$options1 = array();
$options1['setShowAddNew'] = 'false';
$moduleBuilder->addModuleOrGroup(new ModuleTab('CompanySetting','Setting','Company','SettingAdapter','{"name":["Company:"]}','name',true,$options1));
$moduleBuilder->addModuleOrGroup(new ModuleTab('SystemSetting','Setting','System','SettingAdapter','{"name":["System:"]}','name',false,$options1));
$moduleBuilder->addModuleOrGroup(new ModuleTab('EmailSetting','Setting','Email','SettingAdapter','{"name":["Email:"]}','name',false,$options1));
$moduleBuilder->addModuleOrGroup(new ModuleTab('LeaveSetting','Setting','Leave / PTO','SettingAdapter','{"name":["Leave:"]}','name',false,$options1));
$moduleBuilder->addModuleOrGroup(new ModuleTab('LDAPSetting','Setting','LDAP','SettingAdapter','{"name":["LDAP:"]}','name',false,$options1));
$moduleBuilder->addModuleOrGroup(new ModuleTab('OtherSetting','Setting','Other','SettingAdapter','{"name":["Projects:","Attendance:","Recruitment:","Notifications:","Expense:","Travel:","Api:"]}','name',false,$options1));
echo UIManager::getInstance()->renderModule($moduleBuilder);
?>
</div>
<script>
var modJsList = new Array();
modJsList['tabSetting'] = new SettingAdapter('Setting','Setting','','name');
modJsList['tabSetting'].setShowAddNew(false);
var modJs = modJsList['tabSetting'];
$(window).load(function() {
modJs.loadRemoteDataForSettings();
});
</script>
<?php include APP_BASE_PATH.'footer.php';?>

View File

@@ -62,24 +62,46 @@ SettingAdapter.method('edit', function(id) {
SettingAdapter.method('fillForm', function(object) {
this.uber('fillForm',object);
var metaField = this.getMetaFieldForRendering('value');
var metaVal = object[metaField];
var formFields = null;
if(metaVal != "" && metaVal != undefined){
var formFields = [
[ "id", {"label":"ID","type":"hidden"}],
JSON.parse(metaVal)
];
}
this.uber('fillForm',object, null, formFields);
$("#helptext").html(object.description);
});
SettingAdapter.method('loadRemoteDataForSettings', function () {
var field = ["country", {"label": "Country", "type": "select2", "remote-source": ["Country", "code", "name"]}];
if (field[1]['remote-source'] != undefined && field[1]['remote-source'] != null) {
var key = field[1]['remote-source'][0] + "_" + field[1]['remote-source'][1] + "_" + field[1]['remote-source'][2];
this.fieldMasterDataKeys[key] = false;
this.sourceMapping[field[0]] = field[1]['remote-source'];
var fields = [];
var field = null;
fields.push(["country", {"label": "Country", "type": "select2multi", "remote-source": ["Country", "id", "name"]}]);
fields.push(["currency", {"label": "Currency", "type": "select2multi", "remote-source": ["CurrencyType","id","code+name"]}]);
fields.push(["nationality", {"label": "Nationality", "type": "select2multi", "remote-source": ["Nationality","id","name"]}]);
var callBackData = {};
callBackData['callBack'] = 'initFieldMasterDataResponse';
callBackData['callBackData'] = [key];
for(index in fields){
field = fields[index];
if (field[1]['remote-source'] != undefined && field[1]['remote-source'] != null) {
var key = field[1]['remote-source'][0] + "_" + field[1]['remote-source'][1] + "_" + field[1]['remote-source'][2];
this.fieldMasterDataKeys[key] = false;
this.sourceMapping[field[0]] = field[1]['remote-source'];
var callBackData = {};
callBackData['callBack'] = 'initFieldMasterDataResponse';
callBackData['callBackData'] = [key];
this.getFieldValues(field[1]['remote-source'], callBackData);
}
}
this.getFieldValues(field[1]['remote-source'], callBackData);
}
});

View File

@@ -1,19 +0,0 @@
<?php
class TravelActionManager extends ApproveAdminActionManager{
public function getModelClass(){
return "EmployeeTravelRecord";
}
public function getItemName(){
return "TravelRequest";
}
public function getModuleName(){
return "Travel Management";
}
public function getModuleTabUrl(){
return "g=modules&n=travel&m=module_Travel_Management";
}
}

View File

@@ -1,128 +0,0 @@
<?php
if (!class_exists('TravelAdminManager')) {
class TravelAdminManager extends AbstractModuleManager{
public function initializeUserClasses(){
if(defined('MODULE_TYPE') && MODULE_TYPE != 'admin'){
$this->addUserClass("EmployeeImmigration");
$this->addUserClass("EmployeeTravelRecord");
}
}
public function initializeFieldMappings(){
$this->addFileFieldMapping('EmployeeImmigration', 'attachment1', 'name');
$this->addFileFieldMapping('EmployeeImmigration', 'attachment2', 'name');
$this->addFileFieldMapping('EmployeeImmigration', 'attachment3', 'name');
$this->addFileFieldMapping('EmployeeTravelRecord', 'attachment1', 'name');
$this->addFileFieldMapping('EmployeeTravelRecord', 'attachment2', 'name');
$this->addFileFieldMapping('EmployeeTravelRecord', 'attachment3', 'name');
}
public function initializeDatabaseErrorMappings(){
}
public function setupModuleClassDefinitions(){
$this->addModelClass('ImmigrationDocument');
$this->addModelClass('EmployeeImmigration');
$this->addModelClass('EmployeeTravelRecord');
}
}
}
if (!class_exists('ImmigrationDocument')) {
class ImmigrationDocument extends ICEHRM_Record {
var $_table = 'ImmigrationDocuments';
public function getAdminAccess(){
return array("get","element","save","delete");
}
public function getManagerAccess(){
return array("get","element","save","delete");
}
public function getUserAccess(){
return array("get");
}
public function getUserOnlyMeAccess(){
return array("get","element");
}
}
}
if (!class_exists('EmployeeImmigration')) {
class EmployeeImmigration extends ICEHRM_Record {
var $_table = 'EmployeeImmigrations';
public function getAdminAccess(){
return array("get","element","save","delete");
}
public function getManagerAccess(){
return array("get","element","save","delete");
}
public function getUserAccess(){
return array("get");
}
public function getUserOnlyMeAccess(){
return array("element","save","delete");
}
}
}
if (!class_exists('EmployeeTravelRecord')) {
class EmployeeTravelRecord extends ApproveModel
{
var $_table = 'EmployeeTravelRecords';
var $notificationModuleName = "Travel Management";
var $notificationUnitName = "TravelRequest";
var $notificationUnitPrefix = "A";
var $notificationUnitAdminUrl = "g=admin&n=travel&m=admin_Employees";
var $preApproveSettingName = "Travel: Pre-Approve Travel Request";
public function getAdminAccess()
{
return array("get", "element", "save", "delete");
}
public function getManagerAccess()
{
return array("get", "element", "save", "delete");
}
public function getUserAccess()
{
return array("get");
}
public function getUserOnlyMeAccess()
{
return array("element", "save", "delete");
}
public function fieldsNeedToBeApproved()
{
return array(
"travel_from",
"travel_to",
"travel_date",
"return_date",
"funding",
"currency"
);
}
}
}

View File

@@ -1,19 +0,0 @@
<div class="col-lg-3 col-xs-12">
<div class="small-box bg-red">
<div class="inner">
<h3>
Travel
</h3>
<p id="numberOfTravel">
Requests
</p>
</div>
<div class="icon">
<i class="ion ion-plane"></i>
</div>
<a href="#_moduleLink_#" class="small-box-footer" id="travelLink">
Manage Travel <i class="fa fa-arrow-circle-right"></i>
</a>
</div>
</div>

View File

@@ -1,78 +0,0 @@
<?php
/*
This file is part of iCE Hrm.
iCE Hrm is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
iCE Hrm is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with iCE Hrm. If not, see <http://www.gnu.org/licenses/>.
------------------------------------------------------------------
Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd]
Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah)
*/
$moduleName = 'travel';
define('MODULE_PATH',dirname(__FILE__));
include APP_BASE_PATH.'header.php';
include APP_BASE_PATH.'modulejslibs.inc.php';
$options = array();
$options['setRemoteTable'] = 'true';
$moduleBuilder = new ModuleBuilder();
$moduleBuilder->addModuleOrGroup(new ModuleTab('EmployeeTravelRecord','EmployeeTravelRecord','Travel Requests','EmployeeTravelRecordAdapter','','',true,$options));
echo UIManager::getInstance()->renderModule($moduleBuilder);
$itemName = 'TravelRequest';
$moduleName = 'Travel Management';
$itemNameLower = strtolower($itemName);
$statuses = array("Approved","Pending","Rejected","Cancelled");
?><div class="modal" id="<?=$itemNameLower?>StatusModel" tabindex="-1" role="dialog" aria-labelledby="messageModelLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><li class="fa fa-times"/></button>
<h3 style="font-size: 17px;">Change <?=$itemName?> Status</h3>
</div>
<div class="modal-body">
<form id="expenseStatusForm">
<div class="control-group">
<label class="control-label" for="expense_status"><?=$itemName?> Status</label>
<div class="controls">
<select type="text" id="<?=$itemNameLower?>_status" class="form-control" name="<?=$itemNameLower?>_status" value="">
<?php foreach($statuses as $status){?>
<option value="<?=$status?>"><?=$status?></option>
<?php }?>
</select>
</div>
</div>
<div class="control-group">
<label class="control-label" for="expense_status">Status Change Note</label>
<div class="controls">
<textarea id="<?=$itemNameLower?>_reason" class="form-control" name="<?=$itemNameLower?>_reason" maxlength="500"></textarea>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button class="btn btn-primary" onclick="modJs.changeStatus();">Change <?=$itemName?> Status</button>
<button class="btn" onclick="modJs.closeDialog();">Not Now</button>
</div>
</div>
</div>
</div>
<?php
include APP_BASE_PATH.'footer.php';

View File

@@ -1,182 +0,0 @@
/**
* Author: Thilina Hasantha
*/
/**
* ImmigrationDocumentAdapter
*/
function ImmigrationDocumentAdapter(endPoint) {
this.initAdapter(endPoint);
}
ImmigrationDocumentAdapter.inherits(AdapterBase);
ImmigrationDocumentAdapter.method('getDataMapping', function() {
return [
"id",
"name",
"details",
"required",
"alert_on_missing",
"alert_before_expiry"
];
});
ImmigrationDocumentAdapter.method('getHeaders', function() {
return [
{ "sTitle": "ID" ,"bVisible":false},
{ "sTitle": "Name" },
{ "sTitle": "Details"},
{ "sTitle": "Compulsory"},
{ "sTitle": "Alert If Not Found"},
{ "sTitle": "Alert Before Expiry"}
];
});
ImmigrationDocumentAdapter.method('getFormFields', function() {
return [
[ "id", {"label":"ID","type":"hidden"}],
[ "name", {"label":"Name","type":"text","validation":""}],
[ "details", {"label":"Details","type":"textarea","validation":"none"}],
[ "required", {"label":"Compulsory","type":"select","source":[["No","No"],["Yes","Yes"]]}],
[ "alert_on_missing", {"label":"Alert If Not Found","type":"select","source":[["No","No"],["Yes","Yes"]]}],
[ "alert_before_expiry", {"label":"Alert Before Expiry","type":"select","source":[["No","No"],["Yes","Yes"]]}],
[ "alert_before_day_number", {"label":"Days for Expiry Alert","type":"text","validation":""}]
];
});
/**
* EmployeeImmigrationAdapter
*/
function EmployeeImmigrationAdapter(endPoint) {
this.initAdapter(endPoint);
}
EmployeeImmigrationAdapter.inherits(AdapterBase);
EmployeeImmigrationAdapter.method('getDataMapping', function() {
return [
"id",
"employee",
"document",
"documentname",
"valid_until",
"status"
];
});
EmployeeImmigrationAdapter.method('getHeaders', function() {
return [
{ "sTitle": "ID" ,"bVisible":false},
{ "sTitle": "Employee" },
{ "sTitle": "Document" },
{ "sTitle": "Document Id" },
{ "sTitle": "Valid Until"},
{ "sTitle": "Status"}
];
});
EmployeeImmigrationAdapter.method('getFormFields', function() {
return [
[ "id", {"label":"ID","type":"hidden"}],
[ "employee", {"label":"Employee","type":"select2","remote-source":["Employee","id","first_name+last_name"]}],
[ "document", {"label":"Document","type":"select2","remote-source":["ImmigrationDocument","id","name"]}],
[ "documentname", {"label":"Document Id","type":"text","validation":""}],
[ "valid_until", {"label":"Valid Until","type":"date","validation":"none"}],
[ "status", {"label":"Status","type":"select","source":[["Active","Active"],["Inactive","Inactive"],["Draft","Draft"]]}],
[ "details", {"label":"Details","type":"textarea","validation":"none"}],
[ "attachment1", {"label":"Attachment 1","type":"fileupload","validation":"none"}],
[ "attachment2", {"label":"Attachment 2","type":"fileupload","validation":"none"}],
[ "attachment3", {"label":"Attachment 3","type":"fileupload","validation":"none"}]
];
});
EmployeeImmigrationAdapter.method('getFilters', function() {
return [
[ "employee", {"label":"Employee","type":"select2","remote-source":["Employee","id","first_name+last_name"]}]
];
});
/**
* EmployeeTravelRecordAdapter
*/
function EmployeeTravelRecordAdapter(endPoint,tab,filter,orderBy) {
this.initAdapter(endPoint,tab,filter,orderBy);
this.itemName = 'TravelRequest';
this.itemNameLower = 'travelrequest';
this.modulePathName = 'travel';
}
EmployeeTravelRecordAdapter.inherits(ApproveAdminAdapter);
EmployeeTravelRecordAdapter.method('getDataMapping', function() {
return [
"id",
"employee",
"type",
"purpose",
"travel_from",
"travel_to",
"travel_date",
"status"
];
});
EmployeeTravelRecordAdapter.method('getHeaders', function() {
return [
{ "sTitle": "ID" ,"bVisible":false},
{ "sTitle": "Employee" },
{ "sTitle": "Travel Type" },
{ "sTitle": "Purpose" },
{ "sTitle": "From"},
{ "sTitle": "To"},
{ "sTitle": "Travel Date"},
{ "sTitle": "Status"}
];
});
EmployeeTravelRecordAdapter.method('getFormFields', function() {
return [
["id", {"label": "ID", "type": "hidden"}],
["employee", {
"label": "Employee",
"type": "select2",
"sort": "none",
"allow-null": false,
"remote-source": ["Employee", "id", "first_name+last_name", "getActiveSubordinateEmployees"]
}],
["type", {
"label": "Travel Type",
"type": "select",
"source": [["Local", "Local"], ["International", "International"]]
}],
["purpose", {"label": "Purpose of Travel", "type": "textarea", "validation": ""}],
["travel_from", {"label": "Travel From", "type": "text", "validation": ""}],
["travel_to", {"label": "Travel To", "type": "text", "validation": ""}],
["travel_date", {"label": "Travel Date", "type": "datetime", "validation": ""}],
["return_date", {"label": "Return Date", "type": "datetime", "validation": ""}],
["details", {"label": "Notes", "type": "textarea", "validation": "none"}],
["currency", {"label": "Currency", "type": "select2", "allow-null":false, "remote-source": ["CurrencyType", "id", "code"]}],
["funding", {"label": "Total Funding Proposed", "type": "text", "validation": "float"}],
["attachment1", {"label": "Itinerary / Cab Receipt", "type": "fileupload", "validation": "none"}],
["attachment2", {"label": "Other Attachment 1", "type": "fileupload", "validation": "none"}],
["attachment3", {"label": "Other Attachment 2", "type": "fileupload", "validation": "none"}]
];
});

View File

@@ -1,12 +0,0 @@
{
"label":"Travel Administration",
"menu":"Employees",
"order":"6",
"icon":"fa-plane",
"user_levels":["Admin","Manager"],
"dashboardPosition":12,
"permissions":
{
}
}

View File

@@ -23,8 +23,16 @@ Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilin
class UsersActionManager extends SubActionManager{
public function changePassword($req){
if($this->user->user_level == 'Admin' || $this->user->id == $req->id){
$user = $this->baseService->getElement('User',$req->id);
if(defined('DEMO_MODE')){
return new IceResponse(IceResponse::ERROR,"You are not allowed to change the password in demo mode");
}
$user = new User();
$user->Load("id = ?",array($req->id));
LogManager::getInstance()->debug("Current User:".print_r($this->user,true));
LogManager::getInstance()->debug("Edit User:".print_r($user,true));
if($this->user->user_level == 'Admin' || $this->user->id == $user->id){
if(empty($user->id)){
return new IceResponse(IceResponse::ERROR,"Please save the user first");
}

View File

@@ -54,11 +54,40 @@ if (!class_exists('User')) {
if(count($users) > 0){
return new IceResponse(IceResponse::ERROR,"A user with same authentication email already exist");
}
//Check if you are trying to change user level
$oldUser = new User();
$oldUser->Load("id = ?",array($obj->id));
if($oldUser->user_level != $obj->user_level && $oldUser->user_level == 'Admin'){
$adminUsers = $userTemp->Find("user_level = ?",array("Admin"));
if(count($adminUsers) == 1 && $adminUsers[0]->id == $obj->id){
return new IceResponse(IceResponse::ERROR,"You are the only admin user for the application. You are not allowed to revoke your admin rights");
}
}
}
//Check if the user have rights to the default module
if(!empty($obj->default_module)){
$module = new Module();
$module->Load("id = ?",array($obj->default_module));
if($module->mod_group == "user"){
$module->mod_group = "modules";
}
$moduleManager = BaseService::getInstance()->getModuleManager($module->mod_group, $module->name);
if(!BaseService::getInstance()->isModuleAllowedForGivenUser($moduleManager, $obj)){
return new IceResponse(IceResponse::ERROR,"This module can not be set as the default module for the user since the user do not have access to this module");
}
}
return new IceResponse(IceResponse::SUCCESS,"");
}
var $_table = 'Users';
}
}

View File

@@ -23,8 +23,20 @@ Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilin
class EmployeesActionManager extends SubActionManager{
public function get($req){
$profileId = $this->getCurrentProfileId();
$subordinate = new Employee();
$subordinatesCount = $subordinate->Count("supervisor = ? and id = ?",array($profileId, $req->id));
$employee = $this->baseService->getElement('Employee',$this->getCurrentProfileId(),$req->map,true);
if($this->user->user_level == 'Admin' || $subordinatesCount > 0){
$id = $req->id;
}
if(empty($id)){
$id = $profileId;
}
$employee = $this->baseService->getElement('Employee',$id,$req->map,true);
$subordinate = new Employee();
$subordinates = $subordinate->Find("supervisor = ?",array($employee->id));
@@ -53,11 +65,19 @@ class EmployeesActionManager extends SubActionManager{
}
public function deleteProfileImage($req){
if($this->user->user_level == 'Admin' || $this->user->employee == $req->id){
$profileId = $this->getCurrentProfileId();
$subordinate = new Employee();
$subordinatesCount = $subordinate->Count("supervisor = ? and id = ?",array($profileId, $req->id));
if($this->user->user_level == 'Admin' || $this->user->employee == $req->id || $subordinatesCount == 1){
$fs = FileService::getInstance();
$res = $fs->deleteProfileImage($req->id);
return new IceResponse(IceResponse::SUCCESS,$res);
}
return new IceResponse(IceResponse::ERROR,"Not allowed to delete profile image");
}
public function changePassword($req){
@@ -66,7 +86,8 @@ class EmployeesActionManager extends SubActionManager{
return new IceResponse(IceResponse::ERROR,"You are not allowed to change passwords of other employees");
}
$user = $this->baseService->getElement('User',$this->user->id);
$user = new User();
$user->Load("id = ?",array($this->user->id));
if(empty($user->id)){
return new IceResponse(IceResponse::ERROR,"Error occured while changing password");
}

View File

@@ -1,59 +1,69 @@
<div class="row-fluid">
<div class="col-xs-12 col-md-3">
<div class="row">
<div class="col-xs-12 col-md-2">
<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;">
<img id="profile_image__id_" src="" class="img-polaroid img-thumbnail" style="max-width: 140px;max-height: 140px;">
</div>
</div>
</div>
<div class="col-xs-12 col-md-9">
<div class="col-xs-12 col-md-10">
<div class="row-fluid">
<div class="col-md-12"><h2 id="name"></h2></div>
</div>
<div class="row-fluid">
<div class="col-md-12">
<p>
<i class="fa fa-phone"></i> <span id="mobile_phone"></span>&nbsp;&nbsp;
<i class="fa fa-envelope"></i> <span id="work_email"></span>
</p>
</div>
</div>
<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>
<button id="employeeProfileEditInfo" class="btn btn-small btn-success" onclick="modJs.editEmployee();" style="margin-right:10px;"><i class="fa fa-edit"></i> 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-small btn-primary" type="button" style="margin-right:10px;"><i class="fa fa-upload"></i> Upload Profile Image</button>
<button id="employeeDeleteProfileImage" onclick="modJs.deleteProfileImage(_id_);return false;" class="btn btn-small btn-warning" type="button" style="margin-right:10px;"><i class="fa fa-times"></i> Delete Profile Image</button>
<button id="employeeUpdatePassword" onclick="modJs.changePassword();return false;" class="btn btn-small btn-success" type="button" style="margin-right:10px;"><i class="fa fa-lock"></i> 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" style="font-size:13px;font-size:13px;">#_label_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" style="font-size:13px;">#_label_nic_num_#</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" style="font-size:13px;">#_label_ssn_num_#</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" style="margin-left:10px;">
<div class="panel panel-default" style="width:97.5%;">
<div class="panel-heading"><h4>Personal Information</h4></div>
<div class="panel-body">
<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" style="font-size:13px;">#_label_driving_license_#</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" style="font-size:13px;">#_label_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" style="font-size:13px;">#_label_birthday_#</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" style="font-size:13px;">#_label_gender_#</label>
<label class="control-label col-xs-12 iceLabel" style="font-size:13px;font-weight: bold;" id="gender"></label>
</div>
</div>
@@ -61,87 +71,78 @@
<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" style="font-size:13px;">#_label_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" style="font-size:13px;">#_label_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" style="font-size:13px;">#_label_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>
<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" style="margin-left:10px;margin-top:20px;">
<div class="panel panel-default" style="width:97.5%;">
<div class="panel-heading"><h4>Contact Information</h4></div>
<div class="panel-body">
<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" style="font-size:13px;">#_label_address1_#</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" style="font-size:13px;">#_label_address2_#</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" style="font-size:13px;">#_label_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" style="font-size:13px;">#_label_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" style="font-size:13px;">#_label_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" style="font-size:13px;">#_label_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" style="font-size:13px;">#_label_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" style="font-size:13px;">#_label_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>
<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" style="margin-left:10px;margin-top:20px;">
<div class="panel panel-default" style="width:97.5%;">
<div class="panel-heading"><h4>Job Details</h4></div>
<div class="panel-body">
<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" style="font-size:13px;">#_label_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" style="font-size:13px;">#_label_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;">
@@ -149,17 +150,18 @@
<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" style="font-size:13px;">Direct Reports</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" style="font-size:13px;">#_label_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>

View File

@@ -1,17 +1,17 @@
<div class="col-lg-3 col-xs-12">
<!-- small box -->
<div class="small-box bg-aqua">
<div class="small-box bg-red">
<div class="inner">
<h3>My Travel</h3>
<h3>My Profile</h3>
<p>
Management
Edit Details
</p>
</div>
<div class="icon">
<i class="ion ion-plane"></i>
<i class="ion ion-ios7-person"></i>
</div>
<a href="#_moduleLink_#" class="small-box-footer" id="mytravelLink">
Travel Management <i class="fa fa-arrow-circle-right"></i>
<a href="#_moduleLink_#" class="small-box-footer" id="myProfileLink">
Manage Profile <i class="fa fa-arrow-circle-right"></i>
</a>
</div>
</div>

View File

@@ -25,9 +25,32 @@ $moduleName = 'employees';
define('MODULE_PATH',dirname(__FILE__));
include APP_BASE_PATH.'header.php';
include APP_BASE_PATH.'modulejslibs.inc.php';
$fieldNameMap = BaseService::getInstance()->getFieldNameMappings("Employee");
$customFields = BaseService::getInstance()->getCustomFields("Employee");
?>
<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>
<script type="text/javascript" src="<?=BASE_URL.'js/d3js/d3.js?v='.$jsVersion?>"></script>
<script type="text/javascript" src="<?=BASE_URL.'js/d3js/d3.layout.js?v='.$jsVersion?>"></script>
<style type="text/css">
.node circle {
cursor: pointer;
fill: #fff;
stroke: steelblue;
stroke-width: 1.5px;
}
.node text {
font-size: 11px;
}
path.link {
fill: none;
stroke: #ccc;
stroke-width: 1.5px;
}
</style>
<div class="span9">
<ul class="nav nav-tabs" id="modTab" style="margin-bottom:0px;margin-left:5px;border-bottom: none;">
@@ -37,20 +60,15 @@ include APP_BASE_PATH.'modulejslibs.inc.php';
<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 id="Employee" class="container reviewBlock" data-content="List" style="padding:25px 0px 0px 0px; width:99%;">
</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 class="tab-pane reviewBlock" id="tabPageCompanyGraph" style="overflow-x: scroll;">
</div>
<div id="CompanyGraphForm" class="reviewBlock" data-content="Form" style="padding-left:5px;display:none;">
</div>
</div>
</div>
@@ -58,6 +76,8 @@ include APP_BASE_PATH.'modulejslibs.inc.php';
<script>
var modJsList = new Array();
modJsList['tabEmployee'] = new EmployeeAdapter('Employee');
modJsList['tabEmployee'].setFieldNameMap(<?=json_encode($fieldNameMap)?>);
modJsList['tabEmployee'].setCustomFields(<?=json_encode($customFields)?>);
modJsList['tabCompanyGraph'] = new CompanyGraphAdapter('CompanyStructure');
var modJs = modJsList['tabEmployee'];

View File

@@ -22,12 +22,57 @@ Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilin
function EmployeeAdapter(endPoint) {
this.initAdapter(endPoint);
this.fieldNameMap = {};
this.hiddenFields = {};
this.tableFields = {};
this.formOnlyFields = {};
this.customFields = [];
}
EmployeeAdapter.inherits(AdapterBase);
this.currentUserId = null;
EmployeeAdapter.method('setFieldNameMap', function(fields) {
var field;
for(var i=0;i<fields.length;i++){
field = fields[i];
this.fieldNameMap[field.name] = field;
if(field.display == "Hidden"){
this.hiddenFields[field.name] = field;
}else{
if(field.display == "Table and Form"){
this.tableFields[field.name] = field;
}else{
this.formOnlyFields[field.name] = field;
}
}
}
});
EmployeeAdapter.method('setCustomFields', function(fields) {
var field, parsed;
for(var i=0;i<fields.length;i++){
field = fields[i];
if(field.display != "Hidden" && field.data != "" && field.data != undefined){
try{
parsed = JSON.parse(field.data);
if(parsed == undefined || parsed == null){
continue;
}else if(parsed.length != 2){
continue;
}else if(parsed[1].type == undefined || parsed[1].type == null){
continue;
}
this.customFields.push(parsed);
}catch(e){
}
}
}
});
EmployeeAdapter.method('getDataMapping', function() {
return [
"id",
@@ -55,7 +100,7 @@ EmployeeAdapter.method('getHeaders', function() {
});
EmployeeAdapter.method('getFormFields', function() {
var fields, newFields = [];
var employee_id, ssn_num, employment_status, job_title, pay_grade, joined_date, department, work_email, country;
if(this.checkPermission("Edit Employee Number") == "Yes"){
@@ -112,7 +157,7 @@ EmployeeAdapter.method('getFormFields', function() {
country = [ "country", {"label":"Country","type":"placeholder","remote-source":["Country","code","name"]}];
}
return [
fields = [
[ "id", {"label":"ID","type":"hidden","validation":""}],
employee_id,
[ "first_name", {"label":"First Name","type":"text","validation":""}],
@@ -144,6 +189,24 @@ EmployeeAdapter.method('getFormFields', function() {
joined_date,
department
];
for(var i=0;i<this.customFields.length;i++){
fields.push(this.customFields[i]);
}
for(var i=0;i<fields.length;i++){
tempField = fields[i];
if(this.hiddenFields[tempField[0]] == undefined || this.hiddenFields[tempField[0]] == null ){
if(this.fieldNameMap[tempField[0]] != undefined && this.fieldNameMap[tempField[0]] != null){
title = this.fieldNameMap[tempField[0]].textMapped;
tempField[1]['label'] = title;
}
newFields.push(tempField);
}
}
return newFields;
});
EmployeeAdapter.method('getSourceMapping' , function() {
@@ -187,17 +250,28 @@ EmployeeAdapter.method('modEmployeeDeleteProfileImageCallBack', function(data) {
});
EmployeeAdapter.method('modEmployeeGetSuccessCallBack' , function(data) {
var fields = this.getFormFields();
var currentEmpId = data[1];
var userEmpId = data[2];
data = data[0];
var html = this.getCustomTemplate('myDetails.html');
for(var i=0;i<fields.length;i++) {
if(this.fieldNameMap[fields[i][0]] != undefined && this.fieldNameMap[fields[i][0]] != null){
title = this.fieldNameMap[fields[i][0]].textMapped;
html = html.replace("#_label_"+fields[i][0]+"_#",title);
}
}
html = html.replace(/#_.+_#/i,"");
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]]);
$("#"+this.getTableName()+" #" + fields[i][0]+"_Name").html(data[fields[i][0]+"_Name"]);
}
var subordinates = "";
@@ -218,13 +292,6 @@ EmployeeAdapter.method('modEmployeeGetSuccessCallBack' , function(data) {
$("#"+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;
@@ -318,16 +385,15 @@ EmployeeAdapter.method('changePasswordFailCallBack', function(callBackData,serve
* Company Graph
*/
function CompanyGraphAdapter(endPoint) {
function CompanyStructureAdapter(endPoint) {
this.initAdapter(endPoint);
}
CompanyGraphAdapter.inherits(AdapterBase);
CompanyStructureAdapter.inherits(AdapterBase);
CompanyGraphAdapter.method('getDataMapping', function() {
CompanyStructureAdapter.method('getDataMapping', function() {
return [
"id",
"title",
@@ -338,7 +404,7 @@ CompanyGraphAdapter.method('getDataMapping', function() {
];
});
CompanyGraphAdapter.method('getHeaders', function() {
CompanyStructureAdapter.method('getHeaders', function() {
return [
{ "sTitle": "ID","bVisible":false },
{ "sTitle": "Name" },
@@ -349,7 +415,7 @@ CompanyGraphAdapter.method('getHeaders', function() {
];
});
CompanyGraphAdapter.method('getFormFields', function() {
CompanyStructureAdapter.method('getFormFields', function() {
return [
[ "id", {"label":"ID","type":"hidden","validation":""}],
[ "title", {"label":"Name","type":"text","validation":""}],
@@ -361,25 +427,252 @@ CompanyGraphAdapter.method('getFormFields', function() {
];
});
CompanyGraphAdapter.method('createTable', function(elementId) {
function CompanyGraphAdapter(endPoint) {
this.initAdapter(endPoint);
this.nodeIdCounter = 0;
}
CompanyGraphAdapter.inherits(CompanyStructureAdapter);
CompanyGraphAdapter.method('convertToTree', function(data) {
var ice = {};
ice['id'] = -1;
ice['title'] = '';
ice['name'] = '';
ice['children'] = [];
var parent = null;
var added = {};
for(var i=0;i<data.length;i++){
data[i].name = data[i].title;
if(data[i].parent != null && data[i].parent != undefined){
parent = this.findParent(data,data[i].parent);
if(parent != null){
if(parent.children == undefined || parent.children == null){
parent.children = [];
}
parent.children.push(data[i]);
}
}
}
for(var i=0;i<data.length;i++){
if(data[i].parent == null || data[i].parent == undefined){
ice['children'].push(data[i]);
}
}
return ice;
});
CompanyGraphAdapter.method('findParent', function(data, parent) {
for(var i=0;i<data.length;i++){
if(data[i].title == parent || data[i].title == parent){
return data[i];
}
}
return null;
});
CompanyGraphAdapter.method('createTable', function(elementId) {
$("#tabPageCompanyGraph").html("");
var that = this;
var sourceData = this.sourceData;
if(modJs['r'] == undefined || modJs['r'] == null){
modJs['r'] = Raphael("CompanyGraph", 800, 1000);
}else{
return;
}
//this.fixCyclicParent(sourceData);
var treeData = this.convertToTree(sourceData);
var r = modJs['r'];
var m = [20, 120, 20, 120],
w = 5000 - m[1] - m[3],
h = 1000 - m[0] - m[2],
root;
for(var i=0; i< sourceData.length; i++){
sourceData[i].parent = sourceData[i]._original[6];
}
var tree = d3.layout.tree()
.size([h, w]);
this.diagonal = d3.svg.diagonal()
.projection(function(d) { return [d.y, d.x]; });
this.vis = d3.select("#tabPageCompanyGraph").append("svg:svg")
.attr("width", w + m[1] + m[3])
.attr("height", h + m[0] + m[2])
.append("svg:g")
.attr("transform", "translate(" + m[3] + "," + m[0] + ")");
root = treeData;
root.x0 = h / 2;
root.y0 = 0;
function toggleAll(d) {
if (d.children) {
console.log(d.name);
d.children.forEach(toggleAll);
that.toggle(d);
}
}
this.update(root, tree, root);
var hierarchy = new HierarchyJs();
var nodes = hierarchy.createNodes(sourceData);
hierarchy.createHierarchy(nodes, r);
});
CompanyGraphAdapter.method('update', function(source, tree, root) {
var that = this;
var duration = d3.event && d3.event.altKey ? 5000 : 500;
// Compute the new tree layout.
var nodes = tree.nodes(root).reverse();
// Normalize for fixed-depth.
nodes.forEach(function(d) { d.y = d.depth * 180; });
// Update the nodes<65>
var node = that.vis.selectAll("g.node")
.data(nodes, function(d) { return d.id || (d.id = ++that.nodeIdCounter); });
// Enter any new nodes at the parent's previous position.
var nodeEnter = node.enter().append("svg:g")
.attr("class", "node")
.attr("transform", function(d) { return "translate(" + source.y0 + "," + source.x0 + ")"; })
.on("click", function(d) { that.toggle(d); that.update(d, tree, root); });
nodeEnter.append("svg:circle")
.attr("r", 1e-6)
.style("fill", function(d) { return d._children ? "lightsteelblue" : "#fff"; });
nodeEnter.append("svg:text")
.attr("x", function(d) { return d.children || d._children ? -10 : 10; })
.attr("dy", ".35em")
.attr("text-anchor", function(d) { return d.children || d._children ? "end" : "start"; })
.text(function(d) { return d.name; })
.style("fill-opacity", 1e-6);
// Transition nodes to their new position.
var nodeUpdate = node.transition()
.duration(duration)
.attr("transform", function(d) { return "translate(" + d.y + "," + d.x + ")"; });
nodeUpdate.select("circle")
.attr("r", 4.5)
.style("fill", function(d) { return d._children ? "lightsteelblue" : "#fff"; });
nodeUpdate.select("text")
.style("fill-opacity", 1);
// Transition exiting nodes to the parent's new position.
var nodeExit = node.exit().transition()
.duration(duration)
.attr("transform", function(d) { return "translate(" + source.y + "," + source.x + ")"; })
.remove();
nodeExit.select("circle")
.attr("r", 1e-6);
nodeExit.select("text")
.style("fill-opacity", 1e-6);
// Update the links<6B>
var link = that.vis.selectAll("path.link")
.data(tree.links(nodes), function(d) { return d.target.id; });
// Enter any new links at the parent's previous position.
link.enter().insert("svg:path", "g")
.attr("class", "link")
.attr("d", function(d) {
var o = {x: source.x0, y: source.y0};
return that.diagonal({source: o, target: o});
})
.transition()
.duration(duration)
.attr("d", that.diagonal);
// Transition links to their new position.
link.transition()
.duration(duration)
.attr("d", that.diagonal);
// Transition exiting nodes to the parent's new position.
link.exit().transition()
.duration(duration)
.attr("d", function(d) {
var o = {x: source.x, y: source.y};
return that.diagonal({source: o, target: o});
})
.remove();
// Stash the old positions for transition.
nodes.forEach(function(d) {
d.x0 = d.x;
d.y0 = d.y;
});
});
// Toggle children.
CompanyGraphAdapter.method('toggle', function(d) {
if (d.children) {
d._children = d.children;
d.children = null;
} else {
d.children = d._children;
d._children = null;
}
});
CompanyGraphAdapter.method('getSourceDataById', function(id) {
for(var i=0; i< this.sourceData.length; i++){
if(this.sourceData[i].id == id){
return this.sourceData[i];
}
}
return null;
});
CompanyGraphAdapter.method('fixCyclicParent', function(sourceData) {
var errorMsg = "";
for(var i=0; i< sourceData.length; i++){
var obj = sourceData[i];
var curObj = obj;
var parentIdArr = {};
parentIdArr[curObj.id] = 1;
while(curObj.parent != null && curObj.parent != undefined){
var parent = this.getSourceDataById(curObj.parent);
if(parent == null){
break;
}else if(parentIdArr[parent.id] == 1){
errorMsg = obj.title +"'s parent structure set to "+parent.title+"<br/>";
obj.parent = null;
break;
}
parentIdArr[parent.id] = 1;
curObj = parent;
}
}
if(errorMsg != ""){
this.showMessage("Company Structure is having a cyclic dependency","We found a cyclic dependency due to following reasons:<br/>"+errorMsg);
return false;
}
return true;
});

View File

@@ -4,6 +4,7 @@
"order":"2",
"icon":"fa-user",
"user_levels":["Admin","Manager","Employee"],
"dashboardPosition":101,
"permissions":
{

View File

@@ -1,7 +1,10 @@
{
"Personal Information":"fa-male",
"Subordinates":"fa-user",
"Leave":"fa-calendar-o",
"Time Management":"fa-clock-o",
"Documents":"fa-files-o",
"Company":"fa-building",
"Training":"fa-briefcase",
"Travel Management":"fa-plane",
"Finance":"fa-money"
"Finance":"fa-money"
}

View File

@@ -32,8 +32,6 @@ EmployeeSalaryAdapter.method('getDataMapping', function() {
return [
"id",
"component",
"pay_frequency",
"currency",
"amount",
"details"
];
@@ -43,8 +41,6 @@ EmployeeSalaryAdapter.method('getHeaders', function() {
return [
{ "sTitle": "ID" ,"bVisible":false},
{ "sTitle": "Salary Component" },
{ "sTitle": "Pay Frequency"},
{ "sTitle": "Currency"},
{ "sTitle": "Amount"},
{ "sTitle": "Details"}
];
@@ -54,8 +50,6 @@ 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

@@ -1,59 +0,0 @@
<?php
class TravelActionManager extends ApproveModuleActionManager{
public function getModelClass(){
return "EmployeeTravelRecord";
}
public function getItemName(){
return "TravelRequest";
}
public function getModuleName(){
return "Travel Management";
}
public function getModuleTabUrl(){
return "g=admin&n=travel&m=admin_Employees#tabEmployeeTravelRecord";
}
}
/*
class TravelActionManager extends SubActionManager{
public function cancelTravel($req){
$employee = $this->baseService->getElement('Employee',$this->getCurrentProfileId(),null,true);
$employeeTravel = new EmployeeTravelRecord();
$employeeTravel->Load("id = ?",array($req->id));
if($employeeTravel->id != $req->id){
return new IceResponse(IceResponse::ERROR,"Travel record not found");
}
if($this->user->user_level != 'Admin' && $this->getCurrentProfileId() != $employeeTravel->employee){
return new IceResponse(IceResponse::ERROR,"Only an admin or owner of the travel request can do this");
}
if($employeeTravel->status != 'Approved'){
return new IceResponse(IceResponse::ERROR,"Only an approved travel request can be cancelled");
}
$employeeTravel->status = 'Cancellation Requested';
$ok = $employeeTravel->Save();
if(!$ok){
LogManager::getInstance()->error("Error occured while cancelling the travel:".$employeeTravel->ErrorMsg());
return new IceResponse(IceResponse::ERROR,"Error occurred while cancelling the travel request. Please contact admin.");
}
$this->baseService->audit(IceConstants::AUDIT_ACTION, "Travel cancellation \ start:".$employeeTravel->date_start."\ end:".$employeeTravel->date_end);
$notificationMsg = $employee->first_name." ".$employee->last_name." cancelled a travel. Visit travel management module to approve";
$this->baseService->notificationManager->addNotification($employee->supervisor,$notificationMsg,'{"type":"url","url":"g=admin&n=travel&m=admin_Employees#tabEmployeeTravelRecord"}',
"Travel Module", null, false, true);
return new IceResponse(IceResponse::SUCCESS,$employeeTravel);
}
}
*/

View File

@@ -1,66 +0,0 @@
<?php
/*
This file is part of iCE Hrm.
iCE Hrm is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
iCE Hrm is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with iCE Hrm. If not, see <http://www.gnu.org/licenses/>.
------------------------------------------------------------------
Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd]
Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah)
*/
$moduleName = 'travel';
$moduleMainName = "EmployeeTravelRecord";
$moduleItemName = "Travel Request";
define('MODULE_PATH',dirname(__FILE__));
include APP_BASE_PATH.'header.php';
include APP_BASE_PATH.'modulejslibs.inc.php';
?><div class="span9">
<ul class="nav nav-tabs" id="modTab" style="margin-bottom:0px;margin-left:5px;border-bottom: none;">
<li class="active"><a id="tab<?=$moduleMainName?>" href="#tabPage<?=$moduleMainName?>">Travel Requests</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tabPage<?=$moduleMainName?>">
<div id="<?=$moduleMainName?>" class="reviewBlock" data-content="List" style="padding-left:5px;">
</div>
<div id="<?=$moduleMainName?>Form" class="reviewBlock" data-content="Form" style="padding-left:5px;display:none;">
</div>
</div>
</div>
</div>
<script>
var modJsList = new Array();
modJsList['tab<?=$moduleMainName?>'] = new <?=$moduleMainName?>Adapter('<?=$moduleMainName?>','<?=$moduleMainName?>');
<?php if(isset($modulePermissions['perm']['Add '.$moduleItemName]) && $modulePermissions['perm']['Add '.$moduleItemName] == "No"){?>
modJsList['tab<?=$moduleMainName?>'].setShowAddNew(false);
<?php }?>
<?php if(isset($modulePermissions['perm']['Delete '.$moduleItemName]) && $modulePermissions['perm']['Delete '.$moduleItemName] == "No"){?>
modJsList['tab<?=$moduleMainName?>'].setShowDelete(false);
<?php }?>
<?php if(isset($modulePermissions['perm']['Edit '.$moduleItemName]) && $modulePermissions['perm']['Edit '.$moduleItemName] == "No"){?>
modJsList['tab<?=$moduleMainName?>'].setShowEdit(false);
<?php }?>
var modJs = modJsList['tab<?=$moduleMainName?>'];
</script>
<?php include APP_BASE_PATH.'footer.php';?>

View File

@@ -1,158 +0,0 @@
/*
This file is part of iCE Hrm.
Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd]
Developer: Thilina Hasantha (thilina.hasantha[at]gmail.com / facebook.com/thilinah)
*/
function EmployeeImmigrationAdapter(endPoint) {
this.initAdapter(endPoint);
}
EmployeeImmigrationAdapter.inherits(AdapterBase);
EmployeeImmigrationAdapter.method('getDataMapping', function() {
return [
"id",
"document",
"documentname",
"valid_until",
"status"
];
});
EmployeeImmigrationAdapter.method('getHeaders', function() {
return [
{ "sTitle": "ID" ,"bVisible":false},
{ "sTitle": "Document" },
{ "sTitle": "Document Id" },
{ "sTitle": "Valid Until"},
{ "sTitle": "Status"}
];
});
EmployeeImmigrationAdapter.method('getFormFields', function() {
return [
[ "id", {"label":"ID","type":"hidden"}],
[ "document", {"label":"Document","type":"select2","remote-source":["ImmigrationDocument","id","name"]}],
[ "documentname", {"label":"Document Id","type":"text","validation":""}],
[ "valid_until", {"label":"Valid Until","type":"date","validation":"none"}],
[ "status", {"label":"Status","type":"select","source":[["Active","Active"],["Inactive","Inactive"],["Draft","Draft"]]}],
[ "details", {"label":"Details","type":"textarea","validation":"none"}],
[ "attachment1", {"label":"Attachment 1","type":"fileupload","validation":"none"}],
[ "attachment2", {"label":"Attachment 2","type":"fileupload","validation":"none"}],
[ "attachment3", {"label":"Attachment 3","type":"fileupload","validation":"none"}]
];
});
function EmployeeTravelRecordAdapter(endPoint) {
this.initAdapter(endPoint);
}
EmployeeTravelRecordAdapter.inherits(AdapterBase);
EmployeeTravelRecordAdapter.method('getDataMapping', function() {
return [
"id",
"type",
"purpose",
"travel_from",
"travel_to",
"travel_date",
"return_date",
"status"
];
});
EmployeeTravelRecordAdapter.method('getHeaders', function() {
return [
{ "sTitle": "ID" ,"bVisible":false},
{ "sTitle": "Travel Type" },
{ "sTitle": "Purpose" },
{ "sTitle": "From"},
{ "sTitle": "To"},
{ "sTitle": "Travel Date"},
{ "sTitle": "Return Date"},
{ "sTitle": "Status"}
];
});
EmployeeTravelRecordAdapter.method('getFormFields', function() {
return [
[ "id", {"label":"ID","type":"hidden"}],
[ "type", {"label":"Travel Type","type":"select","source":[["Local","Local"],["International","International"]]}],
[ "purpose", {"label":"Purpose of Travel","type":"textarea","validation":""}],
[ "travel_from", {"label":"Travel From","type":"text","validation":""}],
[ "travel_to", {"label":"Travel To","type":"text","validation":""}],
[ "travel_date", {"label":"Travel Date","type":"datetime","validation":""}],
[ "return_date", {"label":"Return Date","type":"datetime","validation":""}],
[ "details", {"label":"Notes","type":"textarea","validation":"none"}],
[ "currency", {"label":"Currency","type":"select2","allow-null":false,"remote-source":["CurrencyType","id","code"]}],
[ "funding", {"label":"Total Funding Proposed","type":"text","validation":"float"}],
[ "attachment1", {"label":"Itinerary / Cab Receipt","type":"fileupload","validation":"none"}],
[ "attachment2", {"label":"Other Attachment 1","type":"fileupload","validation":"none"}],
[ "attachment3", {"label":"Other Attachment 2","type":"fileupload","validation":"none"}]
];
});
EmployeeTravelRecordAdapter.method('getActionButtonsHtml', function(id,data) {
var editButton = '<img class="tableActionButton" src="_BASE_images/edit.png" style="cursor:pointer;" rel="tooltip" title="Edit" onclick="modJs.edit(_id_);return false;"></img>';
var deleteButton = '<img class="tableActionButton" src="_BASE_images/delete.png" style="margin-left:15px;cursor:pointer;" rel="tooltip" title="Delete" onclick="modJs.deleteRow(_id_);return false;"></img>';
var requestCancellationButton = '<img class="tableActionButton" src="_BASE_images/delete.png" style="margin-left:15px;cursor:pointer;" rel="tooltip" title="Cancel Travel Request" onclick="modJs.cancelTravel(_id_);return false;"></img>';
var html = '<div style="width:80px;">_edit__delete_</div>';
if(this.showDelete){
if(data[7] == "Approved"){
html = html.replace('_delete_',requestCancellationButton);
}else{
html = html.replace('_delete_',deleteButton);
}
}else{
html = html.replace('_delete_','');
}
if(this.showEdit){
html = html.replace('_edit_',editButton);
}else{
html = html.replace('_edit_','');
}
html = html.replace(/_id_/g,id);
html = html.replace(/_BASE_/g,this.baseUrl);
return html;
});
EmployeeTravelRecordAdapter.method('cancelTravel', function(id) {
var that = this;
var object = {};
object['id'] = id;
var reqJson = JSON.stringify(object);
var callBackData = [];
callBackData['callBackData'] = [];
callBackData['callBackSuccess'] = 'cancelSuccessCallBack';
callBackData['callBackFail'] = 'cancelFailCallBack';
this.customAction('cancelTravel','modules=travel',reqJson,callBackData);
});
EmployeeTravelRecordAdapter.method('cancelSuccessCallBack', function(callBackData) {
this.showMessage("Successful", "Travel request cancellation request sent");
this.get([]);
});
EmployeeTravelRecordAdapter.method('cancelFailCallBack', function(callBackData) {
this.showMessage("Error Occurred while cancelling Travel request", callBackData);
});

View File

@@ -1,23 +0,0 @@
{
"label":"Travel",
"menu":"Travel Management",
"order":"1",
"icon":"fa-plane",
"user_levels":["Admin","Manager","Employee"],
"dashboardPosition":107,
"permissions":
{
"Manager":{
"Add Travel Request":"Yes",
"Edit Travel Request":"Yes",
"Delete Travel Request":"Yes"
},
"Employee":{
"Add Travel Request":"Yes",
"Edit Travel Request":"Yes",
"Delete Travel Request":"Yes"
}
}
}

View File

@@ -529,9 +529,28 @@ for these clients. The clients section represent both external and internal clie
That way you can attach each and every project to a client.
###Employee Projects
Under employee projects tab you can assign projects to employees. You need to add projects to employees to enable them to add time against
these projects in time-sheets.
Release note v16.0
------------------
### Features
* Advanced Employee Management Module is now included in IceHrm Open Source Edition
* LDAP Module which was only available in IceHrm Enterprise is now included in open source also
* Initial implementation of icehrm REST Api for reading employee details
* Improvements to data filtering
* Multiple tabs for settings module
* Overtime reports - now its possible to calculate overtime for employees.compatible with US overtime rules
* Logout the user if tried accessing an unauthorized module
* Setting for updating module names
### Fixes
* Fix issue: classes should be loaded even the module is disabled
* Deleting the only Admin user is not allowed
* Fixes for handling non UTF-8
* Fix for non-mandatory select boxes are shown as mandatory
Release note v15.2
------------------

View File

@@ -680,6 +680,299 @@ ApproveModuleAdapter.method('getActionButtonsHtml', function(id,data) {
/**
* TableEditAdapter
*/
function TableEditAdapter(endPoint) {
this.initAdapter(endPoint);
this.cellDataUpdates = {};
this.modulePath = '';
this.rowFieldName = '';
this.columnFieldName = '';
this.rowTable = '';
this.columnTable = '';
this.valueTable = '';
this.csvData = [];
}
TableEditAdapter.inherits(AdapterBase);
TableEditAdapter.method('setModulePath', function(path) {
this.modulePath = path;
});
TableEditAdapter.method('setRowFieldName', function(name) {
this.rowFieldName = name;
});
TableEditAdapter.method('setTables', function(rowTable, columnTable, valueTable) {
this.rowTable = rowTable;
this.columnTable = columnTable;
this.valueTable = valueTable;
});
TableEditAdapter.method('setColumnFieldName', function(name) {
this.columnFieldName = name;
});
TableEditAdapter.method('getDataMapping', function() {
return [
];
});
TableEditAdapter.method('getFormFields', function() {
return [
];
});
TableEditAdapter.method('get', function() {
this.getAllData();
});
TableEditAdapter.method('getAllData', function(save) {
var req = {};
req.rowTable = this.rowTable;
req.columnTable = this.columnTable;
req.valueTable = this.valueTable;
req = this.addAdditionalRequestData('getAllData', req);
req.save = (save == undefined || save == null || save == false)?0:1;
var reqJson = JSON.stringify(req);
var callBackData = [];
callBackData['callBackData'] = [];
callBackData['callBackSuccess'] = 'getAllDataSuccessCallBack';
callBackData['callBackFail'] = 'getAllDataFailCallBack';
this.customAction('getAllData',this.modulePath,reqJson,callBackData);
});
TableEditAdapter.method('getDataItem', function(row,column,allData) {
var columnData = allData[1];
var rowData = allData[0];
var serverData = allData[2];
if(column == -1){
return rowData[row].name;
}else{
return this.getDataItemByKeyValues(this.rowFieldName, rowData[row].id, this.columnFieldName, columnData[column].id, serverData);
}
});
TableEditAdapter.method('getDataItemByKeyValues', function(rowKeyName, rowKeyVal, colKeyName, colKeyVal, data) {
for(var i=0;i<data.length;i++){
if(data[i][rowKeyName] == rowKeyVal && data[i][colKeyName] == colKeyVal){
return (data[i].amount != undefined && data[i].amount != null)?data[i].amount:"";
}
}
return "";
});
TableEditAdapter.method('getAllDataSuccessCallBack', function(allData) {
var serverData = allData[2];
var columnData = allData[1];
var rowData = allData[0];
var data = [];
for(var i=0;i<rowData.length;i++){
var row = [];
for(var j=-1;j<columnData.length;j++){
row[j+1] = this.getDataItem(i, j,allData);
}
data.push(this.preProcessTableData(row));
}
this.sourceData = serverData;
this.tableData = data;
this.setHeaders(columnData,rowData);
this.createTable(this.getTableName());
$("#"+this.getTableName()+'Form').hide();
$("#"+this.getTableName()).show();
this.csvData = [];
var tmpRow = [];
for(var i=0;i<columnData.length;i++){
tmpRow.push(columnData[i].name);
}
tmpRow = this.modifyCSVHeader(tmpRow);
this.csvData.push(tmpRow);
for(var i=0; i<data.length; i++){
this.csvData.push(data[i]);
}
});
TableEditAdapter.method('modifyCSVHeader', function(header) {
return header;
});
TableEditAdapter.method('getAllDataFailCallBack', function(callBackData,serverData) {
});
TableEditAdapter.method('setHeaders', function(columns, rows) {
var headers = [];
headers.push({ "sTitle": "", sWidth:"180px;"});
var sclass = "";
for(var i=0;i<columns.length;i++){
if(columns[i].editable == undefined || columns[i].editable == null || columns[i].editable == 'Yes'){
sclass = "editcell";
}else{
sclass = "";
}
headers.push({ "sTitle": columns[i].name,sClass: sclass,
"fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
$(nTd).data('colId',columns[iCol-1].id);
$(nTd).data('rowId',rows[iRow].id);
}});
}
this.headers = headers;
});
TableEditAdapter.method('getHeaders', function() {
return this.headers;
});
TableEditAdapter.method('createTable', function(elementId) {
var data = this.getTableData();
var headers = this.getHeaders();
if(this.showActionButtons()){
headers.push({ "sTitle": "", "sClass": "center" });
}
if(this.showActionButtons()){
for(var i=0;i<data.length;i++){
data[i].push(this.getActionButtonsHtml(data[i][0],data[i]));
}
}
var html = "";
html = this.getTableTopButtonHtml()+'<div class="box-body table-responsive"><table cellpadding="0" cellspacing="0" border="0" class="table table-bordered table-striped" id="grid"></table></div>';
//Find current page
var activePage = $('#'+elementId +" .dataTables_paginate .active a").html();
var start = 0;
if(activePage != undefined && activePage != null){
start = parseInt(activePage, 10)*15 - 15;
}
$('#'+elementId).html(html);
var dataTableParams = {
"oLanguage": {
"sLengthMenu": "_MENU_ records per page"
},
"aaData": data,
"aoColumns": headers,
"bSort": false,
"iDisplayLength": 15,
"iDisplayStart": start
};
var customTableParams = this.getCustomTableParams();
$.extend(dataTableParams, customTableParams);
$('#'+elementId+' #grid').dataTable( dataTableParams );
$(".dataTables_paginate ul").addClass("pagination");
$(".dataTables_length").hide();
$(".dataTables_filter input").addClass("form-control");
$(".dataTables_filter input").attr("placeholder","Search");
$(".dataTables_filter label").contents().filter(function(){
return (this.nodeType == 3);
}).remove();
//$('.tableActionButton').tooltip();
$('#'+elementId+' #grid').editableTableWidget();
$('#'+elementId+' #grid .editcell').on('validate', function(evt, newValue) {
return modJs.validateCellValue($(this), evt, newValue);
});
});
TableEditAdapter.method('addCellDataUpdate' , function(colId, rowId, data) {
this.cellDataUpdates[colId+"="+rowId] = [colId, rowId, data];
});
TableEditAdapter.method('addAdditionalRequestData' , function(type, req) {
return req;
});
TableEditAdapter.method('sendCellDataUpdates' , function() {
var req = this.cellDataUpdates;
req.rowTable = this.rowTable;
req.columnTable = this.columnTable;
req.valueTable = this.valueTable;
req = this.addAdditionalRequestData('updateData', req);
var reqJson = JSON.stringify(req);
var callBackData = [];
callBackData['callBackData'] = [];
callBackData['callBackSuccess'] = 'updateDataSuccessCallBack';
callBackData['callBackFail'] = 'updateDataFailCallBack';
this.showLoader();
this.customAction('updateData',this.modulePath,reqJson,callBackData);
});
TableEditAdapter.method('updateDataSuccessCallBack', function(callBackData,serverData) {
this.hideLoader();
modJs.cellDataUpdates = {};
modJs.get();
});
TableEditAdapter.method('updateDataFailCallBack', function(callBackData,serverData) {
this.hideLoader();
});
TableEditAdapter.method('sendAllCellDataUpdates' , function() {
var req = this.cellDataUpdates;
req.rowTable = this.rowTable;
req.columnTable = this.columnTable;
req.valueTable = this.valueTable;
req = this.addAdditionalRequestData('updateAllData', req);
var reqJson = JSON.stringify(req);
var callBackData = [];
callBackData['callBackData'] = [];
callBackData['callBackSuccess'] = 'updateDataAllSuccessCallBack';
callBackData['callBackFail'] = 'updateDataAllFailCallBack';
this.showLoader();
this.customAction('updateAllData',this.modulePath,reqJson,callBackData);
});
TableEditAdapter.method('updateDataAllSuccessCallBack', function(callBackData,serverData) {
this.hideLoader();
modJs.cellDataUpdates = {};
modJs.getAllData(true);
});
TableEditAdapter.method('updateDataAllFailCallBack', function(callBackData,serverData) {
this.hideLoader();
});
TableEditAdapter.method('showActionButtons' , function() {
return false;
});
/**
* RequestCache

View File

@@ -1725,6 +1725,9 @@ IceHRMBase.method('fillForm', function(object, formId, fields) {
}
$(formId + ' #'+fields[i][0]).select2('val',msVal);
var select2Height = $(formId + ' #'+fields[i][0]).find(".select2-choices").height();
$(formId + ' #'+fields[i][0]).find(".controls").css('min-height', select2Height+"px");
$(formId + ' #'+fields[i][0]).css('min-height', select2Height+"px");
}else if(fields[i][1].type == 'datagroup'){
try{
@@ -1764,7 +1767,13 @@ IceHRMBase.method('renderFormField', function(field) {
}
var t = this.fieldTemplates[field[1].type];
if(field[1].validation != "none" && field[1].validation != "emailOrEmpty" && field[1].validation != "numberOrEmpty" && field[1].type != "placeholder" && field[1].label.indexOf('*') < 0){
field[1].label = field[1].label + '<font class="redFont">*</font>';
var tempSelectBoxes = ['select','select2'];
if(tempSelectBoxes.indexOf(field[1].type) >= 0 && field[1]['allow-null'] == true){
}else{
field[1].label = field[1].label + '<font class="redFont">*</font>';
}
}
if(field[1].type == 'text' || field[1].type == 'textarea' || field[1].type == 'hidden' || field[1].type == 'label' || field[1].type == 'placeholder'){
t = t.replace(/_id_/g,field[0]);

View File

@@ -65,6 +65,10 @@ abstract class AbstractModuleManager{
*/
public abstract function setupModuleClassDefinitions();
public function initCalculationHooks(){
}
public function initQuickAccessMenu(){
}
@@ -208,5 +212,9 @@ abstract class AbstractModuleManager{
$eh->Save();
}
public function addCalculationHook($code, $name, $class, $method){
BaseService::getInstance()->addCalculationHook($code, $name, $class, $method);
}
}

View File

@@ -46,6 +46,7 @@ class BaseService{
var $emailSender = null;
var $user = null;
var $historyManagers = array();
var $calculationHooks = array();
private static $me = null;
@@ -133,8 +134,13 @@ class BaseService{
$list = $obj->Find("1=1".$query.$orderBy,$queryData);
}
$newList = array();
foreach($list as $listObj){
$newList[] = $this->cleanUpAdoDB($listObj);
}
if(!empty($mappingStr) && count($map)>0){
$list = $this->populateMapping($list, $map);
$list = $this->populateMapping($newList, $map);
}
return $list;
@@ -363,7 +369,7 @@ class BaseService{
$processedList = array();
foreach($list as $obj){
$processedList[] = $obj->postProcessGetData($obj);
$processedList[] = $this->cleanUpAdoDB($obj->postProcessGetData($obj));
}
$list = $processedList;
@@ -488,7 +494,8 @@ class BaseService{
}
}
}
return $obj->postProcessGetData($obj);
$obj = $obj->postProcessGetElement($obj);
return $this->cleanUpAdoDB($obj->postProcessGetData($obj));
}
return null;
}
@@ -685,6 +692,7 @@ class BaseService{
}
foreach($list as $obj){
$obj = $this->cleanUpAdoDB($obj);
if(count($values) == 1){
$ret[$obj->$key] = $obj->$value;
}else{
@@ -1258,6 +1266,60 @@ class BaseService{
return $obj;
}
public function addCalculationHook($code, $name, $class, $method){
$calcualtionHook = new CalculationHook();
$calcualtionHook->code = $code;
$calcualtionHook->name = $name;
$calcualtionHook->class = $class;
$calcualtionHook->method = $method;
$this->calculationHooks[$code] = $calcualtionHook;
}
public function getCalculationHooks(){
return array_values($this->calculationHooks);
}
public function getCalculationHook($code){
return $this->calculationHooks[$code];
}
public function executeCalculationHook($parameters, $code = NULL){
$ch = BaseService::getInstance()->getCalculationHook($code);
if(empty($ch->code)){
return null;
}
$class = $ch->class;
return call_user_func_array(array(new $class(), $ch->method), $parameters);
}
public function cleanNonUTFChar($obj){
$regex = <<<'END'
/
(
(?: [\x00-\x7F] # single-byte sequences 0xxxxxxx
| [\xC0-\xDF][\x80-\xBF] # double-byte sequences 110xxxxx 10xxxxxx
| [\xE0-\xEF][\x80-\xBF]{2} # triple-byte sequences 1110xxxx 10xxxxxx * 2
| [\xF0-\xF7][\x80-\xBF]{3} # quadruple-byte sequence 11110xxx 10xxxxxx * 3
){1,100} # ...one or more times
)
| . # anything else
/x
END;
if(is_string($obj)){
return preg_replace($regex, '$1', $obj);
}else{
foreach($obj as $key => $val){
$obj->$key = preg_replace($regex, '$1', $val);
}
return $obj;
}
}
}

View File

@@ -102,7 +102,7 @@ class IceCron{
return true;
}
}else{
if(intval(date('m')) <= intval($time) && date('H') != date('H',strtotime($lastRunTime))){
if(intval(date('i')) <= intval($time) && date('H') != date('H',strtotime($lastRunTime))){
return true;
}
}
@@ -113,7 +113,7 @@ class IceCron{
return true;
}
}else{
if(intval(date('H')) <= intval($time) && date('d') != date('d',strtotime($lastRunTime))){
if(intval(date('H')) >= intval($time) && date('d') != date('d',strtotime($lastRunTime))){
return true;
}
}
@@ -124,7 +124,7 @@ class IceCron{
return true;
}
}else{
if(intval(date('d')) <= intval($time) && date('m') != date('m',strtotime($lastRunTime))){
if(intval(date('d')) >= intval($time) && date('m') != date('m',strtotime($lastRunTime))){
return true;
}
}
@@ -134,7 +134,7 @@ class IceCron{
return true;
}
}else{
if(intval(date('m')) <= intval($time) && date('Y') != date('Y',strtotime($lastRunTime))){
if(intval(date('m')) >= intval($time) && date('Y') != date('Y',strtotime($lastRunTime))){
return true;
}
}

176
src/classes/Macaw.php Executable file
View File

@@ -0,0 +1,176 @@
<?php
namespace NoahBuscher\Macaw;
/**
* @method static Macaw get(string $route, Callable $callback)
* @method static Macaw post(string $route, Callable $callback)
* @method static Macaw put(string $route, Callable $callback)
* @method static Macaw delete(string $route, Callable $callback)
* @method static Macaw options(string $route, Callable $callback)
* @method static Macaw head(string $route, Callable $callback)
*/
class Macaw
{
public static $halts = false;
public static $routes = array();
public static $methods = array();
public static $callbacks = array();
public static $patterns = array(
':any' => '[^/]+',
':num' => '[0-9]+',
':all' => '.*'
);
public static $error_callback;
/**
* Defines a route w/ callback and method
*/
public static function __callstatic($method, $params)
{
$uri = dirname($_SERVER['PHP_SELF']).$params[0];
$callback = $params[1];
array_push(self::$routes, $uri);
array_push(self::$methods, strtoupper($method));
array_push(self::$callbacks, $callback);
}
/**
* Defines callback if route is not found
*/
public static function error($callback)
{
self::$error_callback = $callback;
}
public static function haltOnMatch($flag = true)
{
self::$halts = $flag;
}
/**
* Runs the callback for the given request
*/
public static function dispatch()
{
$uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$method = $_SERVER['REQUEST_METHOD'];
$searches = array_keys(static::$patterns);
$replaces = array_values(static::$patterns);
$found_route = false;
self::$routes = str_replace('//', '/', self::$routes);
// check if route is defined without regex
if (in_array($uri, self::$routes)) {
$route_pos = array_keys(self::$routes, $uri);
foreach ($route_pos as $route) {
//using an ANY option to match both GET and POST requests
if (self::$methods[$route] == $method || self::$methods[$route] == 'ANY') {
$found_route = true;
//if route is not an object
if(!is_object(self::$callbacks[$route])){
//grab all parts based on a / separator
$parts = explode('/',self::$callbacks[$route]);
//collect the last index of the array
$last = end($parts);
//grab the controller name and method call
$segments = explode('@',$last);
//instanitate controller
$controller = new $segments[0]();
//call method
$controller->$segments[1]();
if (self::$halts) return;
} else {
//call closure
call_user_func(self::$callbacks[$route]);
if (self::$halts) return;
}
}
}
} else {
// check if defined with regex
$pos = 0;
foreach (self::$routes as $route) {
if (strpos($route, ':') !== false) {
$route = str_replace($searches, $replaces, $route);
}
if (preg_match('#^' . $route . '$#', $uri, $matched)) {
if (self::$methods[$pos] == $method) {
$found_route = true;
array_shift($matched); //remove $matched[0] as [1] is the first parameter.
if(!is_object(self::$callbacks[$pos])){
//grab all parts based on a / separator
$parts = explode('/',self::$callbacks[$pos]);
//collect the last index of the array
$last = end($parts);
//grab the controller name and method call
$segments = explode('@',$last);
//instanitate controller
$controller = new $segments[0]();
//fix multi parameters
if(!method_exists($controller, $segments[1])){
echo "controller and action not found";
}else{
call_user_func_array(array($controller, $segments[1]), $matched);
}
//call method and pass any extra parameters to the method
// $controller->$segments[1](implode(",", $matched));
if (self::$halts) return;
} else {
call_user_func_array(self::$callbacks[$pos], $matched);
if (self::$halts) return;
}
}
}
$pos++;
}
}
// run the error callback if the route was not found
if ($found_route == false) {
if (!self::$error_callback) {
self::$error_callback = function() {
header($_SERVER['SERVER_PROTOCOL']." 404 Not Found");
echo '404';
};
}
call_user_func(self::$error_callback);
}
}
}

View File

@@ -49,14 +49,14 @@ class RestApiManager{
$accessToken = $this->generateUserAccessToken($user)->getData();
if(!empty($accessTokenObj->id)){
$accessTokenObj->token = $accessToken;
$accessTokenObj->hash = base64_encode(CLIENT_BASE_URL).":".md5($accessTokenObj->token);
$accessTokenObj->hash = md5(CLIENT_BASE_URL.$accessTokenObj->token);
$accessTokenObj->updated = date("Y-m-d H:i:s");
$accessTokenObj->Save();
}else{
$accessTokenObj = new RestAccessToken();
$accessTokenObj->userId = $user->id;
$accessTokenObj->token = $accessToken;
$accessTokenObj->hash = base64_encode(CLIENT_BASE_URL).":".md5($accessTokenObj->token);
$accessTokenObj->hash = md5(CLIENT_BASE_URL.$accessTokenObj->token);
$accessTokenObj->updated = date("Y-m-d H:i:s");
$accessTokenObj->created = date("Y-m-d H:i:s");
$accessTokenObj->Save();
@@ -69,13 +69,14 @@ class RestApiManager{
public function validateAccessToken($hash){
$accessTokenObj = new RestAccessToken();
LogManager::getInstance()->info("AT Hash:".$hash);
$accessTokenObj->Load("hash = ?",array($hash));
LogManager::getInstance()->info("AT Hash Object:".json_encode($accessTokenObj));
if(!empty($accessTokenObj->id) && $accessTokenObj->hash == $hash){
return $this->validateAccessTokenInner($accessTokenObj->token);
}
return new IceResponse(IceResponse::ERROR, "Acess Token not found");
return new IceResponse(IceResponse::ERROR, "Access Token not found");
}
private function validateAccessTokenInner($accessToken){
@@ -122,30 +123,40 @@ class RestApiManager{
class RestEndPoint{
var $url;
public function setUrl($url){
$this->url = $url;
public function process($type , $parameter = NULL){
$resp = $this->$type($parameter);
$this->printResponse($resp);
}
public function getUrl(){
return $this->url;
public function get($parameter){
return new IceResponse(IceResponse::ERROR, "Method not Implemented");
}
public function get($parameters){
return new IceResponse(IceResponse::ERROR, false);
public function post($parameter){
return new IceResponse(IceResponse::ERROR, "Method not Implemented");
}
public function post($parameters){
return new IceResponse(IceResponse::ERROR, false);
public function put($parameter){
return new IceResponse(IceResponse::ERROR, "Method not Implemented");
}
public function put($parameters){
return new IceResponse(IceResponse::ERROR, false);
public function delete($parameter){
return new IceResponse(IceResponse::ERROR, "Method not Implemented");
}
public function delete($parameters){
return new IceResponse(IceResponse::ERROR, false);
public function clearObject($obj){
return BaseService::getInstance()->cleanUpAdoDB($obj);
}
public function validateAccessToken(){
$accessTokenValidation = RestApiManager::getInstance()->validateAccessToken($_REQUEST['access_token']);
return $accessTokenValidation;
}
public function printResponse($response){
echo json_encode($response,JSON_PRETTY_PRINT);
}
}

View File

@@ -90,7 +90,18 @@ if(in_array($table, BaseService::getInstance()->userTables) && !$skipProfileRest
}
$subordinatesIds.=$sub->id;
}
$subordinatesIds.="";
if($obj->allowIndirectMapping()){
$indeirectEmployees = $subordinate->Find("indirect_supervisors IS NOT NULL and indirect_supervisors <> '' and status = 'Active'", array());
foreach($indeirectEmployees as $ie){
$indirectSupervisors = json_decode($ie->indirect_supervisors, true);
if(in_array($cemp, $indirectSupervisors)){
if($subordinatesIds != ""){
$subordinatesIds.=",";
}
$subordinatesIds.=$ie->id;
}
}
}
$sql = "Select count(id) as count from ".$obj->_table." where ".SIGN_IN_ELEMENT_MAPPING_FIELD_NAME." in (".$subordinatesIds.") ".$countFilterQuery;
LogManager::getInstance()->debug("Count Filter Query 2:".$sql);
LogManager::getInstance()->debug("Count Filter Query Data 2:".json_encode($countFilterQueryData));

View File

@@ -12,6 +12,7 @@ include (APP_BASE_PATH."utils/SessionUtils.php");
include (APP_BASE_PATH."utils/InputCleaner.php");
include (APP_BASE_PATH."utils/LogManager.php");
include (APP_BASE_PATH."utils/CalendarTools.php");
include (APP_BASE_PATH."utils/EvalMath.php");
$_REQUEST = InputCleaner::cleanParameters($_REQUEST);

View File

@@ -0,0 +1,132 @@
/*global $, window*/
$.fn.editableTableWidget = function (options) {
'use strict';
return $(this).each(function () {
var buildDefaultOptions = function () {
var opts = $.extend({}, $.fn.editableTableWidget.defaultOptions);
opts.editor = opts.editor.clone();
return opts;
},
activeOptions = $.extend(buildDefaultOptions(), options),
ARROW_LEFT = 37, ARROW_UP = 38, ARROW_RIGHT = 39, ARROW_DOWN = 40, ENTER = 13, ESC = 27, TAB = 9,
element = $(this),
editor = activeOptions.editor.css('position', 'absolute').hide().appendTo(element.parent()),
active,
showEditor = function (select) {
//active = element.find('td:focus');
active = element.find('td.editcell:focus');
if (active.length) {
editor.val(active.text())
.removeClass('error')
.show()
.offset(active.offset())
.css(active.css(activeOptions.cloneProperties))
.width(active.width())
.height(active.height())
.focus();
if (select) {
editor.select();
}
}
},
setActiveText = function () {
var text = editor.val(),
evt = $.Event('change'),
originalContent;
if (active.text() === text || editor.hasClass('error')) {
return true;
}
originalContent = active.html();
active.text(text).trigger(evt, text);
if (evt.result === false) {
active.html(originalContent);
}
},
movement = function (element, keycode) {
if (keycode === ARROW_RIGHT) {
return element.next('td');
} else if (keycode === ARROW_LEFT) {
return element.prev('td');
} else if (keycode === ARROW_UP) {
return element.parent().prev().children().eq(element.index());
} else if (keycode === ARROW_DOWN) {
return element.parent().next().children().eq(element.index());
}
return [];
};
editor.blur(function () {
setActiveText();
editor.hide();
}).keydown(function (e) {
if (e.which === ENTER) {
setActiveText();
editor.hide();
active.focus();
e.preventDefault();
e.stopPropagation();
} else if (e.which === ESC) {
editor.val(active.text());
e.preventDefault();
e.stopPropagation();
editor.hide();
active.focus();
} else if (e.which === TAB) {
active.focus();
} else if (this.selectionEnd - this.selectionStart === this.value.length) {
var possibleMove = movement(active, e.which);
if (possibleMove.length > 0) {
possibleMove.focus();
e.preventDefault();
e.stopPropagation();
}
}
})
.on('input paste', function () {
var evt = $.Event('validate');
active.trigger(evt, editor.val());
if (evt.result === false) {
editor.addClass('error');
} else {
editor.removeClass('error');
}
});
element.on('click keypress dblclick', showEditor)
.css('cursor', 'pointer')
.keydown(function (e) {
var prevent = true,
possibleMove = movement($(e.target), e.which);
if (possibleMove.length > 0) {
possibleMove.focus();
} else if (e.which === ENTER) {
showEditor(false);
} else if (e.which === 17 || e.which === 91 || e.which === 93) {
showEditor(true);
prevent = false;
} else {
prevent = false;
}
if (prevent) {
e.stopPropagation();
e.preventDefault();
}
});
element.find('td').prop('tabindex', 1);
$(window).on('resize', function () {
if (editor.is(':visible')) {
editor.offset(active.offset())
.width(active.width())
.height(active.height());
}
});
});
};
$.fn.editableTableWidget.defaultOptions = {
cloneProperties: ['padding', 'padding-top', 'padding-bottom', 'padding-left', 'padding-right',
'text-align', 'font', 'font-size', 'font-family', 'font-weight',
'border', 'border-top', 'border-bottom', 'border-left', 'border-right'],
editor: $('<input>')
};

View File

@@ -4,4 +4,4 @@ $_SESSION['user'] = null;
session_destroy();
session_write_close();
$user = null;
header("Location:".CLIENT_BASE_URL."login.php");
header("Location:".CLIENT_BASE_URL."login.php?login=no");

View File

@@ -61,6 +61,10 @@ class ICEHRM_Record extends ADOdb_Active_Record{
return $obj;
}
public function postProcessGetElement($obj){
return $obj;
}
public function getDefaultAccessLevel(){
return array("get","element","save","delete");
}

View File

@@ -48,6 +48,17 @@ class Setting extends ICEHRM_Record {
return array();
}
public function postProcessGetElement($obj){
if($obj->name == 'Api: REST Api Token'){
$user = BaseService::getInstance()->getCurrentUser();
$dbUser = new User();
$dbUser->Load("id = ?",array($user->id));
$resp = RestApiManager::getInstance()->getAccessTokenForUser($dbUser);
$obj->value = $resp->getData();
}
return $obj;
}
var $_table = 'Settings';
}

View File

@@ -23,6 +23,12 @@ if(SettingsManager::getInstance()->getSetting("System: Add New Permissions") ==
SettingsManager::getInstance()->setSetting("System: Add New Permissions","0");
}
$resetModuleNames = false;
if(SettingsManager::getInstance()->getSetting("System: Reset Module Names") == "1"){
$resetModuleNames = true;
SettingsManager::getInstance()->setSetting("System: Reset Module Names","0");
}
function includeModuleManager($type,$name,$data){
$moduleCapsName = ucfirst($name);
$moduleTypeCapsName = ucfirst($type); // Admin or Modules
@@ -104,6 +110,12 @@ foreach($ams as $am){
createPermissions($meta, $dbModule->id);
}
if($resetModuleNames){
$dbModule->label = $arr['label'];
$dbModule->menu = $arr['menu'];
$dbModule->icon = $arr['icon'];
$dbModule->Save();
}
$arr['name'] = $dbModule->name;
$arr['label'] = $dbModule->label;
@@ -191,6 +203,12 @@ foreach($ams as $am){
createPermissions($meta, $dbModule->id);
}
if($resetModuleNames){
$dbModule->label = $arr['label'];
$dbModule->menu = $arr['menu'];
$dbModule->icon = $arr['icon'];
$dbModule->Save();
}
$arr['name'] = $dbModule->name;
$arr['label'] = $dbModule->label;

View File

@@ -6,27 +6,26 @@ include ("config.base.php");
include ("include.common.php");
include("server.includes.inc.php");
//clean request uri
LogManager::getInstance()->info("REQUEST_URI :".$_SERVER['REQUEST_URI']);
$parts = explode("?", $_SERVER['REQUEST_URI']);
$uri = $parts[0];
if(substr($uri, -1) == "/"){
$uri = substr($uri, 0, -1);
}
if(SettingsManager::getInstance()->getSetting('Api: REST Api Enabled') == '1') {
LogManager::getInstance()->info("REQUEST_URI Cleaned :".$uri);
$type = strtolower($_SERVER['REQUEST_METHOD']);
define('REST_API_PATH', '/api/');
LogManager::getInstance()->info("Request: " . $_REQUEST);
\NoahBuscher\Macaw\Macaw::get(REST_API_PATH . 'echo', function () {
echo "Echo " . rand();
});
$moduleManagers = BaseService::getInstance()->getModuleManagers();
foreach ($moduleManagers as $moduleManagerObj) {
$moduleManagerObj->setupRestEndPoints();
}
\NoahBuscher\Macaw\Macaw::dispatch();
$supportedMethods = array('get','post','put','delete');
if(!in_array($type, $supportedMethods)){
echo json_encode(new IceResponse(IceResponse::ERROR, "Method not supported"));
exit();
}
$response = RestApiManager::getInstance()->process($type, $uri, $_REQUEST);
if($response->getStatus() == IceResponse::SUCCESS){
echo json_encode($response,JSON_PRETTY_PRINT);
}else{
echo json_encode($response,JSON_PRETTY_PRINT);
echo "REST Api is not enabled. Please set 'Api: REST Api Enabled' setting to true";
}
exit();

View File

@@ -39,6 +39,7 @@ include (APP_BASE_PATH."classes/UIManager.php");
include (APP_BASE_PATH."classes/RestApiManager.php");
include (APP_BASE_PATH."classes/ModuleBuilder.php");
include (APP_BASE_PATH."classes/SimpleImage.php");
include (APP_BASE_PATH."classes/Macaw.php");
include (APP_BASE_PATH."classes/crypt/Aes.php");
include (APP_BASE_PATH."classes/crypt/AesCtr.php");
@@ -112,7 +113,8 @@ if(defined('CLIENT_PATH')){
$moduleManagerObj->setupUserClasses($userTables);
$moduleManagerObj->setupFileFieldMappings($fileFields);
$moduleManagerObj->setupErrorMappings($mysqlErrors);
$moduleManagerObj->setupRestEndPoints();
//$moduleManagerObj->setupRestEndPoints();
$moduleManagerObj->initCalculationHooks();
$modelClassList = $moduleManagerObj->getModelClasses();

View File

@@ -263,4 +263,34 @@ if($action == 'get'){
}
echo json_encode($ret);
$res = json_encode($ret);
if(empty($res) && !empty($ret)){
//Do this only if there is a json encoding error
if(!empty($ret['object'])) {
if (is_array($ret['object'])) {
$newObjects = array();
foreach ($ret['object'] as $obj) {
$newObjects[] = BaseService::getInstance()->cleanNonUTFChar($obj);
}
$ret['object'] = $newObjects;
} else {
$ret['object'] = BaseService::getInstance()->cleanNonUTFChar($ret['object']);
}
}else if(!empty($ret['data'])){
if (is_array($ret['data'])) {
$newObjects = array();
foreach ($ret['data'] as $obj) {
$newObjects[] = BaseService::getInstance()->cleanNonUTFChar($obj);
}
$ret['data'] = $newObjects;
} else {
$ret['data'] = BaseService::getInstance()->cleanNonUTFChar($ret['data']);
}
}
echo json_encode($ret);
}else{
echo $res;
}

608
src/utils/EvalMath.php Normal file
View File

@@ -0,0 +1,608 @@
<?php
/*
================================================================================
EvalMath - PHP Class to safely evaluate math expressions
Copyright (C) 2005 Miles Kaufmann <http://www.twmagic.com/>
================================================================================
NAME
EvalMath - safely evaluate math expressions
SYNOPSIS
<?
include('evalmath.class.php');
$m = new EvalMath;
// basic evaluation:
$result = $m->evaluate('2+2');
// supports: order of operation; parentheses; negation; built-in functions
$result = $m->evaluate('-8(5/2)^2*(1-sqrt(4))-8');
// create your own variables
$m->evaluate('a = e^(ln(pi))');
// or functions
$m->evaluate('f(x,y) = x^2 + y^2 - 2x*y + 1');
// and then use them
$result = $m->evaluate('3*f(42,a)');
?>
DESCRIPTION
Use the EvalMath class when you want to evaluate mathematical expressions
from untrusted sources. You can define your own variables and functions,
which are stored in the object. Try it, it's fun!
METHODS
$m->evalute($expr)
Evaluates the expression and returns the result. If an error occurs,
prints a warning and returns false. If $expr is a function assignment,
returns true on success.
$m->e($expr)
A synonym for $m->evaluate().
$m->vars()
Returns an associative array of all user-defined variables and values.
$m->funcs()
Returns an array of all user-defined functions.
PARAMETERS
$m->suppress_errors
Set to true to turn off warnings when evaluating expressions
$m->last_error
If the last evaluation failed, contains a string describing the error.
(Useful when suppress_errors is on).
AUTHOR INFORMATION
Copyright 2005, Miles Kaufmann.
LICENSE
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1 Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote
products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
/**
* This class was heavily modified in order to get usefull spreadsheet emulation ;-)
* skodak
*
*/
if(!class_exists('EvalMath')) {
class EvalMath
{
/** @var string Pattern used for a valid function or variable name. Note, var and func names are case insensitive. */
private static $namepat = '[a-z][a-z0-9_]*';
var $suppress_errors = false;
var $last_error = null;
var $v = array(); // variables (and constants)
var $f = array(); // user-defined functions
var $vb = array(); // constants
var $fb = array( // built-in functions
'sin', 'sinh', 'arcsin', 'asin', 'arcsinh', 'asinh',
'cos', 'cosh', 'arccos', 'acos', 'arccosh', 'acosh',
'tan', 'tanh', 'arctan', 'atan', 'arctanh', 'atanh',
'sqrt', 'abs', 'ln', 'log', 'exp', 'floor', 'ceil');
var $fc = array( // calc functions emulation
'average' => array(-1), 'max' => array(-1), 'min' => array(-1),
'mod' => array(2), 'pi' => array(0), 'power' => array(2),
'round' => array(1, 2), 'sum' => array(-1), 'rand_int' => array(2),
'rand_float' => array(0));
var $allowimplicitmultiplication;
public function __construct($allowconstants = false, $allowimplicitmultiplication = false)
{
if ($allowconstants) {
$this->v['pi'] = pi();
$this->v['e'] = exp(1);
}
$this->allowimplicitmultiplication = $allowimplicitmultiplication;
}
/**
* Old syntax of class constructor. Deprecated in PHP7.
*
* @deprecated since Moodle 3.1
*/
public function EvalMath($allowconstants = false, $allowimplicitmultiplication = false)
{
debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER);
self::__construct($allowconstants, $allowimplicitmultiplication);
}
function e($expr)
{
return $this->evaluate($expr);
}
function evaluate($expr)
{
$this->last_error = null;
$expr = trim($expr);
if (substr($expr, -1, 1) == ';') $expr = substr($expr, 0, strlen($expr) - 1); // strip semicolons at the end
//===============
// is it a variable assignment?
if (preg_match('/^\s*(' . self::$namepat . ')\s*=\s*(.+)$/', $expr, $matches)) {
if (in_array($matches[1], $this->vb)) { // make sure we're not assigning to a constant
return $this->trigger(get_string('cannotassigntoconstant', 'mathslib', $matches[1]));
}
if (($tmp = $this->pfx($this->nfx($matches[2]))) === false) return false; // get the result and make sure it's good
$this->v[$matches[1]] = $tmp; // if so, stick it in the variable array
return $this->v[$matches[1]]; // and return the resulting value
//===============
// is it a function assignment?
} elseif (preg_match('/^\s*(' . self::$namepat . ')\s*\(\s*(' . self::$namepat . '(?:\s*,\s*' . self::$namepat . ')*)\s*\)\s*=\s*(.+)$/', $expr, $matches)) {
$fnn = $matches[1]; // get the function name
if (in_array($matches[1], $this->fb)) { // make sure it isn't built in
return $this->trigger(get_string('cannotredefinebuiltinfunction', 'mathslib', $matches[1]));
}
$args = explode(",", preg_replace("/\s+/", "", $matches[2])); // get the arguments
if (($stack = $this->nfx($matches[3])) === false) return false; // see if it can be converted to postfix
for ($i = 0; $i < count($stack); $i++) { // freeze the state of the non-argument variables
$token = $stack[$i];
if (preg_match('/^' . self::$namepat . '$/', $token) and !in_array($token, $args)) {
if (array_key_exists($token, $this->v)) {
$stack[$i] = $this->v[$token];
} else {
return $this->trigger(get_string('undefinedvariableinfunctiondefinition', 'mathslib', $token));
}
}
}
$this->f[$fnn] = array('args' => $args, 'func' => $stack);
return true;
//===============
} else {
return $this->pfx($this->nfx($expr)); // straight up evaluation, woo
}
}
function vars()
{
return $this->v;
}
function funcs()
{
$output = array();
foreach ($this->f as $fnn => $dat)
$output[] = $fnn . '(' . implode(',', $dat['args']) . ')';
return $output;
}
/**
* @param string $name
* @return boolean Is this a valid var or function name?
*/
public static function is_valid_var_or_func_name($name)
{
return preg_match('/' . self::$namepat . '$/iA', $name);
}
//===================== HERE BE INTERNAL METHODS ====================\\
// Convert infix to postfix notation
function nfx($expr)
{
$index = 0;
$stack = new EvalMathStack;
$output = array(); // postfix form of expression, to be passed to pfx()
$expr = trim(strtolower($expr));
$ops = array('+', '-', '*', '/', '^', '_');
$ops_r = array('+' => 0, '-' => 0, '*' => 0, '/' => 0, '^' => 1); // right-associative operator?
$ops_p = array('+' => 0, '-' => 0, '*' => 1, '/' => 1, '_' => 1, '^' => 2); // operator precedence
$expecting_op = false; // we use this in syntax-checking the expression
// and determining when a - is a negation
if (preg_match("/[^\w\s+*^\/()\.,-]/", $expr, $matches)) { // make sure the characters are all good
return $this->trigger(get_string('illegalcharactergeneral', 'mathslib', $matches[0]));
}
while (1) { // 1 Infinite Loop ;)
$op = substr($expr, $index, 1); // get the first character at the current index
// find out if we're currently at the beginning of a number/variable/function/parenthesis/operand
$ex = preg_match('/^(' . self::$namepat . '\(?|\d+(?:\.\d*)?(?:(e[+-]?)\d*)?|\.\d+|\()/', substr($expr, $index), $match);
//===============
if ($op == '-' and !$expecting_op) { // is it a negation instead of a minus?
$stack->push('_'); // put a negation on the stack
$index++;
} elseif ($op == '_') { // we have to explicitly deny this, because it's legal on the stack
return $this->trigger(get_string('illegalcharacterunderscore', 'mathslib')); // but not in the input expression
//===============
} elseif ((in_array($op, $ops) or $ex) and $expecting_op) { // are we putting an operator on the stack?
if ($ex) { // are we expecting an operator but have a number/variable/function/opening parethesis?
if (!$this->allowimplicitmultiplication) {
return $this->trigger(get_string('implicitmultiplicationnotallowed', 'mathslib'));
} else {// it's an implicit multiplication
$op = '*';
$index--;
}
}
// heart of the algorithm:
while ($stack->count > 0 and ($o2 = $stack->last()) and in_array($o2, $ops) and ($ops_r[$op] ? $ops_p[$op] < $ops_p[$o2] : $ops_p[$op] <= $ops_p[$o2])) {
$output[] = $stack->pop(); // pop stuff off the stack into the output
}
// many thanks: http://en.wikipedia.org/wiki/Reverse_Polish_notation#The_algorithm_in_detail
$stack->push($op); // finally put OUR operator onto the stack
$index++;
$expecting_op = false;
//===============
} elseif ($op == ')' and $expecting_op) { // ready to close a parenthesis?
while (($o2 = $stack->pop()) != '(') { // pop off the stack back to the last (
if (is_null($o2)) return $this->trigger(get_string('unexpectedclosingbracket', 'mathslib'));
else $output[] = $o2;
}
if (preg_match('/^(' . self::$namepat . ')\($/', $stack->last(2), $matches)) { // did we just close a function?
$fnn = $matches[1]; // get the function name
$arg_count = $stack->pop(); // see how many arguments there were (cleverly stored on the stack, thank you)
$fn = $stack->pop();
$output[] = array('fn' => $fn, 'fnn' => $fnn, 'argcount' => $arg_count); // send function to output
if (in_array($fnn, $this->fb)) { // check the argument count
if ($arg_count > 1) {
$a = new stdClass();
$a->expected = 1;
$a->given = $arg_count;
return $this->trigger(get_string('wrongnumberofarguments', 'mathslib', $a));
}
} elseif (array_key_exists($fnn, $this->fc)) {
$counts = $this->fc[$fnn];
if (in_array(-1, $counts) and $arg_count > 0) {
} elseif (!in_array($arg_count, $counts)) {
$a = new stdClass();
$a->expected = implode('/', $this->fc[$fnn]);
$a->given = $arg_count;
return $this->trigger(get_string('wrongnumberofarguments', 'mathslib', $a));
}
} elseif (array_key_exists($fnn, $this->f)) {
if ($arg_count != count($this->f[$fnn]['args'])) {
$a = new stdClass();
$a->expected = count($this->f[$fnn]['args']);
$a->given = $arg_count;
return $this->trigger(get_string('wrongnumberofarguments', 'mathslib', $a));
}
} else { // did we somehow push a non-function on the stack? this should never happen
return $this->trigger(get_string('internalerror', 'mathslib'));
}
}
$index++;
//===============
} elseif ($op == ',' and $expecting_op) { // did we just finish a function argument?
while (($o2 = $stack->pop()) != '(') {
if (is_null($o2)) return $this->trigger(get_string('unexpectedcomma', 'mathslib')); // oops, never had a (
else $output[] = $o2; // pop the argument expression stuff and push onto the output
}
// make sure there was a function
if (!preg_match('/^(' . self::$namepat . ')\($/', $stack->last(2), $matches))
return $this->trigger(get_string('unexpectedcomma', 'mathslib'));
$stack->push($stack->pop() + 1); // increment the argument count
$stack->push('('); // put the ( back on, we'll need to pop back to it again
$index++;
$expecting_op = false;
//===============
} elseif ($op == '(' and !$expecting_op) {
$stack->push('('); // that was easy
$index++;
$allow_neg = true;
//===============
} elseif ($ex and !$expecting_op) { // do we now have a function/variable/number?
$expecting_op = true;
$val = $match[1];
if (preg_match('/^(' . self::$namepat . ')\($/', $val, $matches)) { // may be func, or variable w/ implicit multiplication against parentheses...
if (in_array($matches[1], $this->fb) or array_key_exists($matches[1], $this->f) or array_key_exists($matches[1], $this->fc)) { // it's a func
$stack->push($val);
$stack->push(1);
$stack->push('(');
$expecting_op = false;
} else { // it's a var w/ implicit multiplication
$val = $matches[1];
$output[] = $val;
}
} else { // it's a plain old var or num
$output[] = $val;
}
$index += strlen($val);
//===============
} elseif ($op == ')') {
//it could be only custom function with no params or general error
if ($stack->last() != '(' or $stack->last(2) != 1) return $this->trigger(get_string('unexpectedclosingbracket', 'mathslib'));
if (preg_match('/^(' . self::$namepat . ')\($/', $stack->last(3), $matches)) { // did we just close a function?
$stack->pop();// (
$stack->pop();// 1
$fn = $stack->pop();
$fnn = $matches[1]; // get the function name
$counts = $this->fc[$fnn];
if (!in_array(0, $counts)) {
$a = new stdClass();
$a->expected = $this->fc[$fnn];
$a->given = 0;
return $this->trigger(get_string('wrongnumberofarguments', 'mathslib', $a));
}
$output[] = array('fn' => $fn, 'fnn' => $fnn, 'argcount' => 0); // send function to output
$index++;
$expecting_op = true;
} else {
return $this->trigger(get_string('unexpectedclosingbracket', 'mathslib'));
}
//===============
} elseif (in_array($op, $ops) and !$expecting_op) { // miscellaneous error checking
return $this->trigger(get_string('unexpectedoperator', 'mathslib', $op));
} else { // I don't even want to know what you did to get here
return $this->trigger(get_string('anunexpectederroroccured', 'mathslib'));
}
if ($index == strlen($expr)) {
if (in_array($op, $ops)) { // did we end with an operator? bad.
return $this->trigger(get_string('operatorlacksoperand', 'mathslib', $op));
} else {
break;
}
}
while (substr($expr, $index, 1) == ' ') { // step the index past whitespace (pretty much turns whitespace
$index++; // into implicit multiplication if no operator is there)
}
}
while (!is_null($op = $stack->pop())) { // pop everything off the stack and push onto output
if ($op == '(') return $this->trigger(get_string('expectingaclosingbracket', 'mathslib')); // if there are (s on the stack, ()s were unbalanced
$output[] = $op;
}
return $output;
}
// evaluate postfix notation
function pfx($tokens, $vars = array())
{
if ($tokens == false) return false;
$stack = new EvalMathStack;
foreach ($tokens as $token) { // nice and easy
// if the token is a function, pop arguments off the stack, hand them to the function, and push the result back on
if (is_array($token)) { // it's a function!
$fnn = $token['fnn'];
$count = $token['argcount'];
if (in_array($fnn, $this->fb)) { // built-in function:
if (is_null($op1 = $stack->pop())) return $this->trigger(get_string('internalerror', 'mathslib'));
$fnn = preg_replace("/^arc/", "a", $fnn); // for the 'arc' trig synonyms
if ($fnn == 'ln') $fnn = 'log';
eval('$stack->push(' . $fnn . '($op1));'); // perfectly safe eval()
} elseif (array_key_exists($fnn, $this->fc)) { // calc emulation function
// get args
$args = array();
for ($i = $count - 1; $i >= 0; $i--) {
if (is_null($args[] = $stack->pop())) return $this->trigger(get_string('internalerror', 'mathslib'));
}
$res = call_user_func_array(array('EvalMathFuncs', $fnn), array_reverse($args));
if ($res === FALSE) {
return $this->trigger(get_string('internalerror', 'mathslib'));
}
$stack->push($res);
} elseif (array_key_exists($fnn, $this->f)) { // user function
// get args
$args = array();
for ($i = count($this->f[$fnn]['args']) - 1; $i >= 0; $i--) {
if (is_null($args[$this->f[$fnn]['args'][$i]] = $stack->pop())) return $this->trigger(get_string('internalerror', 'mathslib'));
}
$stack->push($this->pfx($this->f[$fnn]['func'], $args)); // yay... recursion!!!!
}
// if the token is a binary operator, pop two values off the stack, do the operation, and push the result back on
} elseif (in_array($token, array('+', '-', '*', '/', '^'), true)) {
if (is_null($op2 = $stack->pop())) return $this->trigger(get_string('internalerror', 'mathslib'));
if (is_null($op1 = $stack->pop())) return $this->trigger(get_string('internalerror', 'mathslib'));
switch ($token) {
case '+':
$stack->push($op1 + $op2);
break;
case '-':
$stack->push($op1 - $op2);
break;
case '*':
$stack->push($op1 * $op2);
break;
case '/':
if ($op2 == 0) return $this->trigger(get_string('divisionbyzero', 'mathslib'));
$stack->push($op1 / $op2);
break;
case '^':
$stack->push(pow($op1, $op2));
break;
}
// if the token is a unary operator, pop one value off the stack, do the operation, and push it back on
} elseif ($token == "_") {
$stack->push(-1 * $stack->pop());
// if the token is a number or variable, push it on the stack
} else {
if (is_numeric($token)) {
$stack->push($token);
} elseif (array_key_exists($token, $this->v)) {
$stack->push($this->v[$token]);
} elseif (array_key_exists($token, $vars)) {
$stack->push($vars[$token]);
} else {
return $this->trigger(get_string('undefinedvariable', 'mathslib', $token));
}
}
}
// when we're out of tokens, the stack should have a single element, the final result
if ($stack->count != 1) return $this->trigger(get_string('internalerror', 'mathslib'));
return $stack->pop();
}
// trigger an error, but nicely, if need be
function trigger($msg)
{
$this->last_error = $msg;
if (!$this->suppress_errors) trigger_error($msg, E_USER_WARNING);
return false;
}
}
// for internal use
class EvalMathStack
{
var $stack = array();
var $count = 0;
function push($val)
{
$this->stack[$this->count] = $val;
$this->count++;
}
function pop()
{
if ($this->count > 0) {
$this->count--;
return $this->stack[$this->count];
}
return null;
}
function last($n = 1)
{
if ($this->count - $n >= 0) {
return $this->stack[$this->count - $n];
}
return null;
}
}
// spreadsheet functions emulation
class EvalMathFuncs
{
static function average()
{
$args = func_get_args();
return (call_user_func_array(array('self', 'sum'), $args) / count($args));
}
static function max()
{
$args = func_get_args();
$res = array_pop($args);
foreach ($args as $a) {
if ($res < $a) {
$res = $a;
}
}
return $res;
}
static function min()
{
$args = func_get_args();
$res = array_pop($args);
foreach ($args as $a) {
if ($res > $a) {
$res = $a;
}
}
return $res;
}
static function mod($op1, $op2)
{
return $op1 % $op2;
}
static function pi()
{
return pi();
}
static function power($op1, $op2)
{
return pow($op1, $op2);
}
static function round($val, $precision = 0)
{
return round($val, $precision);
}
static function sum()
{
$args = func_get_args();
$res = 0;
foreach ($args as $a) {
$res += $a;
}
return $res;
}
protected static $randomseed = null;
static function set_random_seed($randomseed)
{
self::$randomseed = $randomseed;
}
static function get_random_seed()
{
if (is_null(self::$randomseed)) {
return microtime();
} else {
return self::$randomseed;
}
}
static function rand_int($min, $max)
{
if ($min >= $max) {
return false; //error
}
$noofchars = ceil(log($max + 1 - $min, '16'));
$md5string = md5(self::get_random_seed());
$stringoffset = 0;
do {
while (($stringoffset + $noofchars) > strlen($md5string)) {
$md5string .= md5($md5string);
}
$randomno = hexdec(substr($md5string, $stringoffset, $noofchars));
$stringoffset += $noofchars;
} while (($min + $randomno) > $max);
return $min + $randomno;
}
static function rand_float()
{
$randomvalues = unpack('v', md5(self::get_random_seed(), true));
return array_shift($randomvalues) / 65536;
}
}
}