34 return 'b_sender_posting';
44 'data_type' =>
'integer',
46 'autocomplete' =>
true,
48 'MAILING_ID' => array(
49 'data_type' =>
'integer',
53 'MAILING_CHAIN_ID' => array(
54 'data_type' =>
'integer',
58 'DATE_CREATE' => array(
59 'data_type' =>
'datetime',
63 'DATE_UPDATE' => array(
64 'data_type' =>
'datetime',
69 'data_type' =>
'string',
71 'default_value' => static::STATUS_NEW,
74 'data_type' =>
'datetime',
76 'DATE_PAUSE' => array(
77 'data_type' =>
'datetime',
80 'data_type' =>
'datetime',
82 'COUNT_READ' => array(
83 'data_type' =>
'integer',
86 'COUNT_CLICK' => array(
87 'data_type' =>
'integer',
90 'COUNT_UNSUB' => array(
91 'data_type' =>
'integer',
94 'COUNT_SEND_ALL' => array(
95 'data_type' =>
'integer',
98 'COUNT_SEND_NONE' => array(
99 'data_type' =>
'integer',
102 'COUNT_SEND_ERROR' => array(
103 'data_type' =>
'integer',
106 'COUNT_SEND_SUCCESS' => array(
107 'data_type' =>
'integer',
110 'COUNT_SEND_DENY' => array(
111 'data_type' =>
'integer',
114 'CONSENT_SUPPORT' => array(
115 'data_type' =>
'boolean',
116 'values' => array(
'N',
'Y'),
117 'default_value' =>
'N',
121 'data_type' =>
'Bitrix\Sender\Internals\Model\LetterTable',
122 'reference' => array(
'=this.MAILING_CHAIN_ID' =>
'ref.ID'),
125 'data_type' =>
'Bitrix\Sender\MailingTable',
126 'reference' => array(
'=this.MAILING_ID' =>
'ref.ID'),
128 'MAILING_CHAIN' => array(
129 'data_type' =>
'Bitrix\Sender\MailingChainTable',
130 'reference' => array(
'=this.MAILING_CHAIN_ID' =>
'ref.ID'),
132 'POSTING_RECIPIENT' => array(
133 'data_type' =>
'Bitrix\Sender\PostingRecipientTable',
134 'reference' => array(
'=this.ID' =>
'ref.POSTING_ID'),
136 'POSTING_READ' => array(
137 'data_type' =>
'Bitrix\Sender\PostingReadTable',
138 'reference' => array(
'=this.ID' =>
'ref.POSTING_ID'),
140 'POSTING_CLICK' => array(
141 'data_type' =>
'Bitrix\Sender\PostingClickTable',
142 'reference' => array(
'=this.ID' =>
'ref.POSTING_ID'),
144 'POSTING_UNSUB' => array(
145 'data_type' =>
'Bitrix\Sender\PostingUnsubTable',
146 'reference' => array(
'=this.ID' =>
'ref.POSTING_ID'),
163 if(array_key_exists(
'ID', $data[
'primary']))
165 $listId[] = $data[
'primary'][
'ID'];
170 foreach($data[
'primary'] as $primKey => $primVal)
171 $filter[$primKey] = $primVal;
173 $tableDataList = static::getList(array(
174 'select' => array(
'ID'),
177 while($tableData = $tableDataList->fetch())
179 $listId[] = $tableData[
'ID'];
184 foreach($listId as $primaryId)
186 $primary = array(
'POSTING_ID' => $primaryId);
209 $row = PostingRecipientTable::getRow(array(
210 'select' => array(
'ID'),
212 '=CONTACT_ID' => $ar[
'CONTACT_ID'],
213 '=POSTING_ID' => $ar[
'POSTING_ID']
228 PostingRecipientTable::add($ar);
256 $select = [
'CNT',
'STATUS'];
257 $filter = !$customFilter?[
'POSTING_ID' => $id] : [
'LOGIC' =>
'AND',[
'POSTING_ID' => $id],$customFilter];
258 $postingContactDb = PostingRecipientTable::getList([
263 while($postingContact = $postingContactDb->fetch())
264 $statusList[$postingContact[
'STATUS']] = intval($postingContact[
'CNT']);
278 $ar = static::getRecipientCountByStatus($id);
280 $count = (array_key_exists($status, $ar) ? $ar[$status] : 0);
282 foreach ($ar as $k => $v) $count += $v;
295 $ar = static::getRecipientCountByStatus($id);
297 foreach ($ar as $k => $v)
308 if($count > 0 && $countNew > 0)
310 return round(($count - $countNew) / $count, 2) * 100;
340 $entity = static::getEntity();
341 $connection = $entity->getConnection();
343 \CTimeZone::disable();
345 'DELETE FROM %s WHERE %s',
346 $connection->getSqlHelper()->quote($entity->getDbTableName()),
347 Query::buildFilterSql($entity, $filter)
349 $res = $connection->query($sql);
350 \CTimeZone::enable();
365 return 'b_sender_posting_read';
375 'data_type' =>
'integer',
377 'autocomplete' =>
true,
379 'POSTING_ID' => array(
381 'data_type' =>
'integer',
383 'RECIPIENT_ID' => array(
385 'data_type' =>
'integer',
387 'DATE_INSERT' => array(
388 'data_type' =>
'datetime',
404 $data = $data[
'fields'];
407 Model\Posting\RecipientTable::update($data[
'RECIPIENT_ID'], [
'IS_READ' =>
'Y']);
410 $resultDb = static::getList(array(
'filter' => array(
'RECIPIENT_ID' => $data[
'RECIPIENT_ID'])));
411 if($resultDb->getSelectedRowsCount() == 1)
413 Model\PostingTable::update($data[
'POSTING_ID'], array(
430 $entity = static::getEntity();
431 $connection = $entity->getConnection();
433 \CTimeZone::disable();
435 'DELETE FROM %s WHERE %s',
436 $connection->getSqlHelper()->quote($entity->getDbTableName()),
437 Query::buildFilterSql($entity, $filter)
439 $res = $connection->query($sql);
440 \CTimeZone::enable();
454 return 'b_sender_posting_click';
464 'data_type' =>
'integer',
466 'autocomplete' =>
true,
468 'POSTING_ID' => array(
470 'data_type' =>
'integer',
472 'RECIPIENT_ID' => array(
474 'data_type' =>
'integer',
476 'DATE_INSERT' => array(
477 'data_type' =>
'datetime',
481 'data_type' =>
'string',
484 'data_type' =>
'Bitrix\Sender\PostingTable',
485 'reference' => array(
'=this.POSTING_ID' =>
'ref.ID'),
500 $data = $data[
'fields'];
503 Model\Posting\RecipientTable::update($data[
'RECIPIENT_ID'], [
'IS_CLICK' =>
'Y']);
506 $resultDb = static::getList(
508 'filter' => array(
'RECIPIENT_ID' => $data[
'RECIPIENT_ID']),
513 if($resultDb->getSelectedRowsCount() == 1)
515 Model\PostingTable::update($data[
'POSTING_ID'], array(
533 $entity = static::getEntity();
534 $connection = $entity->getConnection();
536 \CTimeZone::disable();
538 'DELETE FROM %s WHERE %s',
539 $connection->getSqlHelper()->quote($entity->getDbTableName()),
540 Query::buildFilterSql($entity, $filter)
542 $res = $connection->query($sql);
543 \CTimeZone::enable();
556 return 'b_sender_posting_unsub';
566 'data_type' =>
'integer',
568 'autocomplete' =>
true,
570 'POSTING_ID' => array(
572 'data_type' =>
'integer',
574 'RECIPIENT_ID' => array(
576 'data_type' =>
'integer',
578 'DATE_INSERT' => array(
579 'data_type' =>
'datetime',
583 'data_type' =>
'Bitrix\Sender\PostingTable',
584 'reference' => array(
'=this.POSTING_ID' =>
'ref.ID'),
586 'POSTING_RECIPIENT' => array(
587 'data_type' =>
'Bitrix\Sender\PostingRecipientTable',
588 'reference' => array(
'=this.RECIPIENT_ID' =>
'ref.ID'),
603 $data = $data[
'fields'];
606 Model\Posting\RecipientTable::update($data[
'RECIPIENT_ID'], [
'IS_UNSUB' =>
'Y']);
609 $resultDb = static::getList(array(
'filter' => array(
'RECIPIENT_ID' => $data[
'RECIPIENT_ID'])));
610 if($resultDb->getSelectedRowsCount() == 1)
612 Model\PostingTable::update($data[
'POSTING_ID'], array(
630 $entity = static::getEntity();
631 $connection = $entity->getConnection();
633 \CTimeZone::disable();
635 'DELETE FROM %s WHERE %s',
636 $connection->getSqlHelper()->quote($entity->getDbTableName()),
637 Query::buildFilterSql($entity, $filter)
639 $res = $connection->query($sql);
640 \CTimeZone::enable();
677 return 'b_sender_posting_recipient';
687 'data_type' =>
'integer',
689 'autocomplete' =>
true,
691 'POSTING_ID' => array(
693 'data_type' =>
'integer',
696 'data_type' =>
'string',
699 'default_value' => static::SEND_RESULT_NONE,
701 'DATE_SENT' => array(
702 'data_type' =>
'datetime',
704 'DATE_DENY' => array(
705 'data_type' =>
'datetime',
707 'CONTACT_ID' => array(
709 'data_type' =>
'integer',
712 'data_type' =>
'integer',
715 'data_type' =>
'text',
716 'serialized' =>
true,
719 'data_type' =>
'integer',
722 'data_type' =>
'string',
725 'data_type' =>
'string',
728 'data_type' =>
'string',
731 'data_type' =>
'Bitrix\Sender\ContactTable',
732 'reference' => array(
'=this.CONTACT_ID' =>
'ref.ID'),
735 'data_type' =>
'Bitrix\Sender\PostingTable',
736 'reference' => array(
'=this.POSTING_ID' =>
'ref.ID'),
738 'POSTING_READ' => array(
739 'data_type' =>
'Bitrix\Sender\PostingReadTable',
740 'reference' => array(
'=this.ID' =>
'ref.RECIPIENT_ID'),
742 'POSTING_CLICK' => array(
743 'data_type' =>
'Bitrix\Sender\PostingClickTable',
744 'reference' => array(
'=this.ID' =>
'ref.RECIPIENT_ID'),
746 'POSTING_UNSUB' => array(
747 'data_type' =>
'Bitrix\Sender\PostingUnsubTable',
748 'reference' => array(
'=this.ID' =>
'ref.RECIPIENT_ID'),
768 'DESC' =>
Loc::getMessage(
"SENDER_POSTING_PERSONALIZE_FIELD_NAME_DESC"),
771 'CODE' =>
'EMAIL_TO',
773 'DESC' =>
Loc::getMessage(
"SENDER_POSTING_PERSONALIZE_FIELD_EMAIL_DESC"),
776 if (!Integration\Bitrix24\Service::isCloud())
781 'DESC' =>
Loc::getMessage(
"SENDER_POSTING_PERSONALIZE_FIELD_USER_ID_DESC"),
784 'CODE' =>
'SITE_NAME',
785 'NAME' =>
Loc::getMessage(
"SENDER_POSTING_PERSONALIZE_FIELD_SITE_NAME"),
786 'DESC' =>
Loc::getMessage(
"SENDER_POSTING_PERSONALIZE_FIELD_SITE_NAME_DESC"),
789 'CODE' =>
'SENDER_CHAIN_CODE',
790 'NAME' =>
Loc::getMessage(
"SENDER_POSTING_PERSONALIZE_FIELD_SENDER_CHAIN_ID"),
791 'DESC' =>
Loc::getMessage(
"SENDER_POSTING_PERSONALIZE_FIELD_SENDER_CHAIN_ID_DESC"),
797 (static::$personalizeList ? static::$personalizeList : array())
807 self::SEND_RESULT_NONE =>
Loc::getMessage(
'SENDER_POSTING_RECIPIENT_STATUS_N'),
808 self::SEND_RESULT_SUCCESS =>
Loc::getMessage(
'SENDER_POSTING_RECIPIENT_STATUS_S'),
809 self::SEND_RESULT_ERROR =>
Loc::getMessage(
'SENDER_POSTING_RECIPIENT_STATUS_E'),
810 self::SEND_RESULT_DENY =>
Loc::getMessage(
'SENDER_POSTING_RECIPIENT_STATUS_D'),
811 self::SEND_RESULT_WAIT_ACCEPT =>
Loc::getMessage(
'SENDER_POSTING_RECIPIENT_STATUS_A')
817 return (static::getCount([
'=POSTING_ID' => $postingId,
'=STATUS' => self::SEND_RESULT_NONE]) > 0);
830 $entity = static::getEntity();
831 $connection = $entity->getConnection();
833 \CTimeZone::disable();
835 'DELETE FROM %s WHERE %s',
836 $connection->getSqlHelper()->quote($entity->getDbTableName()),
837 Query::buildFilterSql($entity, $filter)
839 $res = $connection->query($sql);
840 \CTimeZone::enable();
static loadMessages($file)
static getMessage($code, $replace=null, $language=null)
const STATUS_SENT_WITH_ERRORS
static deleteList(array $filter)
static onAfterAdd(Entity\Event $event)
static deleteList(array $filter)
static onAfterAdd(Entity\Event $event)
static getConflictFields()
static deleteList(array $filter)
const SEND_RESULT_WAIT_ACCEPT
const SEND_RESULT_SUCCESS
static getPersonalizeList()
static setPersonalizeList(array $personalizeList=null)
static hasUnprocessed($postingId, $threadId=null)
static onDelete(Entity\Event $event)
static deleteList(array $filter)
static getRecipientCountByStatus($id, ?array $customFilter=null)
static getSendPercent($id)
static getRecipientCount($id, $status='')
static addRecipient($ar, $checkDuplicate=false)
static initGroupRecipients($postingId, $checkDuplicate=true)
static getRecipientStatusToPostingFieldMap()
static deleteList(array $filter)
static onAfterAdd(Entity\Event $event)