CModule::IncludeModule('crm');
$rs = CCrmFieldMulti::GetList(
array(),
array(
'ENTITY_ID' => 'LEAD', // выбираем только email лида
"VALUE" => "test@mail.ru",
//"@ELEMENT_ID" => array(1,2), // ID выбираемых лидов
//"TYPE_ID" => "EMAIL",
'COMPLEX_ID' => 'EMAIL_WORK' // тип email: "Рабочий"
)
);
while($ar = $rs->Fetch())
{
echo '<pre>';
print_r($ar);
echo '</pre>';
}
//Устанавливаем дело-звонок и напоминание для сделки
$arFieldsDelo = array(
'TYPE_ID' => CCrmActivityType::Call,
'PROVIDER_ID' => 'VOXIMPLANT_CALL',
'ASSOCIATED_ENTITY_ID' => $_GET['deal'],
'SUBJECT' => "Тема",
'COMPLETED' => 'N',
'RESPONSIBLE_ID' => "ID отвественного",
'NOTIFY_TYPE' => \CCrmActivityNotifyType::Min,
'NOTIFY_VALUE' => 20,
'DESCRIPTION' => "Описание",
'START_TIME' => $_GET['datetime'],
'END_TIME' => $_GET['datetime'],
'PRIORITY' => CCrmActivityPriority::Medium,
'AUTHOR_ID' => $_GET['assigned'],
'ORIGIN_ID' => 'XYZ_1',
'DIRECTION' => CCrmActivityDirection::Outgoing,
'OWNER_ID' => $_GET['deal'],
'OWNER_TYPE_ID' => CCrmOwnerType::Deal,
);
$arComms = array(
array(
'ID' => 0,
'TYPE' => 'PHONE',
'VALUE' => $_GET['contactTel'],
'ENTITY_ID' => $_GET['deal'],
'ENTITY_TYPE_ID' => 'DEAL'
)
);
$ID = CCrmActivity::Add($arFieldsDelo, false, true, array('REGISTER_SONET_EVENT' => false));
if($ID > 0)
{
//сохраняем дело в календарь
CCrmActivity::SaveCommunications($ID, $arComms, $arFieldsDelo, true, false);
}
}