for Katya

 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?
CModule::IncludeModule('nbsriter');
CModule::IncludeModule('nbs_extended_api');
CModule::IncludeModule('nbs_ad_campaign');
if(!CModule::IncludeModule("refcode"))
exit ("Ref code");
if(!CModule::IncludeModule("nbs_crm_sync"))
echo "Модуль не установлен! ";
$rsUsers = CUser::GetList(($by="id"), ($order="asc"), array()); // выбираем пользователей
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)
{
$acampID = ACampUser::isUserRegistered($arFields['ID']);
if($acampID)
{
$acamp = ACamp::getACapmDataByID($acampID);
echo cryptRefCode($acamp[0]['SOURCE_TYPE'],$acamp[0]['SOURCE_ID'])."-".$acamp[0]['ADVERSTING_ID']."<br/>";
}
else
{
$parent = User::getParentID ($arFields['ID']); // получаем парента нового юзера
}
if($parent['TYPE'] == "L")
{
$users = UserInLink::getAllUserInLink(73663);
$assigned = $users[rand(0, count($users)-1)] ;
}
elseif ($parent['TYPE'] == "U") {
$assigned = $parent['ID'];
}
var_dump ("USER ID".$arFields['ID']."<br/>");
var_dump ("PARENT ID".$parent['ID']."<br/>");
var_dump (cryptRefCode($parent['TYPE'], $parent['ID'])."<br/>");
if ($arFields['ID'] == 2000)
exit;
//$arParams = array( "ASSIGNED_BY_ID" => $assigned, "SOURCE_ID" => UserCRM::getSourceIDByFromID(User::getRegistrationSource($arFields['ID'])) );
//$CCrmContact = new CCrmContact(false);
// $CCrmContact->Update( $isUserHaveCRMID['PROPERTY_CRM_CONTACT_ID_VALUE'], $arParams );
}
}
}
NBSExtendedAPI::xvardump("User imported in CRM =)");