Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- /*
- * Класс для экспорта заявок в CRM Akado
- *
- */
- Class CCrmExport
- {
- private $clientId;
- private $connectionPointId;
- private $flat;
- private $tariffCodes;
- private $customerLastName;
- private $customerFirstName;
- private $customerMiddleName;
- private $customerMobilePhone;
- private $customerComment;
- private $customerAddress;
- private $customerProduct;
- protected $webFormId = NULL;
- protected $resultId = NULL;
- protected $formAnswer = array();
- protected $formResult = array();
- protected $availableForms = array();
- public $logFile;
- function __construct($webFormId,$resultId)
- {
- CModule::IncludeModule("form");
- $this->clientId = "2";
- $this->webFormId = $webFormId;
- $this->resultId = $resultId;
- $this->availableForms = array('ORDER');
- $_SERVER["DOCUMENT_ROOT"] = "/adv/vhosts/akado.ru/htdocs";
- }
- protected function prepareFormData()
- {
- $arResult = $this->formResult;
- $arAnswer = $this->formAnswer;
- $arFields["ID"] = $arResult["ID"];
- $arFields["NAME"] = $arResult["NAME"];
- $arFields["EMAIL"] = $arAnswer["new_field_email"][0]["USER_TEXT"];
- return $arFields;
- }
- protected function getFormResult()
- {
- if ($this->webFormId>0){
- $rsForm = CForm::GetByID($this->webFormId);
- $arForm = $rsForm->Fetch();
- if (in_array($arForm["SID"], $this->availableForms)) {
- $this->formResult = Array();
- $arAnswer2 = Array();
- $this->formAnswer = CFormResult::GetDataByID($this->resultId, array(), $this->formResult, $arAnswer2);
- return $this->formAnswer;
- }
- }
- return false;
- }
- protected function generateUuid()
- {
- return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
- mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),
- mt_rand( 0, 0xffff ),
- mt_rand( 0, 0x0fff ) | 0x4000,
- mt_rand( 0, 0x3fff ) | 0x8000,
- mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff )
- );
- }
- public function onAfterResultAddHandler($WEB_FORM_ID, $RESULT_ID)
- {
- $instance = new self($WEB_FORM_ID,$RESULT_ID);
- $instance->executeExport();
- file_put_contents($this->logFile, print_r($RESULT_ID, true));
- }
- protected function executeExport()
- {
- if (!$this->getFormResult()) return false;
- $arFields = $this->prepareFormData();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement