vyacheslavkulik
8/12/2015 - 7:19 AM

send

send

case 'send_services':
  CModule::IncludeModule("iblock");
  if(!empty($_REQUEST["name"])) {
   if(!empty($_REQUEST["phone"])) {
    if(!empty($_REQUEST["email"]) && !check_email($_REQUEST["email"])) {
     $arResult["STATUS"] = 0;
     $arResult["ERROR"] = "Поле «Email» заполнено неверно.";
    } else {
     $arResult["STATUS"] = 1;
     $el = new CIBlockElement;
     $PROP = array();
     $PROP["PHONE"] = $_REQUEST["phone"];
     $PROP["MAIL"] = $_REQUEST["email"];
     $phrase = $APPLICATION->get_cookie("utm_term");
     $search = $APPLICATION->get_cookie("search_system");
     if (isset($phrase) && $phrase != "") {
      $PROP['PHRASE'] = $phrase;
     }
     if (isset($search) && $search != "") {
      $PROP['SEARCH_SYSTEM'] = $search; 
     }
     $pay_click = $APPLICATION->get_cookie("pay_click");
     if (isset($pay_click) && $pay_click != "") {
      $PROP['PAY_CLICK'] = $pay_click;
     }
     $arService = Array(
      "IBLOCK_ID" => SERVICES,
      "PROPERTY_VALUES" => $PROP,
      "NAME" => $_REQUEST["name"],
      "PREVIEW_TEXT" => $_REQUEST["PREVIEW_TEXT"],
     );
   
     if($ID = $el->Add($arService)) {
      $arSend = array(
       "NAME" => $_REQUEST["name"],
       "MESSAGE" => $_REQUEST["PREVIEW_TEXT"],
       "MAIL" => $_REQUEST["email"],
       "TYPE_OF_SERVICE" => $_REQUEST['service'],
       "PHONE" => $_REQUEST["result"]["PROPERTY"]["PHONE"]
      );
      CEvent::Send("FORM_FILLING", "s1", $arSend, "Y", 72);
     }
     else {
      $arResult["STATUS"] = 0;
      $arResult["ERROR"] = $user->LAST_ERROR; 
     }
    }
   }
  }
  echo json_encode($arResult);
 break;
<?
define('NO_KEEP_STATISTIC', true);
define('NO_AGENT_STATISTIC', true);
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");

switch ($_REQUEST["typeform"]) {
	
case 'subscribe-form':
	//CModule::IncludeModule("iblock");

 if(!empty($_REQUEST["name"])) {
   if(empty($_REQUEST["phone"])) {
     $arResult["STATUS"] = 0;
     $arResult["ERROR"] = "Поле «Email» заполнено неверно.";
	 echo false;
    } else {
     $arResult["STATUS"] = 1;  
      $arSend = array(
       "NAME" => $_REQUEST["name"],
       "PHONE" => $_REQUEST["phone"]
      );
      CEvent::Send("FORM_FILLING", "s1", $arSend, "Y", 29);
    }
   }
	//echo json_encode($arResult);
	echo true;
 break;
}

?>