1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
letter.php
См. документацию.
1<?php
8namespace Bitrix\Sender\Entity;
9
10use Bitrix\Main\Application;
11use Bitrix\Main\ArgumentException;
12use Bitrix\Main\DB;
13use Bitrix\Main\Error;
14use Bitrix\Main\InvalidOperationException;
15use Bitrix\Main\Localization\Loc;
16use Bitrix\Main\Result;
17use Bitrix\Main\Type\Date;
18use Bitrix\Main\Type\DateTime;
19use Bitrix\Sender\Dispatch;
20use Bitrix\Sender\FileTable;
21use Bitrix\Sender\Integration;
22use Bitrix\Sender\Internals\Model\LetterSegmentTable;
23use Bitrix\Sender\Internals\Model\LetterTable;
24use Bitrix\Sender\Internals\Model\MessageFieldTable;
25use Bitrix\Sender\Internals\SqlBatch;
26use Bitrix\Sender\Message as MainMessage;
27use Bitrix\Sender\Posting;
28use Bitrix\Sender\Recipient;
29use Bitrix\Sender\Security;
30use Bitrix\Sender\Templates;
31use Bitrix\Sender\TemplateTable;
32
33Loc::loadMessages(__FILE__);
34
35class Letter extends Base
36{
38 protected $postingData = null;
39
41 protected $message;
42
45 protected $messagesCache = [];
46
48 protected $duration;
49
51 protected $method;
52
54 protected $state;
55
57 protected $counter;
58
64 protected static function getFilterFields()
65 {
66 return array(
67 array(
68 'CODE' => 'IS_ADS',
69 'VALUE' => 'N',
70 'FILTER' => '=IS_ADS'
71 ),
72 );
73 }
74
80 public static function getDataClass()
81 {
82 return LetterTable::getEntity()->getDataClass();
83 }
84
91 public static function getList(array $parameters = array())
92 {
93 if (!isset($parameters['select']))
94 {
95 $parameters['select'] = static::getDefaultSelectFields();
96 }
97 if (!isset($parameters['filter']))
98 {
99 $parameters['filter'] = array();
100 }
101
102 foreach (static::getFilterFields() as $field)
103 {
104 if (!$field['FILTER'])
105 {
106 continue;
107 }
108
109 if (isset($parameters['filter'][$field['FILTER']]))
110 {
111 $current = $parameters['filter'][$field['FILTER']];
112 if (is_array($field['VALUE']))
113 {
114 if (!is_array($current) && in_array($current, $field['VALUE']))
115 {
116 continue;
117 }
118 }
119 }
120
121 $parameters['filter'][$field['FILTER']] = $field['VALUE'];
122 }
123
124 return LetterTable::getList($parameters);
125 }
126
127 public static function getDefaultSelectFields()
128 {
129 return array(
130 '*',
131 'SITE_ID' => 'CAMPAIGN.SITE_ID',
132 'CAMPAIGN_ACTIVE' => 'CAMPAIGN.ACTIVE',
133
134 'DATE_SEND' => 'CURRENT_POSTING.DATE_SEND',
135 'DATE_PAUSE' => 'CURRENT_POSTING.DATE_PAUSE',
136 'DATE_SENT' => 'CURRENT_POSTING.DATE_SENT',
137
138 'COUNT_SEND_ALL' => 'CURRENT_POSTING.COUNT_SEND_ALL',
139 'COUNT_SEND_NONE' => 'CURRENT_POSTING.COUNT_SEND_NONE',
140 'COUNT_SEND_ERROR' => 'CURRENT_POSTING.COUNT_SEND_ERROR',
141 'COUNT_SEND_SUCCESS' => 'CURRENT_POSTING.COUNT_SEND_SUCCESS',
142 'COUNT_SEND_DENY' => 'CURRENT_POSTING.COUNT_SEND_DENY',
143
144 'USER_NAME' => 'CREATED_BY_USER.NAME',
145 'USER_LAST_NAME' => 'CREATED_BY_USER.LAST_NAME',
146 'USER_ID' => 'CREATED_BY',
147 );
148 }
149
157 public static function getListWithMessageFields(array $parameters = array())
158 {
159 $result = [];
160 $messageIds = [];
161 $list = static::getList($parameters);
162 while ($item = $list->fetch())
163 {
164 $result[] = $item;
165 if ($item['MESSAGE_ID'])
166 {
167 $messageIds[] = $item['MESSAGE_ID'];
168 }
169 }
170 if ($messageIds)
171 {
172 $messageFields = [];
173 $rows = MessageFieldTable::getList(['filter' => ['=MESSAGE_ID' => $messageIds]]);
174 while ($messageField = $rows->fetch())
175 {
176 $messageFields[$messageField['MESSAGE_ID']][] = $messageField;
177 }
178 foreach ($result as $key => $item)
179 {
180 if ($messageFields[$item['MESSAGE_ID']])
181 {
182 $result[$key]['MESSAGE_FIELDS'] = $messageFields[$item['MESSAGE_ID']];
183 }
184 }
185 }
186 $dbResult = new \Bitrix\Main\DB\ArrayResult($result);
187
188 return $dbResult;
189 }
190
198 public static function createInstanceById($id = null, array $messageCodes = [])
199 {
200 $code = null;
201 if ($id)
202 {
203 $row = LetterTable::getRow([
204 'select' => ['MESSAGE_CODE'],
205 'filter' => ['=ID' => $id],
206 ]);
207 if ($row)
208 {
209 $code = $row['MESSAGE_CODE'];
210 }
211 else
212 {
213 $id = null;
214 }
215 }
216
218 if (!$instance)
219 {
220 return null;
221 }
222
223 if ($id)
224 {
225 $instance->load($id);
226 }
228 {
229 $instance->set('MESSAGE_CODE', $code);
230 }
231
232 return $instance;
233 }
234
242 public static function createInstanceByArray(array $data, array $messageCodes = [])
243 {
244 $code = empty($data['MESSAGE_CODE']) ? null : $data['MESSAGE_CODE'];
246 $instance->loadByArray($data);
247
248 return $instance;
249 }
250
257 public static function createInstanceByPostingId($postingId)
258 {
259 $row = LetterTable::getList(array(
260 'select' => array('ID', 'IS_ADS'),
261 'filter' => array('=POSTING_ID' => $postingId),
262 'limit' => 1
263 ))->fetch();
264 if (!$row)
265 {
266 return new static();
267 }
268
269 if ($row['IS_ADS'] === 'Y')
270 {
271 return new Ad($row['ID']);
272 }
273 else
274 {
275 return new static($row['ID']);
276 }
277 }
278
286 public static function createInstanceByContactId($contactId, array $messageCodes = [])
287 {
288 $typeId = Contact::create($contactId)->get('TYPE_ID') ?: Recipient\Type::EMAIL;
289 switch ($typeId)
290 {
293 break;
296 break;
297 default:
298 return null;
299 }
300
301 return self::createInstanceByCode($code, $messageCodes);
302 }
303
304 protected static function createInstanceByCode($code = null, array $messageCodes = [])
305 {
306 if (!$code && empty($messageCodes))
307 {
308 return null;
309 }
310
311 if (!$code)
312 {
313 $code = current($messageCodes);
314 }
315
316 if (empty($messageCodes))
317 {
318 $messageCodes = [$code];
319 }
320
321 if (!in_array($code, $messageCodes))
322 {
323 return null;
324 }
325
326 try
327 {
329 } catch (ArgumentException $e)
330 {
331 return null;
332 }
333
334 if ($message->isAds() || $message->isMarketing())
335 {
336 $instance = new Ad();
337 }
338 elseif ($message->isReturnCustomer())
339 {
340 $instance = new Rc();
341 }
342 elseif ($message->isMailing())
343 {
344 $instance = new Letter();
345 }
346 else
347 {
348 $instance = new Toloka();
349 }
350
351 return $instance;
352 }
353
359 protected function getDefaultData()
360 {
361 return array(
362 'TITLE' => '',
363 'MESSAGE_ID' => '',
364 'MESSAGE_CODE' => MainMessage\Adapter::CODE_MAIL,
365 'SEGMENTS_INCLUDE' => array(),
366 'SEGMENTS_EXCLUDE' => array(),
367 );
368 }
369
377 protected function saveData($id, array $data)
378 {
379 if(!$this->getMessage()->isAvailable())
380 {
381 $this->addError(Loc::getMessage('SENDER_ENTITY_LETTER_ERROR_NOT_AVAILABLE'));
382 return $id;
383 }
384
385 $segmentsInclude = $data['SEGMENTS_INCLUDE'];
386 $segmentsExclude = $data['SEGMENTS_EXCLUDE'];
387
388 foreach (static::getFilterFields() as $field)
389 {
390 if (!$field['CODE'])
391 {
392 continue;
393 }
394
395 if (is_array($field['VALUE']))
396 {
397 if (empty($data[$field['CODE']]) || !in_array($data[$field['CODE']], $field['VALUE']))
398 {
399 $data[$field['CODE']] = current($field['VALUE']);
400 }
401 }
402 else
403 {
404 $data[$field['CODE']] = $field['VALUE'];
405 }
406 }
407 $this->filterDataByEntityFields(LetterTable::getEntity(), $data);
408
409 $initialId = $id;
410 $previousData = $id ? LetterTable::getRowById($id) : null;
411 $previousData = $previousData ?: array();
412
413 // segment check
414 if(!is_array($segmentsInclude) || count($segmentsInclude) == 0)
415 {
416 if (
417 (
418 isset($data['NOT_USE_SEGMENTS'])
419 && !$data['NOT_USE_SEGMENTS']
420 )
421 && $data['IS_TRIGGER'] <> 'Y'
422 && $previousData['IS_TRIGGER'] <> 'Y'
423 )
424 {
425 $this->addError(Loc::getMessage('SENDER_ENTITY_LETTER_ERROR_NO_SEGMENTS'));
426 return $id;
427 }
428 }
429 $segmentsExclude = is_array($segmentsExclude) ? $segmentsExclude : array();
430
431 // campaign setting
432 if (!isset($data['CAMPAIGN_ID']))
433 {
434 $data['CAMPAIGN_ID'] = Campaign::getDefaultId(SITE_ID);
435 $this->set('CAMPAIGN_ID', $data['CAMPAIGN_ID']);
436 }
437
438 // parent letter setting for triggers
439 if (!$id && $data['IS_TRIGGER'] === 'Y')
440 {
441 if (empty($data['PARENT_ID']))
442 {
443 $previousLetter = (new Chain)->load($data['CAMPAIGN_ID'])->getLast();
444 if ($previousLetter && $previousLetter->getId() != $this->getId())
445 {
446 $data['PARENT_ID'] = $previousLetter->getId();
447 }
448 }
449
450 if (!isset($data['TIME_SHIFT']))
451 {
452 $data['TIME_SHIFT'] = 1440;
453 }
454
455 $data['STATUS'] = Dispatch\State::WAITING;
456 $data['REITERATE'] = 'Y';
457 }
458
459
460 if ($this->filterDataByChanging($data, $previousData))
461 {
462 $id = $this->saveByEntity(LetterTable::getEntity(), $id, $data);
463 }
464
465 if ($this->canChangeSegments())
466 {
467 $this->saveDataSegments($id, $segmentsInclude, $segmentsExclude);
468
469 $data['DATE_UPDATE'] = new DateTime();
470 $this->saveByEntity(LetterTable::getEntity(), $id, $data);
471 }
472
473 if ($this->hasErrors())
474 {
475 return $id;
476 }
477
478 // update template use count
479 $this->updateTemplateUseCount($data, $previousData);
480
481 // change status for init recipients
482 if (!$initialId && !$this->isTrigger())
483 {
484 $this->setId($id)->getState()->init();
485 }
486
487 return $id;
488 }
489
490 protected function prepareSearchContent()
491 {
492 $content = $this->getSearchBuilder()->getContent();
493 $content->addUserById($this->get('CREATED_BY'));
494 $content->addText($this->get('TITLE'));
495 $config = $this->getMessage()->getConfiguration();
496
497 foreach ($config->getOptions() as $option)
498 {
499 $value = $option->getValue();
500 if (!$value)
501 {
502 continue;
503 }
504
505 switch ($option->getType())
506 {
507 case $option::TYPE_EMAIL:
508 $content->addEmail($value);
509 break;
510
511 case $option::TYPE_HTML:
512 case $option::TYPE_MAIL_EDITOR:
513 $content->addHtmlLayout($value);
514 break;
515
516 case $option::TYPE_TEXT:
517 case $option::TYPE_STRING:
518 case $option::TYPE_PRESET_STRING:
519 case $option::TYPE_SMS_EDITOR:
520 $content->addText($value);
521 break;
522 }
523 }
524
525 return $this;
526 }
527
528 protected function saveDataSegments($id, array $segmentsInclude, array $segmentsExclude)
529 {
530 $segmentsExclude = array_unique($segmentsExclude);
531 $segmentsInclude = array_unique($segmentsInclude);
532 $segmentsInclude = array_diff($segmentsInclude, $segmentsExclude);
533
534 $segmentsList = array(
535 array(
536 'list' => $segmentsExclude,
537 'include' => false
538 ),
539 array(
540 'list' => $segmentsInclude,
541 'include' => true
542 ),
543 );
544
545 $oldSegments = $this->loadDataSegments($id);
546 $letter = LetterTable::getById($id)->fetch();
547 LetterSegmentTable::deleteList(array('LETTER_ID' => $id));
548
549 $isChanged = false;
550 $dataToInsert = [];
551 foreach ($segmentsList as $segments)
552 {
553 if(empty($segments['list']))
554 {
555 continue;
556 }
557
558 $typeCode = $segments['include'] ? 'INCLUDE' : 'EXCLUDE';
559 $list = [];
560 foreach ($segments['list'] as $segment)
561 {
562 $list[] = ['DATE_UPDATE' => $letter['DATE_UPDATE'], 'ID' => $segment];
563 $dataToInsert[] = [
564 'CHAIN_ID' => $id,
565 'GROUP_ID' => $segment,
566 'INCLUDE' => $segments['include'],
567 ];
568 }
569
570 $newest = self::getArrayDiffNewest($list, $oldSegments[$typeCode]);
571 $removed = self::getArrayDiffRemoved($list, $oldSegments[$typeCode]);
572
573 if (count($newest) === 0 && count($removed) === 0)
574 {
575 continue;
576 }
577
578 if (count($newest) > 0)
579 {
580 Segment::updateUseCounters($newest, $segments['include']);
581 }
582
583 $isChanged = true;
584 }
585 if (!empty($dataToInsert))
586 {
587 SqlBatch::insert(LetterSegmentTable::getTableName(), $dataToInsert);
588 }
589
590 if ($isChanged && $this->getId() && $this->get('POSTING_ID'))
591 {
593 ->run($this->get('POSTING_ID'), false);
594 }
595 }
596
597 private static function getArrayDiffNewest(array $current, array $old)
598 {
599 return array_udiff($current, $old, function($first, $second)
600 {
601 return $first['DATE_UPDATE'] < $second['DATE_UPDATE'] || $first['ID'] != $second['ID'];
602 });
603 }
604
605 private static function getArrayDiffRemoved(array $current, array $old)
606 {
607 return self::getArrayDiffNewest($old, $current);
608 }
609
610 protected function updateTemplateUseCount(array $data, array $previousData)
611 {
612 if (!isset($data['TEMPLATE_TYPE']) || !isset($data['TEMPLATE_ID']))
613 {
614 return false;
615 }
616
617 if (Templates\Type::getCode(Templates\Type::USER) !== $data['TEMPLATE_TYPE'])
618 {
619 return false;
620 }
621 if (
622 isset($previousData['TEMPLATE_ID'])
623 && $data['TEMPLATE_ID'] === $previousData['TEMPLATE_ID']
624 && $data['TEMPLATE_TYPE'] === $previousData['TEMPLATE_TYPE']
625 )
626 {
627 return false;
628 }
629
630 return TemplateTable::incUseCount($data['TEMPLATE_ID']);
631 }
632
639 public function loadData($id)
640 {
641 $data = static::getList(array(
642 'filter' => array(
643 '=ID' => $id
644 )
645 ))->fetch();
646 if (!is_array($data))
647 {
648 return null;
649 }
650
651 $segments = $this->loadDataSegments($id);
652 foreach ($segments as $typeCode => $list)
653 {
654 foreach($list as $item)
655 {
656 $data["SEGMENTS_$typeCode"][] = $item['ID'];
657 }
658 }
659
660 return $data;
661 }
662
668 public function hasStatistics()
669 {
670 return (
671 $this->getState()->wasStartedSending()
672 &&
673 !$this->getState()->isPlanned()
674 &&
675 $this->getMessage()->hasStatistics()
676 );
677 }
678
684 public function canChangeSegments()
685 {
686 return !$this->getState()->wasPostingBuilt();
687 }
688
695 public function loadDataSegments($id)
696 {
697 $data = array('INCLUDE' => array(), 'EXCLUDE' => array());
698 $segments = LetterSegmentTable::getList(array(
699 'select' => ['INCLUDE', 'LETTER_ID', 'SEGMENT_ID', 'DATE_UPDATE' => 'SEGMENT.DATE_UPDATE'],
700 'filter'=>array(
701 '=LETTER_ID'=> $id
702 )
703 ));
704 foreach($segments as $segment)
705 {
706 if ($segment['INCLUDE'])
707 {
708 $data['INCLUDE'][] =
709 [ 'ID' => $segment['SEGMENT_ID'], 'DATE_UPDATE' => $segment['DATE_UPDATE']];
710 }
711 else
712 {
713 $data['EXCLUDE'][] =
714 [ 'ID' => $segment['SEGMENT_ID'], 'DATE_UPDATE' => $segment['DATE_UPDATE']];
715 }
716 }
717
718 return $data;
719 }
720
726 public function canChangeTemplate()
727 {
728 if ($this->getState()->isFinished())
729 {
730 return false;
731 }
732
733 //return $this->getMessage()->getCode() !== MainMessage\Adapter::CODE_MAIL;
734 return true;
735 }
736
743 public function getMessage()
744 {
745 $messageCode = $this->get('MESSAGE_CODE') ?: MainMessage\Adapter::CODE_MAIL;
746 $messageId = $this->get('MESSAGE_ID') ?: null;
747
748 $messageFields = [];
749 if (isset($this->data['MESSAGE_FIELDS']) && $this->data['MESSAGE_FIELDS'])
750 {
751 foreach ($this->data['MESSAGE_FIELDS'] as $field)
752 {
753 $messageFields[$field['CODE']] = $field['VALUE'];
754 }
755 }
756 if ($this->messagesCache && isset($this->messagesCache[$messageCode]))
757 {
758 $this->message = $this->messagesCache[$messageCode];
759 if ($messageFields)
760 {
761 $this->message->setConfigurationData($messageFields);
762 }
763 return $this->message;
764 }
765
766 $this->message = MainMessage\Adapter::create($messageCode);
767 $createdById = $this->get('CREATED_BY') ?: Security\User::current()->getId();
768 $this->message->getConfiguration()->set('LETTER_CREATED_BY_ID', $createdById);
769 $this->message->setSiteId($this->get('SITE_ID'));
770 if ($messageFields)
771 {
772 $this->message->setConfigurationData($messageFields);
773 }
774 $this->message->loadConfiguration($messageId);
775
776 $this->messagesCache[$messageCode] = $this->message;
777
778 return $this->message;
779 }
780
786 public function isSupportHeatMap()
787 {
788 return $this->getMessage()->getCode() == MainMessage\Adapter::CODE_MAIL;
789 }
790
796 public function isSupportReiterate()
797 {
798 if (in_array($this->getMessage()->getCode(), ['rc_lead', 'rc_deal']))
799 {
800 return true;
801 }
802
804 }
805
811 public function getCampaignId()
812 {
813 return $this->get('CAMPAIGN_ID');
814 }
815
821 public function getDuration()
822 {
823 if ($this->duration)
824 {
825 return $this->duration;
826 }
827
828 $this->duration = new Dispatch\Duration($this);
829
830 return $this->duration;
831 }
832
838 public function getState()
839 {
840 if ($this->state)
841 {
842 return $this->state;
843 }
844
845 $this->state = new Dispatch\State($this);
846
847 return $this->state;
848 }
849
855 public function getMethod()
856 {
857 if ($this->method)
858 {
859 return $this->method;
860 }
861
862 $this->method = new Dispatch\Method($this);
863
864 return $this->method;
865 }
866
872 public function getCounter()
873 {
874 if ($this->counter)
875 {
876 return $this->counter;
877 }
878
879 $this->counter = new Posting\Counter($this);
880
881 return $this->counter;
882 }
883
889 protected function getTester()
890 {
891 return $this->getMessage()->getTester();
892 }
893
899 public function isReiterate()
900 {
901 return $this->get('REITERATE') === 'Y';
902 }
903
909 public function isTrigger()
910 {
911 return $this->get('IS_TRIGGER') === 'Y';
912 }
913
919 public function isSupportTesting()
920 {
921 return $this->getTester()->isSupport();
922 }
923
929 public function remove()
930 {
931 return $this->removeByEntity(LetterTable::getEntity(), $this->getId());
932 }
933
940 public static function removeById($id)
941 {
942 return static::create()->removeByEntity(LetterTable::getEntity(), $id);
943 }
944
950 public function copy()
951 {
952 $configurationId = $this->getMessage()->getConfiguration()->getId();
953 if (!$configurationId)
954 {
955 return null;
956 }
957
958 $result = $this->getMessage()->copyConfiguration($configurationId);
959 if (!$result->isSuccess() || !$result->getId())
960 {
961 return null;
962 }
963
964 $data = array(
965 'CAMPAIGN_ID' => $this->get('CAMPAIGN_ID'),
966 'MESSAGE_CODE' => $this->get('MESSAGE_CODE'),
967 'MESSAGE_ID' => $result->getId(),
968 'REITERATE' => $this->get('REITERATE'),
969 'TEMPLATE_TYPE' => $this->get('TEMPLATE_TYPE'),
970 'TEMPLATE_ID' => $this->get('TEMPLATE_ID'),
971 'CREATED_BY' => $this->getUser()->getId(),
972 'UPDATED_BY' => $this->getUser()->getId(),
973 'IS_TRIGGER' => $this->get('IS_TRIGGER'),
974 'TITLE' => Loc::getMessage('SENDER_ENTITY_LETTER_COPY_PREFIX') . ' ' . $this->get('TITLE'),
975 'SEGMENTS_INCLUDE' => $this->get('SEGMENTS_INCLUDE'),
976 'SEGMENTS_EXCLUDE' => $this->get('SEGMENTS_EXCLUDE'),
977 );
978 $instance = static::create()->mergeData($data);
979 $instance->save();
980 $this->getErrorCollection()->add($instance->getErrors());
981
982 if (
983 !is_null($this->getMessage()->getConfiguration()->get('MESSAGE'))
984 && !is_null($instance->getId())
985 )
986 {
988 $instance->getId(),
989 0,
990 $this->getMessage()->getConfiguration()->get('MESSAGE')
991 );
992 }
993
994 return $instance->getId();
995 }
996
1004 public function test(array $codes, array $parameters = array())
1005 {
1006 return $this->getTester()->send($codes, $parameters);
1007 }
1008
1015 public function plan(Date $date)
1016 {
1017 try
1018 {
1019 return $this->getState()->plan($date);
1020 }
1021 catch (InvalidOperationException $exception)
1022 {
1023 $this->errors->setError(new Error($exception->getMessage()));
1024 return false;
1025 }
1026 }
1027
1033 public function wait()
1034 {
1035 if ($this->isTrigger())
1036 {
1037 try
1038 {
1039 return $this->getState()->wait();
1040 }
1041 catch (InvalidOperationException $exception)
1042 {
1043 $this->errors->setError(new Error($exception->getMessage()));
1044 return false;
1045 }
1046 }
1047
1048 if (!$this->isReiterate())
1049 {
1050 $this->errors->setError(new Error('Entity is not reiterate.'));
1051 return false;
1052 }
1053
1054 try
1055 {
1056 $scheduleTime = Dispatch\MethodSchedule::parseTimesOfDay($this->get('TIMES_OF_DAY'));
1057 $scheduleMonths = Dispatch\MethodSchedule::parseMonthsOfYear($this->get('MONTHS_OF_YEAR'));
1058 $scheduleWeekDays = Dispatch\MethodSchedule::parseDaysOfWeek($this->get('DAYS_OF_WEEK'));
1059 $scheduleMonthDays = Dispatch\MethodSchedule::parseDaysOfMonth($this->get('DAYS_OF_MONTH'));
1060 $method = (new Dispatch\MethodSchedule($this))
1061 ->setMonthsOfYear($scheduleMonths)
1062 ->setDaysOfMonth($scheduleMonthDays)
1063 ->setDaysOfWeek($scheduleWeekDays)
1064 ->setTime($scheduleTime[0], $scheduleTime[1]);
1065 $this->getState()->wait($method);
1066 return true;
1067 }
1068 catch (InvalidOperationException $exception)
1069 {
1070 $this->errors->setError(new Error($exception->getMessage()));
1071 return false;
1072 }
1073 }
1074
1080 public function send()
1081 {
1082 try
1083 {
1084 return $this->getState()->send();
1085 }
1086 catch (InvalidOperationException $exception)
1087 {
1088 $this->errors->setError(new Error($exception->getMessage()));
1089 return false;
1090 }
1091 }
1092
1098 public function sendErrors()
1099 {
1100 try
1101 {
1102 return $this->getState()->sendErrors();
1103 }
1104 catch (InvalidOperationException $exception)
1105 {
1106 $this->errors->setError(new Error($exception->getMessage()));
1107 return false;
1108 }
1109 }
1110
1116 public function stop()
1117 {
1118 try
1119 {
1120 return $this->getState()->stop();
1121 }
1122 catch (InvalidOperationException $exception)
1123 {
1124 $this->errors->setError(new Error($exception->getMessage()));
1125 return false;
1126 }
1127 }
1128
1134 public function halt()
1135 {
1136 try
1137 {
1138 return $this->getState()->halt();
1139 }
1140 catch (InvalidOperationException $exception)
1141 {
1142 $this->errors->setError(new Error($exception->getMessage()));
1143 return false;
1144 }
1145 }
1146
1152 public function resume()
1153 {
1154 try
1155 {
1156 return $this->getState()->resume();
1157 }
1158 catch (InvalidOperationException $exception)
1159 {
1160 $this->errors->setError(new Error($exception->getMessage()));
1161 return false;
1162 }
1163 }
1164
1170 public function pause()
1171 {
1172 try
1173 {
1174 return $this->getState()->pause();
1175 }
1176 catch (InvalidOperationException $exception)
1177 {
1178 $this->errors->setError(new Error($exception->getMessage()));
1179 return false;
1180 }
1181 }
1182
1188 public function getLastPostingData()
1189 {
1190 $defaults = array();
1191
1192 if (!$this->getId())
1193 {
1194 return $defaults;
1195 }
1196
1197 if ($this->postingData !== null)
1198 {
1199 return $this->postingData;
1200 }
1201
1202 $this->postingData = $defaults;
1203 $postingFilter = array(
1204 '=ID' => $this->getId(),
1205 //'!POSTING.DATE_SENT' => null
1206 );
1207
1208 $postings = static::getList(array(
1209 'select' => array(
1210 'POSTING_ID',
1211 'LETTER_ID' => 'ID',
1212 'CAMPAIGN_ID',
1213 'TITLE' => 'TITLE',
1214 'MAILING_NAME' => 'CAMPAIGN.NAME',
1215 'DATE_SENT' => 'POSTING.DATE_SENT',
1216 'COUNT_SEND_ERROR' => 'POSTING.COUNT_SEND_ERROR',
1217 'CREATED_BY' => 'CREATED_BY',
1218 'CREATED_BY_NAME' => 'CREATED_BY_USER.NAME',
1219 'CREATED_BY_LAST_NAME' => 'CREATED_BY_USER.LAST_NAME',
1220 'CREATED_BY_SECOND_NAME' => 'CREATED_BY_USER.SECOND_NAME',
1221 'CREATED_BY_LOGIN' => 'CREATED_BY_USER.LOGIN',
1222 'CREATED_BY_TITLE' => 'CREATED_BY_USER.TITLE',
1223 ),
1224 'filter' => $postingFilter,
1225 'limit' => 1,
1226 'order' => array('POSTING.DATE_SENT' => 'DESC', 'POSTING.DATE_CREATE' => 'DESC'),
1227 ));
1228 if ($postingData = $postings->fetch())
1229 {
1230 $this->postingData = $postingData + $this->postingData;
1231 }
1232
1233 return $this->postingData;
1234 }
1235}
if(isset( $_REQUEST["mode"]) &&$_REQUEST["mode"]=="ajax") if(isset($_REQUEST["mode"]) && $_REQUEST["mode"]=="save_lru" &&check_bitrix_sessid()) $first
Определения access_dialog.php:54
$messageFields
Определения callback_ednaru.php:22
if(! $messageFields||!isset($messageFields['message_id'])||!isset($messageFields['status'])||!CModule::IncludeModule("messageservice")) $messageId
Определения callback_ismscenter.php:26
Определения error.php:15
getCode()
Определения error.php:54
Определения date.php:9
static parseMonthsOfYear($monthsOfYear)
Определения methodschedule.php:347
static parseDaysOfMonth($daysOfMonth)
Определения methodschedule.php:256
static parseTimesOfDay($time)
Определения methodschedule.php:383
static parseDaysOfWeek($daysOfWeek)
Определения methodschedule.php:311
const WAITING
Определения state.php:36
Определения ad.php:19
static getDefaultId($siteId=null)
Определения campaign.php:63
plan(Date $date)
Определения letter.php:1015
isSupportHeatMap()
Определения letter.php:786
getMessage()
Определения letter.php:743
static createInstanceByArray(array $data, array $messageCodes=[])
Определения letter.php:242
getTester()
Определения letter.php:889
loadDataSegments($id)
Определения letter.php:695
canChangeTemplate()
Определения letter.php:726
hasStatistics()
Определения letter.php:668
static getList(array $parameters=array())
Определения letter.php:91
test(array $codes, array $parameters=array())
Определения letter.php:1004
loadData($id)
Определения letter.php:639
static createInstanceByPostingId($postingId)
Определения letter.php:257
isSupportTesting()
Определения letter.php:919
getCounter()
Определения letter.php:872
static getFilterFields()
Определения letter.php:64
static getDefaultSelectFields()
Определения letter.php:127
$messagesCache
Определения letter.php:45
saveDataSegments($id, array $segmentsInclude, array $segmentsExclude)
Определения letter.php:528
isReiterate()
Определения letter.php:899
canChangeSegments()
Определения letter.php:684
getCampaignId()
Определения letter.php:811
getDuration()
Определения letter.php:821
getDefaultData()
Определения letter.php:359
static createInstanceByContactId($contactId, array $messageCodes=[])
Определения letter.php:286
isTrigger()
Определения letter.php:909
isSupportReiterate()
Определения letter.php:796
updateTemplateUseCount(array $data, array $previousData)
Определения letter.php:610
static getDataClass()
Определения letter.php:80
getLastPostingData()
Определения letter.php:1188
static removeById($id)
Определения letter.php:940
static createInstanceByCode($code=null, array $messageCodes=[])
Определения letter.php:304
static createInstanceById($id=null, array $messageCodes=[])
Определения letter.php:198
static getListWithMessageFields(array $parameters=array())
Определения letter.php:157
getMethod()
Определения letter.php:855
saveData($id, array $data)
Определения letter.php:377
prepareSearchContent()
Определения letter.php:490
Определения rc.php:20
static updateUseCounters(array $list, $isInclude=true)
Определения segment.php:471
static syncFiles(int $entityId, int $entityType, string $template, bool $deleteFiles=true, bool $onDeleteEntity=false)
Определения filetable.php:75
static create($code)
Определения adapter.php:90
static create()
Определения builder.php:75
const EMAIL
Определения type.php:21
const PHONE
Определения type.php:22
static current()
Определения user.php:47
static incUseCount($id)
Определения template.php:115
$content
Определения commerceml.php:144
$data['IS_AVAILABLE']
Определения .description.php:13
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
const CODE_SMS
Определения ibase.php:20
const CODE_MAIL
Определения ibase.php:17
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
Определения options.php:195
hasErrors()
Определения errorableimplementation.php:17
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
$instance
Определения ps_b24_final.php:14
$config
Определения quickway.php:69
if(empty($signedUserToken)) $key
Определения quickway.php:257
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
$option
Определения options.php:1711
const SITE_ID
Определения sonet_set_content_view.php:12
$rows
Определения options.php:264
$dbResult
Определения updtr957.php:3