1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
user.php
См. документацию.
1<?php
2
4
6$GLOBALS["SALE_USER_ACCOUNT"] = array();
7
8/***********************************************************************/
9/*********** CSaleUserAccount ****************************************/
10/***********************************************************************/
12{
13 public static function DoPayOrderFromAccount($userId, $currency, $orderId, $orderSum, $arOptions, &$arErrors)
14 {
15 if (!array_key_exists("ONLY_FULL_PAY_FROM_ACCOUNT", $arOptions))
16 $arOptions["ONLY_FULL_PAY_FROM_ACCOUNT"] = COption::GetOptionString("sale", "ONLY_FULL_PAY_FROM_ACCOUNT", "N");
17
18 $dbUserAccount = CSaleUserAccount::GetList(
19 array(),
20 array(
21 "USER_ID" => $userId,
22 "CURRENCY" => $currency,
23 )
24 );
25 $arUserAccount = $dbUserAccount->Fetch();
26
27 if (!$arUserAccount)
28 return false;
29 if ($arUserAccount["CURRENT_BUDGET"] <= 0)
30 return false;
31 if (($arOptions["ONLY_FULL_PAY_FROM_ACCOUNT"] == "Y") && (doubleval($arUserAccount["CURRENT_BUDGET"]) < doubleval($orderSum)))
32 return false;
33
34 $withdrawSum = CSaleUserAccount::Withdraw(
35 $userId,
36 $orderSum,
39 );
40
41 if ($withdrawSum > 0)
42 {
44 "SUM_PAID" => $withdrawSum,
45 "USER_ID" => $userId
46 );
47
49 if ($withdrawSum == $orderSum)
50 CSaleOrder::PayOrder($orderId, "Y", False, False);
51
52 return true;
53 }
54
55 return false;
56 }
57
58 //********** ADD, UPDATE, DELETE **************//
59 public static function CheckFields($ACTION, &$arFields, $ID = 0)
60 {
61 if ((is_set($arFields, "USER_ID") || $ACTION=="ADD") && intval($arFields["USER_ID"]) <= 0)
62 {
63 $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGU_EMPTY_USER_ID"), "EMPTY_USER_ID");
64 return false;
65 }
66 if ((is_set($arFields, "CURRENCY") || $ACTION=="ADD") && $arFields["CURRENCY"] == '')
67 {
68 $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGU_EMPTY_CURRENCY"), "EMPTY_CURRENCY");
69 return false;
70 }
71
72 if (is_set($arFields, "CURRENT_BUDGET") || $ACTION=="ADD")
73 {
74 $arFields["CURRENT_BUDGET"] = str_replace(",", ".", $arFields["CURRENT_BUDGET"]);
75 $arFields["CURRENT_BUDGET"] = doubleval($arFields["CURRENT_BUDGET"]);
76 }
77
78 if ((is_set($arFields, "LOCKED") || $ACTION=="ADD") && $arFields["LOCKED"] != "Y")
79 $arFields["LOCKED"] = "N";
80
81 if (is_set($arFields, "USER_ID"))
82 {
83 $dbUser = CUser::GetByID($arFields["USER_ID"]);
84 if (!$dbUser->Fetch())
85 {
86 $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["USER_ID"], GetMessage("SKGU_NO_USER")), "ERROR_NO_USER_ID");
87 return false;
88 }
89 }
90
91 return true;
92 }
93
94 public static function Delete($ID)
95 {
96 global $DB;
97
98 $ID = (int)$ID;
99 if ($ID <= 0)
100 return False;
101
102 foreach (GetModuleEvents('sale', 'OnBeforeUserAccountDelete', true) as $arEvent)
103 {
104 if (ExecuteModuleEventEx($arEvent, array($ID))===false)
105 {
106 return false;
107 }
108 }
109
110 $arOldUserAccount = CSaleUserAccount::GetByID($ID);
111
113 array(),
114 array("USER_ID" => $arOldUserAccount["USER_ID"], "CURRENCY" => $arOldUserAccount["CURRENCY"]),
115 false,
116 false,
117 array("ID", "USER_ID")
118 );
119 while($arTrans = $dbTrans -> Fetch())
120 CSaleUserTransact::Delete($arTrans["ID"]);
121
122 unset($GLOBALS["SALE_USER_ACCOUNT"]["SALE_USER_ACCOUNT_CACHE_".$ID]);
123 unset($GLOBALS["SALE_USER_ACCOUNT"]["SALE_USER_ACCOUNT_CACHE_".$arOldUserAccount["USER_ID"]."_".$arOldUserAccount["CURRENCY"]]);
124
125 $res = $DB->Query("DELETE FROM b_sale_user_account WHERE ID = ".$ID." ", true);
126
127 foreach (GetModuleEvents('sale', 'OnAfterUserAccountDelete', true) as $arEvent)
128 {
129 ExecuteModuleEventEx($arEvent, Array($ID));
130 }
131
132 return $res;
133 }
134
135 //********** LOCK **************//
136 public static function Lock($userID, $payCurrency)
137 {
138 global $DB, $APPLICATION;
139
140 $userID = (int)$userID;
141 if ($userID <= 0)
142 return false;
143
144 $payCurrency = trim($payCurrency);
145 if ($payCurrency == '')
146 return false;
147
148 CTimeZone::Disable();
149 $dbUserAccount = CSaleUserAccount::GetList(
150 array(),
151 array("USER_ID" => $userID, "CURRENCY" => $payCurrency),
152 false,
153 false,
154 array("ID", "LOCKED", "DATE_LOCKED")
155 );
156 CTimeZone::Enable();
157 if ($arUserAccount = $dbUserAccount->Fetch())
158 {
159 $dateLocked = 0;
160 if ($arUserAccount["LOCKED"] == "Y")
161 {
162 if (!($dateLocked = MakeTimeStamp($arUserAccount["DATE_LOCKED"], CSite::GetDateFormat("FULL", SITE_ID))))
163 $dateLocked = mktime(0, 0, 0, 1, 1, 1990);
164 }
165
166 if (defined("SALE_TIME_LOCK_USER") && intval(SALE_TIME_LOCK_USER) > 0)
167 $timeLockUser = intval(SALE_TIME_LOCK_USER);
168 else
169 $timeLockUser = 10 * 60;
170
171 if (($arUserAccount["LOCKED"] != "Y")
172 || (($arUserAccount["LOCKED"] == "Y") && ((time() - $dateLocked) > $timeLockUser)))
173 {
175 "LOCKED" => "Y",
176 "=DATE_LOCKED" => $DB->GetNowFunction()
177 );
178 if (CSaleUserAccount::Update($arUserAccount["ID"], $arFields))
179 return true;
180 else
181 return false;
182 }
183 else
184 {
185 $APPLICATION->ThrowException(GetMessage("SKGU_ACCOUNT_LOCKED"), "ACCOUNT_LOCKED");
186 return false;
187 }
188 }
189 else
190 {
192 "USER_ID" => $userID,
193 "CURRENT_BUDGET" => 0.0,
194 "CURRENCY" => $payCurrency,
195 "LOCKED" => "Y",
196 "=TIMESTAMP_X" => $DB->GetNowFunction(),
197 "=DATE_LOCKED" => $DB->GetNowFunction()
198 );
200 return true;
201 else
202 return false;
203 }
204 }
205
206 public static function UnLock($userID, $payCurrency)
207 {
208 $userID = (int)$userID;
209 if ($userID <= 0)
210 return false;
211
212 $payCurrency = trim($payCurrency);
213 if ($payCurrency == '')
214 return false;
215
216 CTimeZone::Disable();
217 $dbUserAccount = CSaleUserAccount::GetList(
218 array(),
219 array("USER_ID" => $userID, "CURRENCY" => $payCurrency),
220 false,
221 false,
222 array("ID", "LOCKED", "DATE_LOCKED")
223 );
224 CTimeZone::Enable();
225 if ($arUserAccount = $dbUserAccount->Fetch())
226 {
227 if ($arUserAccount["LOCKED"] == "Y")
228 {
230 "LOCKED" => "N",
231 "DATE_LOCKED" => false
232 );
233 if (CSaleUserAccount::Update($arUserAccount["ID"], $arFields))
234 {
235 return true;
236 }
237 else
238 {
239 return false;
240 }
241 }
242 else
243 {
244 return true;
245 }
246 }
247 else
248 {
250 "USER_ID" => $userID,
251 "CURRENT_BUDGET" => 0.0,
252 "CURRENCY" => $payCurrency,
253 "LOCKED" => "N",
254 "DATE_LOCKED" => false
255 );
257 return true;
258 else
259 return false;
260 }
261 }
262
263 public static function UnLockByID($ID)
264 {
265 global $APPLICATION;
266
267 $ID = (int)$ID;
268 if ($ID <= 0)
269 return false;
270
271 if ($arUserAccount = CSaleUserAccount::GetByID($ID))
272 {
273 if ($arUserAccount["LOCKED"] == "Y")
274 {
276 "LOCKED" => "N",
277 "DATE_LOCKED" => false
278 );
279 if (CSaleUserAccount::Update($arUserAccount["ID"], $arFields))
280 return true;
281 else
282 return false;
283 }
284 else
285 {
286 return true;
287 }
288 }
289 else
290 {
291 $APPLICATION->ThrowException(GetMessage("SKGU_NO_ACCOUNT"), "NO_ACCOUNT");
292 return false;
293 }
294 }
295
296 //********** ACTIONS **************//
297
298 // Pay money from the local user account. Increase the local user account if necessary.
299 // $userID - ID of the user
300 // $paySum - payment sum
301 // $payCurrency - currency
302 // $orderID - ID of order (if known)
303 // $useCC - increase the local user account from credit card if necessary (default - True)
304 // Return True if the necessary sum withdraw from an account or False in other way
305 public static function Pay($userID, $paySum, $payCurrency, $orderID = 0, $useCC = true, $paymentId = null)
306 {
307 global $DB, $APPLICATION, $USER;
308
309 $errorCode = "";
310
311 $userID = (int)$userID;
312 if ($userID <= 0)
313 {
314 $APPLICATION->ThrowException(GetMessage("SKGU_EMPTY_USER_ID"), "EMPTY_USER_ID");
315 return false;
316 }
317
318 $paySum = str_replace(",", ".", $paySum);
319 $paySum = (float)$paySum;
320 if ($paySum <= 0)
321 {
322 $APPLICATION->ThrowException(GetMessage("SKGU_EMPTY_SUM"), "EMPTY_SUM");
323 return false;
324 }
325
326 $payCurrency = trim($payCurrency);
327 if ($payCurrency == '')
328 {
329 $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGU_EMPTY_CURRENCY"), "EMPTY_CURRENCY");
330 return false;
331 }
332
333 $orderID = (int)$orderID;
334 $paymentId = (int)$paymentId;
335
336 $useCC = ($useCC ? true : false);
337
338 if (!CSaleUserAccount::Lock($userID, $payCurrency))
339 {
340 $APPLICATION->ThrowException(GetMessage("SKGU_ERROR_LOCK"), "ACCOUNT_NOT_LOCKED");
341 return false;
342 }
343
344 $currentBudget = 0.0;
345
346 // Check current user account budget
347 $dbUserAccount = CSaleUserAccount::GetList(
348 array(),
349 array("USER_ID" => $userID, "CURRENCY" => $payCurrency)
350 );
351 if ($arUserAccount = $dbUserAccount->Fetch())
352 $currentBudget = roundEx((float)$arUserAccount["CURRENT_BUDGET"], SALE_VALUE_PRECISION);
353
354 $withdrawSum = 0;
355 if (($currentBudget < $paySum) && $useCC)
356 {
357 $payOverdraft = $paySum - $currentBudget;
358
359 // Try to get money from credit cards
360 $bPayed = false;
361 $dbUserCards = CSaleUserCards::GetList(
362 array("SORT" => "ASC"),
363 array("USER_ID" => $userID, "CURRENCY" => $payCurrency, "ACTIVE" => "Y")
364 );
365 while ($arUserCard = $dbUserCards->Fetch())
366 {
367 if ($withdrawSum = CSaleUserCards::Withdraw($payOverdraft, $payCurrency, $arUserCard, $orderID))
368 {
369 $bPayed = true;
370 break;
371 }
372 }
373
374 if (!$bPayed)
375 {
376 $dbUserCards = CSaleUserCards::GetList(
377 array("SORT" => "ASC"),
378 array("USER_ID" => $userID, "CURRENCY" => "", "ACTIVE" => "Y")
379 );
380 while ($arUserCard = $dbUserCards->Fetch())
381 {
382 if ($withdrawSum = CSaleUserCards::Withdraw($payOverdraft, $payCurrency, $arUserCard, $orderID))
383 {
384 $bPayed = true;
385 break;
386 }
387 }
388 }
389
390 if ($bPayed)
391 {
393 "USER_ID" => $userID,
394 "=TIMESTAMP_X" => $DB->GetNowFunction(),
395 "TRANSACT_DATE" => date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL", SITE_ID))),
396 "AMOUNT" => $withdrawSum,
397 "CURRENCY" => $payCurrency,
398 "DEBIT" => "Y",
399 "ORDER_ID" => ($orderID > 0 ? $orderID : false),
400 "PAYMENT_ID" => ($paymentId > 0 ? $paymentId : false),
401 "DESCRIPTION" => "CC_CHARGE_OFF",
402 "EMPLOYEE_ID" => self::getEmployeeId()
403 );
404 CTimeZone::Disable();
406 CTimeZone::Enable();
407
408 if ($arUserAccount)
409 {
411 "CURRENT_BUDGET" => ($withdrawSum + $currentBudget)
412 );
413 CSaleUserAccount::Update($arUserAccount["ID"], $arFields);
414 }
415 else
416 {
418 "USER_ID" => $userID,
419 "CURRENT_BUDGET" => ($withdrawSum + $currentBudget),
420 "CURRENCY" => $payCurrency
421 );
423 }
424 }
425 }
426
427 if ($withdrawSum + $currentBudget >= $paySum)
428 {
429 if ($arUserAccount)
430 {
432 "CURRENT_BUDGET" => ($withdrawSum + $currentBudget - $paySum)
433 );
434 CSaleUserAccount::Update($arUserAccount["ID"], $arFields);
435 }
436 else
437 {
439 "USER_ID" => $userID,
440 "CURRENT_BUDGET" => ($withdrawSum + $currentBudget - $paySum),
441 "CURRENCY" => $payCurrency
442 );
444 }
445
447 "USER_ID" => $userID,
448 "=TIMESTAMP_X" => $DB->GetNowFunction(),
449 "TRANSACT_DATE" => date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL", SITE_ID))),
450 "AMOUNT" => $paySum,
451 "CURRENCY" => $payCurrency,
452 "DEBIT" => "N",
453 "ORDER_ID" => ($orderID > 0 ? $orderID : false),
454 "PAYMENT_ID" => ($paymentId > 0 ? $paymentId : false),
455 "DESCRIPTION" => "ORDER_PAY",
456 "EMPLOYEE_ID" => self::getEmployeeId()
457 );
458 CTimeZone::Disable();
460 CTimeZone::Enable();
461
462 CSaleUserAccount::UnLock($userID, $payCurrency);
463 return true;
464 }
465
466 CSaleUserAccount::UnLock($userID, $payCurrency);
467 $APPLICATION->ThrowException(GetMessage("SKGU_NO_ENOUGH"), "CANT_PAY");
468
469 return false;
470 }
471
472 // Pay money from the local user account. If there is not enough money on the local user
473 // account then withdraw the max available sum.
474 // $userID - ID of the user
475 // $paySum - payment sum
476 // $payCurrency - currency
477 // $orderID - ID of order (if known)
478 // Return withdrawn sum or False
479 public static function Withdraw($userID, $paySum, $payCurrency, $orderID = 0)
480 {
481 global $DB, $APPLICATION, $USER;
482
483 $errorCode = "";
484
485 $userID = (int)$userID;
486 if ($userID <= 0)
487 {
488 $APPLICATION->ThrowException(GetMessage("SKGU_EMPTYID"), "EMPTY_USER_ID");
489 return false;
490 }
491
492 $paySum = str_replace(",", ".", $paySum);
493 $paySum = (float)$paySum;
494 if ($paySum <= 0)
495 {
496 $APPLICATION->ThrowException(GetMessage("SKGU_EMPTY_SUM"), "EMPTY_SUM");
497 return false;
498 }
499
500 $payCurrency = trim($payCurrency);
501 if ($payCurrency == '')
502 {
503 $APPLICATION->ThrowException(GetMessage("SKGU_EMPTY_CUR"), "EMPTY_CURRENCY");
504 return false;
505 }
506
507 $orderID = (int)$orderID;
508
509 if (!CSaleUserAccount::Lock($userID, $payCurrency))
510 {
511 $APPLICATION->ThrowException(GetMessage("SKGU_ACCOUNT_NOT_LOCKED"), "ACCOUNT_NOT_LOCKED");
512 return false;
513 }
514
515 $currentBudget = 0.0;
516
517 // Check current user account budget
518 $dbUserAccount = CSaleUserAccount::GetList(
519 array(),
520 array("USER_ID" => $userID, "CURRENCY" => $payCurrency)
521 );
522 if ($arUserAccount = $dbUserAccount->Fetch())
523 {
524 $currentBudget = (float)$arUserAccount["CURRENT_BUDGET"];
525
526 if ($orderID > 0)
527 {
528 $registry = \Bitrix\Sale\Registry::getInstance(\Bitrix\Sale\Registry::REGISTRY_TYPE_ORDER);
529
531 $orderClass = $registry->getOrderClassName();
532
534 if ($order = $orderClass::load($orderID))
535 {
537 if (($paymentCollection = $order->getPaymentCollection()) && $paymentCollection->isExistsInnerPayment())
538 {
540 if (($payment = $paymentCollection->getInnerPayment()) && $payment->isPaid())
541 {
542 return 0;
543 }
544 }
545 }
546 }
547
548 if ($currentBudget > 0)
549 {
550 $withdrawSum = $paySum;
551 if ($withdrawSum > $currentBudget)
552 $withdrawSum = $currentBudget;
553
555 "CURRENT_BUDGET" => ($currentBudget - $withdrawSum)
556 );
557 CSaleUserAccount::Update($arUserAccount["ID"], $arFields);
558
560 "USER_ID" => $userID,
561 "=TIMESTAMP_X" => $DB->GetNowFunction(),
562 "TRANSACT_DATE" => date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL", SITE_ID))),
563 "AMOUNT" => $withdrawSum,
564 "CURRENCY" => $payCurrency,
565 "DEBIT" => "N",
566 "ORDER_ID" => ($orderID > 0 ? $orderID : false),
567 "DESCRIPTION" => "ORDER_PAY",
568 "EMPLOYEE_ID" => self::getEmployeeId()
569 );
573
574 CSaleUserAccount::UnLock($userID, $payCurrency);
575 return $withdrawSum;
576 }
577 }
578
579 CSaleUserAccount::UnLock($userID, $payCurrency);
580 return false;
581 }
582
583 // Modify sum of the current local user account.
584 // $userID - ID of the user
585 // $sum - payment sum
586 // $currency - currency
587 // $description - reason of modification
588 // Return True on success or False in other way
589 public static function UpdateAccount($userID, $sum, $currency, $description = "", $orderID = 0, $notes = "", $paymentId = null)
590 {
591 global $DB, $APPLICATION, $USER;
592
593 $userID = (int)$userID;
594 if ($userID <= 0)
595 {
596 $APPLICATION->ThrowException(GetMessage("SKGU_EMPTYID"), "EMPTY_USER_ID");
597 return False;
598 }
599 $dbUser = CUser::GetByID($userID);
600 if (!$dbUser->Fetch())
601 {
602 $APPLICATION->ThrowException(str_replace("#ID#", $userID, GetMessage("SKGU_NO_USER")), "ERROR_NO_USER_ID");
603 return False;
604 }
605
606 $sum = (float)str_replace(",", ".", $sum);
607
608 $currency = trim($currency);
609 if ($currency === '')
610 {
611 $APPLICATION->ThrowException(GetMessage("SKGU_EMPTY_CUR"), "EMPTY_CURRENCY");
612 return False;
613 }
614
615 $orderID = (int)$orderID;
616 $paymentId = (int)$paymentId;
617 if (!CSaleUserAccount::Lock($userID, $currency))
618 {
619 $APPLICATION->ThrowException(GetMessage("SKGU_ACCOUNT_NOT_WORK"), "ACCOUNT_NOT_LOCKED");
620 return False;
621 }
622
623 $currentBudget = 0.0000;
624
625 $result = false;
626
627 $dbUserAccount = CSaleUserAccount::GetList(
628 array(),
629 array("USER_ID" => $userID, "CURRENCY" => $currency)
630 );
631 if ($arUserAccount = $dbUserAccount->Fetch())
632 {
633 $currentBudget = floatval($arUserAccount["CURRENT_BUDGET"]);
635 "=TIMESTAMP_X" => $DB->GetNowFunction(),
636 "CURRENT_BUDGET" => $arUserAccount["CURRENT_BUDGET"] + $sum
637 );
638
639 if (!empty($notes))
640 {
641 $arFields['CHANGE_REASON'] = $notes;
642 }
643
644 $result = CSaleUserAccount::Update($arUserAccount["ID"], $arFields);
645 }
646 else
647 {
648 $currentBudget = floatval($sum);
650 "USER_ID" => $userID,
651 "CURRENT_BUDGET" => $sum,
652 "CURRENCY" => $currency,
653 "LOCKED" => "Y",
654 "=TIMESTAMP_X" => $DB->GetNowFunction(),
655 "=DATE_LOCKED" => $DB->GetNowFunction()
656 );
657
658 if (!empty($notes))
659 {
660 $arFields['CHANGE_REASON'] = $notes;
661 }
663 }
664
665 if ($result)
666 {
667 if (isset($GLOBALS["SALE_USER_ACCOUNT"]["SALE_USER_ACCOUNT_CACHE_".$userID."_".$currency]))
668 unset($GLOBALS["SALE_USER_ACCOUNT"]["SALE_USER_ACCOUNT_CACHE_".$userID."_".$currency]);
669
671 "USER_ID" => $userID,
672 "=TIMESTAMP_X" => $DB->GetNowFunction(),
673 "TRANSACT_DATE" => date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL", SITE_ID))),
674 "CURRENT_BUDGET" => $currentBudget,
675 "AMOUNT" => ($sum > 0 ? $sum : -$sum),
676 "CURRENCY" => $currency,
677 "DEBIT" => ($sum > 0 ? "Y" : "N"),
678 "ORDER_ID" => ($orderID > 0 ? $orderID : false),
679 "PAYMENT_ID" => ($paymentId > 0 ? $paymentId : false),
680 "DESCRIPTION" => (($description <> '') ? $description : null),
681 "NOTES" => (($notes <> '') ? $notes : False),
682 "EMPLOYEE_ID" => self::getEmployeeId()
683 );
684 CTimeZone::Disable();
686 CTimeZone::Enable();
687 }
688
690 return $result;
691 }
692
693 private static function getEmployeeId(): bool|int
694 {
695 global $USER;
696
697 if (
698 isset($USER)
699 && $USER instanceof \CUser
700 && $USER->IsAuthorized()
701 )
702 {
703 $userId = (int)$USER->GetID();
704 if ($userId > 0)
705 {
706 return $userId;
707 }
708 }
709
710 return false;
711 }
712
713 //********** EVENTS **************//
714 public static function OnBeforeCurrencyDelete($Currency)
715 {
716 $Currency = (string)$Currency;
717 if ($Currency === '')
718 return true;
719
720 $cnt = CSaleUserAccount::GetList(array(), array("CURRENCY" => $Currency), array());
721 if ($cnt > 0)
722 return false;
723
724 return true;
725 }
726
727 public static function OnUserDelete($userID)
728 {
729 $userID = (int)$userID;
730
731 $bSuccess = true;
732
733 $dbUserAccounts = CSaleUserAccount::GetList(array(), array("USER_ID" => $userID), false, false, array("ID"));
734 while ($arUserAccount = $dbUserAccounts->Fetch())
735 {
736 if (!CSaleUserAccount::Delete($arUserAccount["ID"]))
737 $bSuccess = false;
738 }
739
740 return $bSuccess;
741 }
742
743 public static function OnBeforeUserDelete($userID)
744 {
745 global $APPLICATION;
746
747 $userID = (int)$userID;
748
749 $bCanDelete = true;
750
751 $dbUserAccounts = CSaleUserAccount::GetList(
752 array(),
753 array("USER_ID" => $userID, "!CURRENT_BUDGET" => 0),
754 false,
755 false,
756 array("ID")
757 );
758 if ($arUserAccount = $dbUserAccounts->Fetch())
759 {
760 $APPLICATION->ThrowException(str_replace("#USER_ID#", $userID, GetMessage("UA_ERROR_USER")), "ERROR_UACCOUNT");
761 return false;
762 }
763
764 return $bCanDelete;
765 }
766}
$sum
Определения checkout.php:6
global $APPLICATION
Определения include.php:80
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
Определения user.php:12
static OnBeforeCurrencyDelete($Currency)
Определения user.php:714
static Delete($ID)
Определения user.php:94
static UnLock($userID, $payCurrency)
Определения user.php:206
static Lock($userID, $payCurrency)
Определения user.php:136
static UnLockByID($ID)
Определения user.php:263
static CheckFields($ACTION, &$arFields, $ID=0)
Определения user.php:59
static Pay($userID, $paySum, $payCurrency, $orderID=0, $useCC=true, $paymentId=null)
Определения user.php:305
static OnUserDelete($userID)
Определения user.php:727
static UpdateAccount($userID, $sum, $currency, $description="", $orderID=0, $notes="", $paymentId=null)
Определения user.php:589
static OnBeforeUserDelete($userID)
Определения user.php:743
static DoPayOrderFromAccount($userId, $currency, $orderId, $orderSum, $arOptions, &$arErrors)
Определения user.php:13
static Withdraw($sum, $currency, $arUserCard, $orderID=0)
Определения user_cards.php:333
static Delete($ID)
Определения user_transact.php:46
static Update($ID, $arFields, $bDateUpdate=true)
Определения order.php:140
static Add($arFields)
Определения user.php:186
static GetByID($ID)
Определения user.php:10
static GetList($arOrder=array(), $arFilter=array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array())
Определения user.php:80
static Update($ID, $arFields)
Определения user.php:245
static GetList($arOrder=array(), $arFilter=array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array())
Определения user_cards.php:33
static Add($arFields)
Определения user_transact.php:144
static GetList($arOrder=array(), $arFilter=array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array())
Определения user_transact.php:32
static Disable()
Определения time.php:31
static Enable()
Определения time.php:36
$arFields
Определения dblapprove.php:5
$orderId
Определения payment.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
$result
Определения get_property_values.php:14
if($ajaxMode) $ID
Определения get_user.php:27
if(Loader::includeModule( 'bitrix24')) elseif(Loader::includeModule('intranet') &&CIntranetUtils::getPortalZone() !=='ru') $description
Определения .description.php:24
global $DB
Определения cron_frame.php:29
global $USER
Определения csv_new_run.php:40
$ACTION
Определения csv_new_setup.php:27
$arOptions
Определения structure.php:223
roundEx($value, $prec=0)
Определения tools.php:4635
ExecuteModuleEventEx($arEvent, $arParams=[])
Определения tools.php:5214
GetModuleEvents($MODULE_ID, $MESSAGE_ID, $bReturnArray=false)
Определения tools.php:5177
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения tools.php:3778
is_set($a, $k=false)
Определения tools.php:2133
GetMessage($name, $aReplace=null)
Определения tools.php:3397
MakeTimeStamp($datetime, $format=false)
Определения tools.php:538
$payment
Определения payment.php:14
$order
Определения payment.php:8
$paymentCollection
Определения payment.php:11
$GLOBALS["SALE_USER_ACCOUNT"]
Определения user.php:6
const SALE_TIME_LOCK_USER
Определения user.php:5
$currency
Определения template.php:266
const SALE_VALUE_PRECISION
Определения include.php:46
$orderID
Определения result.php:9
const SITE_ID
Определения sonet_set_content_view.php:12
$GLOBALS['_____370096793']
Определения update_client.php:1