switch ($_REQUEST['action']) { case "delete": @set_time_limit(0); $DB->StartTransaction(); $dataDeleteDb = \Bitrix\Sender\TemplateTable::delete($dataPrimary); if (!$dataDeleteDb->isSuccess()) { $DB->Rollback(); $LAST_ERROR = $dataDeleteDb->getErrorMessages(); $lAdmin->AddGroupError(GetMessage("rub_del_err") . '<br>' . $LAST_ERROR[0], $ID); } $DB->Commit(); break; case "activate": case "deactivate": $arFields = array("ACTIVE" => $_REQUEST['action'] == "activate" ? "Y" : "N"); $dataUpdateDb = \Bitrix\Sender\TemplateTable::update($dataPrimary, $arFields); if (!$dataUpdateDb->isSuccess()) { $LAST_ERROR = $dataUpdateDb->getErrorMessages(); $LAST_ERROR = $LAST_ERROR[0]; $lAdmin->AddGroupError(GetMessage("rub_save_error") . '<br>' . $LAST_ERROR, $ID); } break; } } } $templateListDb = \Bitrix\Sender\TemplateTable::getList(array('select' => array('*'), 'filter' => $arFilter, 'order' => array($by => $order))); $rsData = new CAdminResult($templateListDb, $sTableID); $rsData->NavStart(); $lAdmin->NavText($rsData->GetNavPrint(GetMessage("rub_nav"))); $lAdmin->AddHeaders(array(array("id" => "ID", "content" => "ID", "sort" => "ID", "align" => "right", "default" => true), array("id" => "NAME", "content" => GetMessage("rub_name"), "sort" => "NAME", "default" => true), array("id" => "ACTIVE", "content" => GetMessage("rub_act"), "sort" => "ACTIVE", "default" => true))); while ($arRes = $rsData->NavNext(true, "f_")) {
$MESSAGE_OLD = false; if ($ID > 0) { $templateOld = \Bitrix\Sender\TemplateTable::getRowById(array('ID' => $ID)); if ($templateOld) { $MESSAGE_OLD = $templateOld['MESSAGE']; } } $MESSAGE = CMain::ProcessLPA($MESSAGE, $MESSAGE_OLD); } $CONTENT = ''; if (!empty($MESSAGE)) { $CONTENT = $MESSAGE; } $arFields = array("ACTIVE" => $ACTIVE != "Y" ? "N" : "Y", "CONTENT" => $CONTENT, "NAME" => $NAME); if ($ID > 0) { $mailingUpdateDb = \Bitrix\Sender\TemplateTable::update($ID, $arFields); $res = $mailingUpdateDb->isSuccess(); if (!$res) { $arError = $mailingUpdateDb->getErrorMessages(); } } else { $mailingAddDb = \Bitrix\Sender\TemplateTable::add($arFields); if ($mailingAddDb->isSuccess()) { $ID = $mailingAddDb->getId(); $res = $ID > 0; } else { $arError = $mailingAddDb->getErrorMessages(); } } if ($res) { if ($apply != "") {