4define(
"SALE_DEBUG",
false);
10 "CHECKBOX" =>
GetMessage(
"SALE_TYPE_CHECKBOX"),
12 "MULTISELECT" =>
GetMessage(
"SALE_TYPE_MULTISELECT"),
13 "TEXTAREA" =>
GetMessage(
"SALE_TYPE_TEXTAREA"),
14 "LOCATION" =>
GetMessage(
"SALE_TYPE_LOCATION"),
19if (!Loader::includeModule(
'currency'))
23define(
"SALE_PROC_REC_NUM", 3);
25define(
"SALE_PROC_REC_ATTEMPTS", 3);
27define(
"SALE_PROC_REC_TIME", 43200);
29define(
"SALE_PROC_REC_FREQUENCY", 7200);
31define(
"SALE_REPORT_OWNER_ID",
'sale');
33define(
"CACHED_b_sale_order", 3600*24);
46define(
"SALE_VALUE_PRECISION", 4);
47define(
"SALE_WEIGHT_PRECISION", 3);
49define(
'BX_SALE_MENU_CATALOG_CLEAR',
'Y');
52 "ID" =>
array(
"COLUMN_NAME" =>
"ID",
"NAME" =>
GetMessage(
"SI_ORDER_ID"),
"SELECT" =>
"ID,DATE_INSERT",
"CUSTOM" =>
"Y",
"SORT" =>
"ID"),
53 "LID" =>
array(
"COLUMN_NAME" =>
GetMessage(
"SI_SITE"),
"NAME" =>
GetMessage(
"SI_SITE"),
"SELECT" =>
"LID",
"CUSTOM" =>
"N",
"SORT" =>
"LID"),
54 "PERSON_TYPE" =>
array(
"COLUMN_NAME" =>
GetMessage(
"SI_PAYER_TYPE"),
"NAME" =>
GetMessage(
"SI_PAYER_TYPE"),
"SELECT" =>
"PERSON_TYPE_ID",
"CUSTOM" =>
"Y",
"SORT" =>
"PERSON_TYPE_ID"),
55 "PAYED" =>
array(
"COLUMN_NAME" =>
GetMessage(
"SI_PAID"),
"NAME" =>
GetMessage(
"SI_PAID_ORDER"),
"SELECT" =>
"PAYED,DATE_PAYED,EMP_PAYED_ID",
"CUSTOM" =>
"Y",
"SORT" =>
"PAYED"),
56 "PAY_VOUCHER_NUM" =>
array(
"COLUMN_NAME" =>
GetMessage(
"SI_NO_PP"),
"NAME" =>
GetMessage(
"SI_NO_PP_DOC"),
"SELECT" =>
"PAY_VOUCHER_NUM",
"CUSTOM" =>
"N",
"SORT" =>
"PAY_VOUCHER_NUM"),
57 "PAY_VOUCHER_DATE" =>
array(
"COLUMN_NAME" =>
GetMessage(
"SI_DATE_PP"),
"NAME" =>
GetMessage(
"SI_DATE_PP_DOC"),
"SELECT" =>
"PAY_VOUCHER_DATE",
"CUSTOM" =>
"N",
"SORT" =>
"PAY_VOUCHER_DATE"),
58 "DELIVERY_DOC_NUM" =>
array(
"COLUMN_NAME" =>
GetMessage(
"SI_DATE_PP_DELIVERY_DOC_NUM"),
"NAME" =>
GetMessage(
"SI_DATE_PP_DOC_DELIVERY_DOC_NUM"),
"SELECT" =>
"DELIVERY_DOC_NUM",
"CUSTOM" =>
"N",
"SORT" =>
"DELIVERY_DOC_NUM"),
59 "DELIVERY_DOC_DATE" =>
array(
"COLUMN_NAME" =>
GetMessage(
"SI_DATE_PP_DELIVERY_DOC_DATE"),
"NAME" =>
GetMessage(
"SI_DATE_PP_DOC_DELIVERY_DOC_DATE"),
"SELECT" =>
"DELIVERY_DOC_DATE",
"CUSTOM" =>
"N",
"SORT" =>
"DELIVERY_DOC_DATE"),
60 "CANCELED" =>
array(
"COLUMN_NAME" =>
GetMessage(
"SI_CANCELED"),
"NAME" =>
GetMessage(
"SI_CANCELED_ORD"),
"SELECT" =>
"CANCELED,DATE_CANCELED,EMP_CANCELED_ID",
"CUSTOM" =>
"Y",
"SORT" =>
"CANCELED"),
61 "STATUS" =>
array(
"COLUMN_NAME" =>
GetMessage(
"SI_STATUS"),
"NAME" =>
GetMessage(
"SI_STATUS_ORD"),
"SELECT" =>
"STATUS_ID,DATE_STATUS,EMP_STATUS_ID",
"CUSTOM" =>
"Y",
"SORT" =>
"STATUS_ID"),
62 "PRICE_DELIVERY" =>
array(
"COLUMN_NAME" =>
GetMessage(
"SI_DELIVERY"),
"NAME" =>
GetMessage(
"SI_DELIVERY"),
"SELECT" =>
"PRICE_DELIVERY,CURRENCY",
"CUSTOM" =>
"Y",
"SORT" =>
"PRICE_DELIVERY"),
63 "ALLOW_DELIVERY" =>
array(
"COLUMN_NAME" =>
GetMessage(
"SI_ALLOW_DELIVERY"),
"NAME" =>
GetMessage(
"SI_ALLOW_DELIVERY1"),
"SELECT" =>
"ALLOW_DELIVERY,DATE_ALLOW_DELIVERY,EMP_ALLOW_DELIVERY_ID",
"CUSTOM" =>
"Y",
"SORT" =>
"ALLOW_DELIVERY"),
64 "PRICE" =>
array(
"COLUMN_NAME" =>
GetMessage(
"SI_SUM"),
"NAME" =>
GetMessage(
"SI_SUM_ORD"),
"SELECT" =>
"PRICE,CURRENCY",
"CUSTOM" =>
"Y",
"SORT" =>
"PRICE"),
65 "SUM_PAID" =>
array(
"COLUMN_NAME" =>
GetMessage(
"SI_SUM_PAID"),
"NAME" =>
GetMessage(
"SI_SUM_PAID1"),
"SELECT" =>
"SUM_PAID,CURRENCY",
"CUSTOM" =>
"Y",
"SORT" =>
"SUM_PAID"),
66 "USER" =>
array(
"COLUMN_NAME" =>
GetMessage(
"SI_BUYER"),
"NAME" =>
GetMessage(
"SI_BUYER"),
"SELECT" =>
"USER_ID",
"CUSTOM" =>
"Y",
"SORT" =>
"USER_ID"),
67 "PAY_SYSTEM" =>
array(
"COLUMN_NAME" =>
GetMessage(
"SI_PAY_SYS"),
"NAME" =>
GetMessage(
"SI_PAY_SYS"),
"SELECT" =>
"PAY_SYSTEM_ID",
"CUSTOM" =>
"Y",
"SORT" =>
"PAY_SYSTEM_ID"),
68 "DELIVERY" =>
array(
"COLUMN_NAME" =>
GetMessage(
"SI_DELIVERY_SYS"),
"NAME" =>
GetMessage(
"SI_DELIVERY_SYS"),
"SELECT" =>
"DELIVERY_ID",
"CUSTOM" =>
"Y",
"SORT" =>
"DELIVERY_ID"),
69 "DATE_UPDATE" =>
array(
"COLUMN_NAME" =>
GetMessage(
"SI_DATE_UPDATE"),
"NAME" =>
GetMessage(
"SI_DATE_UPDATE"),
"SELECT" =>
"DATE_UPDATE",
"CUSTOM" =>
"N",
"SORT" =>
"DATE_UPDATE"),
70 "PS_STATUS" =>
array(
"COLUMN_NAME" =>
GetMessage(
"SI_PAYMENT_PS"),
"NAME" =>
GetMessage(
"SI_PS_STATUS"),
"SELECT" =>
"PS_STATUS,PS_RESPONSE_DATE",
"CUSTOM" =>
"N",
"SORT" =>
"PS_STATUS"),
71 "PS_SUM" =>
array(
"COLUMN_NAME" =>
GetMessage(
"SI_PS_SUM"),
"NAME" =>
GetMessage(
"SI_PS_SUM1"),
"SELECT" =>
"PS_SUM,PS_CURRENCY",
"CUSTOM" =>
"Y",
"SORT" =>
"PS_SUM"),
72 "TAX_VALUE" =>
array(
"COLUMN_NAME" =>
GetMessage(
"SI_TAX"),
"NAME" =>
GetMessage(
"SI_TAX_SUM"),
"SELECT" =>
"TAX_VALUE,CURRENCY",
"CUSTOM" =>
"Y",
"SORT" =>
"TAX_VALUE"),
73 "BASKET" =>
array(
"COLUMN_NAME" =>
GetMessage(
"SI_ITEMS"),
"NAME" =>
GetMessage(
"SI_ITEMS_ORD"),
"SELECT" =>
"",
"CUSTOM" =>
"Y",
"SORT" =>
"")
76require_once __DIR__.
'/autoload.php';
83 "MESSAGE" =>
GetMessage(
"SALE_PAYSYSTEM_CONVERT_ERROR",
array(
'#LANG#' => LANGUAGE_ID)),
84 "TAG" =>
"SALE_PAYSYSTEM_CONVERT_ERROR",
85 "MODULE_ID" =>
"sale",
86 "ENABLE_CLOSE" =>
"Y",
87 "PUBLIC_SECTION" =>
"N"
97 array(
"NAME" =>
"ASC"),
98 array(
"FUSER_ID" => $fUserID,
"LID" =>
SITE_ID,
"ORDER_ID" =>
"NULL")
113 array(
"FUSER_ID" => $fUserID,
"LID" =>
SITE_ID,
"ORDER_ID" =>
false),
116 array(
'ID',
'CALLBACK_FUNC',
'PRODUCT_PROVIDER_CLASS',
'MODULE',
'PRODUCT_ID',
'QUANTITY',
'NOTES')
120 $res[
'CALLBACK_FUNC'] = (string)
$res[
'CALLBACK_FUNC'];
121 $res[
'PRODUCT_PROVIDER_CLASS'] = (string)
$res[
'PRODUCT_PROVIDER_CLASS'];
122 if (
$res[
'CALLBACK_FUNC'] !=
'' ||
$res[
'PRODUCT_PROVIDER_CLASS'] !=
'')
124 $basketID[] =
$res[
'ID'];
127 if (!empty($basketID))
130 array(
'NAME' =>
'ASC'),
131 array(
'ID' => $basketID)
133 while ($basket = $basketIterator->GetNext())
135 unset($basket, $basketIterator);
144 if ($withoutFormat ===
true)
155 $fSum = (float)$fSum;
161 return number_format($fSum, $intDecimals,
'.',
'');
164 return CCurrencyLang::CurrencyFormat($fSum, $strCurrency, !($OnlyValue ===
true));
173 $arOrder = CSaleOrder::GetByID(
$ORDER_ID);
176 if ($arOrder[
"PS_STATUS"] !=
"Y")
178 if ($arOrder[
"PAYED"] !=
"N")
181 if ($arOrder[
"CURRENCY"] == $arOrder[
"PS_CURRENCY"]
182 && DoubleVal($arOrder[
"PRICE"]) == DoubleVal($arOrder[
"PS_SUM"]))
184 if (CSaleOrder::PayOrder($arOrder[
"ID"],
"Y",
true,
false))
193 $GLOBALS[
"APPLICATION"]->ThrowException(
GetMessage(
"SALE_INCLUDE_CURRENCY"),
"SALE_DEPENDES_CURRENCY");
197if (file_exists(
$_SERVER[
"DOCUMENT_ROOT"].
"/bitrix/modules/sale/ru/include.php"))
198 include(
$_SERVER[
"DOCUMENT_ROOT"].
"/bitrix/modules/sale/ru/include.php");
204 $productID = intval($productID);
205 $userID = intval($userID);
206 $bPaid = ($bPaid ? True : False);
215 if (!($arOrder = CSaleOrder::GetByID(
$orderID)))
219 $arAmount = unserialize(
220 COption::GetOptionString(
223 'a:4:{i:1;a:2:{s:6:"AMOUNT";s:2:"10";s:8:"CURRENCY";s:3:"EUR";}i:2;a:2:{s:6:"AMOUNT";s:2:"20";s:8:"CURRENCY";s:3:"EUR";}i:3;a:2:{s:6:"AMOUNT";s:2:"30";s:8:"CURRENCY";s:3:"EUR";}i:4;a:2:{s:6:"AMOUNT";s:2:"40";s:8:"CURRENCY";s:3:"EUR";}}'
225 [
'allowed_classes' =>
false]
227 if (!array_key_exists($productID, $arAmount))
230 $currentPrice = $arAmount[$productID][
"AMOUNT"] * $quantity;
231 $currentCurrency = $arAmount[$productID][
"CURRENCY"];
232 if ($arAmount[$productID][
"CURRENCY"] != $baseLangCurrency)
235 $currentCurrency = $baseLangCurrency;
250 static $formattedUsersName =
array();
251 static $siteNameFormat =
'';
260 if (!isset($formattedUsersName[$id]))
264 else if(!isset($formattedUsersName[
$userId]))
269 if (
count($newUsers) > 0)
273 'select' =>
array(
'ID',
'NAME',
'LAST_NAME',
'SECOND_NAME',
'LOGIN',
'EMAIL'),
274 'filter' =>
array(
'ID' => $newUsers)
277 while ($arUser = $resUsers->Fetch())
279 if ($siteNameFormat ==
'')
280 $siteNameFormat = CSite::GetNameFormat(
false);
281 $formattedUsersName[$arUser[
'ID']] = CUser::FormatName($siteNameFormat, $arUser,
true,
true);
285 $publicMode = (defined(
"PUBLIC_MODE") && PUBLIC_MODE == 1);
286 $selfFolderUrl = (defined(
"SELF_FOLDER_URL") ? SELF_FOLDER_URL :
"/bitrix/admin/");
293 require_once(
$_SERVER[
"DOCUMENT_ROOT"].
BX_ROOT.
"/modules/main/interface/admin_lib.php");
303 $userUrl =
$selfFolderUrl.
"sale_buyers_profile.php?USER_ID=".$uId.
"&lang=".LANGUAGE_ID;
307 $userUrl =
$selfFolderUrl.
"user_edit.php?ID=".$uId.
"&lang=".LANGUAGE_ID;
315 $formatted =
'[<a href="/bitrix/admin/user_edit.php?ID='.$uId.
'&lang='.LANGUAGE_ID.
'">'.$uId.
'</a>] ';
317 $formatted .=
'<a href="'.$userUrl.
'">';
318 $formatted .= $formattedUsersName[$uId];
320 $formatted .=
'</a>';
328 $result .=
'[<a href="/bitrix/admin/user_edit.php?ID='.$userId.
'&lang='.LANGUAGE_ID.
'">'.
$userId.
'</a>] ';
343 $result .=
'<a href="'.$userUrl.
'">';
362 static $measures =
array();
363 $newMeasure =
array();
364 if (Loader::includeModule(
'catalog'))
366 $arDefaultMeasure = CCatalogMeasure::getDefaultMeasure(
true,
true);
367 $arElementId =
array();
368 $basketLinks =
array();
371 if (isset($arItem[
'MEASURE_NAME']) && $arItem[
'MEASURE_NAME'] <>
'')
373 $measureText = $arItem[
'MEASURE_NAME'];
374 $measureCode = intval($arItem[
'MEASURE_CODE']);
378 $productID = (int)$arItem[
"PRODUCT_ID"];
379 if (!isset($basketLinks[$productID]))
380 $basketLinks[$productID] =
array();
381 $basketLinks[$productID][] = $keyBasket;
382 $arElementId[] = $productID;
384 $measureText = $arDefaultMeasure[
'~SYMBOL_RUS'];
391 unset($productID, $keyBasket, $arItem);
393 if (!empty($arElementId))
395 $arBasket2Measure =
array();
398 array(
"ID" => $arElementId),
401 array(
"ID",
"MEASURE")
403 while (
$arRes = $dbres->Fetch())
407 if (
$arRes[
'MEASURE'] <= 0)
409 if (!isset($arBasket2Measure[
$arRes[
'MEASURE']]))
413 if (!isset($measures[
$arRes[
'MEASURE']]) && !in_array(
$arRes[
'MEASURE'], $newMeasure))
414 $newMeasure[] =
$arRes[
'MEASURE'];
418 if (!empty($newMeasure))
420 $dbMeasure = CCatalogMeasure::GetList(
422 array(
"ID" => array_values($newMeasure)),
425 array(
'ID',
'SYMBOL_RUS',
'CODE')
427 while ($arMeasure = $dbMeasure->Fetch())
428 $measures[$arMeasure[
'ID']] = $arMeasure;
431 foreach ($arBasket2Measure as $measureId => $productIds)
433 if (!isset($measures[$measureId]))
435 foreach ($productIds as $productId)
437 if (isset($basketLinks[$productId]) && !empty($basketLinks[$productId]))
439 foreach ($basketLinks[$productId] as $keyBasket)
441 $arBasketItems[$keyBasket][
'MEASURE_TEXT'] = $measures[$measureId][
'SYMBOL_RUS'];
442 $arBasketItems[$keyBasket][
'MEASURE'] = $measures[$measureId][
'ID'];
461 if (Loader::includeModule(
'catalog'))
463 static $cacheRatio =
array();
466 if (is_array($helperCacheRatio) && !empty($helperCacheRatio))
468 $cacheRatio = array_merge($cacheRatio, $helperCacheRatio);
472 $arElementId =
array();
481 $hash = md5((!empty($arItem[
'PRODUCT_PROVIDER_CLASS']) ? $arItem[
'PRODUCT_PROVIDER_CLASS']:
"").
"|".(!empty($arItem[
'MODULE']) ? $arItem[
'MODULE']:
"").
"|".$arItem[
"PRODUCT_ID"]);
483 if (isset($cacheRatio[
$hash]))
485 if (isset($cacheRatio[
$hash][
'RATIO']))
491 if (isset($cacheRatio[
$hash][
'ID']))
499 $arElementId[$arItem[
"PRODUCT_ID"]] = $arItem[
"PRODUCT_ID"];
502 if (!isset(
$map[$arItem[
"PRODUCT_ID"]]))
507 $map[$arItem[
"PRODUCT_ID"]][] =
$key;
510 if (!empty($arElementId))
512 $dbRatio = \Bitrix\Catalog\MeasureRatioTable::getList(
array(
513 'select' =>
array(
'*'),
514 'filter' =>
array(
'@PRODUCT_ID' => $arElementId,
'=IS_DEFAULT' =>
'Y')
516 while ($arRatio = $dbRatio->fetch())
518 if (empty(
$map[$arRatio[
"PRODUCT_ID"]]))
521 foreach (
$map[$arRatio[
"PRODUCT_ID"]] as
$key)
529 $hash = md5((!empty($itemData[
'PRODUCT_PROVIDER_CLASS']) ? $itemData[
'PRODUCT_PROVIDER_CLASS']:
"").
"|".(!empty($itemData[
'MODULE']) ? $itemData[
'MODULE']:
"").
"|".$itemData[
"PRODUCT_ID"]);
531 $cacheRatio[
$hash] = $arRatio;
535 unset($arRatio, $dbRatio);
537 unset($arElementId,
$map);
551 if (!Loader::includeModule(
"iblock"))
554 if (empty($arElementId))
557 $arSelect = array_filter($arSelect,
'checkProductPropCode');
558 foreach (array_keys($arSelect) as $index)
560 if (mb_substr($arSelect[$index], 0, 9) ===
'PROPERTY_')
562 if (mb_substr($arSelect[$index], -6) ===
'_VALUE')
563 $arSelect[$index] = mb_substr($arSelect[$index], 0, -6);
568 $arProductData =
array();
569 $arElementData =
array();
570 $res = CIBlockElement::GetList(
572 array(
"=ID" => array_unique($arElementId)),
575 array(
"ID",
"IBLOCK_ID")
577 while ($arElement =
$res->Fetch())
578 $arElementData[$arElement[
"IBLOCK_ID"]][] = $arElement[
"ID"];
580 foreach ($arElementData as
$iblockId => $arElemId)
582 $res = CIBlockElement::GetList(
589 while ($arElement =
$res->GetNext())
591 $id = $arElement[
"ID"];
592 foreach ($arElement as
$key => $value)
594 if (!isset($arProductData[$id]))
595 $arProductData[$id] =
array();
597 if (isset($arProductData[$id][
$key])
598 && !is_array($arProductData[$id][
$key])
599 && $value !== $arProductData[$id][
$key]
600 && !in_array($value, explode(
", ", $arProductData[$id][
$key]))
603 $arProductData[$id][
$key] .=
", ".$value;
607 $arProductData[$id][
$key] = $value;
613 return $arProductData;
618 return ($selectItem !==
null && $selectItem !==
'' && $selectItem !==
'PROPERTY_');
623 if (!is_array($oldProps) || !is_array($newProps))
627 if (empty($newProps))
629 if (empty($oldProps))
631 foreach ($oldProps as &$oldValue)
635 $propId = (isset($oldValue[
'CODE']) ? (string)$oldValue[
'CODE'] :
'').
':'.$oldValue[
'NAME'];
636 foreach ($newProps as $newKey => $newValue)
638 $newId = (isset($newValue[
'CODE']) ? (string)$newValue[
'CODE'] :
'').
':'.$newValue[
'NAME'];
639 if ($newId == $propId)
648 $oldValue[
'VALUE'] = $newProps[
$key][
'VALUE'];
649 unset($newProps[
$key]);
654 if (!empty($newProps))
656 foreach ($newProps as &$newValue)
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
static get($moduleId, $name, $default="", $siteId=false)
static getList(array $parameters=array())
static getRatioDataCache()
static ConvertCurrency($valSum, $curFrom, $curTo, $valDate="")
static UpdatePrice($ID, $callbackFunc='', $module='', $productID=0, $quantity=0, $renewal='N', $productProvider='', $notes='')
static GetBasketUserID($bSkipFUserInit=false)
static UpdateAccount($userID, $sum, $currency, $description="", $orderID=0, $notes="", $paymentId=null)
static IsFeatureEnabled($_1488512778)
static GetList($arOrder=array(), $arFilter=array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array())
static GetList($arOrder=array(), $arFilter=array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array())
static GetLangCurrency($siteId)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
global $adminSidePanelHelper
$_SERVER["DOCUMENT_ROOT"]
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
GetMessage($name, $aReplace=null)
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
if(empty($signedUserToken)) $key
</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."%"
if($params["BILLBY_ORDER_SUBJECT"]) if( $params["PAYMENT_DATE_PAY_BEFORE"]) if($params['BILLBY_PAYER_SHOW']=='Y') $currencyFormat
SaleFormatCurrency($fSum, $strCurrency, $OnlyValue=false, $withoutFormat=false)
if( $psConverted=='') GetBasketListSimple($bSkipFUserInit=true)
CurrencyModuleUnInstallSale()
GetFormatedUserName($userId, $bEnableId=true, $createEditLink=true)
updateBasketOffersProps($oldProps, $newProps)
getProductProps($arElementId, $arSelect)
GetBasketList($bSkipFUserInit=true)
global $SALE_TIME_PERIOD_TYPES
getMeasures($arBasketItems)
checkProductPropCode($selectItem)
PayUserAccountDeliveryOrderCallback($productID, $userID, $bPaid, $orderID, $quantity=1)
if(CSalePaySystemAction::GetParamValue("ORDER_SUBJECT", false)) if(CSalePaySystemAction::GetParamValue("DATE_PAY_BEFORE", false)) if(CSalePaySystemAction::GetParamValue("BUYER_NAME", false)) $arBasketItems
$GLOBALS['_____370096793']