🧲 New features Custom user role permissions Employee edit form updated Employee daily task list Attendance and employee distribution charts on dashboard Improvements to company structure and company assets module Improved tables for displaying data in several modules Faster data loading (specially for employee module) Initials based profile pictures Re-designed login page Re-designed user profile page Improvements to filtering New REST endpoints for employee qualifications 🐛 Bug fixes Fixed, issue with managers being able to create performance reviews for employees who are not their direct reports Fixed, issues related to using full profile image instead of using smaller version of profile image Changing third gender to other Improvements and fixes for internal frontend data caching
191 lines
6.2 KiB
PHP
191 lines
6.2 KiB
PHP
<?php
|
|
|
|
use Classes\BaseService;
|
|
use Classes\CustomFieldManager;
|
|
use Classes\JwtTokenService;
|
|
use Classes\Migration\MigrationManager;
|
|
use Classes\NotificationManager;
|
|
use Classes\ReportHandler;
|
|
use Classes\SettingsManager;
|
|
use Utils\LogManager;
|
|
|
|
if (!defined("AWS_REGION")) {
|
|
define('AWS_REGION', 'us-east-1');
|
|
}
|
|
include(APP_BASE_PATH.'lib/adodb512/adodb.inc.php');
|
|
include(APP_BASE_PATH.'lib/adodb512/adodb-active-record.inc.php');
|
|
$ADODB_ASSOC_CASE = 2;
|
|
|
|
//detect admin and user modules
|
|
if (defined("MODULE_PATH")) {
|
|
$tArr = explode("/", MODULE_PATH);
|
|
if (count($tArr) == 1) {
|
|
$tArr = explode("\\", MODULE_PATH);
|
|
}
|
|
if (!defined('MODULE_TYPE')) {
|
|
if (count($tArr) >= 2) {
|
|
define('MODULE_TYPE', $tArr[count($tArr)-2]);
|
|
} else {
|
|
define('MODULE_TYPE', "");
|
|
}
|
|
}
|
|
}
|
|
|
|
$user = \Utils\SessionUtils::getSessionObject('user');
|
|
|
|
$dbLocal = NewADOConnection('mysqli');
|
|
$res = $dbLocal->Connect(APP_HOST, APP_USERNAME, APP_PASSWORD, APP_DB);
|
|
|
|
|
|
\Model\File::SetDatabaseAdapter($dbLocal);
|
|
\Model\Setting::SetDatabaseAdapter($dbLocal);
|
|
\Model\Report::SetDatabaseAdapter($dbLocal);
|
|
\Model\DataEntryBackup::SetDatabaseAdapter($dbLocal);
|
|
\Model\Audit::SetDatabaseAdapter($dbLocal);
|
|
\Model\Notification::SetDatabaseAdapter($dbLocal);
|
|
\Model\RestAccessToken::SetDatabaseAdapter($dbLocal);
|
|
|
|
|
|
$baseService = BaseService::getInstance();
|
|
BaseService::getInstance()->setNonDeletables("User", "id", 1);
|
|
BaseService::getInstance()->setCurrentUser($user);
|
|
BaseService::getInstance()->setCustomFieldManager(new CustomFieldManager());
|
|
BaseService::getInstance()->setDB($dbLocal);
|
|
|
|
$reportHandler = new ReportHandler();
|
|
$settingsManager = SettingsManager::getInstance();
|
|
$notificationManager = new NotificationManager();
|
|
|
|
BaseService::getInstance()->setNotificationManager($notificationManager);
|
|
BaseService::getInstance()->setSettingsManager($settingsManager);
|
|
BaseService::getInstance()->setCustomFieldManager(new CustomFieldManager());
|
|
$migrationManager = new MigrationManager();
|
|
$migrationManager->setMigrationPath(APP_BASE_PATH .'/migrations/');
|
|
BaseService::getInstance()->setMigrationManager($migrationManager);
|
|
|
|
$notificationManager->setBaseService($baseService);
|
|
|
|
if (defined('REDIS_SERVER_URI')
|
|
&& !empty(REDIS_SERVER_URI)
|
|
&& defined('QUERY_CACHE_TYPE')
|
|
&& QUERY_CACHE_TYPE === 'redis'
|
|
) {
|
|
BaseService::getInstance()->setCacheService(
|
|
new \Classes\RedisCacheService(REDIS_SERVER_URI, CLIENT_NAME)
|
|
);
|
|
} else {
|
|
BaseService::getInstance()->setCacheService(
|
|
new \Classes\MemoryCacheService(CLIENT_NAME)
|
|
);
|
|
}
|
|
|
|
$noJSONRequests = SettingsManager::getInstance()->getSetting("System: Do not pass JSON in request");
|
|
|
|
$debugMode = SettingsManager::getInstance()->getSetting("System: Debug Mode");
|
|
if ($debugMode == "1") {
|
|
if (!defined('LOG_LEVEL')) {
|
|
define('LOG_LEVEL', Monolog\Logger::DEBUG);
|
|
}
|
|
error_reporting(E_ALL);
|
|
} else {
|
|
if (!defined('LOG_LEVEL')) {
|
|
define('LOG_LEVEL', Monolog\Logger::INFO);
|
|
}
|
|
error_reporting(E_ERROR);
|
|
}
|
|
|
|
LogManager::getInstance();
|
|
|
|
include("includes.com.php");
|
|
|
|
$userTables = array();
|
|
$fileFields = array();
|
|
$mysqlErrors = array();
|
|
//============ Start - Initializing Modules ==========
|
|
if (defined('CLIENT_PATH')) {
|
|
include APP_BASE_PATH.'modules.php';
|
|
|
|
$moduleManagers = BaseService::getInstance()->getModuleManagers();
|
|
|
|
/* @var \Classes\AbstractModuleManager $moduleManagerObj */
|
|
foreach ($moduleManagers as $moduleManagerObj) {
|
|
$moduleManagerObj->setupModuleClassDefinitions();
|
|
$moduleManagerObj->initializeUserClasses();
|
|
$moduleManagerObj->initializeFieldMappings();
|
|
$moduleManagerObj->initializeDatabaseErrorMappings();
|
|
|
|
$moduleManagerObj->setupUserClasses($userTables);
|
|
$moduleManagerObj->setupFileFieldMappings($fileFields);
|
|
$moduleManagerObj->setupErrorMappings($mysqlErrors);
|
|
//$moduleManagerObj->setupRestEndPoints();
|
|
$moduleManagerObj->initCalculationHooks();
|
|
$moduleManagerObj->initialize();
|
|
|
|
$modelClassList = $moduleManagerObj->getModelClasses();
|
|
$metaData = $moduleManagerObj->getModuleObject();
|
|
foreach ($modelClassList as $modelClass) {
|
|
$modelClassWithNameSpace = $metaData['model_namespace']."\\".$modelClass;
|
|
$modelClassWithNameSpace::SetDatabaseAdapter($dbLocal);
|
|
$baseService->addModelClass($modelClass, $modelClassWithNameSpace);
|
|
}
|
|
}
|
|
}
|
|
//============= End - Initializing Modules ============
|
|
|
|
BaseService::getInstance()->setFileFields($fileFields);
|
|
|
|
BaseService::getInstance()->setUserTables($userTables);
|
|
|
|
BaseService::getInstance()->setSqlErrors($mysqlErrors);
|
|
|
|
|
|
if (class_exists('\\Audit\\Admin\\Api\\AuditActionManager')) {
|
|
$auditManager = new \Audit\Admin\Api\AuditActionManager();
|
|
$auditManager->setBaseService($baseService);
|
|
$auditManager->setUser($user);
|
|
BaseService::getInstance()->setAuditManager($auditManager);
|
|
}
|
|
|
|
$emailEnabled = SettingsManager::getInstance()->getSetting("Email: Enable");
|
|
$emailMode = SettingsManager::getInstance()->getSetting("Email: Mode");
|
|
$uploadS3 = SettingsManager::getInstance()->getSetting("Files: Upload Files to S3");
|
|
|
|
if ($emailMode == "SES" || $uploadS3 == '1') {
|
|
include(APP_BASE_PATH.'lib/aws.phar');
|
|
}
|
|
|
|
$emailSender = null;
|
|
if ($emailEnabled == "1") {
|
|
if ($emailMode == "SMTP") {
|
|
$emailSender = new \Classes\Email\SMTPEmailSender($settingsManager);
|
|
} elseif ($emailMode == "SES") {
|
|
$emailSender = new \Classes\Email\SNSEmailSender($settingsManager);
|
|
} elseif ($emailMode == "PHP Mailer") {
|
|
$emailSender = new \Classes\Email\PHPMailer($settingsManager);
|
|
} elseif ($emailMode == "Swift SMTP") {
|
|
$emailSender = new \Classes\Email\SwiftMailer($settingsManager);
|
|
}
|
|
}
|
|
|
|
BaseService::getInstance()->setEmailSender($emailSender);
|
|
|
|
$jwtService = new JwtTokenService();
|
|
|
|
function shutdown()
|
|
{
|
|
session_write_close();
|
|
$error = error_get_last();
|
|
|
|
if (!empty($error) && isset($error['type']) && in_array($error['type'], [E_ERROR, E_PARSE])) {
|
|
LogManager::getInstance()->notifyException(new ErrorException(
|
|
$error['message'],
|
|
0,
|
|
1,
|
|
$error['file'],
|
|
$error['line']
|
|
));
|
|
}
|
|
}
|
|
|
|
register_shutdown_function('shutdown');
|