update user birtday in crm

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
CModule::IncludeModule('nbsriter');
CModule::IncludeModule('nbs_extended_api');
CModule::IncludeModule('nbs_ad_campaing');
if(!CModule::IncludeModule("refcode"))
exit ("Ref code");
if(!CModule::IncludeModule("nbs_crm_sync"))
echo "Модуль не установлен! ";
$rsUsers = CUser::GetList(($by="id"), ($order="asc"), array("ID"=>640)); // выбираем пользователей
while($arFields = $rsUsers->GetNext())
{
$el = CIBlockElement::GetList(array("ID"=>"DESC"), array( "IBLOCK_ID" => NBSExtendedAPI::getIBlockIDByCode("USERS","NBS_RITER"),
"PROPERTY_USER_ID"=> $arFields['ID'] ), false, false, array("ID","PROPERTY_CRM_CONTACT_ID"));
$isUserHaveCRMID = $el->Fetch();
if( $isUserHaveCRMID['PROPERTY_CRM_CONTACT_ID_VALUE'] != NULL )
{
if ($arFields['ID'] != 1)
{
$arParams = array("UF_CRM_1399725119" => $arFields['PERSONAL_BIRTHDAY']);
$CCrmContact = new CCrmContact(false);
$CCrmContact->Update( $isUserHaveCRMID['PROPERTY_CRM_CONTACT_ID_VALUE'], $arParams );
}
}
}