1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
order_user_props.php
См. документацию.
1<?php
2
4
6{
7 /*
8 public static function TranslateLocationPropertyValues($personTypeId, &$orderProps)
9 {
10 if(CSaleLocation::isLocationProMigrated())
11 {
12 // location ID to CODE
13 $dbOrderProps = CSaleOrderProps::GetList(
14 array("SORT" => "ASC"),
15 array(
16 'PERSON_TYPE_ID' => $personTypeId
17 ),
18 false,
19 false,
20 array("ID", "NAME", "TYPE", "IS_LOCATION", "IS_LOCATION4TAX", "IS_PROFILE_NAME", "IS_PAYER", "IS_EMAIL", "REQUIED", "SORT", "IS_ZIP", "CODE", "MULTIPLE")
21 );
22 while($item = $dbOrderProps->fetch())
23 {
24 if($item['TYPE'] == 'LOCATION' && strlen($orderProps[$item['ID']]))
25 $orderProps[$item['ID']] = CSaleLocation::getLocationCodeByID($orderProps[$item['ID']]);
26 }
27 }
28 }
29 */
30
41 public static function DoSaveUserProfile($userId, $profileId, $profileName, $personTypeId, $orderProps, &$arErrors)
42 {
43 $profileId = intval($profileId);
44
45 $arIDs = array();
46 if ($profileId > 0)
47 {
49 array(),
50 array("ID" => $profileId),
51 false,
52 false,
53 array("ID", "NAME", "USER_ID", "PERSON_TYPE_ID")
54 );
55 $arProfile = $dbProfile->Fetch();
56 if (!$arProfile)
57 {
58 $arErrors[] = array("CODE" => "PROFILE_NOT_FOUND", "TEXT" => GetMessage('SKGOUP_PROFILE_NOT_FOUND'));
59 return false;
60 }
61 if ($arProfile["USER_ID"] != $userId || $arProfile["PERSON_TYPE_ID"] != $personTypeId)
62 {
63 $arErrors[] = array("CODE" => "PARAM", "TEXT" => GetMessage('SKGOUP_PARRAMS_ERROR'));
64 return false;
65 }
66
67 //if (strlen($profileName) > 0 && $profileName != $arProfile["NAME"])
68 if ($profileName <> '')
69 {
70 $arFields = array("NAME" => $profileName, "USER_ID" => $userId);
72 }
73
74 $dbUserPropsValues = CSaleOrderUserPropsValue::GetList(
75 array(),
76 array("USER_PROPS_ID" => $profileId),
77 false,
78 false,
79 array("ID", "ORDER_PROPS_ID")
80 );
81 while ($arUserPropsValue = $dbUserPropsValues->Fetch())
82 $arIDs[$arUserPropsValue["ORDER_PROPS_ID"]] = $arUserPropsValue["ID"];
83 }
84
85 if (!is_array($orderProps) && (int)$orderProps > 0)
86 {
87 $dbOrderPropsValues = CSaleOrderPropsValue::GetList(
88 array(),
89 array("ORDER_ID" => intval($orderProps)),
90 false,
91 false,
92 array("ORDER_PROPS_ID", "VALUE")
93 );
94 $orderProps = array();
95 while ($arOrderPropsValue = $dbOrderPropsValues->Fetch())
96 $orderProps[$arOrderPropsValue["ORDER_PROPS_ID"]] = $arOrderPropsValue["VALUE"];
97 }
98
99 if (empty($orderProps))
100 {
104 return $profileId;
105 }
106
107 $dbOrderProperties = CSaleOrderProps::GetList(
108 array(),
109 array("PERSON_TYPE_ID" => $personTypeId, "ACTIVE" => "Y", "USER_PROPS" => "Y"),
110 false,
111 false,
112 array("ID", "TYPE", "NAME", "CODE", "UTIL", "MULTIPLE")
113 );
114 while ($arOrderProperty = $dbOrderProperties->Fetch())
115 {
116 if (isset($orderProps[$arOrderProperty["ID"]]))
117 {
118 $curVal = $orderProps[$arOrderProperty["ID"]];
119 }
120
121 if (
122 (
123 $arOrderProperty["TYPE"] === "MULTISELECT"
124 || $arOrderProperty["TYPE"] === "SELECT"
125 )
126 && is_array($curVal)
127 )
128 {
129 $curVal = implode(",", $curVal);
130 }
131
132 if (($arOrderProperty["TYPE"] === "FILE") && is_array($curVal))
133 {
134 $fileList = array();
135
136 foreach ($curVal as $fileDat)
137 {
138 if (!empty($fileDat['ID']))
139 {
140 $fileList[] = $fileDat['ID'];
141 }
142 }
143
144 $curVal = serialize($fileList);
145 }
146
147 if ($arOrderProperty["MULTIPLE"] === "Y" && is_array($curVal))
148 {
149 $curVal = serialize($curVal);
150 }
151
152 if (isset($curVal))
153 {
154 if ($profileId <= 0)
155 {
156 if ($profileName == '')
157 $profileName = GetMessage("SOA_PROFILE")." ".Date("Y-m-d");
158
160 "NAME" => $profileName,
161 "USER_ID" => $userId,
162 "PERSON_TYPE_ID" => $personTypeId
163 );
165 if (!$profileId)
166 {
167 $arErrors[] = array("CODE" => "PROFILE_CREATE_ERROR", "TEXT" => GetMessage('SKGOUP_PROFILE_CREATE_ERROR'));
168 return false;
169 }
170 }
171
172 if (array_key_exists($arOrderProperty["ID"], $arIDs))
173 {
174 $arFields = Array(
175 "NAME" => $arOrderProperty["NAME"],
176 "VALUE" => $curVal
177 );
178 CSaleOrderUserPropsValue::Update($arIDs[$arOrderProperty["ID"]], $arFields);
179 unset($arIDs[$arOrderProperty["ID"]]);
180 }
181 else
182 {
184 "USER_PROPS_ID" => $profileId,
185 "ORDER_PROPS_ID" => $arOrderProperty["ID"],
186 "NAME" => $arOrderProperty["NAME"],
187 "VALUE" => $curVal
188 );
190 }
191 }
192 unset($curVal);
193 }
194
195 return $profileId;
196 }
197
198 public static function DoLoadProfiles($userId, $personTypeId = null)
199 {
200 $userId = intval($userId);
201
202 if ($userId <= 0)
203 return null;
204
205 $arResult = array();
206 $arFilter = array("USER_ID" => $userId);
207
208 if ($personTypeId != null)
209 $arFilter["PERSON_TYPE_ID"] = $personTypeId;
210
211 $dbProfile = CSaleOrderUserProps::GetList(
212 array("DATE_UPDATE" => "DESC", "NAME" => "ASC"),
213 $arFilter,
214 false,
215 false,
216 array("ID", "NAME", "PERSON_TYPE_ID", "DATE_UPDATE")
217 );
218
219 while ($arProfile = $dbProfile->GetNext())
220 {
221 if (!array_key_exists($arProfile["PERSON_TYPE_ID"], $arResult))
222 $arResult[$arProfile["PERSON_TYPE_ID"]] = array();
223
224 $arResult[$arProfile["PERSON_TYPE_ID"]][$arProfile["ID"]] = array("NAME" => $arProfile["NAME"], "VALUES" => array(), "VALUES_ORIG" => array());
225
227 array(),
228 array("USER_PROPS_ID" => $arProfile["ID"]),
229 false,
230 false,
231 array("ORDER_PROPS_ID", "NAME", "VALUE", "VALUE_ORIG")
232 );
233 while ($arProps = $dbProps->GetNext())
234 {
235 $arResult[$arProfile["PERSON_TYPE_ID"]][$arProfile["ID"]]["VALUES"][$arProps["ORDER_PROPS_ID"]] = $arProps["VALUE"];
236
237 if(isset($arProps["VALUE_ORIG"]))
238 $arResult[$arProfile["PERSON_TYPE_ID"]][$arProfile["ID"]]["VALUES_ORIG"][$arProps["ORDER_PROPS_ID"]] = $arProps["VALUE_ORIG"];
239 }
240 }
241
242 if (count($arResult) > 0)
243 {
244 if ($personTypeId != null)
245 $arResult = $arResult[$personTypeId];
246 }
247
248 return $arResult;
249 }
250
251 public static function GetByID($ID)
252 {
253 global $DB;
254
255 $ID = intval($ID);
256 $strSql =
257 "SELECT * ".
258 "FROM b_sale_user_props ".
259 "WHERE ID = ".$ID."";
260 $db_res = $DB->Query($strSql);
261
262 if ($res = $db_res->Fetch())
263 {
264 return $res;
265 }
266 return False;
267 }
268
269 public static function CheckFields($ACTION, &$arFields, $ID = 0)
270 {
271 global $DB, $USER;
272
273 if ((is_set($arFields, "PERSON_TYPE_ID") || $ACTION=="ADD") && intval($arFields["PERSON_TYPE_ID"])<=0)
274 {
275 $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGOUP_EMPTY_PERS_TYPE"), "ERROR_NO_PERSON_TYPE_ID");
276 return false;
277 }
278
279 if (false && !$USER->IsAuthorized())
280 {
281 $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGOUP_UNAUTH"), "ERROR_NO_AUTH");
282 return false;
283 }
284
285 if (!is_set($arFields, "USER_ID"))
286 $arFields["USER_ID"] = intval($USER->GetID());
287
288 if ((is_set($arFields, "USER_ID") || $ACTION=="ADD") && intval($arFields["USER_ID"]) <= 0)
289 {
290 $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGOUP_NO_USER_ID"), "ERROR_NO_PERSON_TYPE_ID");
291 return false;
292 }
293
294 return True;
295 }
296
297 public static function Update($ID, $arFields)
298 {
299 global $DB;
300
301 $ID = intval($ID);
303 return false;
304
305 $strUpdate = $DB->PrepareUpdate("b_sale_user_props", $arFields);
306
307 $strSql =
308 "UPDATE b_sale_user_props SET ".
309 " ".$strUpdate.", ".
310 " DATE_UPDATE = ".$DB->GetNowFunction()." ".
311 "WHERE ID = ".$ID." ";
312 $DB->Query($strSql);
313
314 return $ID;
315 }
316
317 public static function ClearEmpty()
318 {
319 global $DB;
320 $strSql =
321 "SELECT UP.ID ".
322 "FROM b_sale_user_props UP ".
323 " LEFT JOIN b_sale_user_props_value UPV ON (UP.ID = UPV.USER_PROPS_ID) ".
324 "WHERE UPV.ID IS NULL ";
325 $db_res = $DB->Query($strSql);
326 while ($res = $db_res->Fetch())
327 {
328 $DB->Query("DELETE FROM b_sale_user_props WHERE ID = ".$res["ID"]."");
329 }
330 }
331
332 public static function Delete($ID)
333 {
334 global $DB;
335 $ID = intval($ID);
336 $DB->Query("DELETE FROM b_sale_user_props_value WHERE USER_PROPS_ID = ".$ID."", true);
337 return $DB->Query("DELETE FROM b_sale_user_props WHERE ID = ".$ID."", true);
338 }
339
340 public static function OnUserDelete($ID)
341 {
342 $ID = intval($ID);
343 $db_res = CSaleOrderUserProps::GetList(($b="ID"), ($o="ASC"), Array("USER_ID"=>$ID));
344 while ($ar_res = $db_res->Fetch())
345 {
347 }
348 return True;
349 }
350}
$db_res
Определения options_user_settings.php:8
$ar_res
Определения options_user_settings_set.php:16
$arResult
Определения generate_coupon.php:16
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static GetList($arOrder=array(), $arFilter=array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array())
Определения order_props_values.php:12
static Delete($ID)
Определения order_user_props.php:332
static ClearEmpty()
Определения order_user_props.php:317
static GetByID($ID)
Определения order_user_props.php:251
static OnUserDelete($ID)
Определения order_user_props.php:340
static CheckFields($ACTION, &$arFields, $ID=0)
Определения order_user_props.php:269
static DoLoadProfiles($userId, $personTypeId=null)
Определения order_user_props.php:198
static DoSaveUserProfile($userId, $profileId, $profileName, $personTypeId, $orderProps, &$arErrors)
Определения order_user_props.php:41
static Update($ID, $arFields)
Определения order_user_props.php:297
static Update($ID, $arFields)
Определения order_user_props_value.php:51
static GetList($arOrder=array(), $arFilter=array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array())
Определения order_props.php:410
static Add($arFields)
Определения order_user_props.php:132
static GetList($arOrder=array(), $arFilter=array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array())
Определения order_user_props.php:7
static Add($arFields)
Определения order_user_props_value.php:178
static GetList($arOrder=array(), $arFilter=array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array())
Определения order_user_props_value.php:7
$arFields
Определения dblapprove.php:5
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$res
Определения filter_act.php:7
if($ajaxMode) $ID
Определения get_user.php:27
global $DB
Определения cron_frame.php:29
global $USER
Определения csv_new_run.php:40
$ACTION
Определения csv_new_setup.php:27
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения tools.php:3778
is_set($a, $k=false)
Определения tools.php:2133
GetMessage($name, $aReplace=null)
Определения tools.php:3397
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
$GLOBALS['_____370096793']
Определения update_client.php:1
$arFilter
Определения user_search.php:106