Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. <?
  2. /**
  3. * Класс для экспорта заявок в CRM Akado
  4. *
  5. */
  6.  
  7. Class CCrmExport
  8. {
  9.  
  10. private $clientId;
  11. private $connectionPointId;
  12. private $flat;
  13. private $tariffCodes;
  14. private $customerLastName;
  15. private $customerFirstName;
  16. private $customerMiddleName;
  17. private $customerMobilePhone;
  18. private $customerComment;
  19. private $customerAddress;
  20. private $customerProduct;
  21.  
  22. protected $webFormId = NULL;
  23. protected $resultId = NULL;
  24. protected $formAnswer = array();
  25. protected $formResult = array();
  26.  
  27. protected $availableForms = array();
  28. public $logFile;
  29.  
  30. function __construct($webFormId,$resultId)
  31. {
  32. CModule::IncludeModule("form");
  33.  
  34. $this->clientId = "2";
  35. $this->webFormId = $webFormId;
  36. $this->resultId = $resultId;
  37. $this->availableForms = array('ORDER');
  38.  
  39. $this->logFile = $_SERVER['DOCUMENT_ROOT'].'/CRM.log';
  40. }
  41.  
  42. protected function prepareFormData()
  43. {
  44. $arResult = $this->formResult;
  45. $arAnswer = $this->formAnswer;
  46.  
  47. $arFields["ID"] = $arResult["ID"];
  48. $arFields["NAME"] = $arResult["NAME"];
  49. $arFields["EMAIL"] = $arAnswer["new_field_email"][0]["USER_TEXT"];
  50.  
  51. return $arFields;
  52. }
  53.  
  54. protected function getFormResult()
  55. {
  56. if ($this->webFormId>0){
  57. $rsForm = CForm::GetByID($this->webFormId);
  58. $arForm = $rsForm->Fetch();
  59.  
  60. if (in_array($arForm["SID"], $this->availableForms)) {
  61. $this->formResult = Array();
  62. $arAnswer2 = Array();
  63. $this->formAnswer = CFormResult::GetDataByID($this->resultId, array(), $this->formResult, $arAnswer2);
  64. return $this->formAnswer;
  65. }
  66. }
  67. return false;
  68. }
  69.  
  70. protected function generateUuid()
  71. {
  72. return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
  73. mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),
  74. mt_rand( 0, 0xffff ),
  75. mt_rand( 0, 0x0fff ) | 0x4000,
  76. mt_rand( 0, 0x3fff ) | 0x8000,
  77. mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff )
  78. );
  79. }
  80.  
  81. function onAfterResultAddHandler($WEB_FORM_ID, $RESULT_ID)
  82. {
  83. file_put_contents($this->logFile, print_r($WEB_FORM_ID, true));
  84.  
  85. $instance = new self($WEB_FORM_ID,$RESULT_ID);
  86. $instance->executeExport();
  87. }
  88.  
  89. protected function executeExport()
  90. {
  91. if (!$this->getFormResult()) return false;
  92. $arFields = $this->prepareFormData();
  93. }
  94.  
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement