Add latest changes from icehrm pro
This commit is contained in:
@@ -1014,6 +1014,18 @@ class BaseService
|
||||
return $adminEmpId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Profile id attached to currently logged in user
|
||||
* @method getCurrentProfileId
|
||||
* @return {Integer}
|
||||
*/
|
||||
public function getCurrentUserProfileId()
|
||||
{
|
||||
$user = SessionUtils::getSessionObject('user');
|
||||
$signInMappingField = SIGN_IN_ELEMENT_MAPPING_FIELD_NAME;
|
||||
return $user->$signInMappingField;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get User by profile id
|
||||
* @method getUserFromProfileId
|
||||
|
||||
@@ -76,7 +76,7 @@ class CustomFieldManager
|
||||
|
||||
$customFieldsListOrdered[] = $order;
|
||||
|
||||
if ($type == "text" || $type == "textarea") {
|
||||
if ($type == "text" || $type == "textarea" || $type == "fileupload") {
|
||||
$object->customFields[$label] = $cf->value;
|
||||
} elseif ($type == 'select' || $type == 'select2') {
|
||||
$options = $customFields[$cf->name]->field_options;
|
||||
@@ -132,7 +132,7 @@ class CustomFieldManager
|
||||
}
|
||||
}
|
||||
|
||||
$object->customFields[$label] = array($object->customFields[$label], $section);
|
||||
$object->customFields[$label] = array($object->customFields[$label], $section, $type);
|
||||
}
|
||||
array_multisort($customFieldsListOrdered, SORT_DESC, SORT_NUMERIC, $object->customFields);
|
||||
|
||||
|
||||
@@ -20,4 +20,5 @@ class IceConstants
|
||||
const NOTIFICATION_LEAVE = "Leave Module";
|
||||
const NOTIFICATION_TIMESHEET = "Time Module";
|
||||
const NOTIFICATION_TRAINING = "Training Module";
|
||||
const NOTIFICATION_ANNOUNCEMENT = "Announcements";
|
||||
}
|
||||
|
||||
@@ -88,6 +88,10 @@ class LanguageManager
|
||||
$pattern = "#<t>(.*?)</t>#";
|
||||
preg_match_all($pattern, $string, $matches);
|
||||
|
||||
if (count($matches[0]) === 0) {
|
||||
return self::tran($string);
|
||||
}
|
||||
|
||||
for ($i = 0; $i<count($matches[0]); $i++) {
|
||||
$tagVal = $matches[1][$i];
|
||||
$fullVal = $matches[0][$i];
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace Classes;
|
||||
|
||||
use Employees\Common\Model\Employee;
|
||||
use Model\Notification;
|
||||
use Users\Common\Model\User;
|
||||
|
||||
@@ -14,6 +15,25 @@ class NotificationManager
|
||||
$this->baseService = $baseService;
|
||||
}
|
||||
|
||||
public function addNotificationToAll(
|
||||
$message,
|
||||
$action,
|
||||
$type,
|
||||
$fromEmployee,
|
||||
$toUserId = null,
|
||||
$fromSystem = false,
|
||||
$sendEmail = false
|
||||
) {
|
||||
$employee = new Employee();
|
||||
$employees = $employee->Find('status = ?', array('Active'));
|
||||
foreach ($employees as $employee) {
|
||||
if ($employee->id === $fromEmployee) {
|
||||
continue;
|
||||
}
|
||||
$this->addNotification($employee->id, $message, $action, $type, $toUserId, $fromSystem, $sendEmail);
|
||||
}
|
||||
}
|
||||
|
||||
public function addNotification(
|
||||
$toEmployee,
|
||||
$message,
|
||||
|
||||
@@ -45,6 +45,11 @@ abstract class SubActionManager
|
||||
return $this->baseService->getCurrentProfileId();
|
||||
}
|
||||
|
||||
public function getCurrentUserProfileId()
|
||||
{
|
||||
return $this->baseService->getCurrentUserProfileId();
|
||||
}
|
||||
|
||||
public function setEmailTemplates($emailTemplates)
|
||||
{
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
namespace Classes;
|
||||
|
||||
use Classes\ModuleBuilder\ModuleBuilder;
|
||||
use Metadata\Common\Model\SupportedLanguage;
|
||||
|
||||
class UIManager
|
||||
{
|
||||
@@ -15,9 +16,10 @@ class UIManager
|
||||
protected $currentProfileBlock = null;
|
||||
protected $switchedProfileBlock = null;
|
||||
|
||||
protected $templates = array();
|
||||
protected $templates = [];
|
||||
|
||||
protected $quickAccessMenuItems = array();
|
||||
protected $quickAccessMenuItems = [];
|
||||
protected $languageMenuItems = [];
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
@@ -32,6 +34,16 @@ class UIManager
|
||||
return self::$me;
|
||||
}
|
||||
|
||||
public function getCurrentProfile()
|
||||
{
|
||||
return $this->currentProfile;
|
||||
}
|
||||
|
||||
public function getSwitchedProfile()
|
||||
{
|
||||
return $this->switchedProfile;
|
||||
}
|
||||
|
||||
private function getTemplate($name, $type)
|
||||
{
|
||||
|
||||
@@ -120,22 +132,43 @@ class UIManager
|
||||
|
||||
public function getMenuBlocks()
|
||||
{
|
||||
$manuItems = array();
|
||||
$menuItems = array();
|
||||
|
||||
if (!empty($this->quickAccessMenuItems)) {
|
||||
$itemsHtml = $this->getQuickAccessMenuItemsHTML();
|
||||
if (!empty($itemsHtml)) {
|
||||
$manuItems[] = new MenuItemTemplate('menuButtonQuick', array("ITEMS"=>$itemsHtml));
|
||||
$menuItems[] = new MenuItemTemplate('menuButtonQuick', array("ITEMS"=>$itemsHtml));
|
||||
}
|
||||
}
|
||||
|
||||
$manuItems[] = new MenuItemTemplate('menuButtonNotification', array());
|
||||
$menuItems[] = new MenuItemTemplate('menuButtonNotification', array());
|
||||
if ($this->user->user_level == "Admin") {
|
||||
$manuItems[] = new MenuItemTemplate('menuButtonSwitchProfile', array());
|
||||
$menuItems[] = new MenuItemTemplate('menuButtonSwitchProfile', array());
|
||||
}
|
||||
|
||||
if (!empty($this->languageMenuItems)) {
|
||||
$itemsHtml = $this->getLanguageMenuItemsHTML();
|
||||
if (!empty($itemsHtml)) {
|
||||
$user = BaseService::getInstance()->getCurrentUser();
|
||||
$supportedLanguage = new SupportedLanguage();
|
||||
$supportedLanguage->Load('id = ?', [$user->lang]);
|
||||
$language = $supportedLanguage->name;
|
||||
if (empty($language)) {
|
||||
$language = SettingsManager::getInstance()->getSetting('System: Language');
|
||||
}
|
||||
$menuItems[] = new MenuItemTemplate(
|
||||
'menuButtonLanguage',
|
||||
array(
|
||||
"ITEMS" => $itemsHtml,
|
||||
"CURRENT_LANG" => $language,
|
||||
"CURRENT_CODE" => $this->getCountryCodeByLanguage($language)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($this->currentProfile)) {
|
||||
$manuItems[] = new MenuItemTemplate('menuButtonProfile', array(
|
||||
$menuItems[] = new MenuItemTemplate('menuButtonProfile', array(
|
||||
"profileImage"=>$this->currentProfile->image,
|
||||
"firstName"=>$this->currentProfile->first_name,
|
||||
"lastName"=>$this->currentProfile->last_name,
|
||||
@@ -144,7 +177,7 @@ class UIManager
|
||||
|
||||
));
|
||||
} else {
|
||||
$manuItems[] = new MenuItemTemplate('menuButtonProfile', array(
|
||||
$menuItems[] = new MenuItemTemplate('menuButtonProfile', array(
|
||||
"profileImage"=>BASE_URL."images/user_male.png",
|
||||
"firstName"=>$this->user->username,
|
||||
"lastName"=>"",
|
||||
@@ -163,7 +196,7 @@ class UIManager
|
||||
}
|
||||
}
|
||||
|
||||
$manuItems[] = new MenuItemTemplate('menuButtonHelp', array(
|
||||
$menuItems[] = new MenuItemTemplate('menuButtonHelp', array(
|
||||
"APP_NAME"=>APP_NAME,
|
||||
"VERSION"=>VERSION,
|
||||
"VERSION_DATE"=>VERSION_DATE,
|
||||
@@ -171,7 +204,7 @@ class UIManager
|
||||
));
|
||||
}
|
||||
|
||||
return $manuItems;
|
||||
return $menuItems;
|
||||
}
|
||||
|
||||
public function getMenuItemsHTML()
|
||||
@@ -191,6 +224,11 @@ class UIManager
|
||||
$this->quickAccessMenuItems[] = array($newName, $icon, $link, $userLevels);
|
||||
}
|
||||
|
||||
public function addLanguageMenuItem($name)
|
||||
{
|
||||
$this->languageMenuItems[] = $name;
|
||||
}
|
||||
|
||||
public function getQuickAccessMenuItemsHTML()
|
||||
{
|
||||
$html = "";
|
||||
@@ -204,6 +242,32 @@ class UIManager
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function getLanguageMenuItemsHTML()
|
||||
{
|
||||
$html = "";
|
||||
foreach ($this->languageMenuItems as $item) {
|
||||
$html .= '<a href="#" onclick="updateLanguage(\''.$item.'\');return false;">
|
||||
<span class="flag-icon flag-icon-'.$this->getCountryCodeByLanguage($item).'"></span>
|
||||
<b>'.strtoupper($item).'</b></a>';
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
protected function getCountryCodeByLanguage($currentLanguage)
|
||||
{
|
||||
$currentCountryCode = $currentLanguage;
|
||||
if ($currentLanguage === 'en') {
|
||||
$currentCountryCode = 'gb';
|
||||
} elseif ($currentLanguage === 'zh') {
|
||||
$currentCountryCode = 'cn';
|
||||
} elseif ($currentLanguage === 'ja') {
|
||||
$currentCountryCode = 'jp';
|
||||
}
|
||||
|
||||
return $currentCountryCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ModuleBuilder $moduleBuilder
|
||||
* @return mixed|string
|
||||
|
||||
Reference in New Issue
Block a user