Upgrade to v26 (#172)
* A bunch of new updates from icehrm pro * Push changes to frontend
This commit is contained in:
@@ -1,25 +1,8 @@
|
||||
<?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)
|
||||
*/
|
||||
Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de)
|
||||
Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah)
|
||||
*/
|
||||
namespace Attendance\Admin\Api;
|
||||
|
||||
use Attendance\Common\Model\Attendance;
|
||||
|
||||
340
core/src/Attendance/Rest/AttendanceRestEndPoint.php
Normal file
340
core/src/Attendance/Rest/AttendanceRestEndPoint.php
Normal file
@@ -0,0 +1,340 @@
|
||||
<?php
|
||||
namespace Attendance\Rest;
|
||||
|
||||
use Attendance\Common\Model\Attendance;
|
||||
use Classes\BaseService;
|
||||
use Classes\Data\Query\DataQuery;
|
||||
use Classes\Data\Query\Filter;
|
||||
use Classes\IceResponse;
|
||||
use Classes\LanguageManager;
|
||||
use Classes\PermissionManager;
|
||||
use Classes\RestEndPoint;
|
||||
use Employees\Common\Model\Employee;
|
||||
use Users\Common\Model\User;
|
||||
use Utils\LogManager;
|
||||
|
||||
class AttendanceRestEndPoint extends RestEndPoint
|
||||
{
|
||||
const ELEMENT_NAME = 'Attendance';
|
||||
|
||||
public function getModelObject($id)
|
||||
{
|
||||
$obj = new Attendance();
|
||||
$obj->Load("id = ?", array($id));
|
||||
return $obj;
|
||||
}
|
||||
|
||||
public function listAll(User $user)
|
||||
{
|
||||
$query = new DataQuery('Attendance');
|
||||
$query->addColumn('id');
|
||||
$query->addColumn('employee');
|
||||
$query->addColumn('in_time');
|
||||
$query->addColumn('out_time');
|
||||
$query->addColumn('note');
|
||||
|
||||
$limit = self::DEFAULT_LIMIT;
|
||||
if (isset($_GET['limit']) && intval($_GET['limit']) > 0) {
|
||||
$limit = intval($_GET['limit']);
|
||||
}
|
||||
$query->setLength($limit);
|
||||
|
||||
if ($user->user_level !== 'Admin') {
|
||||
$query->setIsSubOrdinates(true);
|
||||
}
|
||||
|
||||
return $this->listByQuery($query);
|
||||
}
|
||||
|
||||
public function listEmployeeAttendance(User $user, $parameter)
|
||||
{
|
||||
$query = new DataQuery('Attendance');
|
||||
$query->addColumn('id');
|
||||
$query->addColumn('employee');
|
||||
$query->addColumn('in_time');
|
||||
$query->addColumn('out_time');
|
||||
$query->addColumn('note');
|
||||
|
||||
$limit = self::DEFAULT_LIMIT;
|
||||
if (isset($_GET['limit']) && intval($_GET['limit']) > 0) {
|
||||
$limit = intval($_GET['limit']);
|
||||
}
|
||||
$query->setLength($limit);
|
||||
|
||||
$query->addFilter(new Filter('employee', $parameter));
|
||||
|
||||
return $this->listByQuery($query);
|
||||
}
|
||||
|
||||
public function get(User $user, $parameter)
|
||||
{
|
||||
if (empty($parameter)) {
|
||||
return new IceResponse(IceResponse::ERROR, self::RESPONSE_ERR_ENTITY_NOT_FOUND, 404);
|
||||
}
|
||||
|
||||
if ($user->user_level !== 'Admin' && !PermissionManager::manipulationAllowed(
|
||||
BaseService::getInstance()->getCurrentProfileId(),
|
||||
$this->getModelObject($parameter)
|
||||
)
|
||||
) {
|
||||
return new IceResponse(IceResponse::ERROR, self::RESPONSE_ERR_PERMISSION_DENIED, 403);
|
||||
}
|
||||
|
||||
$mapping = [
|
||||
"employee" => ["Employee", "id", "first_name+last_name"],
|
||||
];
|
||||
|
||||
$emp = BaseService::getInstance()->getElement(
|
||||
self::ELEMENT_NAME,
|
||||
$parameter,
|
||||
json_encode($mapping),
|
||||
true
|
||||
);
|
||||
|
||||
$emp = $this->enrichElement($emp, $mapping);
|
||||
if (!empty($emp)) {
|
||||
$emp = $this->cleanObject($emp);
|
||||
return new IceResponse(IceResponse::SUCCESS, $emp);
|
||||
}
|
||||
return new IceResponse(IceResponse::ERROR, self::RESPONSE_ERR_ENTITY_NOT_FOUND, 404);
|
||||
}
|
||||
|
||||
public function post(User $user)
|
||||
{
|
||||
$body = $this->getRequestBody();
|
||||
|
||||
$permissionResponse = $this->checkBasicPermissions($user, $body['employee']);
|
||||
if ($permissionResponse->getStatus() !== IceResponse::SUCCESS) {
|
||||
return $permissionResponse;
|
||||
}
|
||||
|
||||
$response = BaseService::getInstance()->addElement(self::ELEMENT_NAME, $body);
|
||||
if ($response->getStatus() === IceResponse::SUCCESS) {
|
||||
$response = $this->get($user, $response->getData()->id);
|
||||
$response->setCode(201);
|
||||
return $response;
|
||||
}
|
||||
|
||||
return new IceResponse(IceResponse::ERROR, $response->getData(), 400);
|
||||
}
|
||||
|
||||
protected function getServerTime()
|
||||
{
|
||||
$currentEmployeeTimeZone = BaseService::getInstance()->getCurrentEmployeeTimeZone();
|
||||
|
||||
if (empty($currentEmployeeTimeZone)) {
|
||||
$currentEmployeeTimeZone = 'Asia/Colombo';
|
||||
}
|
||||
date_default_timezone_set('Asia/Colombo');
|
||||
|
||||
$date = new \DateTime("now", new \DateTimeZone('Asia/Colombo'));
|
||||
|
||||
$date->setTimezone(new \DateTimeZone($currentEmployeeTimeZone));
|
||||
return $date->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
public function punchIn(User $user)
|
||||
{
|
||||
$body = $this->getRequestBody();
|
||||
|
||||
if (empty($body['in_time'])) {
|
||||
$body['in_time'] = $this->getServerTime();
|
||||
}
|
||||
|
||||
if (empty($body['in_time'])) {
|
||||
return new IceResponse(IceResponse::ERROR, 'User department timezone is not set', 400);
|
||||
}
|
||||
|
||||
|
||||
$openPunch = $this->getOpenPunch($user, $body['employee'], $body['in_time']);
|
||||
|
||||
if ($openPunch->getStatus() === IceResponse::SUCCESS && !empty($openPunch->getData()['attendnace'])) {
|
||||
return new IceResponse(IceResponse::ERROR, 'User has already punched in for the day ', 400);
|
||||
}
|
||||
|
||||
$permissionResponse = $this->checkBasicPermissions($user, $body['employee']);
|
||||
if ($permissionResponse->getStatus() !== IceResponse::SUCCESS) {
|
||||
return $permissionResponse;
|
||||
}
|
||||
|
||||
$response = BaseService::getInstance()->addElement(self::ELEMENT_NAME, $body);
|
||||
if ($response->getStatus() === IceResponse::SUCCESS) {
|
||||
$attendance = $this->cleanObject($response->getData());
|
||||
$response->setData($attendance);
|
||||
$response->setCode(201);
|
||||
return $response;
|
||||
}
|
||||
|
||||
return new IceResponse(IceResponse::ERROR, $response->getData(), 400);
|
||||
}
|
||||
|
||||
public function punchOut(User $user)
|
||||
{
|
||||
$body = $this->getRequestBody();
|
||||
|
||||
if (empty($body['out_time'])) {
|
||||
$body['out_time'] = $this->getServerTime();
|
||||
}
|
||||
|
||||
$attendance = $this->findAttendance($body['employee'], $body['out_time']);
|
||||
|
||||
if (empty($body['out_time'])) {
|
||||
return new IceResponse(IceResponse::ERROR, 'User department timezone is not set', 400);
|
||||
}
|
||||
|
||||
if ($attendance->employee.'' !== $body['employee'].'') {
|
||||
return new IceResponse(IceResponse::ERROR, 'User has not punched in for the day ', 400);
|
||||
}
|
||||
|
||||
$permissionResponse = $this->checkBasicPermissions($user, $body['employee']);
|
||||
if ($permissionResponse->getStatus() !== IceResponse::SUCCESS) {
|
||||
return $permissionResponse;
|
||||
}
|
||||
|
||||
$response = $this->savePunch(
|
||||
$body['employee'],
|
||||
$attendance->in_time,
|
||||
$body['note'],
|
||||
$body['out_time'],
|
||||
$attendance->id
|
||||
);
|
||||
|
||||
if ($response->getStatus() === IceResponse::SUCCESS) {
|
||||
$attendance = $this->cleanObject($response->getData());
|
||||
$response->setData($attendance);
|
||||
$response->setCode(200);
|
||||
return $response;
|
||||
}
|
||||
|
||||
return new IceResponse(IceResponse::ERROR, $response->getData(), 400);
|
||||
}
|
||||
|
||||
protected function findAttendance($employeeId, $date)
|
||||
{
|
||||
if (strpos($date, ' ')) {
|
||||
$date = explode(' ', $date)[0];
|
||||
}
|
||||
$attendance = new Attendance();
|
||||
$attendance->Load(
|
||||
"employee = ? and DATE_FORMAT( in_time, '%Y-%m-%d' ) = ? and (out_time is NULL
|
||||
or out_time = '0000-00-00 00:00:00')",
|
||||
array($employeeId,$date)
|
||||
);
|
||||
|
||||
return $attendance;
|
||||
}
|
||||
|
||||
public function getOpenPunch($user, $employeeId, $date)
|
||||
{
|
||||
if ($date === 'today') {
|
||||
$date = explode(' ', $this->getServerTime())[0];
|
||||
}
|
||||
|
||||
$employee = BaseService::getInstance()->getElement('Employee', $employeeId, null, true);
|
||||
|
||||
$attendance = $this->findAttendance($employee->id, $date);
|
||||
|
||||
if ($attendance->employee === $employee->id) {
|
||||
//found an open punch
|
||||
$attendance = $this->cleanObject($attendance);
|
||||
return new IceResponse(
|
||||
IceResponse::SUCCESS,
|
||||
['attendance' => $attendance, 'time' => $this->getServerTime()],
|
||||
200
|
||||
);
|
||||
} else {
|
||||
return new IceResponse(IceResponse::SUCCESS, ['time' => $this->getServerTime()], 200);
|
||||
}
|
||||
}
|
||||
|
||||
protected function savePunch($employeeId, $inDateTime, $note = null, $outDateTime = null, $id = null)
|
||||
{
|
||||
$employee = BaseService::getInstance()->getElement(
|
||||
'Employee',
|
||||
$employeeId,
|
||||
null,
|
||||
true
|
||||
);
|
||||
$inDateArr = explode(" ", $inDateTime);
|
||||
$inDate = $inDateArr[0];
|
||||
|
||||
$outDate = "";
|
||||
if (!empty($outDateTime)) {
|
||||
$outDateArr = explode(" ", $outDateTime);
|
||||
$outDate = $outDateArr[0];
|
||||
}
|
||||
|
||||
//check if dates are differnet
|
||||
if (!empty($outDate) && $inDate != $outDate) {
|
||||
return new IceResponse(
|
||||
IceResponse::ERROR,
|
||||
LanguageManager::tran('Attendance entry should be within a single day')
|
||||
);
|
||||
}
|
||||
|
||||
//compare dates
|
||||
if (!empty($outDateTime) && strtotime($outDateTime) <= strtotime($inDateTime)) {
|
||||
return new IceResponse(IceResponse::ERROR, 'Punch-in time should be earlier than Punch-out time');
|
||||
}
|
||||
|
||||
//Find all punches for the day
|
||||
$attendance = new Attendance();
|
||||
$attendanceList = $attendance->Find(
|
||||
"employee = ? and DATE_FORMAT( in_time, '%Y-%m-%d' ) = ?",
|
||||
array($employee->id,$inDate)
|
||||
);
|
||||
|
||||
foreach ($attendanceList as $attendance) {
|
||||
if (!empty($id) && $id == $attendance->id) {
|
||||
continue;
|
||||
}
|
||||
if (empty($attendance->out_time) || $attendance->out_time == "0000-00-00 00:00:00") {
|
||||
return new IceResponse(
|
||||
IceResponse::ERROR,
|
||||
"There is a non closed attendance entry for today.
|
||||
Please mark punch-out time of the open entry before adding a new one"
|
||||
);
|
||||
} elseif (!empty($outDateTime)) {
|
||||
if (strtotime($attendance->out_time) >= strtotime($outDateTime)
|
||||
&& strtotime($attendance->in_time) <= strtotime($outDateTime)) {
|
||||
//-1---0---1---0 || ---0--1---1---0
|
||||
return new IceResponse(IceResponse::ERROR, "Time entry is overlapping with an existing one");
|
||||
} elseif (strtotime($attendance->out_time) >= strtotime($inDateTime)
|
||||
&& strtotime($attendance->in_time) <= strtotime($inDateTime)) {
|
||||
//---0---1---0---1 || ---0--1---1---0
|
||||
return new IceResponse(IceResponse::ERROR, "Time entry is overlapping with an existing one");
|
||||
} elseif (strtotime($attendance->out_time) <= strtotime($outDateTime)
|
||||
&& strtotime($attendance->in_time) >= strtotime($inDateTime)) {
|
||||
//--1--0---0--1--
|
||||
return new IceResponse(IceResponse::ERROR, "Time entry is overlapping with an existing one");
|
||||
}
|
||||
} else {
|
||||
if (strtotime($attendance->out_time) >= strtotime($inDateTime)
|
||||
&& strtotime($attendance->in_time) <= strtotime($inDateTime)) {
|
||||
//---0---1---0
|
||||
return new IceResponse(IceResponse::ERROR, "Time entry is overlapping with an existing one");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$attendance = new Attendance();
|
||||
if (!empty($id)) {
|
||||
$attendance->Load("id = ?", array($id));
|
||||
}
|
||||
$attendance->in_time = $inDateTime;
|
||||
if (empty($outDateTime)) {
|
||||
$attendance->out_time = null;
|
||||
} else {
|
||||
$attendance->out_time = $outDateTime;
|
||||
}
|
||||
|
||||
$attendance->employee = $employeeId;
|
||||
$attendance->note = $note;
|
||||
$ok = $attendance->Save();
|
||||
if (!$ok) {
|
||||
LogManager::getInstance()->info($attendance->ErrorMsg());
|
||||
return new IceResponse(IceResponse::ERROR, "Error occurred while saving attendance");
|
||||
}
|
||||
return new IceResponse(IceResponse::SUCCESS, $attendance);
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ along with Ice Framework. 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)
|
||||
Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah)
|
||||
*/
|
||||
namespace Classes;
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ abstract class ApproveAdminActionManager extends ApproveCommonActionManager
|
||||
$currentEmpId = $this->getCurrentProfileId();
|
||||
|
||||
if (!empty($currentEmpId)) {
|
||||
$employee = $this->baseService->getElement('Employee', $currentEmpId);
|
||||
$employee = $this->baseService->getElement('Employee', $currentEmpId, null, true);
|
||||
|
||||
$notificationMsg
|
||||
= "Your $itemName has been $obj->status by ".$employee->first_name." ".$employee->last_name;
|
||||
@@ -151,7 +151,9 @@ abstract class ApproveAdminActionManager extends ApproveCommonActionManager
|
||||
if (!empty($sendApprovalEmailto)) {
|
||||
$employee = $this->baseService->getElement(
|
||||
'Employee',
|
||||
BaseService::getInstance()->getCurrentProfileId()
|
||||
BaseService::getInstance()->getCurrentProfileId(),
|
||||
null,
|
||||
true
|
||||
);
|
||||
|
||||
$notificationMsg
|
||||
|
||||
@@ -19,7 +19,7 @@ along with Ice Framework. 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)
|
||||
Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah)
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -1131,7 +1131,7 @@ class BaseService
|
||||
if (in_array($type, $accessMatrix)) {
|
||||
//The user has required permission, so return true
|
||||
return true;
|
||||
} else if (!empty($this->currentUser->$userOnlyMeAccessField)){
|
||||
} elseif (!empty($this->currentUser->$userOnlyMeAccessField)) {
|
||||
//Now we need to check whther the user has access to his own records
|
||||
if ($this->isEmployeeSwitched()) {
|
||||
$accessMatrix = $object->getUserOnlyMeSwitchedAccess();
|
||||
@@ -1632,7 +1632,8 @@ END;
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function safeJsonEncode($value, $options = 0, $depth = 512){
|
||||
public function safeJsonEncode($value, $options = 0, $depth = 512)
|
||||
{
|
||||
$encoded = json_encode($value, $options, $depth);
|
||||
switch (json_last_error()) {
|
||||
case JSON_ERROR_NONE:
|
||||
@@ -1653,22 +1654,24 @@ END;
|
||||
}
|
||||
}
|
||||
|
||||
protected function utf8ize($mixed) {
|
||||
protected function utf8ize($mixed)
|
||||
{
|
||||
if (is_array($mixed)) {
|
||||
foreach ($mixed as $key => $value) {
|
||||
$mixed[$key] = $this->utf8ize($value);
|
||||
}
|
||||
} else if (is_object($mixed)) {
|
||||
} elseif (is_object($mixed)) {
|
||||
foreach ($mixed as $key => $value) {
|
||||
$mixed->$key = $this->utf8ize($value);
|
||||
}
|
||||
} else if (is_string ($mixed)) {
|
||||
} elseif (is_string($mixed)) {
|
||||
return utf8_encode($mixed);
|
||||
}
|
||||
return $mixed;
|
||||
}
|
||||
|
||||
public function generateCsrf($formId) {
|
||||
public function generateCsrf($formId)
|
||||
{
|
||||
$csrfToken = sha1(rand(4500, 100000) . time(). CLIENT_BASE_URL. $this->currentUser->id);
|
||||
SessionUtils::saveSessionObject('csrf-'.$formId, $csrfToken);
|
||||
return $csrfToken;
|
||||
|
||||
@@ -31,7 +31,6 @@ class IceCron
|
||||
|
||||
public function isRunNow()
|
||||
{
|
||||
LogManager::getInstance()->debug("Cron ".print_r($this->cron, true));
|
||||
$lastRunTime = $this->cron->lastrun;
|
||||
if (empty($lastRunTime)) {
|
||||
LogManager::getInstance()->debug("Cron ".$this->cron->name." is running since last run time is empty");
|
||||
|
||||
140
core/src/Classes/Cron/Task/DocumentExpiryNotificationTask.php
Normal file
140
core/src/Classes/Cron/Task/DocumentExpiryNotificationTask.php
Normal file
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Thilina
|
||||
* Date: 8/20/17
|
||||
* Time: 1:31 PM
|
||||
*/
|
||||
|
||||
namespace Classes\Cron\Task;
|
||||
|
||||
use Classes\SettingsManager;
|
||||
use Documents\Common\Model\Document;
|
||||
use Documents\Common\Model\EmployeeDocument;
|
||||
use Employees\Common\Model\Employee;
|
||||
use Utils\LogManager;
|
||||
|
||||
class DocumentExpiryNotificationTask extends EmailIceTask
|
||||
{
|
||||
|
||||
protected $documentCache = array();
|
||||
protected $notificationList = array();
|
||||
protected $employeeDocList = array();
|
||||
protected $employeeEmails = array();
|
||||
|
||||
public function execute($cron)
|
||||
{
|
||||
|
||||
if (SettingsManager::getInstance()->getSetting('Notifications: Send Document Expiry Emails') != '1') {
|
||||
LogManager::getInstance()->info(
|
||||
"Notifications: Send Document Expiry Emails is set to No. Do not send emails"
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
//Get documents
|
||||
|
||||
$dayList = array();
|
||||
$dayList[30] = 'expire_notification_month';
|
||||
$dayList[7] = 'expire_notification_week';
|
||||
$dayList[1] = 'expire_notification_day';
|
||||
$dayList[0] = 'expire_notification';
|
||||
|
||||
foreach ($dayList as $k => $v) {
|
||||
$this->expiryDayNotification($k, $v);
|
||||
}
|
||||
|
||||
$this->getExpireDocumentHTMLByEmployee();
|
||||
$this->sendEmployeeEmails($this->employeeEmails, "IceHrm Employee Document Expiry Reminder");
|
||||
}
|
||||
|
||||
private function expiryDayNotification($day, $param)
|
||||
{
|
||||
$date = date('Y-m-d', strtotime("+".$day." days"));
|
||||
|
||||
$employeeDocument = new EmployeeDocument();
|
||||
$employeeDocuments = $employeeDocument->Find(
|
||||
"valid_until IS NOT NULL and valid_until = ?
|
||||
and (expire_notification_last > ? or expire_notification_last = -1) and status = ?",
|
||||
array($date, $day, 'Active')
|
||||
);
|
||||
|
||||
if (!$employeeDocuments) {
|
||||
LogManager::getInstance()->error("Error :".$employeeDocument->ErrorMsg());
|
||||
return;
|
||||
}
|
||||
|
||||
$query = "valid_until IS NOT NULL and valid_until = $date and
|
||||
(expire_notification_last > $day or expire_notification_last == -1)
|
||||
and status = 'Active';";
|
||||
|
||||
LogManager::getInstance()->debug($query);
|
||||
|
||||
foreach ($employeeDocuments as $doc) {
|
||||
LogManager::getInstance()->debug("Employee Doc :".print_r($doc, true));
|
||||
|
||||
if (empty($doc->document)) {
|
||||
continue;
|
||||
}
|
||||
$document = null;
|
||||
if (isset($this->documentCache[$doc->id])) {
|
||||
$document = $this->documentCache[$doc->id];
|
||||
} else {
|
||||
$document = new Document();
|
||||
$document->Load("id = ?", array($doc->document));
|
||||
$this->documentCache[$document->id] = $document;
|
||||
}
|
||||
|
||||
if ($document->$param == "Yes") {
|
||||
if (!isset($this->notificationList[$doc->employee])) {
|
||||
$this->notificationList[$doc->employee] = array();
|
||||
}
|
||||
$this->notificationList[$doc->employee][] = array($doc, $document, $day);
|
||||
}
|
||||
|
||||
$doc->expire_notification_last = $day;
|
||||
$doc->Save();
|
||||
}
|
||||
}
|
||||
|
||||
private function getExpireDocumentHTMLByEmployee()
|
||||
{
|
||||
$row = '<p style="background-color: #EEE;padding: 5px;font-size: 0.9em;font-weight: bold;">'
|
||||
.'<span style="font-size: 1em;font-weight: bold;">'
|
||||
.'#_name_#</span> - Expire in #_days_# day(s)</p><br/><span style="font-size: 0.8em;font-weight: bold;">'
|
||||
.'#_description_#</span><hr/>';
|
||||
|
||||
foreach ($this->notificationList as $key => $val) {
|
||||
$employeeEmail = "";
|
||||
|
||||
foreach ($val as $list) {
|
||||
$trow = $row;
|
||||
$doc = $list[0];
|
||||
$document = $list[1];
|
||||
$days = $list[2];
|
||||
|
||||
$trow = str_replace("#_name_#", $document->name, $trow);
|
||||
$trow = str_replace("#_days_#", $days, $trow);
|
||||
$trow = str_replace("#_description_#", $doc->details, $trow);
|
||||
|
||||
$employeeEmail.=$trow;
|
||||
}
|
||||
|
||||
$employee = new Employee();
|
||||
$employee->Load("id = ?", array($key));
|
||||
|
||||
if (empty($employee->id) || $employee->id != $key) {
|
||||
LogManager::getInstance()->error("Could not load employee with id");
|
||||
return;
|
||||
}
|
||||
|
||||
$emailBody = file_get_contents(
|
||||
APP_BASE_PATH.'/admin/documents/emailTemplates/documentExpireEmailTemplate.html'
|
||||
);
|
||||
$emailBody = str_replace("#_employee_#", $employee->first_name, $emailBody);
|
||||
$emailBody = str_replace("#_documents_#", $employeeEmail, $emailBody);
|
||||
|
||||
$this->employeeEmails[$employee->id] = $emailBody;
|
||||
}
|
||||
}
|
||||
}
|
||||
29
core/src/Classes/Data/DataReader.php
Normal file
29
core/src/Classes/Data/DataReader.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
namespace Classes\Data;
|
||||
|
||||
use Classes\Data\Query\DataQuery;
|
||||
|
||||
class DataReader
|
||||
{
|
||||
public static function getData(DataQuery $query)
|
||||
{
|
||||
$table = $query->getTable();
|
||||
|
||||
$sLimit = " LIMIT " . intval($query->getStartPage()) . ", " . intval($query->getLength());
|
||||
|
||||
$sortData = $query->getSortingData();
|
||||
$data = \Classes\BaseService::getInstance()->getData(
|
||||
$table,
|
||||
$query->getFieldMapping(),
|
||||
json_encode($query->getFilters()),
|
||||
$query->getOrderBy(),
|
||||
$sLimit,
|
||||
json_encode($query->getColumns()),
|
||||
$query->getSearchTerm(),
|
||||
$query->isIsSubOrdinates(),
|
||||
$query->isSkipProfileRestriction(),
|
||||
$sortData
|
||||
);
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
262
core/src/Classes/Data/Query/DataQuery.php
Normal file
262
core/src/Classes/Data/Query/DataQuery.php
Normal file
@@ -0,0 +1,262 @@
|
||||
<?php
|
||||
namespace Classes\Data\Query;
|
||||
|
||||
class DataQuery
|
||||
{
|
||||
protected $table;
|
||||
protected $columns = [];
|
||||
protected $fieldMapping;
|
||||
protected $filters = null;
|
||||
protected $startPage = 0;
|
||||
protected $length = 15;
|
||||
protected $isSubOrdinates = false;
|
||||
protected $skipProfileRestriction = false;
|
||||
protected $sortingEnabled = false;
|
||||
protected $sortColumn;
|
||||
protected $sortOrder = '';
|
||||
protected $searchTerm = null;
|
||||
protected $isLengthSet = false;
|
||||
protected $orderBy = null;
|
||||
|
||||
/**
|
||||
* DataQuery constructor.
|
||||
* @param $table
|
||||
* @param bool $sortingEnabled
|
||||
* @param $sortColumn
|
||||
* @param string $sortOrder
|
||||
*/
|
||||
public function __construct($table, $sortingEnabled = false, $sortColumn = false, $sortOrder = '', $orderBy = null)
|
||||
{
|
||||
$this->table = $table;
|
||||
$this->sortingEnabled = $sortingEnabled;
|
||||
$this->sortColumn = $sortColumn;
|
||||
$this->sortOrder = $sortOrder;
|
||||
$this->orderBy = $orderBy;
|
||||
}
|
||||
|
||||
|
||||
public function addColumn($column)
|
||||
{
|
||||
$this->columns[] = $column;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addFilter($filter)
|
||||
{
|
||||
if ($this->filters === null) {
|
||||
$this->filters = new \stdClass();
|
||||
}
|
||||
$this->filters->{$filter->getName()} = $filter->getValue();
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getColumns()
|
||||
{
|
||||
return $this->columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getFieldMapping()
|
||||
{
|
||||
return $this->fieldMapping;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getFilters()
|
||||
{
|
||||
return $this->filters;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getStartPage()
|
||||
{
|
||||
return $this->startPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getLength()
|
||||
{
|
||||
return $this->length;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSearchTerm()
|
||||
{
|
||||
return $this->searchTerm;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $searchTerm
|
||||
*/
|
||||
public function setSearchTerm($searchTerm)
|
||||
{
|
||||
$this->searchTerm = $searchTerm;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function isIsSubOrdinates()
|
||||
{
|
||||
return $this->isSubOrdinates;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function isSkipProfileRestriction()
|
||||
{
|
||||
return $this->skipProfileRestriction;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getTable()
|
||||
{
|
||||
return $this->table;
|
||||
}
|
||||
|
||||
public function getSortingData()
|
||||
{
|
||||
$data = array();
|
||||
|
||||
$data['sorting'] = $this->sortingEnabled ? '1' : '0';
|
||||
if (!$this->sortingEnabled) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
$data['column'] = $this->sortColumn;
|
||||
$data['order'] = $this->sortOrder;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $length
|
||||
*/
|
||||
public function setLength($length)
|
||||
{
|
||||
$this->length = $length;
|
||||
if ($length > 0) {
|
||||
$this->isLengthSet = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $startPage
|
||||
*/
|
||||
public function setStartPage($startPage)
|
||||
{
|
||||
$this->startPage = $startPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $isSubOrdinates
|
||||
*/
|
||||
public function setIsSubOrdinates($isSubOrdinates)
|
||||
{
|
||||
$this->isSubOrdinates = $isSubOrdinates;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isLengthSet(): bool
|
||||
{
|
||||
return $this->isLengthSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $table
|
||||
*/
|
||||
public function setTable($table)
|
||||
{
|
||||
$this->table = $table;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $columns
|
||||
*/
|
||||
public function setColumns(array $columns)
|
||||
{
|
||||
$this->columns = $columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $fieldMapping
|
||||
*/
|
||||
public function setFieldMapping($fieldMapping)
|
||||
{
|
||||
$this->fieldMapping = $fieldMapping;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $filters
|
||||
*/
|
||||
public function setFilters(array $filters)
|
||||
{
|
||||
$this->filters = $filters;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $skipProfileRestriction
|
||||
*/
|
||||
public function setSkipProfileRestriction(bool $skipProfileRestriction)
|
||||
{
|
||||
$this->skipProfileRestriction = $skipProfileRestriction;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $sortingEnabled
|
||||
*/
|
||||
public function setSortingEnabled(bool $sortingEnabled)
|
||||
{
|
||||
$this->sortingEnabled = $sortingEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $sortColumn
|
||||
*/
|
||||
public function setSortColumn(bool $sortColumn)
|
||||
{
|
||||
$this->sortColumn = $sortColumn;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sortOrder
|
||||
*/
|
||||
public function setSortOrder(string $sortOrder)
|
||||
{
|
||||
$this->sortOrder = $sortOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null
|
||||
*/
|
||||
public function getOrderBy()
|
||||
{
|
||||
return $this->orderBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $orderBy
|
||||
*/
|
||||
public function setOrderBy($orderBy)
|
||||
{
|
||||
$this->orderBy = $orderBy;
|
||||
}
|
||||
}
|
||||
39
core/src/Classes/Data/Query/FieldMapping.php
Normal file
39
core/src/Classes/Data/Query/FieldMapping.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
namespace Classes\Data\Query;
|
||||
|
||||
class FieldMapping implements \JsonSerializable
|
||||
{
|
||||
protected $class;
|
||||
protected $idField;
|
||||
protected $nameField;
|
||||
|
||||
/**
|
||||
* FieldMapping constructor.
|
||||
* @param $class
|
||||
* @param $idField
|
||||
* @param $nameField
|
||||
*/
|
||||
public function __construct($class, $idField, $nameField)
|
||||
{
|
||||
$this->class = $class;
|
||||
$this->idField = $idField;
|
||||
$this->nameField = $nameField;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Specify data which should be serialized to JSON
|
||||
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
|
||||
* @return mixed data which can be serialized by <b>json_encode</b>,
|
||||
* which is a value of any type other than a resource.
|
||||
* @since 5.4.0
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return [
|
||||
$this->class,
|
||||
$this->idField,
|
||||
$this->nameField,
|
||||
];
|
||||
}
|
||||
}
|
||||
51
core/src/Classes/Data/Query/Filter.php
Normal file
51
core/src/Classes/Data/Query/Filter.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
namespace Classes\Data\Query;
|
||||
|
||||
class Filter
|
||||
{
|
||||
private $name;
|
||||
private $value;
|
||||
|
||||
/**
|
||||
* Filter constructor.
|
||||
* @param $name
|
||||
* @param $value
|
||||
*/
|
||||
public function __construct($name, $value)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $name
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function setValue($value)
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,9 @@ namespace Classes\Email;
|
||||
use Classes\Crypt\AesCtr;
|
||||
use Classes\UIManager;
|
||||
use Employees\Common\Model\Employee;
|
||||
use Model\IceEmail;
|
||||
use Users\Common\Model\User;
|
||||
use Utils\LogManager;
|
||||
|
||||
abstract class EmailSender
|
||||
{
|
||||
@@ -22,7 +24,7 @@ abstract class EmailSender
|
||||
$this->settings = $settings;
|
||||
}
|
||||
|
||||
public function sendEmailFromNotification($notification)
|
||||
public function sendEmailFromNotification($notification, $delayed = false)
|
||||
{
|
||||
$toEmail = null;
|
||||
$user = new User();
|
||||
@@ -44,17 +46,50 @@ abstract class EmailSender
|
||||
if ($action->type == "url") {
|
||||
$emailBody = str_replace("#_url_#", CLIENT_BASE_URL."?".$action->url, $emailBody);
|
||||
}
|
||||
$this->sendEmail(
|
||||
'IceHrm Notification from '.$notification->type,
|
||||
$user->email,
|
||||
$emailBody,
|
||||
array(),
|
||||
array(),
|
||||
array()
|
||||
);
|
||||
|
||||
if ($delayed) {
|
||||
$this->sendEmailDelayed(
|
||||
'IceHrm Notification from '.$notification->type,
|
||||
$user->email,
|
||||
$emailBody,
|
||||
array(),
|
||||
array(),
|
||||
array()
|
||||
);
|
||||
} else {
|
||||
$this->sendEmail(
|
||||
'IceHrm Notification from '.$notification->type,
|
||||
$user->email,
|
||||
$emailBody,
|
||||
array(),
|
||||
array(),
|
||||
array()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function sendEmailDelayed($subject, $toEmail, $template, $params, $ccList = array(), $bccList = array())
|
||||
{
|
||||
$email = new IceEmail();
|
||||
$email->subject = $subject;
|
||||
$email->toEmail = $toEmail;
|
||||
$email->template = $template;
|
||||
$email->params = json_encode($params);
|
||||
$email->cclist = json_encode($ccList);
|
||||
$email->bcclist = json_encode($bccList);
|
||||
$email->status = 'Pending';
|
||||
$email->created = date('Y-m-d H:i:s');
|
||||
$email->updated = date('Y-m-d H:i:s');
|
||||
$ok = $email->Save();
|
||||
if (!$ok) {
|
||||
LogManager::getInstance()->error("Error Saving Email: ".$email->ErrorMsg());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function sendEmailFromDB($email)
|
||||
{
|
||||
$params = array();
|
||||
|
||||
@@ -18,7 +18,7 @@ along with Ice Framework. 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)
|
||||
Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah)
|
||||
*/
|
||||
namespace Classes;
|
||||
|
||||
@@ -171,6 +171,8 @@ class FileService
|
||||
$profile->image = BASE_URL."images/user_male.png";
|
||||
}
|
||||
}
|
||||
} elseif (substr($file->filename, 0, 8) === 'https://') {
|
||||
$profile->image = $file->filename;
|
||||
} else {
|
||||
$profile->image = CLIENT_BASE_URL.'data/'.$file->filename;
|
||||
}
|
||||
@@ -210,6 +212,8 @@ class FileService
|
||||
}
|
||||
|
||||
$profile->image = $expireUrl;
|
||||
} elseif (substr($file->filename, 0, 8) === 'https://') {
|
||||
$profile->image = $file->filename;
|
||||
} else {
|
||||
$profile->image = CLIENT_BASE_URL.'data/'.$file->filename;
|
||||
}
|
||||
@@ -224,7 +228,7 @@ class FileService
|
||||
return $profile;
|
||||
}
|
||||
|
||||
public function getFileUrl($fileName, $isExpiring = true)
|
||||
public function getFileUrl($fileName, $isExpiring = true)
|
||||
{
|
||||
$file = new File();
|
||||
$file->Load('name = ?', array($fileName));
|
||||
|
||||
@@ -30,7 +30,7 @@ class NotificationManager
|
||||
if ($employee->id === $fromEmployee) {
|
||||
continue;
|
||||
}
|
||||
$this->addNotification($employee->id, $message, $action, $type, $toUserId, $fromSystem, $sendEmail);
|
||||
$this->addNotification($employee->id, $message, $action, $type, $toUserId, $fromSystem, $sendEmail, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,8 @@ class NotificationManager
|
||||
$type,
|
||||
$toUserId = null,
|
||||
$fromSystem = false,
|
||||
$sendEmail = false
|
||||
$sendEmail = false,
|
||||
$isEmailDelayed = false
|
||||
) {
|
||||
|
||||
|
||||
@@ -108,7 +109,7 @@ class NotificationManager
|
||||
} elseif ($sendEmail) {
|
||||
$emailSender = BaseService::getInstance()->getEmailSender();
|
||||
if (!empty($emailSender)) {
|
||||
$emailSender->sendEmailFromNotification($noti);
|
||||
$emailSender->sendEmailFromNotification($noti, $isEmailDelayed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
46
core/src/Classes/PermissionManager.php
Normal file
46
core/src/Classes/PermissionManager.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Thilina
|
||||
* Date: 11/3/17
|
||||
* Time: 4:11 PM
|
||||
*/
|
||||
|
||||
namespace Classes;
|
||||
|
||||
use Company\Common\Model\CompanyStructure;
|
||||
use Employees\Common\Model\Employee;
|
||||
use Model\BaseModel;
|
||||
|
||||
class PermissionManager
|
||||
{
|
||||
public static function manipulationAllowed($employeeId, BaseModel $object)
|
||||
{
|
||||
$subIds = self::getSubordinateIds($employeeId, $object->allowIndirectMapping());
|
||||
if ($object->table === 'Employees') {
|
||||
return in_array($object->id, $subIds);
|
||||
}
|
||||
|
||||
return in_array($object->employee, $subIds);
|
||||
}
|
||||
|
||||
private static function getSubordinateIds($employeeId, $addIndirect)
|
||||
{
|
||||
$subIds = [$employeeId];
|
||||
$employee = new Employee();
|
||||
$list = $employee->Find("supervisor = ?", array($employeeId));
|
||||
|
||||
foreach ($list as $emp) {
|
||||
$subIds[] = $emp->id;
|
||||
}
|
||||
|
||||
if ($addIndirect) {
|
||||
$list = $employee->Find("indirect_supervisors like ?", array('%\"'.$employeeId.'\"%'));
|
||||
foreach ($list as $emp) {
|
||||
$subIds[] = $emp->id;
|
||||
}
|
||||
}
|
||||
|
||||
return $subIds;
|
||||
}
|
||||
}
|
||||
@@ -120,6 +120,7 @@ class RestEndPoint
|
||||
unset($obj->historyUpdateList);
|
||||
unset($obj->oldObjOrig);
|
||||
unset($obj->oldObj);
|
||||
unset($obj->_org);
|
||||
|
||||
return $obj;
|
||||
}
|
||||
@@ -147,9 +148,13 @@ class RestEndPoint
|
||||
$page = intval($_GET['page']);
|
||||
}
|
||||
|
||||
$limit = static::DEFAULT_LIMIT;
|
||||
if (isset($_GET['limit']) && intval($_GET['limit']) > 0) {
|
||||
$limit = intval($_GET['limit']);
|
||||
if (!$query->isLengthSet()) {
|
||||
$limit = static::DEFAULT_LIMIT;
|
||||
if (isset($_GET['limit']) && intval($_GET['limit']) > 0) {
|
||||
$limit = intval($_GET['limit']);
|
||||
}
|
||||
} else {
|
||||
$limit = $query->getLength();
|
||||
}
|
||||
|
||||
$query->setStartPage(($page - 1) * $limit);
|
||||
|
||||
@@ -18,7 +18,7 @@ along with Ice Framework. 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)
|
||||
Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah)
|
||||
*/
|
||||
namespace Classes;
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@ class UIManager
|
||||
protected $quickAccessMenuItems = [];
|
||||
protected $languageMenuItems = [];
|
||||
|
||||
protected $currentLanguageCode = '';
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
@@ -164,6 +166,8 @@ class UIManager
|
||||
"CURRENT_CODE" => $this->getCountryCodeByLanguage($language)
|
||||
)
|
||||
);
|
||||
|
||||
$this->currentLanguageCode = $this->getCountryCodeByLanguage($language);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,6 +267,10 @@ class UIManager
|
||||
$currentCountryCode = 'cn';
|
||||
} elseif ($currentLanguage === 'ja') {
|
||||
$currentCountryCode = 'jp';
|
||||
} elseif ($currentLanguage === 'sr') {
|
||||
$currentCountryCode = 'rs';
|
||||
} elseif ($currentLanguage === 'sv') {
|
||||
$currentCountryCode = 'se';
|
||||
}
|
||||
|
||||
return $currentCountryCode;
|
||||
@@ -299,4 +307,12 @@ class UIManager
|
||||
|
||||
return $logoFileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCurrentLanguageCode()
|
||||
{
|
||||
return $this->currentLanguageCode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ namespace Employees\Common\Model;
|
||||
use Classes\BaseService;
|
||||
use Classes\FileService;
|
||||
use Classes\IceResponse;
|
||||
use Company\Common\Model\CompanyStructure;
|
||||
use Metadata\Common\Model\Country;
|
||||
use Model\BaseModel;
|
||||
|
||||
class Employee extends BaseModel
|
||||
@@ -213,9 +215,25 @@ class Employee extends BaseModel
|
||||
return $obj;
|
||||
}
|
||||
|
||||
public function fieldValueMethods() {
|
||||
public function fieldValueMethods()
|
||||
{
|
||||
return ['getActiveSubordinateEmployees'];
|
||||
}
|
||||
|
||||
public static function getCurrentEmployeeCompanyStructureCountry()
|
||||
{
|
||||
$cemp = BaseService::getInstance()->getCurrentProfileId();
|
||||
$employee = new Employee();
|
||||
$employee->Load('id = ?', [$cemp]);
|
||||
|
||||
$companyStructure = new CompanyStructure();
|
||||
$companyStructure->Load('id = ?', [$employee->department]);
|
||||
|
||||
$country = new Country();
|
||||
$country->Load('code = ?', [$companyStructure->country]);
|
||||
|
||||
return $country->id;
|
||||
}
|
||||
|
||||
public $table = 'Employees';
|
||||
}
|
||||
|
||||
@@ -76,6 +76,16 @@ class EmployeeRestEndPoint extends RestEndPoint
|
||||
);
|
||||
|
||||
$emp = $this->enrichElement($emp, $mapping);
|
||||
//Get User for the employee
|
||||
$user = new User();
|
||||
$user->Load('employee = ?', [$emp->id]);
|
||||
|
||||
if (!empty($user->id)) {
|
||||
$emp->user_name = $user->username;
|
||||
$emp->user_email = $user->email;
|
||||
$emp->user_level = $user->user_level;
|
||||
}
|
||||
|
||||
if (!empty($emp)) {
|
||||
$emp = $this->cleanObject($emp);
|
||||
$emp = $this->removeNullFields($emp);
|
||||
|
||||
@@ -27,7 +27,10 @@ class EmployeesActionManager extends SubActionManager
|
||||
|
||||
$cempObj = new Employee();
|
||||
$cempObj->Load("id = ?", array($cemp));
|
||||
if ($obj->getUserOnlyMeAccessField() == 'id' &&
|
||||
|
||||
if ($this->user->user_level == 'Admin') {
|
||||
$id = $req->id;
|
||||
} elseif ($obj->getUserOnlyMeAccessField() == 'id' &&
|
||||
SettingsManager::getInstance()->getSetting('System: Company Structure Managers Enabled') == 1 &&
|
||||
CompanyStructure::isHeadOfCompanyStructure($cempObj->department, $cemp)) {
|
||||
$subordinates = $obj->Find("supervisor = ?", array($cemp));
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Thilina
|
||||
* Date: 8/19/17
|
||||
* Time: 12:06 PM
|
||||
*/
|
||||
|
||||
namespace Expenses\Admin\Api;
|
||||
|
||||
use Classes\Approval\ApproveAdminActionManager;
|
||||
|
||||
class ExpensesActionManager extends ApproveAdminActionManager
|
||||
{
|
||||
|
||||
public function getModelClass()
|
||||
{
|
||||
return "EmployeeExpense";
|
||||
}
|
||||
|
||||
public function getItemName()
|
||||
{
|
||||
return "Expense";
|
||||
}
|
||||
|
||||
public function getModuleName()
|
||||
{
|
||||
return "Expense Management";
|
||||
}
|
||||
|
||||
public function getModuleTabUrl()
|
||||
{
|
||||
return "g=modules&n=expenses&m=module_Finance";
|
||||
}
|
||||
|
||||
public function getModuleSubordinateTabUrl()
|
||||
{
|
||||
return "g=modules&n=expenses&m=module_Finance#tabSubordinateEmployeeExpense";
|
||||
}
|
||||
|
||||
public function getModuleApprovalTabUrl()
|
||||
{
|
||||
return "g=modules&n=expenses&m=module_Finance#tabEmployeeExpenseApproval";
|
||||
}
|
||||
|
||||
public function getLogs($req)
|
||||
{
|
||||
return parent::getLogs($req);
|
||||
}
|
||||
|
||||
public function changeStatus($req)
|
||||
{
|
||||
return parent::changeStatus($req);
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
<?php
|
||||
namespace Expenses\Admin\Api;
|
||||
|
||||
use Classes\AbstractModuleManager;
|
||||
|
||||
class ExpensesAdminManager extends AbstractModuleManager
|
||||
{
|
||||
|
||||
public function initializeUserClasses()
|
||||
{
|
||||
if (defined('MODULE_TYPE') && MODULE_TYPE != 'admin') {
|
||||
$this->addUserClass("EmployeeExpense");
|
||||
}
|
||||
}
|
||||
|
||||
public function initializeFieldMappings()
|
||||
{
|
||||
$this->addFileFieldMapping('EmployeeExpense', 'attachment1', 'name');
|
||||
$this->addFileFieldMapping('EmployeeExpense', 'attachment2', 'name');
|
||||
$this->addFileFieldMapping('EmployeeExpense', 'attachment3', 'name');
|
||||
}
|
||||
|
||||
public function initializeDatabaseErrorMappings()
|
||||
{
|
||||
}
|
||||
|
||||
public function setupModuleClassDefinitions()
|
||||
{
|
||||
|
||||
$this->addModelClass('ExpensesCategory');
|
||||
$this->addModelClass('ExpensesPaymentMethod');
|
||||
$this->addModelClass('EmployeeExpense');
|
||||
$this->addModelClass('EmployeeExpenseApproval');
|
||||
}
|
||||
|
||||
public function initCalculationHooks()
|
||||
{
|
||||
$this->addCalculationHook(
|
||||
'ExpensePayrollUtils_getApprovedExpensesTotal',
|
||||
'Total Approved Expenses',
|
||||
ExpensePayrollUtils::class,
|
||||
'getApprovedExpensesTotal'
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Thilina
|
||||
* Date: 8/19/17
|
||||
* Time: 12:10 PM
|
||||
*/
|
||||
|
||||
namespace Expenses\Common\Model;
|
||||
|
||||
use Classes\SettingsManager;
|
||||
use Model\ApproveModel;
|
||||
|
||||
class EmployeeExpense extends ApproveModel
|
||||
{
|
||||
public $table = 'EmployeeExpenses';
|
||||
|
||||
public $notificationModuleName = "Expense Management";
|
||||
public $notificationUnitName = "Expense";
|
||||
public $notificationUnitPrefix = "An";
|
||||
public $notificationUnitAdminUrl = "g=modules&n=expenses&m=module_Finance#tabSubordinateEmployeeExpense";
|
||||
public $preApproveSettingName = "Expense: Pre-Approve Expenses";
|
||||
|
||||
public function isMultiLevelApprovalsEnabled()
|
||||
{
|
||||
return (SettingsManager::getInstance()->getSetting('Expense: Enable Multi Level Approvals') == '1');
|
||||
}
|
||||
|
||||
public function getAdminAccess()
|
||||
{
|
||||
return array("get","element","save","delete");
|
||||
}
|
||||
|
||||
public function getManagerAccess()
|
||||
{
|
||||
if ($this->status == 'Pending') {
|
||||
|
||||
return array("element","save","delete");
|
||||
}
|
||||
|
||||
return array("get","element","save");
|
||||
}
|
||||
|
||||
public function getUserAccess()
|
||||
{
|
||||
return array("get");
|
||||
}
|
||||
|
||||
public function getUserOnlyMeAccess()
|
||||
{
|
||||
if ($this->status == 'Pending') {
|
||||
|
||||
return array("get","element","save","delete");
|
||||
}
|
||||
|
||||
return array("get","element","save");
|
||||
}
|
||||
|
||||
public function fieldsNeedToBeApproved()
|
||||
{
|
||||
return array(
|
||||
"amount",
|
||||
"category",
|
||||
"payment_method",
|
||||
"currency"
|
||||
);
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return 'EmployeeExpense';
|
||||
}
|
||||
|
||||
public function allowIndirectMapping()
|
||||
{
|
||||
if (SettingsManager::getInstance()->getSetting('Expense: Allow Indirect Admins to Approve') == '1') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Thilina
|
||||
* Date: 8/19/17
|
||||
* Time: 12:12 PM
|
||||
*/
|
||||
|
||||
namespace Expenses\Common\Model;
|
||||
|
||||
class EmployeeExpenseApproval extends EmployeeExpense
|
||||
{
|
||||
// @codingStandardsIgnoreStart
|
||||
public function Find($whereOrderBy, $bindarr = false, $pkeysArr = false, $extra = array())
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
return $this->findApprovals(new EmployeeExpense(), $whereOrderBy, $bindarr, $pkeysArr, $extra);
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Thilina
|
||||
* Date: 8/19/17
|
||||
* Time: 12:08 PM
|
||||
*/
|
||||
|
||||
namespace Expenses\Common\Model;
|
||||
|
||||
use Model\BaseModel;
|
||||
|
||||
class ExpensesCategory extends BaseModel
|
||||
{
|
||||
public $table = 'ExpensesCategories';
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Thilina
|
||||
* Date: 8/19/17
|
||||
* Time: 12:10 PM
|
||||
*/
|
||||
|
||||
namespace Expenses\Common\Model;
|
||||
|
||||
use Model\BaseModel;
|
||||
|
||||
class ExpensesPaymentMethod extends BaseModel
|
||||
{
|
||||
public $table = 'ExpensesPaymentMethods';
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Thilina
|
||||
* Date: 8/19/17
|
||||
* Time: 12:20 PM
|
||||
*/
|
||||
|
||||
namespace Expenses\User\Api;
|
||||
|
||||
use Classes\Approval\ApproveModuleActionManager;
|
||||
|
||||
class ExpensesActionManager extends ApproveModuleActionManager
|
||||
{
|
||||
|
||||
public function getModelClass()
|
||||
{
|
||||
return "EmployeeExpense";
|
||||
}
|
||||
|
||||
public function getItemName()
|
||||
{
|
||||
return "Expense";
|
||||
}
|
||||
|
||||
public function getModuleName()
|
||||
{
|
||||
return "Expense Management";
|
||||
}
|
||||
|
||||
public function getModuleTabUrl()
|
||||
{
|
||||
return "g=modules&n=expenses&m=module_Finance#tabSubordinateEmployeeExpense";
|
||||
}
|
||||
|
||||
public function getLogs($req)
|
||||
{
|
||||
return parent::getLogs($req);
|
||||
}
|
||||
|
||||
public function cancel($req)
|
||||
{
|
||||
return parent::cancel($req);
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Thilina
|
||||
* Date: 8/19/17
|
||||
* Time: 12:21 PM
|
||||
*/
|
||||
|
||||
namespace Expenses\User\Api;
|
||||
|
||||
use Classes\AbstractModuleManager;
|
||||
|
||||
class ExpensesModulesManager extends AbstractModuleManager
|
||||
{
|
||||
|
||||
public function initializeUserClasses()
|
||||
{
|
||||
}
|
||||
|
||||
public function initializeFieldMappings()
|
||||
{
|
||||
}
|
||||
|
||||
public function initializeDatabaseErrorMappings()
|
||||
{
|
||||
}
|
||||
|
||||
public function setupModuleClassDefinitions()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -128,11 +128,13 @@ class BaseModel extends \ADOdb_Active_Record
|
||||
return get_called_class();
|
||||
}
|
||||
|
||||
public function fieldValueMethods() {
|
||||
public function fieldValueMethods()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function validateCSRF() {
|
||||
public function validateCSRF()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,5 +41,29 @@ class Setting extends BaseModel
|
||||
return $obj;
|
||||
}
|
||||
|
||||
public function executePostSaveActions($obj)
|
||||
{
|
||||
if (!defined('WEB_ADMIN_BASE_URL')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($obj->name == 'Company: Country') {
|
||||
$updateInvUrl = WEB_ADMIN_BASE_URL.'/app/update_instance.php?client='
|
||||
.CLIENT_NAME.'&country='.$obj->value.'&key='.ADMIN_SEC_KEY;
|
||||
$response = file_get_contents($updateInvUrl);
|
||||
}
|
||||
|
||||
if ($obj->name == 'Company: Vat ID') {
|
||||
$updateInvUrl = WEB_ADMIN_BASE_URL.'/app/update_instance.php?client='
|
||||
.CLIENT_NAME.'&vatId='.$obj->value.'&key='.ADMIN_SEC_KEY;
|
||||
$response = file_get_contents($updateInvUrl);
|
||||
}
|
||||
}
|
||||
|
||||
public function executePostUpdateActions($obj)
|
||||
{
|
||||
$this->executePostSaveActions($obj);
|
||||
}
|
||||
|
||||
public $table = 'Settings';
|
||||
}
|
||||
|
||||
@@ -1,24 +1,7 @@
|
||||
<?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)
|
||||
Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de)
|
||||
Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah)
|
||||
*/
|
||||
namespace Modules\Admin\Api;
|
||||
|
||||
|
||||
@@ -1,24 +1,7 @@
|
||||
<?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)
|
||||
Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de)
|
||||
Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah)
|
||||
*/
|
||||
namespace Modules\Admin\Api;
|
||||
|
||||
|
||||
@@ -1,24 +1,7 @@
|
||||
<?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)
|
||||
Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de)
|
||||
Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah)
|
||||
*/
|
||||
|
||||
namespace Modules\Common\Model;
|
||||
|
||||
59
core/src/Overtime/Admin/Api/OvertimePayrollUtils.php
Normal file
59
core/src/Overtime/Admin/Api/OvertimePayrollUtils.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
namespace Overtime\Admin\Api;
|
||||
|
||||
use Overtime\Common\Model\EmployeeOvertime;
|
||||
|
||||
class OvertimePayrollUtils
|
||||
{
|
||||
public function getApprovedTimeInRequests($employeeId, $startDate, $endDate)
|
||||
{
|
||||
$request = new EmployeeOvertime();
|
||||
$requests = $request->Find(
|
||||
'employee = ?
|
||||
and ((date(start_time) >= ? and date(start_time) <= ?)
|
||||
or (date(end_time) >= ? and date(end_time) <= ?)
|
||||
or (date(start_time) < ? and date(end_time) > ?))
|
||||
and status = ?',
|
||||
array(
|
||||
$employeeId,
|
||||
$startDate,
|
||||
$endDate,
|
||||
$startDate,
|
||||
$endDate,
|
||||
$startDate,
|
||||
$endDate,
|
||||
'Approved'
|
||||
)
|
||||
);
|
||||
|
||||
$seconds = 0;
|
||||
|
||||
$startTime = strtotime($startDate.' 00:00:00');
|
||||
$endTime = strtotime($endDate.' 23:59:59');
|
||||
|
||||
foreach ($requests as $entry) {
|
||||
$entryStartTime = strtotime($entry->start_time);
|
||||
$entryEndTime = strtotime($entry->end_time);
|
||||
|
||||
if ($entryStartTime >= $startTime && $entryEndTime <= $endTime) {
|
||||
$secondsTemp = $entryEndTime - $entryStartTime;
|
||||
} elseif ($entryStartTime < $startTime && $entryEndTime <= $endTime) {
|
||||
$secondsTemp = $entryEndTime - $startTime;
|
||||
} elseif ($entryStartTime >= $startTime && $entryEndTime > $endTime) {
|
||||
$secondsTemp = $endTime - $entryStartTime;
|
||||
} else {
|
||||
$secondsTemp = $endTime - $startTime;
|
||||
}
|
||||
|
||||
if ($secondsTemp < 0) {
|
||||
$secondsTemp = 0;
|
||||
}
|
||||
|
||||
$seconds += $secondsTemp;
|
||||
}
|
||||
|
||||
$totMinutes = round($seconds / 60);
|
||||
|
||||
return round($totMinutes / 60, 2);
|
||||
}
|
||||
}
|
||||
@@ -48,7 +48,8 @@ class Payroll extends BaseModel
|
||||
return $payrolls;
|
||||
}
|
||||
|
||||
public function fieldValueMethods() {
|
||||
public function fieldValueMethods()
|
||||
{
|
||||
return ['getEmployeePayrolls'];
|
||||
}
|
||||
}
|
||||
|
||||
76
core/src/Reports/Admin/Reports/AssetUsageReport.php
Normal file
76
core/src/Reports/Admin/Reports/AssetUsageReport.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
namespace Reports\Admin\Reports;
|
||||
|
||||
use Classes\BaseService;
|
||||
use Reports\Admin\Api\ClassBasedReportBuilder;
|
||||
use Reports\Admin\Api\ReportBuilderInterface;
|
||||
|
||||
class AssetUsageReport extends ClassBasedReportBuilder implements ReportBuilderInterface
|
||||
{
|
||||
|
||||
public function getData($report, $request)
|
||||
{
|
||||
$filters = [];
|
||||
|
||||
if (!empty($request['department']) && $request['department'] !== "NULL") {
|
||||
$filters['department'] = $request['department'];
|
||||
}
|
||||
|
||||
if (!empty($request['type']) && $request['type'] !== "NULL") {
|
||||
$filters['type'] = $request['type'];
|
||||
}
|
||||
|
||||
|
||||
$mapping = [
|
||||
"department" => ["CompanyStructure","id","title"],
|
||||
"employee" => ["Employee","id","first_name+last_name"],
|
||||
"type" => ["AssetType","id","name"],
|
||||
];
|
||||
|
||||
|
||||
$reportColumns = [
|
||||
['label' => 'Code', 'column' => 'code'],
|
||||
['label' => 'Type', 'column' => 'type'],
|
||||
['label' => 'Assigned Employee', 'column' => 'employee'],
|
||||
['label' => 'Assigned Department', 'column' => 'department'],
|
||||
['label' => 'Description', 'column' => 'description'],
|
||||
];
|
||||
|
||||
$customFieldsList = BaseService::getInstance()->getCustomFields('CompanyAsset');
|
||||
|
||||
foreach ($customFieldsList as $customField) {
|
||||
$reportColumns[] = [
|
||||
'label' => $customField->field_label,
|
||||
'column' => $customField->name,
|
||||
];
|
||||
}
|
||||
|
||||
$entries = BaseService::getInstance()->get('CompanyAsset', null, $filters);
|
||||
$data = [];
|
||||
foreach ($entries as $item) {
|
||||
$item = BaseService::getInstance()->enrichObjectMappings($mapping, $item);
|
||||
$item = BaseService::getInstance()->enrichObjectCustomFields('CompanyAsset', $item);
|
||||
$data[] = $item;
|
||||
}
|
||||
|
||||
$mappedColumns = array_keys($mapping);
|
||||
|
||||
|
||||
$reportData = [];
|
||||
$reportData[] = array_column($reportColumns, 'label');
|
||||
|
||||
foreach ($data as $item) {
|
||||
$row = [];
|
||||
foreach ($reportColumns as $column) {
|
||||
if (in_array($column['column'], $mappedColumns)) {
|
||||
$row[] = $item->{$column['column'].'_Name'};
|
||||
} else {
|
||||
$row[] = $item->{$column['column']};
|
||||
}
|
||||
}
|
||||
$reportData[] = $row;
|
||||
}
|
||||
|
||||
return $reportData;
|
||||
}
|
||||
}
|
||||
124
core/src/Reports/Admin/Reports/EmployeeDetailsReport.php
Normal file
124
core/src/Reports/Admin/Reports/EmployeeDetailsReport.php
Normal file
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
namespace Reports\Admin\Reports;
|
||||
|
||||
use Classes\BaseService;
|
||||
use Reports\Admin\Api\ClassBasedReportBuilder;
|
||||
use Reports\Admin\Api\ReportBuilderInterface;
|
||||
|
||||
class EmployeeDetailsReport extends ClassBasedReportBuilder implements ReportBuilderInterface
|
||||
{
|
||||
|
||||
public function getData($report, $request)
|
||||
{
|
||||
$filters = [];
|
||||
|
||||
if (!empty($request['department']) && $request['department'] !== "NULL") {
|
||||
$filters['department'] = $request['department'];
|
||||
}
|
||||
|
||||
if (!empty($request['employment_status']) && $request['employment_status'] !== "NULL") {
|
||||
$filters['employment_status'] = $request['employment_status'];
|
||||
}
|
||||
|
||||
if (!empty($request['job_title']) && $request['job_title'] !== "NULL") {
|
||||
$filters['job_title'] = $request['job_title'];
|
||||
}
|
||||
|
||||
|
||||
$mapping = [
|
||||
"job_title" => ["JobTitle","id","name"],
|
||||
"nationality" => ["Nationality","id","name"],
|
||||
"ethnicity" => ["Ethnicity","id","name"],
|
||||
"immigration_status" => ["ImmigrationStatus","id","name"],
|
||||
"employment_status" => ["EmploymentStatus","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"],
|
||||
"approver1" => ["Employee","id","first_name+last_name"],
|
||||
"approver2" => ["Employee","id","first_name+last_name"],
|
||||
"approver3" => ["Employee","id","first_name+last_name"],
|
||||
"indirect_supervisors" => ["Employee","id","first_name+last_name", true],
|
||||
];
|
||||
|
||||
|
||||
$reportColumns = [
|
||||
['label' => 'Employee ID', 'column' => 'employee_id'],
|
||||
['label' => 'First Name', 'column' => 'first_name'],
|
||||
['label' => 'Middle Name', 'column' => 'middle_name'],
|
||||
['label' => 'Last Name', 'column' => 'last_name'],
|
||||
['label' => 'Nationality', 'column' => 'nationality'],
|
||||
['label' => 'Date of Birth', 'column' => 'birthday'],
|
||||
['label' => 'Gender', 'column' => 'gender'],
|
||||
['label' => 'Marital Status', 'column' => 'marital_status'],
|
||||
['label' => 'Ethnicity', 'column' => 'ethnicity'],
|
||||
['label' => 'Immigration Status', 'column' => 'immigration_status'],
|
||||
['label' => 'SSN Number', 'column' => 'ssn_num'],
|
||||
['label' => 'NIC', 'column' => 'nic_num'],
|
||||
['label' => 'Other ID', 'column' => 'other_id'],
|
||||
['label' => 'Driving License No', 'column' => 'driving_license'],
|
||||
['label' => 'Employment Status', 'column' => 'employment_status'],
|
||||
['label' => 'Job Title', 'column' => 'job_title'],
|
||||
['label' => 'Pay Grade', 'column' => 'pay_grade'],
|
||||
['label' => 'Work Station Id', 'column' => 'work_station_id'],
|
||||
['label' => 'Address Line 1', 'column' => 'address1'],
|
||||
['label' => 'Address Line 2', 'column' => 'address2'],
|
||||
['label' => 'City', 'column' => 'city'],
|
||||
['label' => 'Country', 'column' => 'country'],
|
||||
['label' => 'Province', 'column' => 'province'],
|
||||
['label' => 'Postal Code', 'column' => 'postal_code'],
|
||||
['label' => 'Home Phone', 'column' => 'home_phone'],
|
||||
['label' => 'Mobile Phone', 'column' => 'mobile_phone'],
|
||||
['label' => 'Work Phone', 'column' => 'work_phone'],
|
||||
['label' => 'Work Email', 'column' => 'work_email'],
|
||||
['label' => 'Private Email', 'column' => 'private_email'],
|
||||
['label' => 'Joined Date', 'column' => 'joined_date'],
|
||||
['label' => 'Confirmation Date', 'column' => 'confirmation_date'],
|
||||
['label' => 'Termination Date', 'column' => 'termination_date'],
|
||||
['label' => 'Department', 'column' => 'department'],
|
||||
['label' => 'Supervisor', 'column' => 'supervisor'],
|
||||
['label' => 'Indirect Supervisors', 'column' => 'indirect_supervisors'],
|
||||
['label' => 'First Level Approver', 'column' => 'approver1'],
|
||||
['label' => 'Second Level Approver', 'column' => 'approver2'],
|
||||
['label' => 'Third Level Approver', 'column' => 'approver3'],
|
||||
];
|
||||
|
||||
$customFieldsList = BaseService::getInstance()->getCustomFields('Employee');
|
||||
|
||||
foreach ($customFieldsList as $customField) {
|
||||
$reportColumns[] = [
|
||||
'label' => $customField->field_label,
|
||||
'column' => $customField->name,
|
||||
];
|
||||
}
|
||||
|
||||
$entries = BaseService::getInstance()->get('Employee', null, $filters);
|
||||
$data = [];
|
||||
foreach ($entries as $item) {
|
||||
$item = BaseService::getInstance()->enrichObjectMappings($mapping, $item);
|
||||
$item = BaseService::getInstance()->enrichObjectCustomFields('Employee', $item);
|
||||
$data[] = $item;
|
||||
}
|
||||
|
||||
$mappedColumns = array_keys($mapping);
|
||||
|
||||
|
||||
$reportData = [];
|
||||
$reportData[] = array_column($reportColumns, 'label');
|
||||
|
||||
foreach ($data as $item) {
|
||||
$row = [];
|
||||
foreach ($reportColumns as $column) {
|
||||
if (in_array($column['column'], $mappedColumns)) {
|
||||
$row[] = $item->{$column['column'].'_Name'};
|
||||
} else {
|
||||
$row[] = $item->{$column['column']};
|
||||
}
|
||||
}
|
||||
$reportData[] = $row;
|
||||
}
|
||||
|
||||
return $reportData;
|
||||
}
|
||||
}
|
||||
55
core/src/StaffDirectory/Common/Model/StaffDirectory.php
Normal file
55
core/src/StaffDirectory/Common/Model/StaffDirectory.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Thilina
|
||||
* Date: 8/20/17
|
||||
* Time: 7:40 AM
|
||||
*/
|
||||
|
||||
namespace StaffDirectory\Common\Model;
|
||||
|
||||
use Classes\FileService;
|
||||
use Employees\Common\Model\Employee;
|
||||
use Model\BaseModel;
|
||||
|
||||
class StaffDirectory extends Employee
|
||||
{
|
||||
// @codingStandardsIgnoreStart
|
||||
public function Find($whereOrderBy, $bindarr = false, $pkeysArr = false, $extra = array())
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$res = parent::Find($whereOrderBy, $bindarr, $pkeysArr, $extra);
|
||||
$data = array();
|
||||
//$img = '<img src="_img_" class="img-circle" style="width:45px;height: 45px;" alt="User Image">';
|
||||
foreach ($res as $entry) {
|
||||
$emp = new BaseModel();
|
||||
$emp->id = $entry->id;
|
||||
$emp = FileService::getInstance()->updateProfileImage($emp);
|
||||
//$emp->image = str_replace("_img_",$emp->image,$img);
|
||||
$emp->first_name = $entry->first_name;
|
||||
$emp->last_name = $entry->last_name;
|
||||
$emp->job_title = $entry->job_title;
|
||||
$emp->department = $entry->department;
|
||||
$emp->work_phone = $entry->work_phone;
|
||||
$emp->work_email = $entry->work_email;
|
||||
$emp->joined_date = $entry->joined_date;
|
||||
$emp->gender = $entry->gender;
|
||||
$emp->_org = $entry;
|
||||
$data[] = $emp;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
public function Insert()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
public function Delete()
|
||||
{
|
||||
return;
|
||||
}
|
||||
// @codingStandardsIgnoreEnd
|
||||
}
|
||||
19
core/src/StaffDirectory/Rest/StaffDirectoryRestEndPoint.php
Normal file
19
core/src/StaffDirectory/Rest/StaffDirectoryRestEndPoint.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
namespace StaffDirectory\Rest;
|
||||
|
||||
use Classes\RestEndPoint;
|
||||
use Users\Common\Model\User;
|
||||
use Classes\Data\Query\DataQuery;
|
||||
|
||||
class StaffDirectoryRestEndPoint extends RestEndPoint
|
||||
{
|
||||
public function listAll(User $user)
|
||||
{
|
||||
$query = new DataQuery('StaffDirectory');
|
||||
$query->setFieldMapping(
|
||||
'{"job_title":["JobTitle","id","name"],"department":["CompanyStructure","id","title"]}'
|
||||
);
|
||||
$query->setOrderBy('first_name');
|
||||
return $this->listByQuery($query);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
namespace StaffDirectory\User\Api;
|
||||
|
||||
use Classes\AbstractModuleManager;
|
||||
use StaffDirectory\Rest\StaffDirectoryRestEndPoint;
|
||||
|
||||
class StaffDirectoryModulesManager extends AbstractModuleManager
|
||||
{
|
||||
|
||||
public function initializeUserClasses()
|
||||
{
|
||||
}
|
||||
|
||||
public function initializeFieldMappings()
|
||||
{
|
||||
}
|
||||
|
||||
public function initializeDatabaseErrorMappings()
|
||||
{
|
||||
}
|
||||
|
||||
public function setupModuleClassDefinitions()
|
||||
{
|
||||
$this->addModelClass('StaffDirectory');
|
||||
}
|
||||
|
||||
public function setupRestEndPoints()
|
||||
{
|
||||
\Classes\Macaw::get(REST_API_PATH.'staff', function () {
|
||||
$empRestEndPoint = new StaffDirectoryRestEndPoint();
|
||||
$empRestEndPoint->process('listAll');
|
||||
});
|
||||
}
|
||||
}
|
||||
62
core/src/TimeSheets/User/Api/TimeSheetsPayrollUtils.php
Normal file
62
core/src/TimeSheets/User/Api/TimeSheetsPayrollUtils.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
namespace TimeSheets\User\Api;
|
||||
|
||||
use TimeSheets\Common\Model\EmployeeTimeEntry;
|
||||
use TimeSheets\Common\Model\EmployeeTimeSheet;
|
||||
|
||||
class TimeSheetsPayrollUtils
|
||||
{
|
||||
public function getApprovedTimeInTimeSheets($employeeId, $startDate, $endDate)
|
||||
{
|
||||
$timeSheet = new EmployeeTimeSheet();
|
||||
$timeSheets = $timeSheet->Find(
|
||||
'employee = ? and ((date_start >= ? and date_start <= ?)
|
||||
or (date_end >= ? and date_end <= ?)) and status = ?',
|
||||
array(
|
||||
$employeeId,
|
||||
$startDate,
|
||||
$endDate,
|
||||
$startDate,
|
||||
$endDate,
|
||||
'Approved'
|
||||
)
|
||||
);
|
||||
|
||||
$timeSheetIds = [];
|
||||
foreach ($timeSheets as $timeSheet) {
|
||||
$timeSheetIds[] = $timeSheet->id;
|
||||
}
|
||||
|
||||
$start = $startDate . " 00:00:00";
|
||||
$end = $endDate . " 23:59:59";
|
||||
|
||||
$timeEntry = new EmployeeTimeEntry();
|
||||
$list = $timeEntry->Find(
|
||||
"employee = ? and ((date_start >= ? and date_start <= ?)
|
||||
or (date_end >= ? and date_end <= ?)) and timesheet in
|
||||
(".implode(',', $timeSheetIds).")",
|
||||
array(
|
||||
$employeeId,
|
||||
$start,
|
||||
$end,
|
||||
$start,
|
||||
$end
|
||||
)
|
||||
);
|
||||
|
||||
$seconds = 0;
|
||||
|
||||
foreach ($list as $entry) {
|
||||
$secondsTemp = (strtotime($entry->date_end) - strtotime($entry->date_start));
|
||||
if ($secondsTemp < 0) {
|
||||
$secondsTemp = 0;
|
||||
}
|
||||
|
||||
$seconds += $secondsTemp;
|
||||
}
|
||||
|
||||
$totMinutes = round($seconds / 60);
|
||||
|
||||
return round($totMinutes / 60, 2);
|
||||
}
|
||||
}
|
||||
@@ -1,24 +1,7 @@
|
||||
<?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)
|
||||
Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de)
|
||||
Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah)
|
||||
*/
|
||||
namespace Users\Admin\Api;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ class UsersEmailSender
|
||||
$this->subActionManager = $subActionManager;
|
||||
}
|
||||
|
||||
public function sendWelcomeUserEmail(User $user, string $password, $employee = null)
|
||||
public function sendWelcomeUserEmail(User $user, $password, $employee = null)
|
||||
{
|
||||
|
||||
$params = array();
|
||||
@@ -47,7 +47,7 @@ class UsersEmailSender
|
||||
} else {
|
||||
LogManager::getInstance()->info("[sendWelcomeUserEmail] email is empty");
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,7 @@
|
||||
<?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)
|
||||
Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de)
|
||||
Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah)
|
||||
*/
|
||||
namespace Users\Common\Model;
|
||||
|
||||
|
||||
@@ -1,24 +1,7 @@
|
||||
<?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)
|
||||
Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de)
|
||||
Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah)
|
||||
*/
|
||||
|
||||
namespace Users\Common\Model;
|
||||
|
||||
Reference in New Issue
Block a user