test

 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
60
61
62
63
64
65
66
<?
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 "Модуль не установлен! ";
//$user = CUser::GetByID($arFields['ID']);
static function getUserBonus($USER_ID)
{
$aRes = array();
$el_but = CIBlockElement::GetList(array("ID"=>"DESC"), array("IBLOCK_ID"=>User::getIBlockIDByCode("BALANCE_OPERATIONS"), "=PROPERTY_TO_USER_ID_OR_PRODUCT_LIST"=>$USER_ID, "=PROPERTY_TYPE"=>"BONUS"), false, false,
array("ID", "ACTIVE_FROM","PROPERTY_TYPE", "PROPERTY_DATE", "PROPERTY_SUM", "PROPERTY_USER_ID_OR_DEAL_ID", "PROPERTY_TO_USER_ID_OR_PRODUCT_LIST"));
while($al = $el_but->Fetch())
{
if($al["PROPERTY_TO_USER_ID_OR_PRODUCT_LIST_VALUE"] == $USER_ID)
{
$el = CIBlockElement::GetList(array(), array("IBLOCK_ID"=> User::getIBlockIDByCode("DEALS"), "ID"=> $al["PROPERTY_USER_ID_OR_DEAL_ID_VALUE"] ),
array("PROPERTY_PRODUCT_LIST", "PROPERTY_USER_ID"));
if ($zl = $el->Fetch())
{
$p = CCrmProduct::GetByID($zl["PROPERTY_PRODUCT_LIST_VALUE"]);
$rsUser = CUser::GetByID($zl["PROPERTY_USER_ID_VALUE"]);
$arRes = $rsUser->Fetch();
$TITLE = GetMessage(ToUpper("TYPE_".$al["PROPERTY_TYPE_VALUE"]));
$TYPE = '<a href="/riter/transactions/?ID='.Transaction::getParrentTransaction($al['PROPERTY_USER_ID_OR_DEAL_ID_VALUE']).'">'.$TITLE.'</a>';
$name = $arRes["NAME"]." ".$arRes["LAST_NAME"];//FROM
$SUM = "<font style='float: top; color:green'>".number_format($al["PROPERTY_SUM_VALUE"], 2, '.', ' ')."</font>";//SUMM
$SELLER = "<a href='/company/personal/user/".$arRes['ID']."/'>".$name."</a>";//PURCHASED
//get product price
$el_but = CIBlockElement::GetList(array("ID"=>"DESC"), array("IBLOCK_ID"=>User::getIBlockIDByCode("BALANCE_OPERATIONS"), "=PROPERTY_USER_ID_OR_DEAL_ID"=>$al['PROPERTY_USER_ID_OR_DEAL_ID_VALUE'], "=PROPERTY_TYPE"=>"purchase" ), false, false,
array("ID", "PROPERTY_SUM"));
$res = $el_but->Fetch();
$PRICE = $res['PROPERTY_SUM_VALUE']
//
$user = CUser::GetByID($GLOBALS['USER']->GetID());
$arUser = $user->Fetch();
$myName = $arUser["NAME"]." ".$arUser["LAST_NAME"]; // user name with "TO"
$TO = "<a href='/company/personal/user/".$arUser['ID']."/'>".$myName."</a>";//PURCHASED
$aRes[] = array("ID" => $al["ID"], "TYPE" =>$TYPE, "SUM" =>$SUM, "SELLER"=>$SELLER, "COST" => $PRICE, "FROM" => $SELLER,"TO"=>$TO ,"DATE"=> $al['ACTIVE_FROM'], "PRODUCT" => $p['NAME'], "RES" => $al);
}
}
}
return $aRes;
}