* @copyright Copyright (c) 2012-2019 Metaways Infosystems GmbH (http://www.metaways.de) */ /** * HumanResources config class * * @package HumanResources * @subpackage Config */ class HumanResources_Config extends Tinebase_Config_Abstract { const APP_NAME = 'HumanResources'; const FREE_TIME_TYPE_STATUS = 'freeTimeTypeStatus'; const FREE_TIME_TYPE_STATUS_EXCUSED = 'EXCUSED'; const FREE_TIME_TYPE_STATUS_UNEXCUSED = 'UNEXCUSED'; const FREE_TIME_PROCESS_STATUS = 'freeTimeProcessStatus'; const FREE_TIME_PROCESS_STATUS_REQUESTED = 'REQUESTED'; const FREE_TIME_PROCESS_STATUS_ACCEPTED = 'ACCEPTED'; const FREE_TIME_PROCESS_STATUS_DECLINED = 'DECLINED'; const WTR_CORRECTION_STATUS = 'wtrCorrectionStatus'; const WTR_CORRECTION_STATUS_REQUESTED = 'REQUESTED'; const WTR_CORRECTION_STATUS_ACCEPTED = 'ACCEPTED'; const WTR_CORRECTION_STATUS_DECLINED = 'DECLINED'; /** * Default Feast Calendar (used for tailoring datepicker) * @var string */ const DEFAULT_FEAST_CALENDAR = 'defaultFeastCalendar'; /** * Defines the date when vacation booked from last year can't be taken anymore * * @var string */ const VACATION_EXPIRES = 'vacationExpires'; /** * calculate daily reports * * @var string */ const FEATURE_CALCULATE_DAILY_REPORTS = 'calculateDailyRepots'; /** * enable working time tracking * * @string */ const FEATURE_STREAMS = 'featureStreams'; /** * enable working time tracking * * @string */ const FEATURE_WORKING_TIME_ACCOUNTING = 'workingTimeAccounting'; /** * enable revenue analysis * * @string */ const FEATURE_REVENUE_ANALYSIS = 'revenueAnalysis'; const EMPLOYEE_DEFAULT_AR_WT_DEVICE_ID = 'emplyoeeDefaultARWTDeviceId'; const EMPLOYEE_DEFAULT_AR_PT_DEVICE_ID = 'emplyoeeDefaultARPTDeviceId'; /** * attendance recorder default description * * @stering */ const ATTENDANCE_RECORDER_DEFAULT_TS_DESCRIPTION = 'attendanceRecorderDefaultDescription'; /** * id of (filsystem) container for vacation templates * * @var string */ const REPORT_TEMPLATES_CONTAINER_ID = 'reportTemplatesContainerId'; /** * id of timeaccount for workingtime timesheets */ const WORKING_TIME_TIMEACCOUNT = 'workingTimeTimeAccount'; /** * key field for streams interval (week, month, quarter, year) */ const STREAM_INTERVAL = 'streamInterval'; /** * key field for stream types (velocity stream, working stream, etc.) */ const STREAM_TYPE = 'streamType'; /** * (non-PHPdoc) * @see tine20/Tinebase/Config/Definition::$_properties */ protected static $_properties = array( self::FREE_TIME_TYPE_STATUS => array( //_('Sickness Status') 'label' => 'Sickness Status', //_('Possible sickness status definitions') 'description' => 'Possible sickness status definitions', 'type' => 'keyFieldConfig', 'options' => array('recordModel' => HumanResources_Model_FreeTimeStatus::class), 'clientRegistryInclude' => TRUE, 'default' => array( 'records' => array( array('id' => self::FREE_TIME_TYPE_STATUS_EXCUSED, 'value' => 'Excused', 'icon' => 'images/icon-set/icon_ok.svg', 'system' => TRUE), //_('Excused') array('id' => self::FREE_TIME_TYPE_STATUS_UNEXCUSED, 'value' => 'Unexcused', 'icon' => 'images/icon-set/icon_stop.svg', 'system' => TRUE), //_('Unexcused') ), 'default' => null ) ), self::FREE_TIME_PROCESS_STATUS => array( //_('Vacation Status') 'label' => 'Vacation Status', //_('Possible vacation status definitions') 'description' => 'Possible vacation status definitions', 'type' => 'keyFieldConfig', 'options' => array('recordModel' => HumanResources_Model_FreeTimeStatus::class), 'clientRegistryInclude' => TRUE, 'default' => array( 'records' => array( array('id' => self::FREE_TIME_PROCESS_STATUS_REQUESTED, 'value' => 'Requested', 'icon' => 'images/icon-set/icon_invite.svg', 'system' => TRUE), //_('Requested') array('id' => self::FREE_TIME_PROCESS_STATUS_ACCEPTED, 'value' => 'Accepted', 'icon' => 'images/icon-set/icon_ok.svg', 'system' => TRUE), //_('Accepted') array('id' => self::FREE_TIME_PROCESS_STATUS_DECLINED, 'value' => 'Declined', 'icon' => 'images/icon-set/icon_stop.svg', 'system' => TRUE), //_('Declined') ), 'default' => self::FREE_TIME_PROCESS_STATUS_REQUESTED ) ), self::WTR_CORRECTION_STATUS => array( //_('Working Time Correction Status') 'label' => 'Working Time Correction Status', //_('Working Time Correction Status') 'description' => 'Working Time Correction Status', 'type' => 'keyFieldConfig', 'clientRegistryInclude' => TRUE, 'default' => array( 'records' => array( array('id' => self::WTR_CORRECTION_STATUS_REQUESTED, 'value' => 'Requested', 'icon' => 'images/icon-set/icon_invite.svg', 'system' => TRUE), //_('Requested') array('id' => self::WTR_CORRECTION_STATUS_ACCEPTED, 'value' => 'Accepted', 'icon' => 'images/icon-set/icon_ok.svg', 'system' => TRUE), //_('Accepted') array('id' => self::WTR_CORRECTION_STATUS_DECLINED, 'value' => 'Declined', 'icon' => 'images/icon-set/icon_stop.svg', 'system' => TRUE), //_('Declined') ), 'default' => self::WTR_CORRECTION_STATUS_REQUESTED, ) ), self::DEFAULT_FEAST_CALENDAR => array( // _('Default Holiday Calendar') self::LABEL => 'Default Holiday Calendar', // _('Here you can define the default public holiday calendar used to set public holidays and other free days in datepicker') self::DESCRIPTION => 'Here you can define the default public holiday calendar used to set public holidays and other free days in datepicker', self::TYPE => Tinebase_Config_Abstract::TYPE_RECORD, self::OPTIONS => [ self::APPLICATION_NAME => Tinebase_Config::APP_NAME, self::MODEL_NAME => Tinebase_Model_BankHolidayCalendar::MODEL_NAME_PART, ], self::CLIENTREGISTRYINCLUDE => true, self::SETBYADMINMODULE => true, ), self::ATTENDANCE_RECORDER_DEFAULT_TS_DESCRIPTION => [ // _('AR TS Description') self::LABEL => 'AR TS Description', // _('Default description for attendance recorder created timesheets.') self::DESCRIPTION => 'Default description for attendance recorder created timesheets.', self::TYPE => Tinebase_Config_Abstract::TYPE_STRING, self::CLIENTREGISTRYINCLUDE => false, self::SETBYADMINMODULE => true, self::DEFAULT_STR => 'attendance recorder generated', // _('attendance recorder generated') ], self::EMPLOYEE_DEFAULT_AR_PT_DEVICE_ID => [ // _('Employees default AR PT device id') self::LABEL => 'Employees default AR PT device id', // _('Employees default AR PT device id') self::DESCRIPTION => 'Employees default AR PT device id', self::TYPE => Tinebase_Config_Abstract::TYPE_STRING, self::CLIENTREGISTRYINCLUDE => true, self::SETBYADMINMODULE => true, self::DEFAULT_STR => HumanResources_Model_AttendanceRecorderDevice::SYSTEM_PROJECT_TIME_ID, ], self::EMPLOYEE_DEFAULT_AR_WT_DEVICE_ID => [ // _('Employees default AR WT device id') self::LABEL => 'Employees default AR WT device id', // _('Employees default AR WT device id') self::DESCRIPTION => 'Employees default AR WT device id', self::TYPE => Tinebase_Config_Abstract::TYPE_STRING, self::CLIENTREGISTRYINCLUDE => true, self::SETBYADMINMODULE => true, self::DEFAULT_STR => HumanResources_Model_AttendanceRecorderDevice::SYSTEM_WORKING_TIME_ID, ], self::ENABLED_FEATURES => [ //_('Enabled Features') self::LABEL => 'Enabled Features', //_('Enabled Features in HumanResources Application.') self::DESCRIPTION => 'Enabled Features in HumanResources Application.', self::TYPE => self::TYPE_OBJECT, self::CLASSNAME => Tinebase_Config_Struct::class, self::CLIENTREGISTRYINCLUDE => true, self::CONTENT => [ self::FEATURE_CALCULATE_DAILY_REPORTS => [ self::LABEL => 'Calculate Daily Reports', //_('Calculate Daily Reports') self::DESCRIPTION => 'Activate to calculate daily reports with a nightly scheduler job', //_('Activate to calculate daily reports with a nightly scheduler job') self::TYPE => self::TYPE_BOOL, self::DEFAULT_STR => true, ], self::FEATURE_STREAMS => [ self::LABEL => 'Enable Streams', //_('Enable Streams') self::DESCRIPTION => 'Activate working streams', //_('Activate working streams') self::TYPE => self::TYPE_BOOL, self::DEFAULT_STR => false, ], self::FEATURE_WORKING_TIME_ACCOUNTING => [ self::LABEL => 'Enable Working Time Tracking', //_('Enable Working Time Tracking') self::DESCRIPTION => 'Activate to enable working time tracking and reporting', //_('Activate to enable working time tracking and reporting') self::TYPE => self::TYPE_BOOL, self::DEFAULT_STR => false, ], self::FEATURE_REVENUE_ANALYSIS => [ self::LABEL => 'Enable Revenue Analytics', //_('Enable Revenue Analytics') self::DESCRIPTION => 'Activate to enable revenue analytics', //_('Activate to enable revenue analytics') self::TYPE => self::TYPE_BOOL, self::DEFAULT_STR => false, ], ], self::DEFAULT_STR => [], ], self::VACATION_EXPIRES => array( // _('Vacation expires') 'label' => 'Vacation expires', // _('Here you can define the day when vacation days carried over from last year expire. Please use the format MM-DD.') 'description' => 'Here you can define the day when vacation days carried over from last year expire. Please use the format MM-DD.', 'type' => 'string', 'clientRegistryInclude' => TRUE, 'setByAdminModule' => TRUE, 'default' => '03-31' ), self::REPORT_TEMPLATES_CONTAINER_ID => array( //_('Report Templates Node ID') 'label' => 'Report Templates Node ID', 'description' => 'Report Templates Node ID', 'type' => Tinebase_Config_Abstract::TYPE_STRING, 'clientRegistryInclude' => FALSE, 'setByAdminModule' => FALSE, 'setBySetupModule' => FALSE, ), self::WORKING_TIME_TIMEACCOUNT => array( //_('Timetracker Timeaccount for Workingtime Tracking') 'label' => 'Timetracker Timeaccount for Workingtime Tracking', 'description' => 'Timetracker Timeaccount for Workingtime Tracking', self::TYPE => self::TYPE_RECORD, self::OPTIONS => [ self::APPLICATION_NAME => Timetracker_Config::APP_NAME, self::MODEL_NAME => Timetracker_Model_Timeaccount::MODEL_NAME_PART, ], 'clientRegistryInclude' => true, 'setByAdminModule' => true, 'setBySetupModule' => false, ), self::STREAM_INTERVAL => [ //_('Available Stream Intervals') self::LABEL => 'Available Stream Intervals', self::DESCRIPTION => 'Available Stream Intervals', self::TYPE => 'keyFieldConfig', self::CLIENTREGISTRYINCLUDE => true, self::SETBYADMINMODULE => false, self::DEFAULT_STR => [ self::RECORDS => [ ['system' => 1, 'id' => HumanResources_Model_StreamModality::INT_WEEKLY, 'value' => 'Weekly'], //_('Weekly') ['system' => 1, 'id' => HumanResources_Model_StreamModality::INT_MONTHLY, 'value' => 'Monthly'], //_('Monthly') ['system' => 1, 'id' => HumanResources_Model_StreamModality::INT_QUARTERLY, 'value' => 'Quarterly'], //_('Quarterly') ['system' => 1, 'id' => HumanResources_Model_StreamModality::INT_YEARLY, 'value' => 'Yearly'], //_('Yearly') ], ], ], self::STREAM_TYPE => [ //_('Available Stream Types') self::LABEL => 'Available Stream Types', self::DESCRIPTION => 'Available Stream Types', self::TYPE => 'keyFieldConfig', self::CLIENTREGISTRYINCLUDE => true, self::SETBYADMINMODULE => true, self::DEFAULT_STR => [ self::RECORDS => [ ['id' => 'velocity stream', 'value' => 'Velocity Stream'], //_('Velocity Stream') ['id' => 'working stream', 'value' => 'Working Stream'], //_('Working Stream') ['id' => 'daily business', 'value' => 'Daily Business'], //_('Daily Business') ], ], ], ); /** * (non-PHPdoc) * @see tine20/Tinebase/Config/Abstract::$_appName */ protected $_appName = 'HumanResources'; /** * holds the instance of the singleton * * @var Tinebase_Config */ private static $_instance = NULL; /** * the constructor * * don't use the constructor. use the singleton */ private function __construct() { } /** * the constructor * * don't use the constructor. use the singleton */ private function __clone() { } /** * Returns instance of Tinebase_Config * * @return Tinebase_Config */ public static function getInstance() { if (self::$_instance === NULL) { self::$_instance = new self(); } return self::$_instance; } /** * (non-PHPdoc) * @see tine20/Tinebase/Config/Abstract::getProperties() */ public static function getProperties() { return self::$_properties; } /** * returns the date of vacation expiration for the given year * * @param string $accountYear * @return Tinebase_DateTime|NULL */ public function getVacationExpirationDate($accountYear=null) { $accountYear = $accountYear ?: Tinebase_DateTime::now()->format('Y'); $year = $accountYear+1; [$month, $day] = preg_split('/-/', $this->{self::VACATION_EXPIRES}); return new Tinebase_DateTime("{$year}-{$month}-{$day} 00:00:00"); } }