$arTriggerSettingsTmp[] = $item; } $arTriggerSettings = $arTriggerSettingsTmp; // save chain $result = \Bitrix\Sender\MailingTable::updateChain($ID, $arTriggerSettings); $errorList = array_merge($errorList, $result->getErrorMessages()); if (empty($errorList)) { if ($save != "") { LocalRedirect('/bitrix/admin/sender_mailing_trig_admin.php?lang=' . LANGUAGE_ID); } else { LocalRedirect('/bitrix/admin/sender_mailing_trig_edit.php?ID=' . $ID . '&lang=' . LANGUAGE_ID); } } $chainFieldsList = $arTriggerSettings; } else { $chainFieldsList = \Bitrix\Sender\MailingTable::getChain($ID); } $numberChainItem = 0; $chainFieldsListTmp = array(); foreach ($chainFieldsList as $chain) { $chain['ITEM_SORT'] = $numberChainItem++; $chainFieldsListTmp[] = $chain; } $chainFieldsList = $chainFieldsListTmp; //Edit/Add part ClearVars(); \CJSCore::Init(array("sender_admin")); $APPLICATION->SetTitle(GetMessage("sender_chain_edit_title_edit") . ' "' . $mailing['NAME'] . '"'); require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php"; $aMenu = array(array("TEXT" => GetMessage("sender_chain_edit_list"), "TITLE" => GetMessage("sender_chain_edit_list_title"), "LINK" => "/bitrix/admin/sender_mailing_trig_admin.php?MAILING_ID=" . $MAILING_ID . "&lang=" . LANG, "ICON" => "btn_list")); if ($ID > 0 && $POST_RIGHT >= "W") {
if ($v !== 0 && empty($v)) { unset($arFilter[$k]); } } } $mailing = null; if ($MAILING_ID > 0) { $mailingDb = \Bitrix\Sender\MailingTable::getList(array('filter' => array('ID' => $MAILING_ID, 'IS_TRIGGER' => 'Y'))); if (!($mailing = $mailingDb->fetch())) { $MAILING_ID = 0; } } $statList = array(); if ($MAILING_ID > 0) { $i = 1; $chainList = \Bitrix\Sender\MailingTable::getChain($MAILING_ID); foreach ($chainList as $chain) { $stat = array('NAME' => GetMessage("sender_stat_trig_letter") . $i++, 'SUBJECT' => $chain['SUBJECT'], 'CNT' => array('SENT_SUCCESS' => 0, 'SENT_ERROR' => 0, 'READ' => 0, 'CLICK' => 0, 'UNSUB' => 0, 'GOAL' => 0, 'START' => 0)); $statRawDb = \Bitrix\Sender\PostingRecipientTable::getList(array('select' => array('CNT', 'READ_CNT', 'CLICK_CNT', 'UNSUB_CNT'), 'filter' => array('=POSTING.MAILING_CHAIN_ID' => $chain['ID'], '=STATUS' => array(\Bitrix\Sender\PostingRecipientTable::SEND_RESULT_SUCCESS)), 'runtime' => array(new \Bitrix\Main\Entity\ExpressionField('CNT', 'COUNT(DISTINCT %s)', 'ID'), new \Bitrix\Main\Entity\ExpressionField('READ_CNT', 'COUNT(DISTINCT %s)', 'POSTING_READ.RECIPIENT_ID'), new \Bitrix\Main\Entity\ExpressionField('CLICK_CNT', 'COUNT(DISTINCT %s)', 'POSTING_CLICK.RECIPIENT_ID'), new \Bitrix\Main\Entity\ExpressionField('UNSUB_CNT', 'COUNT(DISTINCT %s)', 'POSTING_UNSUB.RECIPIENT_ID')))); while ($statRaw = $statRawDb->fetch()) { $stat['CNT']['SENT_SUCCESS'] += $statRaw['CNT']; $stat['CNT']['READ'] += $statRaw['READ_CNT']; $stat['CNT']['CLICK'] += $statRaw['CLICK_CNT']; $stat['CNT']['UNSUB'] += $statRaw['UNSUB_CNT']; $stat['CNT']['START'] += $statRaw['CNT']; } $statRawDb = \Bitrix\Sender\PostingRecipientTable::getList(array('select' => array('ID'), 'filter' => array('=POSTING.MAILING_CHAIN_ID' => $chain['ID'], '=STATUS' => array(\Bitrix\Sender\PostingRecipientTable::SEND_RESULT_SUCCESS, \Bitrix\Sender\PostingRecipientTable::SEND_RESULT_DENY), '!DATE_DENY' => null))); $stat['CNT']['GOAL'] = $statRawDb->getSelectedRowsCount(); $statList['CHAIN'][] = $stat; } }