1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
duration.php
См. документацию.
1<?php
9
11
14
15Loc::loadMessages(__FILE__);
16
22{
24 private $letter;
25
27 private $durationCountBased;
28
30 private $durationDateBased;
31
37 public function __construct(Entity\Letter $letter)
38 {
39 $this->letter = $letter;
40 $this->durationCountBased = new DurationCountBased($letter->getMessage());
41 $this->durationDateBased = new DurationDateBased($letter);
42 }
43
49 public function getDate()
50 {
51 $date = new DateTime;
52 $date->add($this->getInterval() . ' seconds');
53 return $date;
54 }
55
61 protected function getCount()
62 {
63 return $this->letter->getCounter()->getUnsent();
64 }
65
71 public function getInterval()
72 {
73 $count = $this->getCount();
74 $interval = $this->durationCountBased->getInterval($count);
75 if (!$interval)
76 {
77 $interval = $this->durationDateBased->getInterval($count);
78 }
79
80 return $interval;
81 }
82
88 public function getFormatted()
89 {
90 return $this->format($this->getDate());
91 }
92
98 public static function getFormattedMinimalInterval()
99 {
100 return Loc::getMessage('SENDER_DISPATCH_DURATION_LESS_HOUR');
101 }
102
108 public static function getFormattedMaximalInterval()
109 {
110 return Loc::getMessage('SENDER_DISPATCH_DURATION_MORE_3_DAYS');
111 }
112
118 public static function getMinimalInterval()
119 {
120 return 3600;
121 }
122
128 public static function getMaximalInterval()
129 {
130 return 3600 * 24 * 3;
131 }
132
138 public static function getWarnInterval()
139 {
140 return self::getMinimalInterval() * 10;
141 }
142
148 public function getFormattedInterval()
149 {
150 if ($this->getInterval() < self::getMinimalInterval())
151 {
153 }
154 elseif ($this->getInterval() > self::getMaximalInterval())
155 {
157 }
158 else
159 {
160 $formatted = \FormatDate('Hdiff', $this->getDate());
161 if (mb_substr($formatted, 0, 1) === '-')
162 {
163 $formatted = mb_substr($formatted, 1);
164 }
165
166 return $formatted;
167 }
168 }
169
176 public function format(DateTime $dateTime = null)
177 {
178 if (!$dateTime)
179 {
180 return '';
181 }
182
183 return \FormatDate('d F, H:i', $dateTime);
184 }
185}
$count
Определения admin_tab.php:4
add($interval)
Определения date.php:145
static getFormattedMaximalInterval()
Определения duration.php:108
__construct(Entity\Letter $letter)
Определения duration.php:37
static getMaximalInterval()
Определения duration.php:128
static getFormattedMinimalInterval()
Определения duration.php:98
static getMinimalInterval()
Определения duration.php:118
static getWarnInterval()
Определения duration.php:138
format(DateTime $dateTime=null)
Определения duration.php:176
FormatDate($format="", $timestamp=false, $now=false, ?string $languageId=null)
Определения tools.php:871
Определения ufield.php:9
Определения ad.php:8
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393