Skip to content

Commit

Permalink
Merge branch 'release/v32.1.0.OS'
Browse files Browse the repository at this point in the history
  • Loading branch information
ddave001 committed May 29, 2022
2 parents f43e870 + cad2c13 commit ddecead
Show file tree
Hide file tree
Showing 24 changed files with 13,369 additions and 31,482 deletions.
2 changes: 1 addition & 1 deletion core/admin/dashboard/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
<div class="col-lg-4 col-xs-12">
<div id="TaskListLoader" style="width:100%;"></div>
<div id="TaskListWrap" style="display: none;box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.24);border: none;margin-bottom: 20px; padding:25px;">
<h4>Things to Do</h4>
<h4><?=t('My Todo List')?></h4>
<div id="TaskList" style="margin-left: 10px; margin-top: 30px;"></div>
</div>
</div>
Expand Down
10 changes: 3 additions & 7 deletions core/api-url-based.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,9 @@

$moduleManagerObj->setupRestEndPoints();
}
$method = $_SERVER['REQUEST_METHOD'];
if (strtoupper($method) === 'GET') {
\Classes\IceRoute::dispatch($_GET['url'], $method);
} else {
$method = strtoupper($_REQUEST['method']);
\Classes\IceRoute::dispatch($_REQUEST['url'], $method);
}

$method = strtoupper($_REQUEST['method']);
\Classes\IceRoute::dispatch($_GET['url'], $method);


}else{
Expand Down
4 changes: 2 additions & 2 deletions core/config.base.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

//Version
define('VERSION', '32.1.0.OS');
define('CACHE_VALUE', '32.1.0.OS.2022-05071325');
define('CACHE_VALUE', '32.1.0.OS.2022-05291325');
define('VERSION_NUMBER', '320100');
define('VERSION_DATE', '07/05/2022');
define('VERSION_DATE', '29/05/2022');

if(!defined('CONTACT_EMAIL')){define('CONTACT_EMAIL','[email protected]');}
if(!defined('KEY_PREFIX')){define('KEY_PREFIX','IceHrm');}
Expand Down
1 change: 1 addition & 0 deletions core/migrations/list.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
$migrationList = [];
$migrationList[] = 'v20220529_330001_google_map_api_key';
$migrationList[] = 'v20220123_310008_remove_photo_att';
$migrationList[] = 'v20220122_310007_career_progression';
$migrationList[] = 'v20220122_310006_update_menu';
Expand Down
12 changes: 0 additions & 12 deletions core/migrations/v20190707_260005_attendance_location.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,6 @@ class v20190707_260005_attendance_location extends AbstractMigration {

public function up(){

$sql = <<<'SQL'
REPLACE INTO `Settings` (`name`, `value`, `description`, `meta`) VALUES
('Attendance: Request Attendance Location on Mobile', '1', 'Push attendance location when marking attendance via mobile app','["value", {"label":"Value","type":"select","source":[["1","Yes"],["0","No"]]}]');
SQL;
$this->executeQuery($sql);

$sql = <<<'SQL'
REPLACE INTO `Settings` (`name`, `value`, `description`, `meta`) VALUES
('System: Google Maps Api Key', '', 'Google Map Api Key','["value", {"label":"Value","type":"select","source":[["1","Yes"],["0","No"]]}]');
SQL;
$this->executeQuery($sql);

$sql = <<<'SQL'
Alter table Attendance add column `map_out_snapshot` longtext default null;
SQL;
Expand Down
27 changes: 27 additions & 0 deletions core/migrations/v20220529_330001_google_map_api_key.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
namespace Classes\Migration;

class v20220529_330001_google_map_api_key extends AbstractMigration {

public function up(){

$sql = <<<'SQL'
REPLACE INTO `Settings` (`name`, `value`, `description`, `meta`, `category`) VALUES
('Attendance: Request Attendance Location on Mobile', '1', 'Push attendance location when marking attendance via mobile app','["value", {"label":"Value","type":"select","source":[["1","Yes"],["0","No"]]}]', 'System');
SQL;
$this->executeQuery($sql);

$sql = <<<'SQL'
REPLACE INTO `Settings` (`name`, `value`, `description`, `meta`, `category`) VALUES
('System: Google Maps Api Key', '', 'Google Map Api Key','["value", {"label":"Value","type":"select","source":[["1","Yes"],["0","No"]]}]', 'System');
SQL;
return $this->executeQuery($sql);

}

public function down(){

return true;
}

}
18 changes: 18 additions & 0 deletions core/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -383,13 +383,19 @@ function createPermissions($meta, $moduleId)
foreach ($adminModules as $fk => $menu) {
foreach ($menu['menu'] as $key => $item) {
// If the user's once of the user roles are blacklisted for the module
if (empty($item['user_roles_blacklist'])) {
$item['user_roles_blacklist'] = [];
}
$commonRoles = array_intersect($item['user_roles_blacklist'], $userRoles);
if (!empty($commonRoles)) {
unset($adminModules[$fk]['menu'][$key]);
}

if (!in_array($user->user_level, $item['user_levels'])) {
if (!empty($userRoles)) {
if (empty($item['user_roles'])) {
$item['user_roles'] = [];
}
$commonRoles = array_intersect($item['user_roles'], $userRoles);
if (empty($commonRoles)) {
unset($adminModules[$fk]['menu'][$key]);
Expand All @@ -404,12 +410,18 @@ function createPermissions($meta, $moduleId)
foreach ($userModules as $fk => $menu) {
foreach ($menu['menu'] as $key => $item) {
// If the user's once of the user roles are blacklisted for the module
if (empty($item['user_roles_blacklist'])) {
$item['user_roles_blacklist'] = [];
}
$commonRoles = array_intersect($item['user_roles_blacklist'], $userRoles);
if (!empty($commonRoles)) {
unset($userModules[$fk]['menu'][$key]);
}
if (!in_array($user->user_level, $item['user_levels'])) {
if (!empty($userRoles)) {
if (empty($item['user_roles'])) {
$item['user_roles'] = [];
}
$commonRoles = array_intersect($item['user_roles'], $userRoles);
if (empty($commonRoles)) {
unset($userModules[$fk]['menu'][$key]);
Expand All @@ -424,12 +436,18 @@ function createPermissions($meta, $moduleId)
foreach ($extensions as $fk => $menu) {
foreach ($menu['menu'] as $key => $item) {
// If the user's once of the user roles are blacklisted for the module
if (empty($item['user_roles_blacklist'])) {
$item['user_roles_blacklist'] = [];
}
$commonRoles = array_intersect($item['user_roles_blacklist'], $userRoles);
if (!empty($commonRoles)) {
unset($extensions[$fk]['menu'][$key]);
}
if (!in_array($user->user_level, $item['user_levels'])) {
if (!empty($userRoles)) {
if (empty($item['user_roles'])) {
$item['user_roles'] = [];
}
$commonRoles = array_intersect($item['user_roles'], $userRoles);
if (empty($commonRoles)) {
unset($extensions[$fk]['menu'][$key]);
Expand Down
2 changes: 1 addition & 1 deletion core/modules/dashboard/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<div class="col-lg-4 col-xs-12">
<div id="TaskListLoader" style="width:100%;"></div>
<div id="TaskListWrap" style="display: none;box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.24);border: none;margin-bottom: 20px; padding:25px;">
<h4>Things to Do</h4>
<h4><?=t('My Todo List')?></h4>
<div id="TaskList" style="margin-left: 10px; margin-top: 30px;"></div>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions core/src/Attendance/Admin/Api/AttendanceTaskCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public function getTasksCreators()
{
$taskCreators = [];

$taskCreators[1] = function () {
$taskCreators[] = function () {
if (!$this->isUserCheckedIn()) {
return (new Task(Task::PRIORITY_ERROR, 'You are currently not checked-in'))
->setLink(
Expand All @@ -25,7 +25,7 @@ public function getTasksCreators()
return null;
};

$taskCreators[2] = function () {
$taskCreators[] = function () {
if ($this->userNeedToCheckOut()) {
return (new Task(Task::PRIORITY_INFO, 'Remember to checkout after finishing work'))
->setLink(
Expand Down
1 change: 1 addition & 0 deletions core/src/Attendance/Rest/AttendanceRestEndPoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public function listAll(User $user, $parameter = null)
$query->addColumn('in_time');
$query->addColumn('out_time');
$query->addColumn('note');
$query->setOrderBy('in_time desc');

$limit = self::DEFAULT_LIMIT;
if (isset($_GET['limit']) && intval($_GET['limit']) > 0) {
Expand Down
6 changes: 3 additions & 3 deletions core/src/Classes/StatsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public static function getEmployeeCount()
$employee = new Employee();
$employeeCount = $employee->DB()->Execute("select count(id) from Employees");
if ($employeeCount) {
$employeeCount = intval($employeeCount->fields[0]);
$employeeCount = intval($employeeCount[0]['count(id)']);
return $employeeCount;
}

Expand All @@ -24,7 +24,7 @@ public static function getActiveEmployeeCount()
$employee = new Employee();
$employeeCount = $employee->DB()->Execute("select count(id) from Employees where status = ?", ['Active']);
if ($employeeCount) {
$employeeCount = intval($employeeCount->fields[0]);
$employeeCount = intval($employeeCount[0]['count(id)']);
return $employeeCount;
}

Expand All @@ -36,7 +36,7 @@ public static function getUserCount()
$user = new User();
$userCount = $user->DB()->Execute("select count(id) from Users");
if ($userCount) {
$userCount = intval($userCount->fields[0]);
$userCount = intval($userCount[0]['count(id)']);
return $userCount;
}

Expand Down
1 change: 1 addition & 0 deletions core/src/Classes/SystemTasks/DTO/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

class Task implements \JsonSerializable
{
const PRIORITY_TOP = 1000;
const PRIORITY_ERROR = 100;
const PRIORITY_WARNING = 50;
const PRIORITY_INFO = 20;
Expand Down
36 changes: 27 additions & 9 deletions core/src/Classes/SystemTasks/SystemTasksService.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,35 +27,53 @@ public function registerTaskCreator(TaskCreator $taskCreator)
$this->taskCreators[] = $taskCreator;
}

// protected function prepareTaskCreatorCallbacks()
// {
// $taskGenerators = [];
// foreach ($this->taskCreators as $taskCreator) {
// $taskList = $taskCreator->getTasksCreators();
// foreach ($taskList as $order => $callback) {
// $nextOrder = $order * 1000;
// while (isset($taskGenerators[$nextOrder])) {
// $nextOrder = 1 + $nextOrder;
// }
//
// $taskGenerators[$nextOrder] = $callback;
// }
// }
//
// return $taskGenerators;
// }


protected function prepareTaskCreatorCallbacks()
{
$taskGenerators = [];
foreach ($this->taskCreators as $taskCreator) {
$taskList = $taskCreator->getTasksCreators();
foreach ($taskList as $order => $callback) {
$nextOrder = $order * 1000;
while (isset($taskGenerators[$nextOrder])) {
$nextOrder = 1 + $nextOrder;
}

$taskGenerators[$nextOrder] = $callback;
foreach ($taskList as $callback) {
$taskGenerators[] = $callback;
}
}

return $taskGenerators;
}


public function getAdminTasks()
{
$tasks = [];
$taskGenerators = $this->prepareTaskCreatorCallbacks();
ksort($taskGenerators);
foreach ($taskGenerators as $key => $callback) {
/** @var Task $task */
$task = $callback();
if (!empty($task)) {
$tasks[] = $task;
}
}

usort($tasks, function ($a, $b) {
return $b->getPriority() - $a->getPriority();
});
return $tasks;
}
}
66 changes: 57 additions & 9 deletions core/src/Documents/Admin/Api/DocumentTaskCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Classes\BaseService;
use Classes\SystemTasks\DTO\Task;
use Classes\SystemTasks\TaskCreator;
use Employees\Admin\Api\EmployeeCache;
use Employees\Common\Model\Employee;

class DocumentTaskCreator implements TaskCreator
Expand All @@ -13,15 +14,16 @@ public function getTasksCreators()
{
$taskCreators = [];

$taskCreators[1] = function () {
$user = BaseService::getInstance()->getCurrentUser();

$taskCreators[] = function () {
$expiredDocumentCount = $this->getMyExpiredDocumentCount();
if ($expiredDocumentCount > 0) {
(new Task(
Task::PRIORITY_ERROR,
return (new Task(
Task::PRIORITY_WARNING,
sprintf(
'You have %s expired documents %s',
$expiredDocumentCount,
$expiredDocumentCount > 0 ? 's' : ''
'You have %s expired documents',
$expiredDocumentCount
)
))->setLink(
CLIENT_BASE_URL.'?g=modules&n=documents&m=module_Documents',
Expand All @@ -32,9 +34,55 @@ public function getTasksCreators()
return null;
};

if ('Admin' === $user->user_level || 'Manager' === $user->user_level) {
$taskCreators[] = function () {
$expiredDocumentCount = $this->getSubordinateExpiredDocumentCount();
if ($expiredDocumentCount > 0) {
return (new Task(
Task::PRIORITY_WARNING,
sprintf(
'Your subordinates have %s expired documents',
$expiredDocumentCount
)
))->setLink(
CLIENT_BASE_URL.'?g=admin&n=documents&m=admin_Manage#tabEmployeeDocument',
'Manage Documents'
);
}

return null;
};
}


return $taskCreators;
}

protected function getSubordinateExpiredDocumentCount()
{
$subIds = EmployeeCache::getSubordinateIds();
if (empty($subIds)) {
return 0;
}

$user = BaseService::getInstance()->getCurrentUser();

if ('Admin' === $user->user_level) {
$query = "select count(id) as c
from EmployeeDocuments
where employee IN (?) and valid_until < ?";
} else {
$query = "select count(id) as c
from EmployeeDocuments
where employee IN (?) and valid_until < ? and visible_to IN ('Manager', 'Owner')";
}

$rs = $user->DB()->Execute($query, [join(',', $subIds), date('Y-m-d')]);
$count = $rs[0]['c'];

return $count;
}

protected function getMyExpiredDocumentCount()
{
$user = BaseService::getInstance()->getCurrentUser();
Expand All @@ -47,12 +95,12 @@ protected function getMyExpiredDocumentCount()

$query = "select count(id) as c
from EmployeeDocuments
where employee = ? and valid_until < ? and visible_to = ?";
where employee = ? and valid_until < ? and (visible_to = ? or visible_to = ?)";

// $user->DB()->SetFetchMode(ADODB_FETCH_ASSOC);
// TODO - sending notifications only for Owner documents, this need to be extended later
$rs = $user->DB()->Execute($query, [$employee->id, date('Y-m-d'), 'Owner']);
$count = $rs->fields['c'];
$rs = $user->DB()->Execute($query, [$employee->id, date('Y-m-d'), 'Owner', 'Owner Only']);
$count = $rs[0]['c'];

return $count;
}
Expand Down
Loading

0 comments on commit ddecead

Please sign in to comment.