Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
messagebase.php
1
<?php
9
namespace
Bitrix\Sender\Integration\Crm\ReturnCustomer
;
10
11
use
Bitrix\Main\Localization\Loc
;
12
use
Bitrix\Main\Result
;
13
use
Bitrix\Main\UI\Extension
;
14
use
Bitrix\Sender\Entity
;
15
use
Bitrix\Sender\Message
;
16
17
Loc::loadMessages
(__FILE__);
18
23
class
MessageBase
implements
Message\iBase
,
Message\iReturnCustomer
24
{
25
const
CODE
=
self::CODE_UNDEFINED
;
26
const
CODE_RC_LEAD
=
'rc_lead'
;
27
const
CODE_RC_DEAL
=
'rc_deal'
;
28
30
protected
$configuration
;
31
33
protected
$configurationId
;
34
38
public
function
__construct
()
39
{
40
$this->configuration =
new
Message\Configuration
();
41
}
42
47
public
function
getName
()
48
{
49
return
Loc::getMessage
(
'SENDER_INTEGRATION_CRM_RC_MESSAGE_NAME'
);
50
}
51
52
public
function
getCode
()
53
{
54
return
static::CODE;
55
}
56
57
public
function
getSupportedTransports
()
58
{
59
return
array(static::CODE);
60
}
61
62
protected
function
setConfigurationOptions
()
63
{
64
}
65
73
public
function
loadConfiguration
($id =
null
)
74
{
75
$this->
setConfigurationOptions
();
76
Entity\Message::create()
77
->setCode($this->
getCode
())
78
->loadConfiguration($id, $this->configuration);
79
80
$assignOption = $this->configuration->getOption(
'ASSIGNED_BY'
);
81
if
($assignOption)
82
{
83
$assignOption->setView(
84
function
() use ($assignOption)
85
{
86
$userList = $assignOption->getValue();
87
$userList = $userList ? explode(
','
, $userList) : [];
88
89
ob_start();
90
$GLOBALS
[
'APPLICATION'
]->includeComponent(
91
"bitrix:main.user.selector"
,
92
".default"
,
93
[
94
"ID"
=>
"sender-crm-rc-message"
,
95
"INPUT_NAME"
=>
"%INPUT_NAME%[]"
,
96
"LIST"
=> $userList,
97
'API_VERSION'
=>
'3'
,
98
"SELECTOR_OPTIONS"
=> array(
99
'context'
=>
'SENDER_USER'
,
100
'allowAddSocNetGroup'
=>
'N'
,
101
'departmentSelectDisable'
=>
'Y'
102
)
103
]
104
);
105
106
return
ob_get_clean();
107
}
108
);
109
}
110
$this->
createDaysAgoView
();
111
112
return
$this->configuration
;
113
}
114
115
protected
function
createDaysAgoView
()
116
{
117
$dealDaysAgoOption = $this->configuration->getOption(
'DEAL_DAYS_AGO'
);
118
$formPreviousOption = $this->configuration->getOption(
'FROM_PREVIOUS'
);
119
120
if
($dealDaysAgoOption && $formPreviousOption)
121
{
122
$dealDaysAgoOption->setView(
123
function
() use ($dealDaysAgoOption, $formPreviousOption)
124
{
125
$prefix =
'CONFIGURATION_'
;
126
$daysAgoCode = htmlspecialcharsbx($prefix.$dealDaysAgoOption->getCode());
127
$fromPreviousCode = htmlspecialcharsbx($prefix.$formPreviousOption->getCode());
128
ob_start();
129
Extension::load(
"sender.rc_editor"
);
130
131
echo
"<input type='number' step='1' id='"
. $daysAgoCode .
"'
132
name='"
. $daysAgoCode .
"'
133
class='bx-sender-form-control' value='"
. (int)$dealDaysAgoOption->getValue() .
"'
134
min='"
. htmlspecialcharsbx($dealDaysAgoOption->getMinValue()) .
"'
135
max='"
. htmlspecialcharsbx($dealDaysAgoOption->getMaxValue()) .
"'
136
/>"
;
137
138
$params = \Bitrix\Main\Web\Json::encode(
139
[
140
'elementId'
=> $daysAgoCode,
141
'conditionElementId'
=> $fromPreviousCode
142
]
143
);
144
145
echo
"<script>new BX.Sender.RcEditor("
.$params.
")</script>"
;
146
147
return
ob_get_clean();
148
}
149
);
150
}
151
}
152
160
public
function
saveConfiguration
(
Message
\
Configuration
$configuration
)
161
{
162
return
Entity\Message::create()
163
->setCode($this->
getCode
())
164
->saveConfiguration($this->configuration);
165
}
166
173
public
function
removeConfiguration
($id)
174
{
175
$result = Entity\Message::removeById($id);
176
return
$result->isSuccess();
177
}
178
185
public
function
copyConfiguration
($id)
186
{
187
return
Entity\Message::create()
188
->setCode($this->
getCode
())
189
->copyConfiguration($id);
190
}
191
197
public
function
getSmsSender
()
198
{
199
return
$this->configuration->getOption(
'SENDER'
)->getValue();
200
}
201
}
Bitrix\Main\Config\Configuration
Definition
configuration.php:7
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Main\ORM\Data\Result
Definition
result.php:16
Bitrix\Main\UI\Extension
Definition
extension.php:11
Bitrix\Sender\Entity\Message
Definition
message.php:27
Bitrix\Sender\Integration\Crm\ReturnCustomer\MessageBase
Definition
messagebase.php:24
Bitrix\Sender\Integration\Crm\ReturnCustomer\MessageBase\CODE
const CODE
Definition
messagebase.php:25
Bitrix\Sender\Integration\Crm\ReturnCustomer\MessageBase\__construct
__construct()
Definition
messagebase.php:38
Bitrix\Sender\Integration\Crm\ReturnCustomer\MessageBase\CODE_RC_LEAD
const CODE_RC_LEAD
Definition
messagebase.php:26
Bitrix\Sender\Integration\Crm\ReturnCustomer\MessageBase\getSmsSender
getSmsSender()
Definition
messagebase.php:197
Bitrix\Sender\Integration\Crm\ReturnCustomer\MessageBase\setConfigurationOptions
setConfigurationOptions()
Definition
messagebase.php:62
Bitrix\Sender\Integration\Crm\ReturnCustomer\MessageBase\getName
getName()
Definition
messagebase.php:47
Bitrix\Sender\Integration\Crm\ReturnCustomer\MessageBase\removeConfiguration
removeConfiguration($id)
Definition
messagebase.php:173
Bitrix\Sender\Integration\Crm\ReturnCustomer\MessageBase\CODE_RC_DEAL
const CODE_RC_DEAL
Definition
messagebase.php:27
Bitrix\Sender\Integration\Crm\ReturnCustomer\MessageBase\createDaysAgoView
createDaysAgoView()
Definition
messagebase.php:115
Bitrix\Sender\Integration\Crm\ReturnCustomer\MessageBase\loadConfiguration
loadConfiguration($id=null)
Definition
messagebase.php:73
Bitrix\Sender\Integration\Crm\ReturnCustomer\MessageBase\$configuration
$configuration
Definition
messagebase.php:30
Bitrix\Sender\Integration\Crm\ReturnCustomer\MessageBase\getCode
getCode()
Definition
messagebase.php:52
Bitrix\Sender\Integration\Crm\ReturnCustomer\MessageBase\$configurationId
$configurationId
Definition
messagebase.php:33
Bitrix\Sender\Integration\Crm\ReturnCustomer\MessageBase\copyConfiguration
copyConfiguration($id)
Definition
messagebase.php:185
Bitrix\Sender\Integration\Crm\ReturnCustomer\MessageBase\saveConfiguration
saveConfiguration(Message\Configuration $configuration)
Definition
messagebase.php:160
Bitrix\Sender\Integration\Crm\ReturnCustomer\MessageBase\getSupportedTransports
getSupportedTransports()
Definition
messagebase.php:57
Bitrix\Sender\Message\iBase
Definition
ibase.php:16
Bitrix\Sender\Message\iBase\CODE_UNDEFINED
const CODE_UNDEFINED
Definition
ibase.php:24
Bitrix\Sender\Message\iReturnCustomer
Definition
ireturncustomer.php:16
Bitrix\Main\$GLOBALS
$GLOBALS['____1444769544']
Definition
license.php:1
Bitrix\Sender\Entity
Definition
ad.php:8
Bitrix\Sender\Integration\Crm\ReturnCustomer
Definition
messagebase.php:9
Bitrix\Sender\Message
Definition
adapter.php:9
modules
sender
lib
integration
crm
returncustomer
messagebase.php
Создано системой
1.10.0