40 if($templateType && $templateType !==
'BASE')
44 if($messageCode && !in_array($messageCode, self::getProvidedMessageCodes()))
49 return self::getTemplates($templateId, $messageCode =
null);
52 private static function getProvidedMessageCodes()
60 private static function getListByType()
65 'SEGMENT_CODES' => [
'case_crm_client_birthday',
'case_crm_lead_birthday'],
68 'METHOD_CODE' => Dispatch\Method::SCHEDULE,
69 'TIMES_OF_DAY' =>
'09:00',
70 'DAYS_OF_WEEK' =>
"1,2,3,4,5,6,7",
75 'SEGMENT_CODES' => [
'case_crm_client_aft_deal_clo'],
78 'METHOD_CODE' => Dispatch\Method::SCHEDULE,
79 'TIMES_OF_DAY' =>
'09:00',
80 'DAYS_OF_WEEK' =>
"1,2,3,4,5,6,7",
85 foreach ($list as $index => $item)
87 $code = mb_strtoupper($item[
'CODE']);
88 $msgPrefix =
'SENDER_PRESET_TEMPLATE_RC_' . $code .
'_';
89 foreach ([
'NAME',
'DESC',
'TITLE',
'TEXT'] as $key)
94 $list[$index] = $item;
99 $code = $holiday->getCode();
100 $name = $holiday->getName();
101 $formattedDate = $holiday->formatDate();
104 'CODE' => $holiday->getCode(),
105 'SEGMENT_CODES' => [
"case_crm_client_$code"],
107 'SENDER_PRESET_TEMPLATE_RC_HINT_ONE_DAY',
109 '%run_date%' => PrettyDate::formatDate($holiday->getDateFrom()),
110 '%date_from%' => PrettyDate::formatDate($holiday->getDateFrom()),
111 '%date_to%' => PrettyDate::formatDate($holiday->getDateTo()),
115 'METHOD_CODE' => Dispatch\Method::SCHEDULE,
116 'TIMES_OF_DAY' =>
'09:00',
117 'DAYS_OF_WEEK' =>
"1,2,3,4,5,6,7",
118 'DAYS_OF_MONTH' => $holiday->getDay(),
119 'MONTHS_OF_YEAR' => $holiday->getMonth(),
123 $msgPrefix =
"SENDER_PRESET_TEMPLATE_RC_HOLIDAY_";
124 foreach ([
'NAME',
'DESC',
'TITLE',
'TEXT'] as $key)
129 '%holiday_name%' => $name,
130 '%holiday_date%' => $formattedDate,
133 $item[$key] = Texts::replace($item[$key] ??
'');
142 private static function getTemplates($templateId =
null, $messageCode =
null)
144 $messageCodes = $messageCode ? array($messageCode) : self::getProvidedMessageCodes();
151 'MESSAGE_CODE' => $messageCodes,
154 'ICON' => BX_ROOT . self::IMAGE_DIR .
"empty.png",
166 foreach (self::getListByType() as $item)
168 $originalCode = mb_strtolower($item[
'CODE']);
169 $code =
'rc_'.mb_strtolower($item[
'CODE']);
170 if($templateId && $code !== $templateId)
175 $segmentTiles = UI\TileView::create();
177 'select' => [
'ID',
'NAME'],
178 'filter' => [
'=CODE' => $item[
'SEGMENT_CODES']]
180 foreach ($segments as $segment)
182 $segmentTiles->addTile($segment[
'ID'], $segment[
'NAME']);
189 'MESSAGE_CODE' => $messageCodes,
191 'HOT' => $item[
'HOT'] ??
'',
192 'ICON' => BX_ROOT . self::IMAGE_DIR .
"$originalCode.png",
194 'NAME' => $item[
'NAME'] ??
'',
195 'DESC' => $item[
'DESC'] ??
'',
196 'HINT' => $item[
'HINT'] ??
'',
200 'VALUE' => $item[
'TITLE'] ??
'',
204 'VALUE' => $item[
'TEXT'] ??
'',
207 'CODE' =>
'ALWAYS_ADD',
211 'SEGMENTS' => $segmentTiles->getTiles(),
212 'DISPATCH' => $item[
'DISPATCH'],
static loadMessages($file)
static getMessage($code, $replace=null, $language=null)