1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
duration.php
См. документацию.
1
<?php
8
namespace
Bitrix\Sender\Dispatch
;
9
10
use
Bitrix\Main\Localization\Loc
;
11
12
use
Bitrix\Main\Type\DateTime
;
13
use
Bitrix\Sender\Entity
;
14
15
Loc::loadMessages(__FILE__);
16
21
class
Duration
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
{
152
return
self::getFormattedMinimalInterval
();
153
}
154
elseif
($this->
getInterval
() > self::getMaximalInterval())
155
{
156
return
self::getFormattedMaximalInterval
();
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
$count
Определения
admin_tab.php:4
Bitrix\Main\Localization\Loc
Определения
loc.php:12
Bitrix\Main\Type\Date\add
add($interval)
Определения
date.php:145
Bitrix\Main\Type\DateTime
Определения
datetime.php:9
Bitrix\Sender\Dispatch\DurationCountBased
Определения
durationcountbased.php:22
Bitrix\Sender\Dispatch\DurationDateBased
Определения
durationdatebased.php:22
Bitrix\Sender\Dispatch\Duration
Определения
duration.php:22
Bitrix\Sender\Dispatch\Duration\getFormattedInterval
getFormattedInterval()
Определения
duration.php:148
Bitrix\Sender\Dispatch\Duration\getFormattedMaximalInterval
static getFormattedMaximalInterval()
Определения
duration.php:108
Bitrix\Sender\Dispatch\Duration\getCount
getCount()
Определения
duration.php:61
Bitrix\Sender\Dispatch\Duration\getDate
getDate()
Определения
duration.php:49
Bitrix\Sender\Dispatch\Duration\getInterval
getInterval()
Определения
duration.php:71
Bitrix\Sender\Dispatch\Duration\__construct
__construct(Entity\Letter $letter)
Определения
duration.php:37
Bitrix\Sender\Dispatch\Duration\getMaximalInterval
static getMaximalInterval()
Определения
duration.php:128
Bitrix\Sender\Dispatch\Duration\getFormattedMinimalInterval
static getFormattedMinimalInterval()
Определения
duration.php:98
Bitrix\Sender\Dispatch\Duration\getMinimalInterval
static getMinimalInterval()
Определения
duration.php:118
Bitrix\Sender\Dispatch\Duration\getWarnInterval
static getWarnInterval()
Определения
duration.php:138
Bitrix\Sender\Dispatch\Duration\format
format(DateTime $dateTime=null)
Определения
duration.php:176
Bitrix\Sender\Dispatch\Duration\getFormatted
getFormatted()
Определения
duration.php:88
Bitrix\Sender\Entity\Letter
Определения
letter.php:36
FormatDate
FormatDate($format="", $timestamp=false, $now=false, ?string $languageId=null)
Определения
tools.php:871
Bitrix\Main\Entity
Определения
ufield.php:9
Bitrix\Sender\Dispatch
Определения
duration.php:8
Bitrix\Sender\Entity
Определения
ad.php:8
elseif
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения
prolog_main_admin.php:393
bitrix
modules
sender
lib
dispatch
duration.php
Создано системой
1.14.0