- Модуль: intranet
- Путь к файлу: ~/bitrix/modules/intranet/lib/ustat/ustat.php
- Класс: BitrixIntranetUStatUStat
- Вызов: UStat::getActivityInfo
static function getActivityInfo()
{
// real active users
$allTodayActiveUsers = array();
$result = UserDayTable::getList(array('filter' => array('=DAY' => ConvertTimeStamp(time(), "SHORT"))));
while ($row = $result->fetch())
{
$allTodayActiveUsers[$row['USER_ID']] = true;
}
// absence data from calendar
$allAbsenceData = CIntranetUtils::getAbsenceData(array(
'DATE_START' => ConvertTimeStamp(mktime(0, 0, 0), 'FULL'), // current day start
'DATE_FINISH' => ConvertTimeStamp(mktime(23, 59, 59), 'FULL'), // current day end
'PER_USER' => true
));
// departments and its' employees
$allDepartments = array();
// userid -> true (working) | false (absent)
$allUsers = array();
$companyStructure = CIntranetUtils::getStructure();
foreach ($companyStructure['DATA'] as $departmentData)
{
// base structure
$department = array(
'EMPLOYEES' => array_filter(array_unique(array_merge(
$departmentData['EMPLOYEES'], array($departmentData['UF_HEAD'])
))),
'ACTIVE_USERS' => 0
);
foreach ($department['EMPLOYEES'] as $employeeId)
{
$allUsers[$employeeId]['DEPARTMENTS'][] = $departmentData['ID'];
// skip absentee
if (isset($allUsers[$employeeId]['ABSENT']) && $allUsers[$employeeId]['ABSENT'] === true)
{
continue;
}
if (!isset($allUsers[$employeeId]['ABSENT']) &&
isset($allAbsenceData[$employeeId]) && static::checkTodayAbsence($allAbsenceData[$employeeId]))
{
// but only if they are really not active today
if (!isset($allTodayActiveUsers[$employeeId]))
{
$allUsers[$employeeId]['ABSENT'] = true;
continue;
}
}
// remember supposed & really active users
++$department['ACTIVE_USERS'];
$allUsers[$employeeId]['ABSENT'] = false;
}
$allDepartments[$departmentData['ID']] = $department;
}
return array($allDepartments, $allUsers);
}