Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
messagebase.php
1<?php
10
16
17Loc::loadMessages(__FILE__);
18
24{
26 const CODE_RC_LEAD = 'rc_lead';
27 const CODE_RC_DEAL = 'rc_deal';
28
30 protected $configuration;
31
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 {
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
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
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}
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
saveConfiguration(Message\Configuration $configuration)
$GLOBALS['____1444769544']
Definition license.php:1