v26.6.0 updates
This commit is contained in:
@@ -9,9 +9,11 @@ use Classes\IceResponse;
|
||||
use Classes\LanguageManager;
|
||||
use Classes\PermissionManager;
|
||||
use Classes\RestEndPoint;
|
||||
use Classes\SettingsManager;
|
||||
use Employees\Common\Model\Employee;
|
||||
use Users\Common\Model\User;
|
||||
use Utils\LogManager;
|
||||
use Utils\NetworkUtils;
|
||||
|
||||
class AttendanceRestEndPoint extends RestEndPoint
|
||||
{
|
||||
@@ -163,7 +165,7 @@ class AttendanceRestEndPoint extends RestEndPoint
|
||||
|
||||
$openPunch = $this->getOpenPunch($user, $body['employee'], $body['in_time']);
|
||||
|
||||
if ($openPunch->getStatus() === IceResponse::SUCCESS && !empty($openPunch->getData()['attendnace'])) {
|
||||
if ($openPunch->getStatus() === IceResponse::SUCCESS && !empty($openPunch->getData()['attendance'])) {
|
||||
return new IceResponse(IceResponse::ERROR, 'User has already punched in for the day ', 400);
|
||||
}
|
||||
|
||||
@@ -172,7 +174,17 @@ class AttendanceRestEndPoint extends RestEndPoint
|
||||
return $permissionResponse;
|
||||
}
|
||||
|
||||
$response = BaseService::getInstance()->addElement(self::ELEMENT_NAME, $body);
|
||||
$response = $this->savePunch(
|
||||
$body['employee'],
|
||||
$body['in_time'],
|
||||
$body['note'],
|
||||
null,
|
||||
null,
|
||||
$body['latitude'],
|
||||
$body['longitude'],
|
||||
NetworkUtils::getClientIp()
|
||||
);
|
||||
|
||||
if ($response->getStatus() === IceResponse::SUCCESS) {
|
||||
$attendance = $this->cleanObject($response->getData());
|
||||
$response->setData($attendance);
|
||||
@@ -211,7 +223,10 @@ class AttendanceRestEndPoint extends RestEndPoint
|
||||
$attendance->in_time,
|
||||
$body['note'],
|
||||
$body['out_time'],
|
||||
$attendance->id
|
||||
$attendance->id,
|
||||
$body['latitude'],
|
||||
$body['longitude'],
|
||||
NetworkUtils::getClientIp()
|
||||
);
|
||||
|
||||
if ($response->getStatus() === IceResponse::SUCCESS) {
|
||||
@@ -262,7 +277,7 @@ class AttendanceRestEndPoint extends RestEndPoint
|
||||
}
|
||||
}
|
||||
|
||||
protected function savePunch($employeeId, $inDateTime, $note = null, $outDateTime = null, $id = null)
|
||||
protected function savePunch($employeeId, $inDateTime, $note = null, $outDateTime = null, $id = null, $latitude = null, $longitude = null, $ip = null)
|
||||
{
|
||||
$employee = BaseService::getInstance()->getElement(
|
||||
'Employee',
|
||||
@@ -339,8 +354,16 @@ class AttendanceRestEndPoint extends RestEndPoint
|
||||
$attendance->in_time = $inDateTime;
|
||||
if (empty($outDateTime)) {
|
||||
$attendance->out_time = null;
|
||||
$attendance->map_lat = $latitude;
|
||||
$attendance->map_lng = $longitude;
|
||||
$attendance->map_snapshot = $this->generateMapLocationImage($latitude, $longitude);
|
||||
$attendance->in_ip = $ip;
|
||||
} else {
|
||||
$attendance->out_time = $outDateTime;
|
||||
$attendance->map_out_lat = $latitude;
|
||||
$attendance->map_out_lng = $longitude;
|
||||
$attendance->map_out_snapshot = $this->generateMapLocationImage($latitude, $longitude);
|
||||
$attendance->out_ip = $ip;
|
||||
}
|
||||
|
||||
$attendance->employee = $employeeId;
|
||||
@@ -352,4 +375,34 @@ class AttendanceRestEndPoint extends RestEndPoint
|
||||
}
|
||||
return new IceResponse(IceResponse::SUCCESS, $attendance);
|
||||
}
|
||||
|
||||
protected function generateMapLocationImage($latitude, $longitude)
|
||||
{
|
||||
if (empty(SettingsManager::getInstance()->getSetting('System: Google Maps Api Key'))
|
||||
|| empty($latitude)
|
||||
|| empty($longitude)
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$location = sprintf('%s,%s', $latitude, $longitude);
|
||||
|
||||
$url = "https://maps.googleapis.com/maps/api/staticmap?&zoom=15&size=210x175&maptype=roadmap
|
||||
&markers=color:blue%7Clabel:S%7C$location&markers=color:green%7Clabel:G%7C$location
|
||||
&markers=color:red%7Clabel:C%7C$location
|
||||
&key=".SettingsManager::getInstance()->getSetting('System: Google Maps Api Key');
|
||||
|
||||
LogManager::getInstance()->info('Url:'.$url);
|
||||
|
||||
$data = file_get_contents($url);
|
||||
|
||||
//LogManager::getInstance()->info('Data:'.$data);
|
||||
if (!empty($data)) {
|
||||
//LogManager::getInstance()->info('Data Base64:'.base64_encode($data));
|
||||
return'data:image/png;base64,' . base64_encode($data);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ use Classes\SettingsManager;
|
||||
use Classes\SubActionManager;
|
||||
use TimeSheets\Common\Model\EmployeeTimeSheet;
|
||||
use Utils\LogManager;
|
||||
use Utils\NetworkUtils;
|
||||
|
||||
class AttendanceActionManager extends SubActionManager
|
||||
{
|
||||
@@ -132,6 +133,7 @@ class AttendanceActionManager extends SubActionManager
|
||||
$openPunch->out_time = $dateTime;
|
||||
$openPunch->note = $req->note;
|
||||
$openPunch->image_out = $req->image;
|
||||
$openPunch->out_ip = NetworkUtils::getClientIp();
|
||||
$this->baseService->audit(IceConstants::AUDIT_ACTION, "Punch Out \ time:".$openPunch->out_time);
|
||||
} else {
|
||||
$openPunch->in_time = $dateTime;
|
||||
@@ -139,6 +141,7 @@ class AttendanceActionManager extends SubActionManager
|
||||
$openPunch->note = $req->note;
|
||||
$openPunch->image_in = $req->image;
|
||||
$openPunch->employee = $employee->id;
|
||||
$openPunch->in_ip = NetworkUtils::getClientIp();
|
||||
$this->baseService->audit(IceConstants::AUDIT_ACTION, "Punch In \ time:".$openPunch->in_time);
|
||||
}
|
||||
$ok = $openPunch->Save();
|
||||
|
||||
@@ -1,25 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
This file is part of Ice Framework.
|
||||
|
||||
Ice Framework 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 Framework 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 Framework. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
------------------------------------------------------------------
|
||||
|
||||
Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd]
|
||||
Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah)
|
||||
*/
|
||||
namespace Classes;
|
||||
|
||||
abstract class AbstractInitialize
|
||||
|
||||
@@ -1,27 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
This file is part of Ice Framework.
|
||||
|
||||
Ice Framework 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 Framework 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 Framework. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
------------------------------------------------------------------
|
||||
|
||||
Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd]
|
||||
Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah)
|
||||
*/
|
||||
|
||||
/**
|
||||
* BaseService class serves as the core logic for managing the application and for handling most
|
||||
* of the tasks related to retriving and saving data. This can be referred within any module using
|
||||
@@ -74,6 +52,8 @@ class BaseService
|
||||
public $modelClassMap = array();
|
||||
public $currentProfileId = false;
|
||||
|
||||
protected $pro = null;
|
||||
|
||||
private static $me = null;
|
||||
|
||||
private function __construct()
|
||||
@@ -1098,6 +1078,42 @@ class BaseService
|
||||
return $obj;
|
||||
}
|
||||
|
||||
public function cleanUpIgnoreKeys($obj)
|
||||
{
|
||||
unset($obj->keysToIgnore);
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
public function cleanUpApprovalModelParameters($obj)
|
||||
{
|
||||
unset($obj->notificationModuleName);
|
||||
unset($obj->notificationUnitName);
|
||||
unset($obj->notificationUnitPrefix);
|
||||
unset($obj->notificationUnitAdminUrl);
|
||||
unset($obj->preApproveSettingName);
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
public function cleanUpAll($obj)
|
||||
{
|
||||
$obj = $this->cleanUpAdoDB($obj);
|
||||
$obj = $this->cleanUpIgnoreKeys($obj);
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
public function cleanUpUser($obj)
|
||||
{
|
||||
$obj = $this->cleanUpAdoDB($obj);
|
||||
unset($obj->password);
|
||||
unset($obj->login_hash);
|
||||
unset($obj->googleUserData);
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
public function setDB($db)
|
||||
{
|
||||
$this->db = $db;
|
||||
@@ -1529,6 +1545,26 @@ class BaseService
|
||||
return call_user_func_array(array(new $class(), $ch->method), $parameters);
|
||||
}
|
||||
|
||||
public function initializePro()
|
||||
{
|
||||
$this->pro = null;
|
||||
if (class_exists('\\Classes\\ProVersion')) {
|
||||
$pro = new ProVersion();
|
||||
if (method_exists($pro, 'isModuleEnabled')) {
|
||||
$this->pro = $pro;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function isModuleEnabled($type, $name)
|
||||
{
|
||||
if ($this->pro === null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $this->pro->isModuleEnabled($type, $name);
|
||||
}
|
||||
|
||||
public function cleanNonUTFChar($obj)
|
||||
{
|
||||
$regex = <<<'END'
|
||||
|
||||
@@ -1,25 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
This file is part of Ice Framework.
|
||||
|
||||
Ice Framework 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 Framework 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 Framework. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
------------------------------------------------------------------
|
||||
|
||||
Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd]
|
||||
Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah)
|
||||
*/
|
||||
namespace Classes;
|
||||
|
||||
use Model\File;
|
||||
|
||||
@@ -228,7 +228,7 @@ class MigrationManager
|
||||
if (count($migrationList) > 0 && (empty($migration->id) || $migrationList[0].".php" != $migration->file)) {
|
||||
LogManager::getInstance()->info("ensureMigrations - execute migrations");
|
||||
$this->queueMigrations();
|
||||
$this->runPendingMigrations();
|
||||
}
|
||||
$this->runPendingMigrations();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ namespace Classes;
|
||||
|
||||
use Classes\Data\DataReader;
|
||||
use Classes\Data\Query\DataQuery;
|
||||
use Classes\Upload\Uploader;
|
||||
use Employees\Common\Model\Employee;
|
||||
use Users\Common\Model\User;
|
||||
use Utils\SessionUtils;
|
||||
@@ -327,4 +328,26 @@ class RestEndPoint
|
||||
$inputJSON = file_get_contents('php://input');
|
||||
return json_decode($inputJSON, true);
|
||||
}
|
||||
|
||||
protected function getFile()
|
||||
{
|
||||
return $_FILES;
|
||||
}
|
||||
|
||||
public function uploadFile(User $user)
|
||||
{
|
||||
$fileData = $this->getFile();
|
||||
$postData = [
|
||||
'file_name' => '_NEW_',
|
||||
'user' => $user->employee,
|
||||
'file_group' => static::ELEMENT_NAME
|
||||
];
|
||||
|
||||
$fileResponse = Uploader::upload($postData, $fileData);
|
||||
if ($fileResponse->getStatus() === IceResponse::SUCCESS) {
|
||||
return new IceResponse(IceResponse::SUCCESS, ['data' => $fileResponse->getData()], 201);
|
||||
}
|
||||
|
||||
return $fileResponse;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,4 @@
|
||||
<?php
|
||||
/*
|
||||
This file is part of Ice Framework.
|
||||
|
||||
Ice Framework 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 Framework 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 Framework. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
------------------------------------------------------------------
|
||||
|
||||
Original work Copyright (c) 2012 [Gamonoid Media Pvt. Ltd]
|
||||
Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah)
|
||||
*/
|
||||
namespace Classes;
|
||||
|
||||
abstract class SubActionManager
|
||||
@@ -56,16 +35,19 @@ abstract class SubActionManager
|
||||
$this->emailTemplates = $emailTemplates;
|
||||
}
|
||||
|
||||
public function getEmailTemplate($name)
|
||||
public function getEmailTemplate($name, $modulePath = null)
|
||||
{
|
||||
if ($modulePath == null) {
|
||||
$modulePath = MODULE_PATH;
|
||||
}
|
||||
//Read module email templates
|
||||
if ($this->emailTemplates == null) {
|
||||
$this->emailTemplates = array();
|
||||
if (is_dir(MODULE_PATH.'/emailTemplates/')) {
|
||||
$ams = scandir(MODULE_PATH.'/emailTemplates/');
|
||||
if (is_dir($modulePath.'/emailTemplates/')) {
|
||||
$ams = scandir($modulePath.'/emailTemplates/');
|
||||
foreach ($ams as $am) {
|
||||
if (!is_dir(MODULE_PATH.'/emailTemplates/'.$am) && $am != '.' && $am != '..') {
|
||||
$this->emailTemplates[$am] = file_get_contents(MODULE_PATH.'/emailTemplates/'.$am);
|
||||
if (!is_dir($modulePath.'/emailTemplates/'.$am) && $am != '.' && $am != '..') {
|
||||
$this->emailTemplates[$am] = file_get_contents($modulePath.'/emailTemplates/'.$am);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,37 +87,43 @@ class UIManager
|
||||
$this->currentProfileBlock = array(
|
||||
"profileImage"=>$profileCurrent->image,
|
||||
"firstName"=>$profileCurrent->first_name,
|
||||
"lastName"=>$profileCurrent->last_name
|
||||
"lastName"=>$profileCurrent->last_name,
|
||||
"profile_url"=>CLIENT_BASE_URL.'?g=admin&n=employees&m=admin_Employees',
|
||||
);
|
||||
|
||||
$this->switchedProfileBlock = array(
|
||||
"profileImage"=>$profileSwitched->image,
|
||||
"firstName"=>$profileSwitched->first_name,
|
||||
"lastName"=>$profileSwitched->last_name
|
||||
"lastName"=>$profileSwitched->last_name,
|
||||
"profile_url"=>CLIENT_BASE_URL.'?g=modules&n=employees&m=module_Personal_Information',
|
||||
);
|
||||
} elseif (!empty($profileCurrent)) {
|
||||
$this->currentProfileBlock = array(
|
||||
"profileImage"=>$profileCurrent->image,
|
||||
"firstName"=>$profileCurrent->first_name,
|
||||
"lastName"=>$profileCurrent->last_name
|
||||
"lastName"=>$profileCurrent->last_name,
|
||||
"profile_url"=>CLIENT_BASE_URL.'?g=modules&n=employees&m=module_Personal_Information',
|
||||
);
|
||||
} elseif (!empty($profileSwitched)) {
|
||||
$this->currentProfileBlock = array(
|
||||
"profileImage"=>BASE_URL."images/user_male.png",
|
||||
"firstName"=>$this->user->username,
|
||||
"lastName"=>""
|
||||
"lastName"=>"",
|
||||
"profile_url"=>CLIENT_BASE_URL.'?g=admin&n=employees&m=admin_Employees',
|
||||
);
|
||||
|
||||
$this->switchedProfileBlock = array(
|
||||
"profileImage"=>$profileSwitched->image,
|
||||
"firstName"=>$profileSwitched->first_name,
|
||||
"lastName"=>$profileSwitched->last_name
|
||||
"lastName"=>$profileSwitched->last_name,
|
||||
"profile_url"=>CLIENT_BASE_URL.'?g=modules&n=employees&m=module_Personal_Information',
|
||||
);
|
||||
} else {
|
||||
$this->currentProfileBlock = array(
|
||||
"profileImage"=>BASE_URL."images/user_male.png",
|
||||
"firstName"=>$this->user->username,
|
||||
"lastName"=>""
|
||||
"lastName"=>"",
|
||||
"profile_url"=>CLIENT_BASE_URL.'?g=admin&n=employees&m=admin_Employees',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,4 +21,43 @@ class Timezone extends BaseModel
|
||||
{
|
||||
return array("get","element");
|
||||
}
|
||||
|
||||
public function getTimezonesWithOffset()
|
||||
{
|
||||
$tz = new Timezone();
|
||||
$tzs = $tz->Find("1 = 1");
|
||||
$modifiedTimeZones = [];
|
||||
foreach ($tzs as $tz) {
|
||||
try {
|
||||
$z = new \DateTimeZone($tz->name);
|
||||
$c = new \DateTime(null, $z);
|
||||
$tz->details = sprintf("(%s) %s", $this->formatOffset($z->getOffset($c)), $tz->name);
|
||||
$modifiedTimeZones[] = $tz;
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
usort($modifiedTimeZones, function ($a, $b) { return strcmp($a->details, $b->details); });
|
||||
return $modifiedTimeZones;
|
||||
}
|
||||
|
||||
public function formatOffset($offset) {
|
||||
$hours = $offset / 3600;
|
||||
$remainder = $offset % 3600;
|
||||
$sign = $hours > 0 ? '+' : '-';
|
||||
$hour = (int) abs($hours);
|
||||
$minutes = (int) abs($remainder / 60);
|
||||
|
||||
if ($hour == 0 AND $minutes == 0) {
|
||||
$sign = ' ';
|
||||
}
|
||||
return 'GMT' . $sign . str_pad($hour, 2, '0', STR_PAD_LEFT)
|
||||
.':'. str_pad($minutes,2, '0');
|
||||
}
|
||||
|
||||
public function fieldValueMethods()
|
||||
{
|
||||
return ['getTimezonesWithOffset'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace Metadata\Rest;
|
||||
|
||||
use Classes\BaseService;
|
||||
use Classes\Data\Query\DataQuery;
|
||||
use Classes\IceResponse;
|
||||
use Classes\RestEndPoint;
|
||||
@@ -44,6 +45,8 @@ class MetadataRestEndPoint extends RestEndPoint
|
||||
$module = new Module();
|
||||
$modules = $module->Find('name = ? and mod_group = ? and status = ?', [$name, 'user', 'Enabled']);
|
||||
|
||||
return count($modules) > 0;
|
||||
BaseService::getInstance()->initializePro();
|
||||
|
||||
return count($modules) > 0 && BaseService::getInstance()->isModuleEnabled('modules', $name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,18 @@
|
||||
|
||||
namespace Model;
|
||||
|
||||
/**
|
||||
* Class Cron
|
||||
* @package Model
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $class
|
||||
* @property int $frequency
|
||||
* @property int $time
|
||||
* @property string $type
|
||||
* @property string $status
|
||||
*/
|
||||
class Cron extends BaseModel
|
||||
{
|
||||
public $table = 'Crons';
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
namespace Model;
|
||||
|
||||
use Classes\BaseService;
|
||||
use Classes\IceResponse;
|
||||
use Classes\RestApiManager;
|
||||
use Users\Common\Model\User;
|
||||
|
||||
@@ -41,10 +42,10 @@ class Setting extends BaseModel
|
||||
return $obj;
|
||||
}
|
||||
|
||||
public function executePostSaveActions($obj)
|
||||
public function validateSave($obj)
|
||||
{
|
||||
if (!defined('WEB_ADMIN_BASE_URL')) {
|
||||
return;
|
||||
return new IceResponse(IceResponse::SUCCESS, "");
|
||||
}
|
||||
|
||||
if ($obj->name == 'Company: Country') {
|
||||
@@ -57,12 +58,42 @@ class Setting extends BaseModel
|
||||
$updateInvUrl = WEB_ADMIN_BASE_URL.'/app/update_instance.php?client='
|
||||
.CLIENT_NAME.'&vatId='.$obj->value.'&key='.ADMIN_SEC_KEY;
|
||||
$response = file_get_contents($updateInvUrl);
|
||||
$response = json_decode($response, true);
|
||||
if ($response['status'] === IceResponse::ERROR) {
|
||||
return new IceResponse(IceResponse::ERROR, $response['data']);
|
||||
}
|
||||
}
|
||||
return new IceResponse(IceResponse::SUCCESS, "");
|
||||
}
|
||||
|
||||
public function executePreSaveActions($obj)
|
||||
{
|
||||
if ($obj->name == 'Leave: Select Leave Period from Employee Department Country') {
|
||||
$oldSetting = new Setting();
|
||||
$oldSetting->Load('name = ?', ['Leave: Select Leave Period from Employee Department Country']);
|
||||
if (class_exists('\Leaves\Common\Model\EmployeeLeave')) {
|
||||
$employeeLeave = new \Leaves\Common\Model\EmployeeLeave();
|
||||
$employeeLeaves = $employeeLeave->Find("1 = 1 limit 1", []);
|
||||
if (count($employeeLeaves) === 1) {
|
||||
$obj->value = $oldSetting->value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new IceResponse(IceResponse::SUCCESS, $obj);
|
||||
}
|
||||
|
||||
public function executePreUpdateActions($obj)
|
||||
{
|
||||
return $this->executePreSaveActions($obj);
|
||||
}
|
||||
|
||||
public function executePostSaveActions($obj)
|
||||
{
|
||||
}
|
||||
|
||||
public function executePostUpdateActions($obj)
|
||||
{
|
||||
$this->executePostSaveActions($obj);
|
||||
}
|
||||
|
||||
public $table = 'Settings';
|
||||
|
||||
@@ -82,4 +82,9 @@ class Project extends BaseModel
|
||||
|
||||
return $employeeProjects;
|
||||
}
|
||||
|
||||
public function fieldValueMethods()
|
||||
{
|
||||
return ['getEmployeeProjects'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
namespace Settings\Admin\Api;
|
||||
|
||||
use Classes\AbstractModuleManager;
|
||||
use Settings\Rest\SettingsRestEndPoint;
|
||||
|
||||
class SettingsAdminManager extends AbstractModuleManager
|
||||
{
|
||||
@@ -35,4 +36,12 @@ class SettingsAdminManager extends AbstractModuleManager
|
||||
{
|
||||
return new SettingsInitialize();
|
||||
}
|
||||
|
||||
public function setupRestEndPoints()
|
||||
{
|
||||
\Classes\Macaw::get(REST_API_PATH.'settings', function () {
|
||||
$restEndPoint = new SettingsRestEndPoint();
|
||||
$restEndPoint->process('getMobileSettings', []);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -301,10 +301,10 @@ class TimeSheetsActionManager extends SubActionManager
|
||||
$project = new $rowTable();
|
||||
|
||||
if (SettingsManager::getInstance()->getSetting("Projects: Make All Projects Available to Employees") == "1") {
|
||||
$projectList = $project->Find("1 = 1");
|
||||
$projectList = $project->Find("1 = 1 order by name");
|
||||
} else {
|
||||
$projectList = $project->Find(
|
||||
"id in (select project from EmployeeProjects where employee = ?)",
|
||||
"id in (select project from EmployeeProjects where employee = ?) order by name",
|
||||
array(BaseService::getInstance()->getCurrentProfileId())
|
||||
);
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ class UsersEmailSender
|
||||
} else {
|
||||
LogManager::getInstance()->info("[sendWelcomeUserEmail] email is empty");
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ namespace Users\Common\Model;
|
||||
use Classes\BaseService;
|
||||
use Model\BaseModel;
|
||||
use Classes\IceResponse;
|
||||
use Modules\Common\Model\Module;
|
||||
|
||||
class User extends BaseModel
|
||||
{
|
||||
@@ -57,23 +56,6 @@ class User extends BaseModel
|
||||
}
|
||||
}
|
||||
|
||||
//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, "");
|
||||
}
|
||||
|
||||
|
||||
@@ -65,11 +65,28 @@ class CalendarTools
|
||||
return $time->format($format);
|
||||
}
|
||||
|
||||
public static function getNumberOfDaysBetweenDates($first, $second)
|
||||
public static function getNumberOfDaysBetweenDates($later, $earlier)
|
||||
{
|
||||
$timeFirst = new \DateTime($first);
|
||||
$timeSecond = new \DateTime($second);
|
||||
$timeFirst = new \DateTime($later);
|
||||
$timeSecond = new \DateTime($earlier);
|
||||
$interval = $timeSecond->diff($timeFirst);
|
||||
return intval($interval->format('%a'));
|
||||
return intval($interval->format('%a')) + 1;
|
||||
}
|
||||
|
||||
public static function getNumberOfMonthsBetweenDates($date1, $date2)
|
||||
{
|
||||
$begin = new \DateTime($date1);
|
||||
$end = new \DateTime($date2);
|
||||
$end = $end->modify('+1 day');
|
||||
|
||||
$interval = \DateInterval::createFromDateString('1 month');
|
||||
|
||||
$period = new \DatePeriod($begin, $interval, $end);
|
||||
$counter = 0;
|
||||
foreach ($period as $dt) {
|
||||
$counter++;
|
||||
}
|
||||
|
||||
return $counter;
|
||||
}
|
||||
}
|
||||
|
||||
26
core/src/Utils/NetworkUtils.php
Normal file
26
core/src/Utils/NetworkUtils.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Utils;
|
||||
|
||||
class NetworkUtils
|
||||
{
|
||||
public static function getClientIp()
|
||||
{
|
||||
$ipaddress = '';
|
||||
if (isset($_SERVER['HTTP_CLIENT_IP']))
|
||||
$ipaddress = $_SERVER['HTTP_CLIENT_IP'];
|
||||
else if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
|
||||
$ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||
else if(isset($_SERVER['HTTP_X_FORWARDED']))
|
||||
$ipaddress = $_SERVER['HTTP_X_FORWARDED'];
|
||||
else if(isset($_SERVER['HTTP_FORWARDED_FOR']))
|
||||
$ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
|
||||
else if(isset($_SERVER['HTTP_FORWARDED']))
|
||||
$ipaddress = $_SERVER['HTTP_FORWARDED'];
|
||||
else if(isset($_SERVER['REMOTE_ADDR']))
|
||||
$ipaddress = $_SERVER['REMOTE_ADDR'];
|
||||
else
|
||||
$ipaddress = 'UNKNOWN';
|
||||
return $ipaddress;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user