-
-
Save xTCry/2d4907e8007895c8806394c5357aa875 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <? | |
| require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php"); | |
| use Bitrix\Main\Mail\Event, | |
| Bitrix\Main\Application, | |
| \Bitrix\Main\Loader; | |
| Loader::includeModule("iblock"); | |
| $request = Application::getInstance()->getContext()->getRequest(); | |
| $arProperties = array( | |
| "NAME" => $request->getPost("name"), | |
| "PHONE" => $request->getPost("phone"), | |
| "MAIL" => $request->getPost("mail"), | |
| "PAGE" => $request->getPost("page"), | |
| "VIEW" => $request->getPost("view"), | |
| ); | |
| $files = $request->getFile("file"); | |
| if (!empty($files)) { | |
| foreach ($files['name'] as $fkey => $name) { | |
| $key = "n" . $fkey; | |
| $arProperties['FILES'][$key] = array( | |
| "VALUE" => array ( | |
| "name" => $files['name'][$fkey], | |
| "size" => $files['size'][$fkey], | |
| "tmp_name" => $files['tmp_name'][$fkey], | |
| "type" => $files['type'][$fkey] | |
| ) | |
| ); | |
| } | |
| } | |
| $arFields = array( | |
| "IBLOCK_ID" => FEEDBACK_IBLOCK_ID, | |
| "NAME" => "заявка от " . date("d.m.Y H:i:s"), | |
| "PROPERTY_VALUES" => $arProperties, | |
| "PREVIEW_TEXT" => $request->getPost("text") | |
| ); | |
| $objElement = new CIBlockElement; | |
| if ($element = $objElement->Add($arFields)) { | |
| if (!empty($files)) { | |
| unset($arFields['FILES']); | |
| $resElement = CIblockElement::GetList(array(), array('IBLOCK_ID' => FEEDBACK_IBLOCK_ID, 'ID' => $element), false, false, array()); | |
| $obElement = $resElement->GetNextElement(); | |
| $arElement = $obElement->GetFields(); | |
| $arElement['PROPERTIES'] = $obElement->GetProperties(); | |
| foreach ($arElement['PROPERTIES']['FILES']['VALUE'] as $file) { | |
| $arFields['FILES'][] = FULL_SITE_URL . CFile::GetPath($file); | |
| } | |
| } | |
| echo 'success'; | |
| } else { | |
| echo $objElement->LAST_ERROR; | |
| } | |
| // отправим письмо | |
| foreach ($arProperties as &$arProperty) { | |
| if (is_array($arProperty)) | |
| $arProperty = implode(", ", $arProperty); | |
| } | |
| $arProperties['TEXT'] = $arFields['PREVIEW_TEXT']; | |
| Event::send(array( | |
| "EVENT_NAME" => "CALLBACK", | |
| "LID" => "s1", | |
| "C_FIELDS" => $arProperties, | |
| )); | |
| require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_after.php"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment