Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
userschedule.php
1<?php
3
5
12{
13 protected $userId;
14
15 public function __construct(int $userId)
16 {
17 $this->userId = $userId;
18 }
19
20 public function isAbsent(): bool
21 {
22 if ($this->canUseIntranet())
23 {
24 return \CIntranetUtils::isUserAbsent($this->userId);
25 }
26
27 return false;
28 }
29
30 public function isWorkDayClosed(): bool
31 {
32 return ($this->getWorkDayStatus() === 'CLOSED');
33 }
34
35 public function getWorkDayStatus(): string
36 {
37 if ($this->canUseTimeman())
38 {
39 $tmUser = new \CTimeManUser($this->userId);
40
41 //speed up!
42 if (method_exists($tmUser, 'getCurrentRecordStatus'))
43 {
44 return $tmUser->getCurrentRecordStatus();
45 }
46
47 return $tmUser->state();
48 }
49
50 return 'UNDEFINED';
51 }
52
53 private function canUseIntranet()
54 {
55 return Main\Loader::includeModule('intranet');
56 }
57
58 private function canUseTimeman()
59 {
60 return Main\Loader::includeModule('timeman');
61 }
62}