1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
affiliate_plan.php
См. документацию.
1
<?php
2
3
IncludeModuleLangFile
(__FILE__);
4
5
$GLOBALS
[
"SALE_AFFILIATE_PLAN"
] = Array();
6
7
class
CAllSaleAffiliatePlan
8
{
9
public
static
function
CheckFields
(
$ACTION
, &
$arFields
,
$ID
= 0)
10
{
12
global
$DB
;
13
14
if
((
is_set
(
$arFields
,
"SITE_ID"
) ||
$ACTION
==
"ADD"
) &&
$arFields
[
"SITE_ID"
] ==
''
)
15
{
16
$GLOBALS
[
"APPLICATION"
]->ThrowException(
GetMessage
(
"SCGAP1_NO_SITE"
),
"EMPTY_SITE_ID"
);
17
return
false
;
18
}
19
if
((
is_set
(
$arFields
,
"NAME"
) ||
$ACTION
==
"ADD"
) &&
$arFields
[
"NAME"
] ==
''
)
20
{
21
$GLOBALS
[
"APPLICATION"
]->ThrowException(
GetMessage
(
"SCGAP1_NO_NAME"
),
"EMPTY_NAME"
);
22
return
false
;
23
}
24
25
$ID
= intval(
$ID
);
26
$arPlan =
false
;
27
if
(
$ACTION
!=
"ADD"
)
28
{
29
if
(
$ID
<= 0)
30
{
31
$GLOBALS
[
"APPLICATION"
]->ThrowException(
GetMessage
(
"SCGAP1_ERROR_FUNC"
),
"FUNCTION_ERROR"
);
32
return
false
;
33
}
34
else
35
{
36
$arPlan =
CSaleAffiliatePlan::GetByID
(
$ID
);
37
if
(!$arPlan)
38
{
39
$GLOBALS
[
"APPLICATION"
]->ThrowException(str_replace(
"#ID#"
,
$ID
,
GetMessage
(
"SCGAP1_NO_PLAN"
)),
"NO_PLAN"
);
40
return
false
;
41
}
42
}
43
}
44
45
if
(
is_set
(
$arFields
,
"DESCRIPTION"
) &&
$arFields
[
"DESCRIPTION"
] ==
''
)
46
$arFields
[
"DESCRIPTION"
] =
false
;
47
48
if
((
is_set
(
$arFields
,
"ACTIVE"
) ||
$ACTION
==
"ADD"
) &&
$arFields
[
"ACTIVE"
] !=
"Y"
)
49
$arFields
[
"ACTIVE"
] =
"N"
;
50
51
if
(
is_set
(
$arFields
,
"BASE_RATE"
))
52
{
53
$arFields
[
"BASE_RATE"
] = str_replace(
","
,
"."
,
$arFields
[
"BASE_RATE"
]);
54
$arFields
[
"BASE_RATE"
] = DoubleVal(
$arFields
[
"BASE_RATE"
]);
55
}
56
57
if
(
is_set
(
$arFields
,
"MIN_PLAN_VALUE"
))
58
{
59
$arFields
[
"MIN_PLAN_VALUE"
] = str_replace(
","
,
"."
,
$arFields
[
"MIN_PLAN_VALUE"
]);
60
$arFields
[
"MIN_PLAN_VALUE"
] = DoubleVal(
$arFields
[
"MIN_PLAN_VALUE"
]);
61
if
(
$arFields
[
"MIN_PLAN_VALUE"
] <= 0)
62
$arFields
[
"MIN_PLAN_VALUE"
] =
false
;
63
}
64
65
if
((
is_set
(
$arFields
,
"BASE_RATE_TYPE"
) ||
$ACTION
==
"ADD"
) &&
$arFields
[
"BASE_RATE_TYPE"
] !=
"F"
)
66
$arFields
[
"BASE_RATE_TYPE"
] =
"P"
;
67
68
$affiliatePlanType = COption::GetOptionString(
"sale"
,
"affiliate_plan_type"
,
"N"
);
69
70
if
(
$ACTION
==
"ADD"
)
71
{
72
if
(
$arFields
[
"BASE_RATE_TYPE"
] ==
"P"
)
73
$arFields
[
"BASE_RATE_CURRENCY"
] =
false
;
74
75
if
(
$arFields
[
"BASE_RATE_TYPE"
] ==
"F"
&& (!
is_set
(
$arFields
,
"BASE_RATE_CURRENCY"
) ||
$arFields
[
"BASE_RATE_CURRENCY"
] ==
''
))
76
{
77
$GLOBALS
[
"APPLICATION"
]->ThrowException(
GetMessage
(
"SCGAP1_NO_CURRENCY"
),
"EMPTY_BASE_RATE_CURRENCY"
);
78
return
false
;
79
}
80
}
81
else
82
{
83
if
(!
is_set
(
$arFields
,
"BASE_RATE_TYPE"
))
84
$arFields
[
"BASE_RATE_TYPE"
] = $arPlan[
"BASE_RATE_TYPE"
];
85
86
if
(
$arFields
[
"BASE_RATE_TYPE"
] ==
"P"
)
87
{
88
$arFields
[
"BASE_RATE_CURRENCY"
] =
false
;
89
}
90
elseif
(
$arFields
[
"BASE_RATE_TYPE"
] ==
"F"
)
91
{
92
if
(!
is_set
(
$arFields
,
"BASE_RATE_CURRENCY"
))
93
$arFields
[
"BASE_RATE_CURRENCY"
] = $arPlan[
"BASE_RATE_CURRENCY"
];
94
95
if
(!
is_set
(
$arFields
,
"BASE_RATE_CURRENCY"
) ||
$arFields
[
"BASE_RATE_CURRENCY"
] ==
''
)
96
{
97
$GLOBALS
[
"APPLICATION"
]->ThrowException(
GetMessage
(
"SCGAP1_NO_CURRENCY"
),
"EMPTY_BASE_RATE_CURRENCY"
);
98
return
false
;
99
}
100
}
101
}
102
103
unset(
$arFields
[
'TIMESTAMP_X'
]);
104
$arFields
[
'~TIMESTAMP_X'
] =
$DB
->GetNowFunction();
105
106
return
True;
107
}
108
109
public
static
function
Delete
(
$ID
)
110
{
111
global
$DB
;
112
113
$ID
= intval(
$ID
);
114
if
(
$ID
<= 0)
115
return
False;
116
117
$db_events =
GetModuleEvents
(
"sale"
,
"OnBeforeAffiliatePlanDelete"
);
118
while
($arEvent = $db_events->Fetch())
119
if
(
ExecuteModuleEventEx
($arEvent, Array(
$ID
))===
false
)
120
121
$cnt =
CSaleAffiliate::GetList
(
array
(),
array
(
"PLAN_ID"
=>
$ID
),
array
());
122
if
(intval($cnt) > 0)
123
{
124
$GLOBALS
[
"APPLICATION"
]->ThrowException(str_replace(
"#ID#"
,
$ID
,
GetMessage
(
"SCGAP1_AFF_EXISTS"
)),
"NOT_EMPTY_PLAN"
);
125
return
false
;
126
}
127
128
unset(
$GLOBALS
[
"SALE_AFFILIATE_PLAN"
][
"SALE_AFFILIATE_PLAN_CACHE_"
.
$ID
]);
129
130
$DB
->Query(
"DELETE FROM b_sale_affiliate_plan_section WHERE PLAN_ID = "
.
$ID
.
" "
,
true
);
131
$bResult =
$DB
->Query(
"DELETE FROM b_sale_affiliate_plan WHERE ID = "
.
$ID
.
" "
,
true
);
132
133
$events =
GetModuleEvents
(
"sale"
,
"OnAfterAffiliatePlanDelete"
);
134
while
($arEvent = $events->Fetch())
135
ExecuteModuleEventEx
($arEvent, Array(
$ID
, $bResult));
136
137
return
$bResult;
138
}
139
140
public
static
function
GetByID
(
$ID
)
141
{
142
global
$DB
;
143
144
$ID
= intval(
$ID
);
145
if
(
$ID
<= 0)
146
return
false
;
147
148
if
(isset(
$GLOBALS
[
"SALE_AFFILIATE_PLAN"
][
"SALE_AFFILIATE_PLAN_CACHE_"
.
$ID
]) && is_array(
$GLOBALS
[
"SALE_AFFILIATE_PLAN"
][
"SALE_AFFILIATE_PLAN_CACHE_"
.
$ID
]))
149
{
150
return
$GLOBALS
[
"SALE_AFFILIATE_PLAN"
][
"SALE_AFFILIATE_PLAN_CACHE_"
.$ID];
151
}
152
else
153
{
154
$strSql =
155
"SELECT AP.ID, AP.SITE_ID, AP.NAME, AP.DESCRIPTION, AP.ACTIVE, AP.BASE_RATE, "
.
156
" AP.BASE_RATE_TYPE, AP.BASE_RATE_CURRENCY, AP.MIN_PAY, AP.MIN_PLAN_VALUE, "
.
157
" "
.$DB->DateToCharFunction(
"AP.TIMESTAMP_X"
,
"FULL"
).
" as TIMESTAMP_X "
.
158
"FROM b_sale_affiliate_plan AP "
.
159
"WHERE AP.ID = "
.$ID.
" "
;
160
161
$db_res
=
$DB
->Query($strSql);
162
if
(
$res
=
$db_res
->Fetch())
163
{
164
$GLOBALS
[
"SALE_AFFILIATE_PLAN"
][
"SALE_AFFILIATE_PLAN_CACHE_"
.$ID] =
$res
;
165
return
$GLOBALS
[
"SALE_AFFILIATE_PLAN"
][
"SALE_AFFILIATE_PLAN_CACHE_"
.$ID];
166
}
167
}
168
169
return
false
;
170
}
171
172
public
static
function
CheckAffiliatePlanFunc
($affiliatePlan)
173
{
174
if
(is_array($affiliatePlan))
175
{
176
$arAffiliatePlan = $affiliatePlan;
177
$affiliatePlanID = intval($arAffiliatePlan[
"ID"
]);
178
179
if
($affiliatePlanID <= 0)
180
{
181
$GLOBALS
[
"APPLICATION"
]->ThrowException(
GetMessage
(
"SCGAP1_ERROR_FUNC"
),
"FUNCTION_ERROR"
);
182
return
false
;
183
}
184
}
185
else
186
{
187
$affiliatePlanID = intval($affiliatePlan);
188
if
($affiliatePlanID <= 0)
189
return
False;
190
191
$dbAffiliatePlan =
CSaleAffiliatePlan::GetList
(
192
array
(),
193
array
(
"ID"
=> $affiliatePlanID,
"ACTIVE"
=>
"Y"
),
194
false
,
195
false
,
196
array
(
"ID"
,
"SITE_ID"
,
"NAME"
,
"DESCRIPTION"
,
"TIMESTAMP_X"
,
"ACTIVE"
,
"BASE_RATE"
,
"BASE_RATE_TYPE"
,
"BASE_RATE_CURRENCY"
,
"MIN_PAY"
,
"MIN_PLAN_VALUE"
)
197
);
198
$arAffiliatePlan = $dbAffiliatePlan->Fetch();
199
if
(!$arAffiliatePlan)
200
{
201
$GLOBALS
[
"APPLICATION"
]->ThrowException(str_replace(
"#ID#"
, $affiliatePlanID,
GetMessage
(
"SCGAP1_NO_PLAN"
)),
"NO_AFFILIATE_PLAN"
);
202
return
false
;
203
}
204
}
205
206
return
$arAffiliatePlan;
207
}
208
}
$db_res
$db_res
Определения
options_user_settings.php:8
CAllSaleAffiliatePlan
Определения
affiliate_plan.php:8
CAllSaleAffiliatePlan\Delete
static Delete($ID)
Определения
affiliate_plan.php:109
CAllSaleAffiliatePlan\CheckAffiliatePlanFunc
static CheckAffiliatePlanFunc($affiliatePlan)
Определения
affiliate_plan.php:172
CAllSaleAffiliatePlan\GetByID
static GetByID($ID)
Определения
affiliate_plan.php:140
CAllSaleAffiliatePlan\CheckFields
static CheckFields($ACTION, &$arFields, $ID=0)
Определения
affiliate_plan.php:9
CSaleAffiliate\GetList
static GetList($arOrder=array(), $arFilter=array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array())
Определения
affiliate.php:9
CSaleAffiliatePlan\GetList
static GetList($arOrder=array(), $arFilter=array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array())
Определения
affiliate_plan.php:9
$arFields
$arFields
Определения
dblapprove.php:5
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$res
$res
Определения
filter_act.php:7
$GLOBALS
$GLOBALS["SALE_AFFILIATE_PLAN"]
Определения
affiliate_plan.php:5
$ID
if($ajaxMode) $ID
Определения
get_user.php:27
$DB
global $DB
Определения
cron_frame.php:29
$ACTION
$ACTION
Определения
csv_new_setup.php:27
ExecuteModuleEventEx
ExecuteModuleEventEx($arEvent, $arParams=[])
Определения
tools.php:5214
GetModuleEvents
GetModuleEvents($MODULE_ID, $MESSAGE_ID, $bReturnArray=false)
Определения
tools.php:5177
IncludeModuleLangFile
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения
tools.php:3778
is_set
is_set($a, $k=false)
Определения
tools.php:2133
GetMessage
GetMessage($name, $aReplace=null)
Определения
tools.php:3397
elseif
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения
prolog_main_admin.php:393
$GLOBALS
$GLOBALS['_____370096793']
Определения
update_client.php:1
bitrix
modules
sale
general
affiliate_plan.php
Создано системой
1.14.0