Esempio n. 1
0
 /** Returns an array, containing information about the product block on its ID.
  * @param $elementId
  * @return array|string
  */
 public static function getProductInfo($elementId)
 {
     $elementId = intval($elementId);
     $result = "";
     if ($elementId <= 0) {
         return $result;
     }
     $dbProduct = CIBlockElement::GetList(array(), array("ID" => $elementId), false, false, array('ID', 'IBLOCK_ID', 'IBLOCK_SECTION_ID', 'DETAIL_PICTURE', 'PREVIEW_PICTURE', 'NAME', 'XML_ID'));
     while ($arProduct = $dbProduct->GetNext()) {
         $imgCode = "";
         if ($arProduct["IBLOCK_ID"] > 0) {
             $arProduct["EDIT_PAGE_URL"] = CIBlock::GetAdminElementEditLink($arProduct["IBLOCK_ID"], $elementId, array("find_section_section" => $arProduct["IBLOCK_SECTION_ID"]));
         }
         if ($arProduct["DETAIL_PICTURE"] > 0) {
             $imgCode = $arProduct["DETAIL_PICTURE"];
         } elseif ($arProduct["PREVIEW_PICTURE"] > 0) {
             $imgCode = $arProduct["PREVIEW_PICTURE"];
         }
         $arProduct["NAME"] = $arProduct["NAME"];
         $arProduct["DETAIL_PAGE_URL"] = htmlspecialcharsex($arProduct["DETAIL_PAGE_URL"]);
         if ($imgCode > 0) {
             $arFile = CFile::GetFileArray($imgCode);
             $arImgProduct = CFile::ResizeImageGet($arFile, array('width' => 80, 'height' => 80), BX_RESIZE_IMAGE_PROPORTIONAL, false, false);
             $arProduct["IMG_URL"] = $arImgProduct['src'];
         }
         return $arProduct;
     }
     return $result;
 }
Esempio n. 2
0
		$save_and_add,
	));
endif;

$tabControl->Show();
if (
	(!defined('BX_PUBLIC_MODE') || BX_PUBLIC_MODE != 1)
	&& CIBlockRights::UserHasRightTo($IBLOCK_ID, $IBLOCK_ID, "iblock_edit")
	&& !$bAutocomplete
)
{

	echo
		BeginNote(),
		GetMessage("IBEL_E_IBLOCK_MANAGE_HINT"),
		' <a href="/bitrix/admin/iblock_edit.php?type='.htmlspecialcharsbx($type).'&amp;lang='.LANGUAGE_ID.'&amp;ID='.$IBLOCK_ID.'&amp;admin=Y&amp;return_url='.urlencode("/bitrix/admin/".CIBlock::GetAdminElementEditLink($IBLOCK_ID, $ID, array("WF" => ($WF=="Y"? "Y": null), "find_section_section" => intval($find_section_section), "return_url" => (strlen($return_url)>0? $return_url: null)))).'">',
		GetMessage("IBEL_E_IBLOCK_MANAGE_HINT_HREF"),
		'</a>',
		EndNote()
	;
}
	//////////////////////////
	//END of the custom form
	//////////////////////////
endif;

}
if ($bAutocomplete)
	require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_popup_admin.php");
elseif ($bPropertyAjax)
	require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_admin_js.php");
Esempio n. 3
0
 private static function GetProductCatalogInfo($productID)
 {
     $productID = (int) $productID;
     if ($productID <= 0) {
         return array();
     }
     if (!($arProduct = static::getHitCache('IBLOCK_ELEMENT', $productID))) {
         $dbProduct = CIBlockElement::GetList(array(), array("ID" => $productID), false, false, array('ID', 'IBLOCK_ID', 'NAME', 'IBLOCK_SECTION_ID'));
         if ($arProduct = $dbProduct->Fetch()) {
             static::setHitCache('IBLOCK_ELEMENT', $productID, $arProduct);
         }
     }
     if (!empty($arProduct) && is_array($arProduct)) {
         if ($arProduct["IBLOCK_ID"] > 0) {
             $arProduct["EDIT_PAGE_URL"] = CIBlock::GetAdminElementEditLink($arProduct["IBLOCK_ID"], $productID);
         }
     }
     return array("#PRODUCT_ID#" => $arProduct["ID"], "#PRODUCT_NAME#" => $arProduct["NAME"]);
 }
Esempio n. 4
0
 /**
  * Returns list of recommended products for specific product.
  *
  * @param int $USER_ID							User id.
  * @param string $LID							Site id.
  * @param array $arFilterRecomendet				Recomendation filter.
  * @param string $recomMore						Get more.
  * @param int $cntProductDefault				Max count.
  * @return array
  */
 function GetRecommendetProduct($USER_ID, $LID, $arFilterRecomendet = array(), $recomMore = 'N', $cntProductDefault = 2)
 {
     $arRecomendetResult = array();
     if (CModule::IncludeModule('catalog') && !empty($arFilterRecomendet)) {
         $arRecomendet = array();
         if (!is_array($arFilterRecomendet)) {
             $arFilterRecomendet = array($arFilterRecomendet);
         }
         Main\Type\Collection::normalizeArrayValuesByInt($arFilterRecomendet);
         if (empty($arFilterRecomendet)) {
             return $arRecomendetResult;
         }
         $iblockRecommended = array();
         $productIterator = Iblock\ElementTable::getList(array('select' => array('ID', 'IBLOCK_ID'), 'filter' => array('@ID' => $arFilterRecomendet, '=ACTIVE' => 'Y')));
         while ($product = $productIterator->fetch()) {
             $product['ID'] = (int) $product['ID'];
             $product['IBLOCK_ID'] = (int) $product['IBLOCK_ID'];
             if (!isset($iblockRecommended[$product['IBLOCK_ID']])) {
                 $iblockRecommended[$product['IBLOCK_ID']] = array();
             }
             $iblockRecommended[$product['IBLOCK_ID']][] = $product['ID'];
         }
         unset($product, $productIterator);
         if (empty($iblockRecommended)) {
             return $arRecomendetResult;
         }
         $propertyList = array();
         $propertyIterator = Iblock\PropertyTable::getList(array('select' => array('ID', 'IBLOCK_ID'), 'filter' => array('@IBLOCK_ID' => array_keys($iblockRecommended), '=CODE' => 'RECOMMEND', '=PROPERTY_TYPE' => Iblock\PropertyTable::TYPE_ELEMENT)));
         while ($property = $propertyIterator->fetch()) {
             $property['ID'] = (int) $property['ID'];
             $property['IBLOCK_ID'] = (int) $property['IBLOCK_ID'];
             $propertyList[$property['IBLOCK_ID']] = $property['ID'];
         }
         unset($property, $propertyIterator);
         if (empty($propertyList)) {
             return $arRecomendetResult;
         }
         foreach ($propertyList as $iblockID => $propertyID) {
             $propertyValue = 'PROPERTY_' . $propertyID;
             $filter = array('ID' => $iblockRecommended[$iblockID], 'IBLOCK_ID' => $iblockID);
             $select = array('ID', 'IBLOCK_ID', $propertyValue);
             $propertyValue .= '_VALUE';
             $elementIterator = CIBlockElement::GetList(array(), $filter, false, false, $select);
             while ($element = $elementIterator->Fetch()) {
                 if (empty($element[$propertyValue])) {
                     continue;
                 }
                 if (is_array($element[$propertyValue])) {
                     foreach ($element[$propertyValue] as &$recId) {
                         $recId = (int) $recId;
                         if ($recId > 0) {
                             $arRecomendet[$recId] = true;
                         }
                     }
                     unset($recId);
                 } else {
                     $recId = (int) $element[$propertyValue];
                     if ($recId > 0) {
                         $arRecomendet[$recId] = true;
                     }
                 }
             }
         }
         unset($element, $elementIterator, $select, $filter, $propertyValue, $propertyID, $iblockID, $propertyList);
         if (!empty($arRecomendet)) {
             $arRecomendet = array_keys($arRecomendet);
             $arBuyerGroups = CUser::GetUserGroup($USER_ID);
             $arFilter = array("ID" => $arRecomendet, "ACTIVE" => "Y");
             $rsElement = CIBlockElement::GetList(array(), $arFilter, false, false, array("NAME", "ID", "LID", 'IBLOCK_ID', 'IBLOCK_SECTION_ID', "DETAIL_PICTURE", "PREVIEW_PICTURE", "DETAIL_PAGE_URL"));
             $currentVatMode = CCatalogProduct::getPriceVatIncludeMode();
             $currentUseDiscount = CCatalogProduct::getUseDiscount();
             CCatalogProduct::setUseDiscount(true);
             CCatalogProduct::setPriceVatIncludeMode(true);
             CCatalogProduct::setUsedCurrency(CSaleLang::GetLangCurrency($LID));
             $i = 0;
             while ($arElement = $rsElement->GetNext()) {
                 if (in_array($arElement["ID"], $arFilterRecomendet)) {
                     continue;
                 }
                 if ($recomMore == "N" && $i < $cntProductDefault || $recomMore == "Y") {
                     $arElement["MODULE"] = "catalog";
                     $arElement["PRODUCT_PROVIDER_CLASS"] = "CCatalogProductProvider";
                     $arElement["PRODUCT_ID"] = $arElement["ID"];
                     $arPrice = CCatalogProduct::GetOptimalPrice($arElement["ID"], 1, $arBuyerGroups, "N", array(), $LID, array());
                     $currentPrice = $arPrice['RESULT_PRICE']['DISCOUNT_PRICE'];
                     $arElement["PRICE"] = $currentPrice;
                     $arElement["CURRENCY"] = $arPrice["RESULT_PRICE"]["CURRENCY"];
                     $arElement["DISCOUNT_PRICE"] = $arPrice['RESULT_PRICE']['DISCOUNT'];
                     if ($arElement["IBLOCK_ID"] > 0 && $arElement["IBLOCK_SECTION_ID"] > 0) {
                         $arElement["EDIT_PAGE_URL"] = CIBlock::GetAdminElementEditLink($arElement["IBLOCK_ID"], $arElement["PRODUCT_ID"], array("find_section_section" => $arElement["IBLOCK_SECTION_ID"], 'WF' => 'Y'));
                     }
                     $arRecomendetResult[] = $arElement;
                     $i++;
                 }
             }
             CCatalogProduct::clearUsedCurrency();
             CCatalogProduct::setPriceVatIncludeMode($currentVatMode);
             CCatalogProduct::setUseDiscount($currentUseDiscount);
             unset($currentUseDiscount, $currentVatMode);
         }
     }
     return $arRecomendetResult;
 }
Esempio n. 5
0
 public static function setCatalogPanelButtons(&$buttons, $iblock, $catalogButtons, $params, $windowParams)
 {
     global $APPLICATION;
     $iblock = (int) $iblock;
     if ($iblock <= 0) {
         return;
     }
     if (empty($params) || !is_array($params)) {
         return;
     }
     if (empty($windowParams) || !is_array($windowParams)) {
         $windowParams = array('width' => 700, 'height' => 400, 'resize' => false);
     }
     if (isset($catalogButtons['add_product'])) {
         $params[self::$strMainPrefix . self::TAB_KEY] = self::TAB_CATALOG;
         $url = '/bitrix/admin/' . CIBlock::GetAdminElementEditLink($iblock, null, $params);
         $action = $APPLICATION->GetPopupLink(array("URL" => $url, "PARAMS" => $windowParams));
         $productButton = array('TITLE' => Loc::getMessage('BT_CAT_ADM_TOOLS_ADD_PROD'), 'TEXT' => Loc::getMessage('BT_CAT_ADM_TOOLS_ADD_PROD_TITLE'), 'ACTION' => 'javascript:' . $action, 'ACTION_URL' => $url, 'ONCLICK' => $action, 'ICON' => 'bx-context-toolbar-create-icon', 'ID' => 'bx-context-toolbar-add-element');
         $buttons['edit']['add_element'] = $productButton;
         $buttons['configure']['add_element'] = $productButton;
         $buttons['intranet'][] = array('TEXT' => $productButton['TEXT'], 'TITLE' => $productButton['TITLE'], 'ICON' => 'add', 'ONCLICK' => $productButton['ACTION'], 'SORT' => 1000);
         $url = str_replace('&bxpublic=Y&from_module=iblock', '', $url);
         $productButton['ACTION'] = "javascript:jsUtils.Redirect([], '" . CUtil::JSEscape($url) . "')";
         unset($productButton['ONCLICK']);
         $buttons['submenu']['add_element'] = $productButton;
         unset($productButton);
     }
     if (isset($catalogButtons['add_sku'])) {
         $params[self::$strMainPrefix . self::TAB_KEY] = self::TAB_SKU;
         $url = '/bitrix/admin/' . CIBlock::GetAdminElementEditLink($iblock, null, $params);
         $action = $APPLICATION->GetPopupLink(array("URL" => $url, "PARAMS" => $windowParams));
         $skuButton = array('TITLE' => Loc::getMessage('BT_CAT_ADM_TOOLS_ADD_SKU'), 'TEXT' => Loc::getMessage('BT_CAT_ADM_TOOLS_ADD_SKU_TITLE'), 'ACTION' => 'javascript:' . $action, 'ACTION_URL' => $url, 'ONCLICK' => $action, 'ICON' => 'bx-context-toolbar-create-icon', 'ID' => 'bx-context-toolbar-add-sku');
         $buttons['edit']['add_sku'] = $skuButton;
         $buttons['configure']['add_sku'] = $skuButton;
         $buttons['intranet'][] = array('TEXT' => $skuButton['TEXT'], 'TITLE' => $skuButton['TITLE'], 'ICON' => 'add', 'ONCLICK' => $skuButton['ACTION'], 'SORT' => 1010);
         $url = str_replace('&bxpublic=Y&from_module=iblock', '', $url);
         $skuButton['ACTION'] = "javascript:jsUtils.Redirect([], '" . CUtil::JSEscape($url) . "')";
         unset($skuButton['ONCLICK']);
         $buttons['submenu']['add_sku'] = $skuButton;
         unset($skuButton);
     }
 }
Esempio n. 6
0
			}
			if(!empty($_REQUEST["productDelay"]))
			{
				$dbItem = CIBlockElement::GetList(array(), array("ID" => $_REQUEST["productDelay"]), false, false, array("ID", "NAME", "IBLOCK_ID", "IBLOCK_SECTION_ID"));
				while($arItem = $dbItem->Fetch())
					echo "<b>"."<a href=\"".CIBlock::GetAdminElementEditLink($arItem["IBLOCK_ID"], $arItem["ID"], array(
						"find_section_section" => $arItem["IBLOCK_SECTION_ID"],
						'WF' => 'Y',
					))."\">".htmlspecialcharsbx($arItem["NAME"])."</a></b> (".GetMessage("NEWO_PRODUCTS_DELAY").")<br />";
			}
			if(!empty($_REQUEST["productNA"]))
			{
				$dbItem = CIBlockElement::GetList(array(), array("ID" => $_REQUEST["productNA"]), false, false, array("ID", "NAME", "IBLOCK_ID", "IBLOCK_SECTION_ID"));
				while($arItem = $dbItem->Fetch())
					echo "<b>"."<a href=\"".CIBlock::GetAdminElementEditLink($arItem["IBLOCK_ID"], $arItem["ID"], array(
						"find_section_section" => $arItem["IBLOCK_SECTION_ID"],
						'WF' => 'Y',
					))."\">".htmlspecialcharsbx($arItem["NAME"])."</a></b> (".GetMessage("NEWO_PRODUCTS_NA").")<br />";
			}
			echo EndNote();
		}
		?>
		<script type="text/javascript">
			var arProduct = [];
			var arProductEditCountProps = [];
			var countProduct = 0;
		</script>
		<?
		$arCurFormat = CCurrencyLang::GetCurrencyFormat($str_CURRENCY);
		$CURRENCY_FORMAT = trim(str_replace("#", '', $arCurFormat["FORMAT_STRING"]));
		$ORDER_TOTAL_PRICE = 0;
		$ORDER_PRICE_WITH_DISCOUNT = 0;
Esempio n. 7
0
function getProductDataToFillBasket($productId, $quantity, $userId, $LID, $userColumns, $tmpId = "")
{
	if (!\Bitrix\Main\Loader::includeModule("catalog"))
		return array();

	$arParams = array();

	$productId = (int)$productId;
	if ($productId <= 0)
	{
		return $arParams;
	}
	$iblockId = (int)CIBlockElement::GetIBlockByID($productId);
	if ($iblockId <= 0)
	{
		return $arParams;
	}

	$arSku2Parent = array();
	$arElementId = array();

	$arElementId[] = $productId;
	$arParent = CCatalogSku::GetProductInfo($productId, $iblockId);
	if ($arParent)
	{
		$arElementId[] = $arParent["ID"];
		$arSku2Parent[$productId] = $arParent["ID"];
	}

	$arPropertyInfo = array();
	$userColumns = (string)$userColumns;
	$arUserColumns = ($userColumns != '') ? explode(",", $userColumns) : array();
	foreach ($arUserColumns as $key => $column)
	{
		if (strncmp($column, 'PROPERTY_', 9) != 0)
		{
			unset($arUserColumns[$key]);
		}
		else
		{
			$propertyCode = substr($column, 9);
			if ($propertyCode == '')
			{
				unset($arUserColumns[$key]);
				continue;
			}
			$dbres = CIBlockProperty::GetList(array(), array("CODE" => $propertyCode));
			if ($arPropData = $dbres->GetNext())
				$arPropertyInfo[$column] = $arPropData;
		}
	}

	$arSelect = array_merge(
		array("ID", "NAME", "LID", "IBLOCK_ID", "IBLOCK_SECTION_ID", "DETAIL_PICTURE", "PREVIEW_PICTURE", "DETAIL_PAGE_URL", "XML_ID", "IBLOCK_XML_ID"),
		$arUserColumns
	);

	$arProductData = getProductProps($arElementId, $arSelect);

	$defaultMeasure = CCatalogMeasure::getDefaultMeasure(true, true);

	if (!empty($arProductData))
	{
		$arElementInfo = array();
		foreach ($arProductData as $elemId => &$arElement)
		{
			foreach ($arElement as $key => $value)
			{
				if (strncmp($key, 'PROPERTY_', 9) == 0 && substr($key, -6) == "_VALUE")
				{
					$columnCode = str_replace("_VALUE", "", $key);
					$arElement[$key] = getIblockPropInfo($value, $arPropertyInfo[$columnCode], array("WIDTH" => 90, "HEIGHT" => 90));
				}
			}
		}
		unset($arElement);

		if (isset($arProductData[$productId]))
			$arElementInfo = $arProductData[$productId];

		if (isset( $arSku2Parent[$productId]))
			$arParent = $arProductData[$arSku2Parent[$productId]];

		if (!empty($arSku2Parent)) // if sku element doesn't have value of some property - we'll show parent element value instead
		{
			foreach ($arUserColumns as $field)
			{
				$fieldVal = $field."_VALUE";
				$parentId = $arSku2Parent[$productId];

				if ((!isset($arElementInfo[$fieldVal]) || (isset($arElementInfo[$fieldVal]) && strlen($arElementInfo[$fieldVal]) == 0))
					&& (isset($arProductData[$parentId][$fieldVal]) && !empty($arProductData[$parentId][$fieldVal]))) // can be array or string
				{
					$arElementInfo[$fieldVal] = $arProductData[$parentId][$fieldVal];
				}
			}
			if (strpos($arElementInfo["~XML_ID"], '#') === false)
			{
				$arElementInfo["~XML_ID"] = $arParent['~XML_ID'].'#'.$arElementInfo["~XML_ID"];
			}
		}

		$arElementInfo["MODULE"] = "catalog";
		$arElementInfo["PRODUCT_PROVIDER_CLASS"] = "CCatalogProductProvider";

		$arElementInfo["PRODUCT_ID"] = $arElementInfo["ID"];

		if ($arElementInfo["IBLOCK_ID"] > 0)
		{
			$arElementInfo["EDIT_PAGE_URL"] = CIBlock::GetAdminElementEditLink($arElementInfo["IBLOCK_ID"], $arElementInfo["PRODUCT_ID"], array(
				"find_section_section" => $arElementInfo["IBLOCK_SECTION_ID"],
				'WF' => 'Y',
			));
		}

		$arBuyerGroups = CUser::GetUserGroup($userId);

		// price
		$arPrice = CCatalogProduct::GetOptimalPrice($arElementInfo["ID"], 1, $arBuyerGroups, "N", array(), $LID);
		$currentPrice = $arPrice["DISCOUNT_PRICE"];
		$arElementInfo["PRICE"] = $currentPrice;
		$arElementInfo["CURRENCY"] = $arPrice["PRICE"]["CURRENCY"];
		$arElementInfo["DISCOUNT_PRICE"] = $arPrice["PRICE"]["PRICE"] - $arPrice["DISCOUNT_PRICE"];
		$currentTotalPrice = ($arElementInfo["PRICE"] + $arElementInfo["DISCOUNT_PRICE"]);
		$discountPercent = 0;
		if ($arElementInfo["DISCOUNT_PRICE"] > 0)
			$discountPercent = intval(($arElementInfo["DISCOUNT_PRICE"] * 100) / $currentTotalPrice);

		$rsProducts = CCatalogProduct::GetList(
			array(),
			array('ID' => $productId),
			false,
			false,
			array('ID', 'QUANTITY', 'WEIGHT', 'MEASURE', 'TYPE', 'BARCODE_MULTI')
		);
		if (!($arProduct = $rsProducts->Fetch()))
		{
			return array();
		}
		$balance = floatval($arProduct["QUANTITY"]);

		// sku props
		$arSkuData = array();
		$arProps[] = array(
			"NAME" => "Catalog XML_ID",
			"CODE" => "CATALOG.XML_ID",
			"VALUE" => $arElementInfo['~IBLOCK_XML_ID']
		);
		$arSkuProperty = CSaleProduct::GetProductSkuProps($productId, '', true);
		if (!empty($arSkuProperty))
		{
			foreach ($arSkuProperty as &$val)
			{
				$arSkuData[] = array(
					'NAME' => $val['NAME'],
					'VALUE' => $val['VALUE'],
					'CODE' => $val['CODE']
				);
			}
			unset($val);
		}
		$arSkuData[] = array(
			"NAME" => "Product XML_ID",
			"CODE" => "PRODUCT.XML_ID",
			"VALUE" => $arElementInfo["~XML_ID"]
		);

		// currency
		$arCurFormat = CCurrencyLang::GetCurrencyFormat($arElementInfo["CURRENCY"]);
		$priceValutaFormat = str_replace("#", "", $arCurFormat["FORMAT_STRING"]);

		$arElementInfo["WEIGHT"] = $arProduct["WEIGHT"];

		// measure
		$arElementInfo["MEASURE_TEXT"] = "";
		if ((int)$arProduct["MEASURE"] > 0)
		{
			$dbMeasure = CCatalogMeasure::GetList(array(), array("ID" => intval($arProduct["MEASURE"])), false, false, array("ID", "SYMBOL_RUS", "SYMBOL_INTL"));
			if ($arMeasure = $dbMeasure->Fetch())
				$arElementInfo["MEASURE_TEXT"] = ($arMeasure["SYMBOL_RUS"] != '' ? $arMeasure["SYMBOL_RUS"] : $arMeasure["SYMBOL_INTL"]);
		}
		if ($arElementInfo["MEASURE_TEXT"] == '')
		{
			$arElementInfo["MEASURE_TEXT"] = ($defaultMeasure["SYMBOL_RUS"] != '' ? $defaultMeasure["SYMBOL_RUS"] : $defaultMeasure["SYMBOL_INTL"]);
		}


		// ratio
		$arElementInfo["RATIO"] = 1;
		$dbratio = CCatalogMeasureRatio::GetList(array(), array("PRODUCT_ID" => $productId));
		if ($arRatio = $dbratio->Fetch())
			$arElementInfo["RATIO"] = $arRatio["RATIO"];

		// image
		if ($arElementInfo["PREVIEW_PICTURE"] > 0)
			$imgCode = $arElementInfo["PREVIEW_PICTURE"];
		elseif ($arElementInfo["DETAIL_PICTURE"] > 0)
			$imgCode = $arElementInfo["DETAIL_PICTURE"];

		if ($imgCode == "" && count($arParent) > 0)
		{
			if ($arParent["PREVIEW_PICTURE"] > 0)
				$imgCode = $arParent["PREVIEW_PICTURE"];
			elseif ($arParent["DETAIL_PICTURE"] > 0)
				$imgCode = $arParent["DETAIL_PICTURE"];
		}

		if ($imgCode > 0)
		{
			$arFile = CFile::GetFileArray($imgCode);
			$arImgProduct = CFile::ResizeImageGet($arFile, array('width'=>80, 'height'=>80), BX_RESIZE_IMAGE_PROPORTIONAL, false, false);
			if (is_array($arImgProduct))
				$imgUrl = $arImgProduct["src"];
		}

		$arSetInfo = array();
		$arStores = array();

		/** @var $productProvider IBXSaleProductProvider */
		if ($productProvider = CSaleBasket::GetProductProvider(array("MODULE" => $arElementInfo["MODULE"], "PRODUCT_PROVIDER_CLASS" => $arElementInfo["PRODUCT_PROVIDER_CLASS"])))
		{
			// get set items if it is set
			if ($arProduct["TYPE"] == CCatalogProduct::TYPE_SET)
			{
				if (method_exists($productProvider, "GetSetItems"))
				{
					$arSets = $productProvider::GetSetItems($productId, CSaleBasket::TYPE_SET);

					if ($tmpId == "")
						$tmpId = randString(7);

					if (!empty($arSets))
					{
						foreach ($arSets as $arSetData)
						{
							foreach ($arSetData["ITEMS"] as $setItem)
							{
								$arSetItemParams = getProductDataToFillBasket($setItem["PRODUCT_ID"], $setItem["QUANTITY"], $userId, $LID, $userColumns, $tmpId); // recursive call

								// re-define some fields with set data values
								$arSetItemParams["id"] = $setItem["PRODUCT_ID"];
								$arSetItemParams["name"] = $setItem["NAME"];
								$arSetItemParams["module"] = $setItem["MODULE"];
								$arSetItemParams["productProviderClass"] = $setItem["PRODUCT_PROVIDER_CLASS"];
								$arSetItemParams["url"] = $setItem["DETAIL_PAGE_URL"];
								$arSetItemParams["quantity"] = $setItem["QUANTITY"] * $quantity;
								$arSetItemParams["barcodeMulti"] = $setItem["BARCODE_MULTI"];
								$arSetItemParams["productType"] = $setItem["TYPE"];
								$arSetItemParams["weight"] = $setItem["WEIGHT"];
								$arSetItemParams["vatRate"] = $setItem["VAT_RATE"];
								$arSetItemParams["setItems"] = "";

								$arSetItemParams["setParentId"] = $productId."_tmp".$tmpId;
								$arSetItemParams["isSetItem"] = "Y";
								$arSetItemParams["isSetParent"] = "N";

								$arSetInfo[] = $arSetItemParams;
							}
						}
					}
				}
			}

			// get stores
			$storeCount = $productProvider::GetStoresCount(array("SITE_ID" => $LID)); // with exact SITE_ID or SITE_ID = NULL

			if ($storeCount > 0)
			{
				if ($arProductStore = $productProvider::GetProductStores(array("PRODUCT_ID" => $productId, "SITE_ID" => $LID)))
					$arStores = $arProductStore;
			}
		}

		$currentTotalPrice = (float)$currentTotalPrice;
		// params array
		$arParams["id"] = $productId;
		$arParams["name"] = $arElementInfo["~NAME"];
		$arParams["url"] = htmlspecialcharsex($arElementInfo["~DETAIL_PAGE_URL"]);
		$arParams["urlEdit"] = $arElementInfo["EDIT_PAGE_URL"];
		$arParams["urlImg"] = $imgUrl;
		$arParams["price"] = floatval($arElementInfo["PRICE"]);
		$arParams["priceBase"] = $currentTotalPrice;
		$arParams["priceBaseFormat"] = CCurrencyLang::CurrencyFormat($currentTotalPrice, $arElementInfo["CURRENCY"], false);
		$arParams["priceFormated"] = CCurrencyLang::CurrencyFormat(floatval($arElementInfo["PRICE"]), $arElementInfo["CURRENCY"], false);
		$arParams["valutaFormat"] = $priceValutaFormat;
		$arParams["dimensions"] = serialize(array("WIDTH" => $arElementInfo["WIDTH"], "HEIGHT" => $arElementInfo["HEIGHT"], "LENGTH" => $arElementInfo["LENGTH"]));
		$arParams["priceDiscount"] = floatval($arElementInfo["DISCOUNT_PRICE"]);
		$arParams["priceTotalFormated"] = CCurrencyLang::CurrencyFormat($currentTotalPrice, $arElementInfo["CURRENCY"], true);
		$arParams["discountPercent"] = $discountPercent;
		$arParams["summaFormated"] = CCurrencyLang::CurrencyFormat($arElementInfo["PRICE"], $arElementInfo["CURRENCY"], false);
		$arParams["quantity"] = $quantity;
		$arParams["module"] = $arElementInfo["MODULE"];
		$arParams["currency"] = $arElementInfo["CURRENCY"];
		$arParams["weight"] = $arElementInfo["WEIGHT"];
		$arParams["vatRate"] = $arPrice["PRICE"]["VAT_RATE"];
		$arParams["priceType"] = $arPrice["PRICE"]["CATALOG_GROUP_NAME"];
		$arParams["balance"] = $balance;
		$arParams["notes"] = (is_array($arPrice["PRICE"]) && array_key_exists("CATALOG_GROUP_NAME", $arPrice["PRICE"])) ? $arPrice["PRICE"]["CATALOG_GROUP_NAME"] : "";
		$arParams["catalogXmlID"] = $arElementInfo["~IBLOCK_XML_ID"];
		$arParams["productXmlID"] = $arElementInfo["~XML_ID"];
		$arParams["callback"] = "";
		$arParams["orderCallback"] = "";
		$arParams["cancelCallback"] = "";
		$arParams["payCallback"] = "";
		$arParams["productProviderClass"] = $arElementInfo["PRODUCT_PROVIDER_CLASS"];
		$arParams["skuProps"] = $arSkuData;
		$arParams["measureText"] = $arElementInfo["MEASURE_TEXT"];
		$arParams["ratio"] = $arElementInfo["RATIO"];
		$arParams["barcodeMulti"] = $arProduct["BARCODE_MULTI"];

		$arParams["productType"] = empty($arSetInfo) ? "" : CSaleBasket::TYPE_SET;
		$arParams["setParentId"] = empty($arSetInfo) ? "" : $productId."_tmp".$tmpId;

		$arParams["setItems"] = $arSetInfo;
		$arParams["isSetItem"] = "N";
		$arParams["isSetParent"] = empty($arSetInfo) ? "N" : "Y";

		$arParams["stores"] = empty($arSetInfo) ? $arStores : array();
		$arParams["productPropsValues"] = $arElementInfo; // along with other information also contains values of properties with correct keys (after getProductProps)
	}

	return $arParams;
}
 }
 foreach ($arSelectedProps as $aProp) {
     $v = '';
     foreach ($arProperties[$aProp['ID']] as $property_value_id => $property_value) {
         $res = '';
         if ($aProp['PROPERTY_TYPE'] == 'F') {
             $res = CFileInput::Show('NO_FIELDS[' . $property_value_id . ']', $property_value, array("IMAGE" => "Y", "PATH" => "Y", "FILE_SIZE" => "Y", "DIMENSIONS" => "Y", "IMAGE_POPUP" => "Y", "MAX_SIZE" => $maxImageSize, "MIN_SIZE" => $minImageSize), array('upload' => false, 'medialib' => false, 'file_dialog' => false, 'cloud' => false, 'del' => false, 'description' => false));
         } elseif ($aProp['PROPERTY_TYPE'] == 'G') {
             $t = GetSectionName($property_value);
             if ($t) {
                 $res = $t['NAME'] . ' [<a href="' . htmlspecialcharsbx(CIBlock::GetAdminSectionEditLink($t['IBLOCK_ID'], $t['ID'])) . '" title="' . GetMessage("SPS_ELSEARCH_SECTION_EDIT") . '">' . $t['ID'] . '</a>]';
             }
         } elseif ($aProp['PROPERTY_TYPE'] == 'E') {
             $t = GetElementName($property_value);
             if ($t) {
                 $res = $t['NAME'] . ' [<a href="' . htmlspecialcharsbx(CIBlock::GetAdminElementEditLink($t['IBLOCK_ID'], $t['ID'])) . '" title="' . GetMessage("SPS_ELSEARCH_ELEMENT_EDIT") . '">' . $t['ID'] . '</a>]';
             }
         } else {
             $res = htmlspecialcharsex($property_value);
         }
         if ($res != "") {
             $v .= ($v != '' ? ' / ' : '') . $res;
         }
     }
     if ($v != "") {
         $row->AddViewField("PROPERTY_" . $aProp['ID'], $v);
     }
     unset($arSelectedProps[$aProp['ID']]["CACHE"]);
 }
 foreach ($arPrices as $price) {
     $row->AddViewField("PRICE" . $price['ID'], $arPricesResult[$price['ID']][$arItems["ID"]]);
            echo GetMessage("IBLOCK_EL_SAVE_AND_ADD");
            ?>
">
	<?php 
            $buttons_add_html = ob_get_contents();
            ob_end_clean();
            $tabControl->Buttons(false, $buttons_add_html);
        } elseif (!$bPropertyAjax && $nobuttons !== "Y") {
            $wfClose = "{\n\t\ttitle: '" . CUtil::JSEscape(GetMessage("IBLOCK_EL_CANC")) . "',\n\t\tname: 'dontsave',\n\t\tid: 'dontsave',\n\t\taction: function () {\n\t\t\tvar FORM = this.parentWindow.GetForm();\n\t\t\tFORM.appendChild(BX.create('INPUT', {\n\t\t\t\tprops: {\n\t\t\t\t\ttype: 'hidden',\n\t\t\t\t\tname: this.name,\n\t\t\t\t\tvalue: 'Y'\n\t\t\t\t}\n\t\t\t}));\n\t\t\tthis.disableUntilError();\n\t\t\tthis.parentWindow.Submit();\n\t\t}\n\t}";
            $save_and_add = "{\n\t\ttitle: '" . CUtil::JSEscape(GetMessage("IBLOCK_EL_SAVE_AND_ADD")) . "',\n\t\tname: 'save_and_add',\n\t\tid: 'save_and_add',\n\t\tclassName: 'adm-btn-add',\n\t\taction: function () {\n\t\t\tvar FORM = this.parentWindow.GetForm();\n\t\t\tFORM.appendChild(BX.create('INPUT', {\n\t\t\t\tprops: {\n\t\t\t\t\ttype: 'hidden',\n\t\t\t\t\tname: 'save_and_add',\n\t\t\t\t\tvalue: 'Y'\n\t\t\t\t}\n\t\t\t}));\n\n\t\t\tthis.parentWindow.hideNotify();\n\t\t\tthis.disableUntilError();\n\t\t\tthis.parentWindow.Submit();\n\t\t}\n\t}";
            $cancel = "{\n\t\ttitle: '" . CUtil::JSEscape(GetMessage("IBLOCK_EL_CANC")) . "',\n\t\tname: 'cancel',\n\t\tid: 'cancel',\n\t\taction: function () {\n\t\t\tBX.WindowManager.Get().Close();\n\t\t\tif(window.reloadAfterClose)\n\t\t\t\ttop.BX.reload(true);\n\t\t}\n\t}";
            $tabControl->ButtonsPublic(array('.btnSave', $ID > 0 && $bWorkflow ? $wfClose : $cancel, $save_and_add));
        }
        $tabControl->Show();
        if ((!defined('BX_PUBLIC_MODE') || BX_PUBLIC_MODE != 1) && CIBlockRights::UserHasRightTo($IBLOCK_ID, $IBLOCK_ID, "iblock_edit") && !$bAutocomplete) {
            echo BeginNote(), GetMessage("IBEL_E_IBLOCK_MANAGE_HINT"), ' <a href="/bitrix/admin/iblock_edit.php?type=' . htmlspecialcharsbx($type) . '&amp;lang=' . LANG . '&amp;ID=' . $IBLOCK_ID . '&amp;admin=Y&amp;return_url=' . urlencode("/bitrix/admin/" . CIBlock::GetAdminElementEditLink($IBLOCK_ID, $ID, array("WF" => $WF == "Y" ? "Y" : null, "find_section_section" => intval($find_section_section), "return_url" => strlen($return_url) > 0 ? $return_url : null))) . '">', GetMessage("IBEL_E_IBLOCK_MANAGE_HINT_HREF"), '</a>', EndNote();
        }
        //////////////////////////
        //END of the custom form
        //////////////////////////
        ?>

<?php 
    }
}
if ($bAutocomplete) {
    require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_popup_admin.php";
} elseif ($bPropertyAjax) {
    require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_admin_js.php";
} else {
    require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_admin.php";
Esempio n. 10
0
 /**
  * @param $productId
  * @param $quantity
  * @param $userId
  * @param $LID
  * @param $userColumns
  * @param string $tmpId we can suggest that this mean the set_item
  * @return array
  * @throws Main\LoaderException
  */
 protected function getProductDataToFillBasket($productId, $quantity, $userId, $LID, $userColumns, $tmpId = "")
 {
     $isSetItem = $tmpId != "";
     if (self::$catalogIncluded === null) {
         self::$catalogIncluded = Main\Loader::includeModule('catalog');
     }
     if (!self::$catalogIncluded) {
         return array();
     }
     $arParams = array();
     static $proxyIblockElement = array();
     static $proxyCatalogMeasure = array();
     static $proxyParent = array();
     static $proxyIblockProperty = array();
     static $proxyProductData = array();
     static $proxyCatalogProduct = array();
     static $proxyCatalogMeasureRatio = array();
     $productId = (int) $productId;
     if ($productId <= 0) {
         return $arParams;
     }
     if (!empty($proxyIblockElement[$productId])) {
         $iblockId = $proxyIblockElement[$productId];
     } else {
         $iblockId = (int) \CIBlockElement::getIBlockByID($productId);
         if ($iblockId > 0) {
             $proxyIblockElement[$productId] = $iblockId;
         }
     }
     if ($iblockId <= 0) {
         return $arParams;
     }
     $arSku2Parent = array();
     $arElementId = array();
     $arElementId[] = $productId;
     $proxyParentKey = $productId . "|" . $iblockId;
     if (!empty($proxyParent[$proxyParentKey]) && is_array($proxyParent[$proxyParentKey])) {
         $arParent = $proxyParent[$proxyParentKey];
     } else {
         $arParent = \CCatalogSku::getProductInfo($productId, $iblockId);
         $proxyParent[$proxyParentKey] = $arParent;
     }
     if ($arParent) {
         $arElementId[] = $arParent["ID"];
         $arSku2Parent[$productId] = $arParent["ID"];
     }
     $arPropertyInfo = array();
     $userColumns = (string) $userColumns;
     $arUserColumns = $userColumns != '' ? explode(",", $userColumns) : array();
     foreach ($arUserColumns as $key => $column) {
         if (strncmp($column, 'PROPERTY_', 9) != 0) {
             unset($arUserColumns[$key]);
         } else {
             $propertyCode = substr($column, 9);
             if ($propertyCode == '') {
                 unset($arUserColumns[$key]);
                 continue;
             }
             if (!empty($proxyIblockProperty[$propertyCode]) && is_array($proxyIblockProperty[$propertyCode])) {
                 $arPropertyInfo[$column] = $proxyIblockProperty[$propertyCode];
             } else {
                 $dbres = \CIBlockProperty::GetList(array(), array("CODE" => $propertyCode));
                 if ($arPropData = $dbres->GetNext()) {
                     $arPropertyInfo[$column] = $arPropData;
                     $proxyIblockProperty[$propertyCode] = $arPropData;
                 }
             }
         }
     }
     $arSelect = array_merge(array("ID", "NAME", "IBLOCK_ID", "IBLOCK_SECTION_ID", "DETAIL_PICTURE", "PREVIEW_PICTURE", "XML_ID", "IBLOCK_XML_ID"), $arUserColumns);
     $proxyProductDataKey = md5(join('|', $arElementId) . "_" . join('|', $arSelect));
     if (!empty($proxyProductData[$proxyProductDataKey]) && is_array($proxyProductData[$proxyProductDataKey])) {
         $arProductData = $proxyProductData[$proxyProductDataKey];
     } else {
         $arProductData = getProductProps($arElementId, $arSelect);
         $proxyProductData[$proxyProductDataKey] = $arProductData;
     }
     $defaultMeasure = \CCatalogMeasure::getDefaultMeasure(true, true);
     if (!empty($arProductData)) {
         $arElementInfo = array();
         foreach ($arProductData as $elemId => &$arElement) {
             foreach ($arElement as $key => $value) {
                 if (strncmp($key, 'PROPERTY_', 9) == 0 && substr($key, -6) == "_VALUE") {
                     $columnCode = str_replace("_VALUE", "", $key);
                     $arElement[$key] = getIblockPropInfo($value, $arPropertyInfo[$columnCode], array("WIDTH" => 90, "HEIGHT" => 90));
                 }
             }
         }
         unset($arElement);
         if (isset($arProductData[$productId])) {
             $arElementInfo = $arProductData[$productId];
         }
         if (isset($arSku2Parent[$productId])) {
             $arParent = $arProductData[$arSku2Parent[$productId]];
         }
         if (!empty($arSku2Parent)) {
             foreach ($arUserColumns as $field) {
                 $fieldVal = $field . "_VALUE";
                 $parentId = $arSku2Parent[$productId];
                 if ((!isset($arElementInfo[$fieldVal]) || isset($arElementInfo[$fieldVal]) && strlen($arElementInfo[$fieldVal]) == 0) && (isset($arProductData[$parentId][$fieldVal]) && !empty($arProductData[$parentId][$fieldVal]))) {
                     $arElementInfo[$fieldVal] = $arProductData[$parentId][$fieldVal];
                 }
             }
             if (strpos($arElementInfo["~XML_ID"], '#') === false) {
                 $arElementInfo["~XML_ID"] = $arParent['~XML_ID'] . '#' . $arElementInfo["~XML_ID"];
             }
         }
         $arElementInfo["MODULE"] = "catalog";
         $arElementInfo["PRODUCT_PROVIDER_CLASS"] = "CCatalogProductProvider";
         $arElementInfo["PRODUCT_ID"] = $arElementInfo["ID"];
         if ($arElementInfo["IBLOCK_ID"] > 0) {
             $arElementInfo["EDIT_PAGE_URL"] = \CIBlock::GetAdminElementEditLink($arElementInfo["IBLOCK_ID"], $arElementInfo["PRODUCT_ID"], array("find_section_section" => $arElementInfo["IBLOCK_SECTION_ID"], 'WF' => 'Y'));
         }
         static $buyersGroups = array();
         if (empty($buyersGroups[$userId])) {
             $buyersGroups[$userId] = \CUser::getUserGroup($userId);
         }
         $arBuyerGroups = $buyersGroups[$userId];
         // price
         $currentVatMode = \CCatalogProduct::getPriceVatIncludeMode();
         $currentUseDiscount = \CCatalogProduct::getUseDiscount();
         \CCatalogProduct::setUseDiscount(!$isSetItem);
         \CCatalogProduct::setPriceVatIncludeMode(true);
         \CCatalogProduct::setUsedCurrency(Sale\Internals\SiteCurrencyTable::getSiteCurrency($LID));
         $arPrice = \CCatalogProduct::getOptimalPrice($arElementInfo["ID"], 1, $arBuyerGroups, "N", array(), $LID);
         \CCatalogProduct::clearUsedCurrency();
         \CCatalogProduct::setPriceVatIncludeMode($currentVatMode);
         \CCatalogProduct::setUseDiscount($currentUseDiscount);
         unset($currentUseDiscount, $currentVatMode);
         $currentPrice = $arPrice['RESULT_PRICE']['DISCOUNT_PRICE'];
         $arElementInfo['PRICE'] = $currentPrice;
         $arElementInfo['CURRENCY'] = $arPrice['RESULT_PRICE']['CURRENCY'];
         $currentTotalPrice = $arPrice['RESULT_PRICE']['BASE_PRICE'];
         $arProduct = array();
         if (!empty($proxyCatalogProduct[$productId]) && is_array($proxyCatalogProduct[$productId])) {
             $arProduct = $proxyCatalogProduct[$productId];
         } else {
             $rsProducts = \CCatalogProduct::getList(array(), array('ID' => $productId), false, false, array('ID', 'QUANTITY', 'WEIGHT', 'MEASURE', 'TYPE', 'BARCODE_MULTI'));
             if ($arProduct = $rsProducts->Fetch()) {
                 $proxyCatalogProduct[$productId] = $arProduct;
             }
         }
         if (empty($arProduct) || !is_array($arProduct)) {
             return array();
         }
         $balance = floatval($arProduct["QUANTITY"]);
         // sku props
         $arSkuData = array();
         $arProps[] = array("NAME" => "Catalog XML_ID", "CODE" => "CATALOG.XML_ID", "VALUE" => $arElementInfo['~IBLOCK_XML_ID']);
         static $proxySkuProperty = array();
         if (!empty($proxySkuProperty[$productId]) && is_array($proxySkuProperty[$productId])) {
             $arSkuProperty = $proxySkuProperty[$productId];
         } else {
             $arSkuProperty = \CSaleProduct::GetProductSkuProps($productId, '', true);
             $proxySkuProperty[$productId] = $arSkuProperty;
         }
         if (!empty($arSkuProperty)) {
             foreach ($arSkuProperty as &$val) {
                 $arSkuData[] = array('NAME' => $val['NAME'], 'VALUE' => $val['VALUE'], 'CODE' => $val['CODE']);
             }
             unset($val);
         }
         $arSkuData[] = array("NAME" => "Product XML_ID", "CODE" => "PRODUCT.XML_ID", "VALUE" => $arElementInfo["~XML_ID"]);
         $arElementInfo["WEIGHT"] = $arProduct["WEIGHT"];
         // measure
         $arElementInfo["MEASURE_TEXT"] = "";
         $arElementInfo["MEASURE_CODE"] = 0;
         if ((int) $arProduct["MEASURE"] > 0) {
             if (!empty($proxyCatalogMeasure[$arProduct["MEASURE"]]) && is_array($proxyCatalogMeasure[$arProduct["MEASURE"]])) {
                 $arMeasure = $proxyCatalogMeasure[$arProduct["MEASURE"]];
             } else {
                 $dbMeasure = \CCatalogMeasure::GetList(array(), array("ID" => intval($arProduct["MEASURE"])), false, false, array("ID", "SYMBOL_RUS", "SYMBOL_INTL"));
                 if ($arMeasure = $dbMeasure->Fetch()) {
                     $proxyCatalogMeasure[$arProduct["MEASURE"]] = $arMeasure;
                 }
             }
             if (!empty($arMeasure) && is_array($arMeasure)) {
                 $arElementInfo["MEASURE_TEXT"] = $arMeasure["SYMBOL_RUS"] != '' ? $arMeasure["SYMBOL_RUS"] : $arMeasure["SYMBOL_INTL"];
                 $arElementInfo["MEASURE_CODE"] = $arMeasure["CODE"];
             }
         }
         if ($arElementInfo["MEASURE_TEXT"] == '') {
             $arElementInfo["MEASURE_TEXT"] = $defaultMeasure["SYMBOL_RUS"] != '' ? $defaultMeasure["SYMBOL_RUS"] : $defaultMeasure["SYMBOL_INTL"];
         }
         // ratio
         $arElementInfo["RATIO"] = 1;
         if (!empty($proxyCatalogMeasureRatio[$productId]) && is_array($proxyCatalogMeasureRatio[$productId])) {
             $arRatio = $proxyCatalogMeasureRatio[$productId];
         } else {
             $dbratio = \CCatalogMeasureRatio::GetList(array(), array("PRODUCT_ID" => $productId));
             if ($arRatio = $dbratio->Fetch()) {
                 $proxyCatalogMeasureRatio[$productId] = $arRatio;
             }
         }
         if (!empty($arRatio) && is_array($arRatio)) {
             $arElementInfo["RATIO"] = $arRatio["RATIO"];
         }
         // image
         $imgCode = '';
         $imgUrl = '';
         if ($arElementInfo["PREVIEW_PICTURE"] > 0) {
             $imgCode = $arElementInfo["PREVIEW_PICTURE"];
         } elseif ($arElementInfo["DETAIL_PICTURE"] > 0) {
             $imgCode = $arElementInfo["DETAIL_PICTURE"];
         }
         if ($imgCode == "" && count($arParent) > 0) {
             if ($arParent["PREVIEW_PICTURE"] > 0) {
                 $imgCode = $arParent["PREVIEW_PICTURE"];
             } elseif ($arParent["DETAIL_PICTURE"] > 0) {
                 $imgCode = $arParent["DETAIL_PICTURE"];
             }
         }
         if ($imgCode > 0) {
             $arFile = \CFile::GetFileArray($imgCode);
             $arImgProduct = \CFile::ResizeImageGet($arFile, array('width' => 80, 'height' => 80), BX_RESIZE_IMAGE_PROPORTIONAL, false, false);
             if (is_array($arImgProduct)) {
                 $imgUrl = $arImgProduct["src"];
             }
         }
         $arSetInfo = array();
         $arStores = array();
         /** @var $productProvider IBXSaleProductProvider */
         if ($productProvider = \CSaleBasket::GetProductProvider(array("MODULE" => $arElementInfo["MODULE"], "PRODUCT_PROVIDER_CLASS" => $arElementInfo["PRODUCT_PROVIDER_CLASS"]))) {
             // get set items if it is set
             if ($arProduct["TYPE"] == \CCatalogProduct::TYPE_SET) {
                 if (method_exists($productProvider, "GetSetItems")) {
                     $arSets = $productProvider::GetSetItems($productId, \CSaleBasket::TYPE_SET);
                     if ($tmpId == "") {
                         $tmpId = randString(7);
                     }
                     if (!empty($arSets)) {
                         foreach ($arSets as $arSetData) {
                             foreach ($arSetData["ITEMS"] as $setItem) {
                                 $arSetItemParams = self::getProductDataToFillBasket($setItem["PRODUCT_ID"], $setItem["QUANTITY"], $userId, $LID, $userColumns, $tmpId);
                                 // recursive call
                                 // re-define some fields with set data values
                                 $arSetItemParams["PARENT_OFFER_ID"] = $productId;
                                 $arSetItemParams["OFFER_ID"] = $setItem["PRODUCT_ID"];
                                 $arSetItemParams["NAME"] = $setItem["NAME"];
                                 $arSetItemParams["MODULE"] = $setItem["MODULE"];
                                 $arSetItemParams["PRODUCT_PROVIDER_CLASS"] = $setItem["PRODUCT_PROVIDER_CLASS"];
                                 $arSetItemParams["QUANTITY"] = $setItem["QUANTITY"] * $quantity;
                                 $arSetItemParams["BARCODE_MULTI"] = $setItem["BARCODE_MULTI"];
                                 $arSetItemParams["PRODUCT_TYPE"] = $setItem["TYPE"];
                                 $arSetItemParams["WEIGHT"] = $setItem["WEIGHT"];
                                 $arSetItemParams["VAT_RATE"] = $setItem["VAT_RATE"];
                                 $arSetItemParams["SET_ITEMS"] = "";
                                 $arSetItemParams["OLD_PARENT_ID"] = $productId . "_tmp" . $tmpId;
                                 $arSetItemParams["IS_SET_ITEM"] = "Y";
                                 $arSetItemParams["IS_SET_PARENT"] = "N";
                                 $arSetItemParams["PROVIDER_DATA"] = serialize($setItem);
                                 $arSetInfo[] = $arSetItemParams;
                             }
                         }
                     }
                 }
             }
             // get stores
             $storeCount = $productProvider::GetStoresCount(array("SITE_ID" => $LID));
             // with exact SITE_ID or SITE_ID = NULL
             if ($storeCount > 0) {
                 if ($arProductStore = $productProvider::GetProductStores(array("PRODUCT_ID" => $productId, "SITE_ID" => $LID))) {
                     $arStores = $arProductStore;
                 }
             }
         }
         $currentTotalPrice = (double) $currentTotalPrice;
         // params array
         $arParams["OFFER_ID"] = $productId;
         $arParams["NAME"] = $arElementInfo["~NAME"];
         $arParams["EDIT_PAGE_URL"] = $arElementInfo["EDIT_PAGE_URL"];
         $arParams["DETAIL_PAGE_URL"] = htmlspecialcharsex($arElementInfo["~DETAIL_PAGE_URL"]);
         $arParams["PICTURE_URL"] = $imgUrl;
         $arParams["PRICE"] = floatval($arElementInfo["PRICE"]);
         $arParams["PRICE_BASE"] = $currentTotalPrice;
         $arParams["DIMENSIONS"] = serialize(array("WIDTH" => $arElementInfo["WIDTH"], "HEIGHT" => $arElementInfo["HEIGHT"], "LENGTH" => $arElementInfo["LENGTH"]));
         $arParams["QUANTITY"] = $quantity;
         $arParams["MODULE"] = $arElementInfo["MODULE"];
         $arParams["CURRENCY"] = $arElementInfo["CURRENCY"];
         $arParams["WEIGHT"] = $arElementInfo["WEIGHT"];
         $arParams["VAT_RATE"] = $arPrice["PRICE"]["VAT_RATE"];
         $arParams["PRICE_TYPE"] = $arPrice["PRICE"]["CATALOG_GROUP_NAME"];
         $arParams["AVAILABLE"] = $balance;
         $arParams["NOTES"] = !empty($arPrice["PRICE"]["CATALOG_GROUP_NAME"]) ? $arPrice["PRICE"]["CATALOG_GROUP_NAME"] : "";
         $arParams["CATALOG_XML_ID"] = $arElementInfo["~IBLOCK_XML_ID"];
         $arParams["PRODUCT_XML_ID"] = $arElementInfo["~XML_ID"];
         $arParams["PRODUCT_PROVIDER_CLASS"] = $arElementInfo["PRODUCT_PROVIDER_CLASS"];
         $arParams["PROPS"] = $arSkuData;
         $arParams["MEASURE_TEXT"] = $arElementInfo["MEASURE_TEXT"];
         $arParams["MEASURE_CODE"] = $arElementInfo["MEASURE_CODE"];
         $arParams["MEASURE_RATIO"] = $arElementInfo["RATIO"];
         $arParams["BARCODE_MULTI"] = $arProduct["BARCODE_MULTI"];
         $arParams["PRODUCT_TYPE"] = empty($arSetInfo) ? "" : \CSaleBasket::TYPE_SET;
         $arParams["OLD_PARENT_ID"] = empty($arSetInfo) ? "" : $productId . "_tmp" . $tmpId;
         $arParams["SET_ITEMS"] = $arSetInfo;
         $arParams["IS_SET_ITEM"] = "N";
         $arParams["IS_SET_PARENT"] = empty($arSetInfo) ? "N" : "Y";
         $arParams["STORES"] = empty($arSetInfo) ? $arStores : array();
         $arParams["PRODUCT_PROPS_VALUES"] = $arElementInfo;
         // along with other information also contains values of properties with correct keys (after getProductProps)
     }
     return $arParams;
 }
	private static function GetProductCatalogInfo($productID)
	{
		$productID = intval($productID);
		$result = "";
		if ($productID <= 0)
			return array();

		$dbProduct = CIBlockElement::GetList(array(), array("ID" => $productID), false, false, array('ID', 'IBLOCK_ID', 'NAME'));
		if ($arProduct = $dbProduct->Fetch())
		{
			if ($arProduct["IBLOCK_ID"] > 0)
				$arProduct["EDIT_PAGE_URL"] = CIBlock::GetAdminElementEditLink($arProduct["IBLOCK_ID"], $productID);
		}

		return array(
			"#PRODUCT_ID#"   => $arProduct["ID"],
			"#PRODUCT_NAME#" => $arProduct["NAME"],
		);
	}
Esempio n. 12
0
	/**
	 * get sku for product
	 *
	 * @param integer $USER_ID
	 * @param string  $LID
	 * @param integer $PRODUCT_ID
	 * @param string  $PRODUCT_NAME
	 * @return array
	 */
	public static function GetProductSku($USER_ID, $LID, $PRODUCT_ID, $PRODUCT_NAME = '', $CURRENCY = '', $arProduct = array())
	{
		$USER_ID = IntVal($USER_ID);

		$PRODUCT_ID = IntVal($PRODUCT_ID);
		if ($PRODUCT_ID <= 0)
			return false;

		$LID = trim($LID);
		if (strlen($LID) <= 0)
			return false;

		$PRODUCT_NAME = trim($PRODUCT_NAME);
		$arResult = array();
		$arOffers = array();

		static $arCacheGroups = array();

		if (!is_set($arCacheGroups[$USER_ID]))
			$arCacheGroups[$USER_ID] = CUser::GetUserGroup($USER_ID);
		$arGroups = $arCacheGroups[$USER_ID];

		if (empty($arProduct))
			$arProduct = CSaleProduct::GetProductListIblockInfo(array($PRODUCT_ID));

		static $arOffersIblock = array();
		if (!is_set($arOffersIblock[$arProduct["IBLOCK_ID"]]))
		{
			$mxResult = CCatalogSKU::GetInfoByProductIBlock($arProduct["IBLOCK_ID"]);
			if (is_array($mxResult))
				$arOffersIblock[$arProduct["IBLOCK_ID"]] = $mxResult["IBLOCK_ID"];
		}

		if ($arOffersIblock[$arProduct["IBLOCK_ID"]] > 0)
		{

			static $arCacheOfferProperties = array();
			if (!is_set($arCacheOfferProperties[$arOffersIblock[$arProduct["IBLOCK_ID"]]]))
			{
				$dbOfferProperties = CIBlock::GetProperties($arOffersIblock[$arProduct["IBLOCK_ID"]], array(), array("!XML_ID" => "CML2_LINK"));
				while($arOfferProperties = $dbOfferProperties->Fetch())
					$arCacheOfferProperties[$arOffersIblock[$arProduct["IBLOCK_ID"]]][] = $arOfferProperties;
			}
			$arOfferProperties = $arCacheOfferProperties[$arOffersIblock[$arProduct["IBLOCK_ID"]]];


			$arIblockOfferProps = array();
			$arIblockOfferPropsFilter = array();
			if (is_array($arOfferProperties))
			{
				foreach ($arOfferProperties as $val)
				{
					$arIblockOfferProps[] = array("CODE" => $val["CODE"], "NAME" => $val["NAME"]);
					$arIblockOfferPropsFilter[] = $val["CODE"];
				}
			}

			$arOffers = CIBlockPriceTools::GetOffersArray(
						$arProduct["IBLOCK_ID"],
						$PRODUCT_ID,
						array("ID" => "DESC"),
						array("NAME"),
						$arIblockOfferPropsFilter,
						0,
						array(),
						1,
						array(),
						$USER_ID,
						$LID
			);
			$arSku = array();
			$minItemPrice = 0;
			$minItemPriceFormat = "";

			$arSkuId = array();
			$arImgSku = array();
			foreach($arOffers as $arOffer)
				$arSkuId[] = $arOffer['ID'];

			if (!empty($arSkuId))
			{
				$res = CIBlockElement::GetList(array(), array("ID" => $arSkuId), false, false, array("ID", "IBLOCK_ID", "NAME", "PREVIEW_PICTURE", "DETAIL_PICTURE", "DETAIL_PAGE_URL"));
				while($arOfferImg = $res->GetNext())
					$arImgSku[$arOfferImg["ID"]] = $arOfferImg;
			}

			foreach($arOffers as $arOffer)
			{
				$arPrice = CCatalogProduct::GetOptimalPrice($arOffer['ID'], 1, $arGroups, "N", array(), $LID);
				if (empty($arPrice))
				{
					break;
				}
				elseif (strlen($CURRENCY) > 0)
				{
					$arPrice["PRICE"]["PRICE"] = CCurrencyRates::ConvertCurrency($arPrice["PRICE"]["PRICE"], $arPrice["PRICE"]["CURRENCY"], $CURRENCY);
					if ($arPrice["DISCOUNT_PRICE"] > 0)
						$arPrice["DISCOUNT_PRICE"] = CCurrencyRates::ConvertCurrency($arPrice["DISCOUNT_PRICE"], $arPrice["PRICE"]["CURRENCY"], $CURRENCY);

					$arPrice["PRICE"]["CURRENCY"] = $CURRENCY;
				}
				$arSkuTmp = array();

				$arOffer["CAN_BUY"] = "N";
				$arCatalogProduct = CCatalogProduct::GetByID($arOffer['ID']);
				if (!empty($arCatalogProduct))
				{
					if ($arCatalogProduct["CAN_BUY_ZERO"]!="Y" && ($arCatalogProduct["QUANTITY_TRACE"]=="Y" && doubleval($arCatalogProduct["QUANTITY"])<=0))
						$arOffer["CAN_BUY"] = "N";
					else
						$arOffer["CAN_BUY"] = "Y";
				}

				$arSkuTmp["ImageUrl"] = '';
				if ($arOffer["CAN_BUY"] == "Y")
				{
					$productImg = "";
					if (isset($arImgSku[$arOffer['ID']]) && !empty($arImgSku[$arOffer['ID']]))
					{
						if ('' == $PRODUCT_NAME)
							$PRODUCT_NAME = $arImgSku[$arOffer['ID']]["~NAME"];

						if($arImgSku[$arOffer['ID']]["PREVIEW_PICTURE"] != "")
							$productImg = $arImgSku[$arOffer['ID']]["PREVIEW_PICTURE"];
						elseif($arImgSku[$arOffer['ID']]["DETAIL_PICTURE"] != "")
							$productImg = $arImgSku[$arOffer['ID']]["DETAIL_PICTURE"];

						if ($productImg == "")
						{
							if($arProduct["PREVIEW_PICTURE"] != "")
								$productImg = $arProduct["PREVIEW_PICTURE"];
							elseif($arProduct["DETAIL_PICTURE"] != "")
								$productImg = $arProduct["DETAIL_PICTURE"];
						}

						if ($productImg != "")
						{
							$arFile = CFile::GetFileArray($productImg);
							$productImg = CFile::ResizeImageGet($arFile, array('width'=>80, 'height'=>80), BX_RESIZE_IMAGE_PROPORTIONAL, false, false);
							$arSkuTmp["ImageUrl"] = $productImg["src"];
						}
					}
				}

				if (($minItemPrice === 0) || ($arPrice["DISCOUNT_PRICE"] < $minItemPrice))
				{
					$minItemPrice = $arPrice["DISCOUNT_PRICE"];
					$minItemPriceFormat = SaleFormatCurrency($arPrice["DISCOUNT_PRICE"], $arPrice["PRICE"]["CURRENCY"]);
				}

				foreach($arIblockOfferProps as $arCode)
				{
					if (array_key_exists($arCode["CODE"], $arOffer["PROPERTIES"]))
					{
						if (is_array($arOffer["PROPERTIES"][$arCode["CODE"]]["VALUE"]))
							$arSkuTmp[] = implode("/", $arOffer["PROPERTIES"][$arCode["CODE"]]["VALUE"]);
						else
							$arSkuTmp[] = $arOffer["PROPERTIES"][$arCode["CODE"]]["VALUE"];
					}
				}

				if (!empty($arCatalogProduct))
				{
					$arSkuTmp["BALANCE"] = $arCatalogProduct["QUANTITY"];
					$arSkuTmp["WEIGHT"] = $arCatalogProduct["WEIGHT"];
					$arSkuTmp["BARCODE_MULTI"] = $arCatalogProduct["BARCODE_MULTI"];
				}
				else
				{
					$arSkuTmp["BALANCE"] = 0;
					$arSkuTmp["WEIGHT"] = 0;
					$arSkuTmp["BARCODE_MULTI"] = 'N';
				}
				$urlEdit = CIBlock::GetAdminElementEditLink(
					$arOffer["IBLOCK_ID"],
					$arOffer['ID'],
					array(
						'find_section_section' => 0,
						'WF' => 'Y',
					)
				);
				$discountPercent = 0;
				$arSkuTmp["USER_ID"] = $USER_ID;
				$arSkuTmp["ID"] = $arOffer["ID"];
				$arSkuTmp["NAME"] = CUtil::JSEscape($arOffer["NAME"]);
				$arSkuTmp["PRODUCT_NAME"] = CUtil::JSEscape($PRODUCT_NAME);
				$arSkuTmp["PRODUCT_ID"] = $PRODUCT_ID;
				$arSkuTmp["LID"] = CUtil::JSEscape($LID);
				$arSkuTmp["MIN_PRICE"] = $minItemPriceFormat;
				$arSkuTmp["URL_EDIT"] = $urlEdit;
				$arSkuTmp["DISCOUNT_PRICE"] = '';
				$arSkuTmp["DISCOUNT_PRICE_FORMATED"] = '';
				$arSkuTmp["PRICE"] = $arPrice["PRICE"]["PRICE"];
				$arSkuTmp["PRICE_FORMATED"] = CurrencyFormatNumber($arPrice["PRICE"]["PRICE"], $arPrice["PRICE"]["CURRENCY"]);

				$arPriceType = GetCatalogGroup($arPrice["PRICE"]["CATALOG_GROUP_ID"]);
				$arSkuTmp["PRICE_TYPE"] = $arPriceType["NAME_LANG"];
				$arSkuTmp["VAT_RATE"] = $arPrice["PRICE"]["VAT_RATE"];

				if (count($arPrice["DISCOUNT"]) > 0)
				{
					$discountPercent = IntVal($arPrice["DISCOUNT"]["VALUE"]);

					$arSkuTmp["DISCOUNT_PRICE"] = $arPrice["DISCOUNT_PRICE"];
					$arSkuTmp["DISCOUNT_PRICE_FORMATED"] = CurrencyFormatNumber($arPrice["DISCOUNT_PRICE"], $arPrice["PRICE"]["CURRENCY"]);
				}

				$arCurFormat = CCurrencyLang::GetCurrencyFormat($arPrice["PRICE"]["CURRENCY"]);
				$arSkuTmp["VALUTA_FORMAT"] = str_replace("#", '', $arCurFormat["FORMAT_STRING"]);
				$arSkuTmp["DISCOUNT_PERCENT"] = $discountPercent;
				$arSkuTmp["CURRENCY"] = $arPrice["PRICE"]["CURRENCY"];
				$arSkuTmp["CAN_BUY"] = $arOffer["CAN_BUY"];

				$arSku[] = $arSkuTmp;
			}
			if ((!is_array($arIblockOfferProps) || empty($arIblockOfferProps)) && is_array($arSku) && !empty($arSku))
			{
				$arIblockOfferProps[0] = array("CODE" => "TITLE", "NAME" => GetMessage("SKU_TITLE"));
				foreach ($arSku as $key => $val)
					$arSku[$key][0] = $val["NAME"];
			}

			$arResult["SKU_ELEMENTS"] = $arSku;
			$arResult["SKU_PROPERTIES"] = $arIblockOfferProps;
			$arResult["OFFERS_IBLOCK_ID"] = $arOffersIblock[$arProduct["IBLOCK_ID"]];
		}//if OFFERS_IBLOCK_ID > 0

		return $arResult;
	}
Esempio n. 13
0
 public static function getIBlockElementContentMenu($intIBlockID, $intID, &$arCatalog, $arParams)
 {
     $arResult = false;
     $intIBlockID = (int) $intIBlockID;
     $intID = (int) $intID;
     if ($intIBlockID <= 0 || $intID <= 0) {
         return false;
     }
     if (empty($arCatalog)) {
         $arCatalog = CCatalogSKU::GetInfoByIBlock($intIBlockID);
     }
     if (empty($arCatalog)) {
         return false;
     }
     if ($arCatalog['CATALOG'] != 'Y') {
         return false;
     }
     if (empty($arParams) || !is_array($arParams)) {
         $arParams = array();
     }
     $boolFeatureSet = CBXFeatures::IsFeatureEnabled('CatCompleteSet');
     $intProductID = CIBlockElement::GetRealElement($intID);
     $strProductType = '';
     if (isset($_REQUEST[self::$strMainPrefix . 'PRODUCT_TYPE'])) {
         $strProductType = (string) $_REQUEST[self::$strMainPrefix . 'PRODUCT_TYPE'];
         if ('' != $strProductType && !in_array($strProductType, self::getTabList())) {
             $strProductType = '';
         }
     }
     if ('' != $strProductType && !$boolFeatureSet) {
         if (self::TAB_SET == $strProductType || self::TAB_GROUP == $strProductType) {
             $strProductType = '';
         }
     }
     $boolExistOffers = false;
     if (CCatalogSKU::TYPE_FULL == $arCatalog['CATALOG_TYPE']) {
         $boolExistOffers = CCatalogSKU::IsExistOffers($intID, $intIBlockID);
     }
     $boolExistSet = CCatalogProductSet::isProductHaveSet($intProductID, CCatalogProductSet::TYPE_SET);
     $boolExistGroup = CCatalogProductSet::isProductHaveSet($intProductID, CCatalogProductSet::TYPE_GROUP);
     $arItems = array();
     if (CCatalogSKU::TYPE_OFFERS != $arCatalog['CATALOG_TYPE']) {
         if (!$boolExistOffers && !$boolExistSet) {
             //product
             $arItems[] = array('ICON' => '', 'TEXT' => Loc::getMessage('BT_CAT_SET_PRODUCT_TYPE_CATALOG'), 'CHECKED' => true);
             if (CCatalogSKU::TYPE_FULL == $arCatalog['CATALOG_TYPE']) {
                 $arNewParams = $arParams;
                 $arNewParams[self::$strMainPrefix . 'PRODUCT_TYPE'] = self::TAB_SKU;
                 $arItems[] = array('ICON' => '', 'TEXT' => Loc::getMessage('BT_CAT_SET_PRODUCT_TYPE_SKU'), 'LINK' => CIBlock::GetAdminElementEditLink($intIBlockID, $intID, $arNewParams));
             }
             if ($boolFeatureSet) {
                 $arNewParams = $arParams;
                 $arNewParams[self::$strMainPrefix . 'PRODUCT_TYPE'] = self::TAB_SET;
                 $arItems[] = array('ICON' => '', 'TEXT' => Loc::getMessage('BT_CAT_SET_PRODUCT_TYPE_SET'), 'LINK' => CIBlock::GetAdminElementEditLink($intIBlockID, $intID, $arNewParams));
             }
         } elseif ($boolExistOffers) {
             //offers
             $arItems[] = array('ICON' => '', 'TEXT' => Loc::getMessage('BT_CAT_SET_PRODUCT_TYPE_CATALOG'), 'TITLE' => Loc::getMessage('BT_CAT_SET_PRODUCT_TYPE_CATALOG_FROM_SKU'), 'SHOW_TITLE' => true, 'DISABLED' => true);
             $arItems[] = array('ICON' => '', 'TEXT' => Loc::getMessage('BT_CAT_SET_PRODUCT_TYPE_SKU'), 'CHECKED' => true);
             if ($boolFeatureSet) {
                 $arItems[] = array('ICON' => '', 'TEXT' => Loc::getMessage('BT_CAT_SET_PRODUCT_TYPE_SET'), 'TITLE' => Loc::getMessage('BT_CAT_SET_PRODUCT_TYPE_SET_FROM_SKU'), 'SHOW_TITLE' => true, 'DISABLED' => true);
             }
         } elseif ($boolExistSet) {
             if ($boolFeatureSet) {
                 //set
                 $arNewParams = $arParams;
                 $arNewParams['setdel'] = 'Y';
                 $arNewParams['sessid'] = bitrix_sessid();
                 $arItems[] = array('ICON' => '', 'TEXT' => Loc::getMessage('BT_CAT_SET_PRODUCT_TYPE_CATALOG'), 'ACTION' => "if(confirm('" . CUtil::JSEscape(Loc::getMessage('BT_CAT_SET_PRODUCT_TYPE_SET_DELETE_CONFIRM')) . "'))window.location='" . CIBlock::GetAdminElementEditLink($intIBlockID, $intID, $arNewParams) . "';");
                 if (CCatalogSKU::TYPE_FULL == $arCatalog['CATALOG_TYPE']) {
                     $arNewParams[self::$strMainPrefix . 'PRODUCT_TYPE'] = self::TAB_SKU;
                     $arItems[] = array('ICON' => '', 'TEXT' => Loc::getMessage('BT_CAT_SET_PRODUCT_TYPE_SKU'), 'ACTION' => "if(confirm('" . CUtil::JSEscape(Loc::getMessage('BT_CAT_SET_PRODUCT_TYPE_SET_DELETE_CONFIRM')) . "'))window.location='" . CIBlock::GetAdminElementEditLink($intIBlockID, $intID, $arNewParams) . "';");
                 }
                 $arItems[] = array('ICON' => '', 'TEXT' => Loc::getMessage('BT_CAT_SET_PRODUCT_TYPE_SET'), 'CHECKED' => true);
             }
         }
     }
     if (!$boolFeatureSet && CCatalogSKU::TYPE_FULL != $arCatalog['CATALOG_TYPE']) {
         $arItems = array();
     }
     //group
     if ($boolFeatureSet && self::TAB_GROUP != $strProductType) {
         $arItems[] = array('SEPARATOR' => 'Y');
         if (!$boolExistGroup) {
             $arNewParams = $arParams;
             $arNewParams[self::$strMainPrefix . 'PRODUCT_TYPE'] = self::TAB_GROUP;
             $arItems[] = array('ICON' => '', 'TEXT' => Loc::getMessage('BT_CAT_SET_PRODUCT_TYPE_GROUP_ADD'), 'LINK' => CIBlock::GetAdminElementEditLink($intIBlockID, $intID, $arNewParams));
         } else {
             $arNewParams = $arParams;
             $arNewParams['groupdel'] = 'Y';
             $arNewParams['sessid'] = bitrix_sessid();
             $arItems[] = array('ICON' => 'delete', 'TEXT' => Loc::getMessage('BT_CAT_SET_PRODUCT_TYPE_GROUP_DELETE'), 'ACTION' => "if(confirm('" . CUtil::JSEscape(Loc::getMessage('BT_CAT_SET_PRODUCT_TYPE_GROUP_DELETE_CONFIRM')) . "'))window.location='" . CIBlock::GetAdminElementEditLink($intIBlockID, $intID, $arNewParams) . "';");
         }
     }
     if (!empty($arItems)) {
         $arResult = array('TEXT' => Loc::getMessage('BT_CAT_SET_PRODUCT_TYPE_SELECTOR'), 'TITLE' => Loc::getMessage('BT_CAT_SET_PRODUCT_TYPE_SELECTOR_TITLE'), 'MENU' => $arItems);
     }
     return $arResult;
 }
Esempio n. 14
0
                $iblockIterator = CIBlock::GetList(array(), array('ID' => $entityId, 'CHECK_PERMISSIONS' => 'Y', 'MIN_PERMISSION' => 'S'), false);
                $iblock = $iblockIterator->Fetch();
                if (empty($iblock)) {
                    $errors[] = Loc::getMessage('BX_IBLOCK_REDIRECT_ENTITY_ERR_IBLOCK_NOT_FOUND');
                } else {
                    $redirectUrl = CIBlock::GetAdminElementListLink($iblock['ID'], array('find_section_section' => -1, 'WF' => 'Y', 'menu' => null));
                }
                unset($iblock, $iblockIterator);
                break;
            case 'ELEMENT':
                $elementIterator = CIBlockElement::GetList(array(), array('ID' => $entityId, 'CHECK_PERMISSIONS' => 'Y', 'MIN_PERMISSION' => 'S'), false, false, array('ID', 'IBLOCK_ID', 'WF_PARENT_ELEMENT_ID'));
                $element = $elementIterator->Fetch();
                if (empty($element)) {
                    $errors[] = Loc::getMessage('BX_IBLOCK_REDIRECT_ENTITY_ERR_ELEMENT_NOT_FOUND');
                } else {
                    $redirectUrl = CIBlock::GetAdminElementEditLink($element['IBLOCK_ID'], !empty($element['WF_PARENT_ELEMENT_ID']) ? $element['WF_PARENT_ELEMENT_ID'] : $element['ID'], array('find_section_section' => -1, 'WF' => 'Y', 'menu' => null));
                }
                unset($element, $elementIterator);
                break;
        }
        if ($redirectUrl != '') {
            LocalRedirect('/bitrix/admin/' . $redirectUrl);
        }
    }
}
$APPLICATION->SetTitle(Loc::getMessage('BX_IBLOCK_REDIRECT_ENTITY_TITLE'));
require $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/prolog_admin_after.php';
if (!empty($errors)) {
    $errorMessage = new CAdminMessage(array('DETAILS' => implode('<br>', $errors), 'TYPE' => 'ERROR', 'HTML' => true));
    echo $errorMessage->Show();
    unset($errorMessage);
Esempio n. 15
0
 /**
  * Returns list of recommended products for specific product
  *
  * @param integer $USER_ID
  * @param string $LID
  * @param array $arFilterRecomendet
  * @param bool $recomMore
  * @param integer $cntProductDefault
  * @return array
  */
 public static function GetRecommendetProduct($USER_ID, $LID, $arFilterRecomendet = array(), $recomMore = 'N', $cntProductDefault = 2)
 {
     $arRecomendetResult = array();
     if (CModule::IncludeModule('catalog') && CModule::IncludeModule('iblock') && count($arFilterRecomendet) > 0) {
         $rsIblock = CIBlock::GetList(array(), array('TYPE' => 'catalog', 'SITE_ID' => $LID, 'ACTIVE' => 'Y', 'CODE' => 'furniture'));
         $arIblock = $rsIblock->Fetch();
         $arFilter = array("ACTIVE" => "Y", "IBLOCK_ID" => $arIblock["ID"], "ID" => $arFilterRecomendet);
         $rsElement = CIBlockElement::GetList(array(), $arFilter, false, false);
         while ($obElement = $rsElement->GetNextElement()) {
             $arElementProps = $obElement->GetProperties();
             if (isset($arElementProps["RECOMMEND"]) && is_array($arElementProps["RECOMMEND"]["VALUE"]) > 0) {
                 foreach ($arElementProps["RECOMMEND"]["VALUE"] as $val) {
                     $arRecomendet[$val] = $val;
                 }
             }
         }
         if (count($arRecomendet) > 0) {
             $arBuyerGroups = CUser::GetUserGroup($USER_ID);
             $arFilter = array("ACTIVE" => "Y", "ID" => $arRecomendet);
             $rsElement = CIBlockElement::GetList(array(), $arFilter, false, false, array("NAME", "ID", "LID", 'IBLOCK_ID', 'IBLOCK_SECTION_ID', "DETAIL_PICTURE", "PREVIEW_PICTURE", "DETAIL_PAGE_URL"));
             while ($arElement = $rsElement->GetNext()) {
                 if (!in_array($arElement["ID"], $arFilterRecomendet)) {
                     if ($recomMore == "N" && $i < $cntProductDefault || $recomMore == "Y") {
                         $arElement["MODULE"] = "catalog";
                         $arElement["PRODUCT_PROVIDER_CLASS"] = "CCatalogProductProvider";
                         $arElement["PRODUCT_ID"] = $arElement["ID"];
                         $arPrice = CCatalogProduct::GetOptimalPrice($arElement["ID"], 1, $arBuyerGroups, "N", array(), $LID);
                         $currentPrice = $arPrice["DISCOUNT_PRICE"];
                         $arElement["PRICE"] = $currentPrice;
                         $arElement["CURRENCY"] = $arPrice["PRICE"]["CURRENCY"];
                         $arElement["DISCOUNT_PRICE"] = $arPrice["PRICE"]["PRICE"] - $arPrice["DISCOUNT_PRICE"];
                         if ($arElement["IBLOCK_ID"] > 0 && $arElement["IBLOCK_SECTION_ID"] > 0) {
                             $arElement["EDIT_PAGE_URL"] = CIBlock::GetAdminElementEditLink($arElement["IBLOCK_ID"], $arElement["PRODUCT_ID"], array("find_section_section" => $arElement["IBLOCK_SECTION_ID"], 'WF' => 'Y'));
                         }
                         $arRecomendetResult[] = $arElement;
                     }
                 }
             }
         }
         return $arRecomendetResult;
     }
 }
Esempio n. 16
0
 /**
  * 
  *
  *
  *
  *
  * @return mixed <p></p>
  *
  *
  * <h4>Example</h4> 
  * <pre>
  * <br><br>
  * </pre>
  *
  *
  *
  * <h4>See Also</h4> 
  * <p></p><a name="examples"></a>
  *
  *
  * @static
  * @link http://dev.1c-bitrix.ru/api_help/iblock/classes/ciblock/getpanelbuttons.php
  * @author Bitrix
  */
 public static function GetPanelButtons($IBLOCK_ID = 0, $ELEMENT_ID = 0, $SECTION_ID = 0, $arOptions = array())
 {
     /** @global CMain $APPLICATION */
     global $APPLICATION;
     $arButtons = array("view" => array(), "edit" => array(), "configure" => array(), "submenu" => array());
     if (array_key_exists("SECTION_BUTTONS", $arOptions) && $arOptions["SECTION_BUTTONS"] === false) {
         $bSectionButtons = false;
     } else {
         $bSectionButtons = true;
     }
     if (array_key_exists("SESSID", $arOptions) && $arOptions["SESSID"] === false) {
         $bSessID = false;
     } else {
         $bSessID = true;
     }
     $IBLOCK_ID = intval($IBLOCK_ID);
     $ELEMENT_ID = intval($ELEMENT_ID);
     $SECTION_ID = intval($SECTION_ID);
     if ($ELEMENT_ID > 0 && ($IBLOCK_ID <= 0 || $bSectionButtons && $SECTION_ID == 0)) {
         $rsIBlockElement = CIBlockElement::GetList(array(), array("ID" => $ELEMENT_ID, "ACTIVE_DATE" => "Y", "ACTIVE" => "Y", "CHECK_PERMISSIONS" => "Y"), false, false, array("ID", "IBLOCK_ID", "IBLOCK_SECTION_ID"));
         if ($arIBlockElement = $rsIBlockElement->Fetch()) {
             $IBLOCK_ID = $arIBlockElement["IBLOCK_ID"];
             $SECTION_ID = $arIBlockElement["IBLOCK_SECTION_ID"];
         }
     }
     if ($IBLOCK_ID <= 0) {
         return $arButtons;
     }
     $bCatalog = false;
     if (isset($arOptions["CATALOG"]) && $arOptions["CATALOG"] == true) {
         if (CModule::IncludeModule('catalog')) {
             $bCatalog = true;
         }
     }
     $return_url = array("add_element" => "", "edit_element" => "", "edit_iblock" => "", "history_element" => "", "edit_section" => "", "add_section" => "", "delete_section" => "", "delete_element" => "", "element_list" => "", "section_list" => "");
     if (array_key_exists("RETURN_URL", $arOptions)) {
         if (is_array($arOptions["RETURN_URL"])) {
             foreach ($arOptions["RETURN_URL"] as $key => $url) {
                 if (!empty($url) && array_key_exists($key, $return_url)) {
                     $return_url[$key] = $url;
                 }
             }
         } elseif (!empty($arOptions["RETURN_URL"])) {
             foreach ($return_url as $key => $url) {
                 $return_url[$key] = $arOptions["RETURN_URL"];
             }
         }
     }
     $str = "";
     foreach ($return_url as $key => $url) {
         if (empty($url)) {
             if (empty($str)) {
                 if (defined("BX_AJAX_PARAM_ID")) {
                     $str = $APPLICATION->GetCurPageParam("", array(BX_AJAX_PARAM_ID));
                 } else {
                     $str = $APPLICATION->GetCurPageParam();
                 }
             }
             $return_url[$key] = $str;
         }
     }
     $arIBlock = CIBlock::GetArrayByID($IBLOCK_ID);
     $bWorkflow = CModule::IncludeModule("workflow") && $arIBlock["WORKFLOW"] !== "N";
     $s = $bWorkflow ? "&WF=Y" : "";
     $arLabels = $arOptions["LABELS"];
     if ($ELEMENT_ID > 0 && CIBlockElementRights::UserHasRightTo($IBLOCK_ID, $ELEMENT_ID, "element_edit")) {
         $url = "/bitrix/admin/" . CIBlock::GetAdminElementEditLink($IBLOCK_ID, $ELEMENT_ID, array("force_catalog" => $bCatalog, "filter_section" => $SECTION_ID, "bxpublic" => "Y", "from_module" => "iblock", "return_url" => $return_url["edit_element"])) . $s;
         $action = $APPLICATION->GetPopupLink(array("URL" => $url, "PARAMS" => array("width" => 700, 'height' => 400, 'resize' => false)));
         $arButton = array("TEXT" => strlen($arLabels["ELEMENT_EDIT_TEXT"]) ? $arLabels["ELEMENT_EDIT_TEXT"] : $arIBlock["ELEMENT_EDIT"], "TITLE" => strlen($arLabels["ELEMENT_EDIT_TITLE"]) ? $arLabels["ELEMENT_EDIT_TITLE"] : $arIBlock["ELEMENT_EDIT"], "ACTION" => 'javascript:' . $action, "ACTION_URL" => $url, "ONCLICK" => $action, "DEFAULT" => $APPLICATION->GetPublicShowMode() != 'configure' ? true : false, "ICON" => "bx-context-toolbar-edit-icon", "ID" => "bx-context-toolbar-edit-element");
         $arButtons["edit"]["edit_element"] = $arButton;
         $arButtons["configure"]["edit_element"] = $arButton;
         $url = str_replace("&bxpublic=Y&from_module=iblock", "", $url);
         $arButton["ACTION"] = "javascript:jsUtils.Redirect([], '" . CUtil::JSEscape($url) . "')";
         unset($arButton["ONCLICK"]);
         $arButtons["submenu"]["edit_element"] = $arButton;
         if ($bWorkflow) {
             $url = "/bitrix/admin/iblock_history_list.php?type=" . $arIBlock["IBLOCK_TYPE_ID"] . "&lang=" . LANGUAGE_ID . "&IBLOCK_ID=" . $IBLOCK_ID . "&ELEMENT_ID=" . $ELEMENT_ID . "&filter_section=" . $SECTION_ID . "&return_url=" . UrlEncode($return_url["history_element"]);
             $arButton = array("TEXT" => GetMessage("IBLOCK_PANEL_HISTORY_BUTTON"), "TITLE" => GetMessage("IBLOCK_PANEL_HISTORY_BUTTON"), "ACTION" => "javascript:jsUtils.Redirect([], '" . CUtil::JSEscape($url) . "')", "ONCLICK" => "jsUtils.Redirect([], '" . CUtil::JSEscape($url) . "')", "ID" => "bx-context-toolbar-history-element");
             $arButtons["submenu"]["history_element"] = $arButton;
         }
     }
     if (CIBlockSectionRights::UserHasRightTo($IBLOCK_ID, $SECTION_ID, "section_element_bind")) {
         $url = "/bitrix/admin/" . CIBlock::GetAdminElementEditLink($IBLOCK_ID, null, array("force_catalog" => $bCatalog, "filter_section" => $SECTION_ID, "IBLOCK_SECTION_ID" => $SECTION_ID, "bxpublic" => "Y", "from_module" => "iblock", "return_url" => $return_url["add_element"]));
         $action = $APPLICATION->GetPopupLink(array("URL" => $url, "PARAMS" => array("width" => 700, 'height' => 400, 'resize' => false)));
         $arButton = array("TEXT" => strlen($arLabels["ELEMENT_ADD_TEXT"]) ? $arLabels["ELEMENT_ADD_TEXT"] : $arIBlock["ELEMENT_ADD"], "TITLE" => strlen($arLabels["ELEMENT_ADD_TITLE"]) ? $arLabels["ELEMENT_ADD_TITLE"] : $arIBlock["ELEMENT_ADD"], "ACTION" => 'javascript:' . $action, "ACTION_URL" => $url, "ONCLICK" => $action, "ICON" => "bx-context-toolbar-create-icon", "ID" => "bx-context-toolbar-add-element");
         $arButtons["edit"]["add_element"] = $arButton;
         $arButtons["configure"]["add_element"] = $arButton;
         $arButtons["intranet"][] = array('TEXT' => $arButton["TEXT"], 'TITLE' => $arButton["TITLE"], 'ICON' => 'add', 'ONCLICK' => $arButton["ACTION"], 'SORT' => 1000);
         $url = str_replace("&bxpublic=Y&from_module=iblock", "", $url);
         $arButton["ACTION"] = "javascript:jsUtils.Redirect([], '" . CUtil::JSEscape($url) . "')";
         unset($arButton["ONCLICK"]);
         $arButtons["submenu"]["add_element"] = $arButton;
     }
     if ($ELEMENT_ID > 0 && CIBlockElementRights::UserHasRightTo($IBLOCK_ID, $ELEMENT_ID, "element_delete")) {
         //Delete Element
         if (!empty($arButtons["edit"])) {
             $arButtons["edit"][] = array("SEPARATOR" => "Y", "HREF" => "");
         }
         if (!empty($arButtons["configure"])) {
             $arButtons["configure"][] = array("SEPARATOR" => "Y", "HREF" => "");
         }
         if (!empty($arButtons["submenu"])) {
             $arButtons["submenu"][] = array("SEPARATOR" => "Y", "HREF" => "");
         }
         $url = CIBlock::GetAdminElementListLink($IBLOCK_ID, array('action' => 'delete'));
         if ($bSessID) {
             $url .= '&' . bitrix_sessid_get();
         }
         $url .= '&ID=' . (preg_match('/^iblock_list_admin\\.php/', $url) ? "E" : "") . $ELEMENT_ID . "&return_url=" . UrlEncode($return_url["delete_element"]);
         $url = "/bitrix/admin/" . $url;
         $arButton = array("TEXT" => strlen($arLabels["ELEMENT_DELETE_TEXT"]) ? $arLabels["ELEMENT_DELETE_TEXT"] : $arIBlock["ELEMENT_DELETE"], "TITLE" => strlen($arLabels["ELEMENT_DELETE_TITLE"]) ? $arLabels["ELEMENT_DELETE_TITLE"] : $arIBlock["ELEMENT_DELETE"], "ACTION" => "javascript:if(confirm('" . GetMessageJS("IBLOCK_PANEL_ELEMENT_DEL_CONF") . "'))jsUtils.Redirect([], '" . CUtil::JSEscape($url) . "')", "ACTION_URL" => $url, "ONCLICK" => "if(confirm('" . GetMessageJS("IBLOCK_PANEL_ELEMENT_DEL_CONF") . "'))jsUtils.Redirect([], '" . CUtil::JSEscape($url) . "')", "ICON" => "bx-context-toolbar-delete-icon", "ID" => "bx-context-toolbar-delete-element");
         $arButtons["edit"]["delete_element"] = $arButton;
         $arButtons["configure"]["delete_element"] = $arButton;
         $arButtons["submenu"]["delete_element"] = $arButton;
     }
     if ($ELEMENT_ID <= 0 && $bSectionButtons) {
         $rsIBTYPE = CIBlockType::GetByID($arIBlock["IBLOCK_TYPE_ID"]);
         if (($arIBTYPE = $rsIBTYPE->Fetch()) && $arIBTYPE["SECTIONS"] == "Y") {
             if ($SECTION_ID > 0 && CIBlockSectionRights::UserHasRightTo($IBLOCK_ID, $SECTION_ID, "section_edit")) {
                 if (!empty($arButtons["edit"])) {
                     $arButtons["edit"][] = array("SEPARATOR" => "Y", "HREF" => "");
                 }
                 if (!empty($arButtons["configure"])) {
                     $arButtons["configure"][] = array("SEPARATOR" => "Y", "HREF" => "");
                 }
                 if (!empty($arButtons["submenu"])) {
                     $arButtons["submenu"][] = array("SEPARATOR" => "Y", "HREF" => "");
                 }
                 $url = "/bitrix/admin/" . CIBlock::GetAdminSectionEditLink($IBLOCK_ID, $SECTION_ID, array("force_catalog" => $bCatalog, "filter_section" => $SECTION_ID, "bxpublic" => "Y", "from_module" => "iblock", "return_url" => $return_url["edit_section"]));
                 $action = $APPLICATION->GetPopupLink(array("URL" => $url, "PARAMS" => array("width" => 700, 'height' => 400, 'resize' => false)));
                 $arButton = array("TEXT" => strlen($arLabels["SECTION_EDIT_TEXT"]) ? $arLabels["SECTION_EDIT_TEXT"] : $arIBlock["SECTION_EDIT"], "TITLE" => strlen($arLabels["SECTION_EDIT_TITLE"]) ? $arLabels["SECTION_EDIT_TITLE"] : $arIBlock["SECTION_EDIT"], "ACTION" => 'javascript:' . $action, "ACTION_URL" => $url, "ICON" => "bx-context-toolbar-edit-icon", "ONCLICK" => $action, "DEFAULT" => $APPLICATION->GetPublicShowMode() != 'configure' ? true : false, "ID" => "bx-context-toolbar-edit-section");
                 $arButtons["edit"]["edit_section"] = $arButton;
                 $arButtons["configure"]["edit_section"] = $arButton;
                 $url = str_replace("&bxpublic=Y&from_module=iblock", "", $url);
                 $arButton["ACTION"] = "javascript:jsUtils.Redirect([], '" . CUtil::JSEscape($url) . "')";
                 unset($arButton["ONCLICK"]);
                 $arButtons["submenu"]["edit_section"] = $arButton;
             }
             if (CIBlockSectionRights::UserHasRightTo($IBLOCK_ID, $SECTION_ID, "section_section_bind")) {
                 $url = "/bitrix/admin/" . CIBlock::GetAdminSectionEditLink($IBLOCK_ID, null, array("force_catalog" => $bCatalog, "IBLOCK_SECTION_ID" => $SECTION_ID, "filter_section" => $SECTION_ID, "bxpublic" => "Y", "from_module" => "iblock", "return_url" => $return_url["add_section"]));
                 $action = $APPLICATION->GetPopupLink(array("URL" => $url, "PARAMS" => array("width" => 700, 'height' => 400, 'resize' => false)));
                 $arButton = array("TEXT" => strlen($arLabels["SECTION_ADD_TEXT"]) ? $arLabels["SECTION_ADD_TEXT"] : $arIBlock["SECTION_ADD"], "TITLE" => strlen($arLabels["SECTION_ADD_TITLE"]) ? $arLabels["SECTION_ADD_TITLE"] : $arIBlock["SECTION_ADD"], "ACTION" => 'javascript:' . $action, "ACTION_URL" => $url, "ICON" => "bx-context-toolbar-create-icon", "ID" => "bx-context-toolbar-add-section", "ONCLICK" => $action);
                 $arButtons["edit"]["add_section"] = $arButton;
                 $arButtons["configure"]["add_section"] = $arButton;
                 $url = str_replace("&bxpublic=Y&from_module=iblock", "", $url);
                 $arButton["ACTION"] = "javascript:jsUtils.Redirect([], '" . CUtil::JSEscape($url) . "')";
                 unset($arButton["ONCLICK"]);
                 $arButtons["submenu"]["add_section"] = $arButton;
             }
             //Delete section
             if ($SECTION_ID > 0 && CIBlockSectionRights::UserHasRightTo($IBLOCK_ID, $SECTION_ID, "section_delete")) {
                 $url = CIBlock::GetAdminSectionListLink($IBLOCK_ID, array('action' => 'delete'));
                 if ($bSessID) {
                     $url .= '&' . bitrix_sessid_get();
                 }
                 $url .= '&ID[]=' . (preg_match('/^iblock_list_admin\\.php/', $url) ? "S" : "") . $SECTION_ID . "&return_url=" . UrlEncode($return_url["delete_section"]);
                 $url = "/bitrix/admin/" . $url;
                 $arButton = array("TEXT" => strlen($arLabels["SECTION_DELETE_TEXT"]) ? $arLabels["SECTION_DELETE_TEXT"] : $arIBlock["SECTION_DELETE"], "TITLE" => strlen($arLabels["SECTION_DELETE_TITLE"]) ? $arLabels["SECTION_DELETE_TITLE"] : $arIBlock["SECTION_DELETE"], "ACTION" => "javascript:if(confirm('" . GetMessageJS("IBLOCK_PANEL_SECTION_DEL_CONF") . "'))jsUtils.Redirect([], '" . CUtil::JSEscape($url) . "')", "ACTION_URL" => $url, "ONCLICK" => "if(confirm('" . GetMessageJS("IBLOCK_PANEL_SECTION_DEL_CONF") . "'))jsUtils.Redirect([], '" . CUtil::JSEscape($url) . "')", "ICON" => "bx-context-toolbar-delete-icon", "ID" => "bx-context-toolbar-delete-section");
                 $arButtons["edit"]["delete_section"] = $arButton;
                 $arButtons["configure"]["delete_section"] = $arButton;
                 $arButtons["submenu"]["delete_section"] = $arButton;
             }
         }
     }
     if ($IBLOCK_ID > 0 && CIBlockRights::UserHasRightTo($IBLOCK_ID, $IBLOCK_ID, "iblock_admin_display")) {
         if (!empty($arButtons["submenu"])) {
             $arButtons["submenu"][] = array("SEPARATOR" => "Y", "HREF" => "");
         }
         if ($SECTION_ID > 0) {
             $url = "/bitrix/admin/" . CIBlock::GetAdminElementListLink($IBLOCK_ID, array('find_section_section' => $SECTION_ID));
         } else {
             $url = "/bitrix/admin/" . CIBlock::GetAdminElementListLink($IBLOCK_ID, array('find_el_y' => 'Y'));
         }
         $arButton = array("TEXT" => strlen($arLabels["ELEMENTS_NAME_TEXT"]) ? $arLabels["ELEMENTS_NAME_TEXT"] : $arIBlock["ELEMENTS_NAME"], "TITLE" => strlen($arLabels["ELEMENTS_NAME_TITLE"]) ? $arLabels["ELEMENTS_NAME_TITLE"] : $arIBlock["ELEMENTS_NAME"], "ACTION" => "javascript:jsUtils.Redirect([], '" . CUtil::JSEscape($url) . "')", "ACTION_URL" => $url, "ONCLICK" => "jsUtils.Redirect([], '" . CUtil::JSEscape($url) . "')", "ID" => "bx-context-toolbar-elements-list");
         $arButtons["submenu"]["element_list"] = $arButton;
         $arButtons["intranet"]["element_list"] = array('TEXT' => $arButton["TEXT"], 'TITLE' => $arButton["TITLE"], 'ICON' => 'settings', 'ONCLICK' => $arButton["ACTION"], 'SORT' => 1010);
         $url = "/bitrix/admin/" . CIBlock::GetAdminSectionListLink($IBLOCK_ID, array('find_section_section' => $SECTION_ID));
         $arButton = array("TEXT" => strlen($arLabels["SECTIONS_NAME_TEXT"]) ? $arLabels["SECTIONS_NAME_TEXT"] : $arIBlock["SECTIONS_NAME"], "TITLE" => strlen($arLabels["SECTIONS_NAME_TITLE"]) ? $arLabels["SECTIONS_NAME_TITLE"] : $arIBlock["SECTIONS_NAME"], "ACTION" => "javascript:jsUtils.Redirect([], '" . CUtil::JSEscape($url) . "')", "ACTION_URL" => $url, "ONCLICK" => "jsUtils.Redirect([], '" . CUtil::JSEscape($url) . "')", "ID" => "bx-context-toolbar-sections-list");
         $arButtons["submenu"]["section_list"] = $arButton;
         if (CIBlockRights::UserHasRightTo($IBLOCK_ID, $IBLOCK_ID, "iblock_edit")) {
             $url = "/bitrix/admin/iblock_edit.php?type=" . $arIBlock["IBLOCK_TYPE_ID"] . "&lang=" . LANGUAGE_ID . "&ID=" . $IBLOCK_ID . "&return_url=" . UrlEncode($return_url["edit_iblock"]);
             $arButton = array("TEXT" => GetMessage("IBLOCK_PANEL_EDIT_IBLOCK_BUTTON", array("#IBLOCK_NAME#" => $arIBlock["NAME"])), "TITLE" => GetMessage("IBLOCK_PANEL_EDIT_IBLOCK_BUTTON", array("#IBLOCK_NAME#" => $arIBlock["NAME"])), "ACTION" => "javascript:jsUtils.Redirect([], '" . CUtil::JSEscape($url) . "')", "ACTION_URL" => $url, "ONCLICK" => "jsUtils.Redirect([], '" . CUtil::JSEscape($url) . "')", "ID" => "bx-context-toolbar-edit-iblock");
             $arButtons["submenu"]["edit_iblock"] = $arButton;
         }
     }
     return $arButtons;
 }
Esempio n. 17
0
 public function GetAdminListViewHTML($arProperty, $arValue, $strHTMLControlName)
 {
     $strResult = '';
     $mxResult = self::GetPropertyValue($arProperty, $arValue);
     if (is_array($mxResult)) {
         $strResult = $mxResult['NAME'] . ' [<a href="/bitrix/admin/' . CIBlock::GetAdminElementEditLink($mxResult['IBLOCK_ID'], $mxResult['ID'], array('WF' => 'Y')) . '" title="' . Loc::getMessage("BT_UT_EAUTOCOMPLETE_MESS_ELEMENT_EDIT") . '">' . $mxResult['ID'] . '</a>]';
     }
     return $strResult;
 }
Esempio n. 18
0
}
$lAdmin->ShowChain($chain);
// toolbar
$boolBtnNew = false;
$aContext = array();
if ($boolIBlockElementAdd) {
    $boolBtnNew = true;
    if (!empty($arCatalog)) {
        CCatalogAdminTools::setProductFormParams();
        $arCatalogBtns = CCatalogAdminTools::getIBlockElementMenu($IBLOCK_ID, $arCatalog, array('IBLOCK_SECTION_ID' => $find_section_section, 'find_section_section' => $find_section_section, 'from' => 'iblock_list_admin'));
        if (!empty($arCatalogBtns)) {
            $aContext = $arCatalogBtns;
        }
    }
    if (empty($aContext)) {
        $aContext[] = array("TEXT" => htmlspecialcharsbx($arIBlock["ELEMENT_ADD"]), "ICON" => "btn_new", "LINK" => CIBlock::GetAdminElementEditLink($IBLOCK_ID, 0, array('IBLOCK_SECTION_ID' => $find_section_section, 'find_section_section' => $find_section_section, 'from' => 'iblock_list_admin')));
    }
}
if (CIBlockSectionRights::UserHasRightTo($IBLOCK_ID, $find_section_section, "section_section_bind") && $arIBTYPE["SECTIONS"] != "N") {
    $aContext[] = array("TEXT" => htmlspecialcharsbx($arIBlock["SECTION_ADD"]), "ICON" => $boolBtnNew ? "" : "btn_new", "LINK" => CIBlock::GetAdminSectionEditLink($IBLOCK_ID, 0, array('IBLOCK_SECTION_ID' => $find_section_section, 'find_section_section' => $find_section_section, 'from' => 'iblock_list_admin')));
}
if (strlen($sLastFolder) > 0) {
    $aContext[] = array("TEXT" => GetMessage("IBLIST_A_UP"), "LINK" => $sLastFolder, "TITLE" => GetMessage("IBLIST_A_UP_TITLE"));
}
if ($bBizproc && IsModuleInstalled("bizprocdesigner")) {
    $bCanDoIt = CBPDocument::CanUserOperateDocumentType(CBPCanUserOperateOperation::CreateWorkflow, $USER->GetID(), array(MODULE_ID, ENTITY, DOCUMENT_TYPE));
    if ($bCanDoIt) {
        $aContext[] = array("TEXT" => GetMessage("IBLIST_BTN_BP"), "ICON" => "btn_bp", "LINK" => 'iblock_bizproc_workflow_admin.php?document_type=iblock_' . $IBLOCK_ID . '&lang=' . LANGUAGE_ID . '&back_url_list=' . urlencode($REQUEST_URI));
    }
}
$lAdmin->AddAdminContextMenu($aContext);
Esempio n. 19
0
													echo '<div class="no_foto">'.GetMessage('SOD_NO_FOTO').'</div>';
											?>
										</td>
										<?
									}

									if ($columnCode == "COLUMN_NAME")
									{
										if ($bUseIblock)
										{
											$arProductInfo = $arBasketElement[$arItem["PRODUCT_ID"]];

											if ($arProductInfo["IBLOCK_ID"] > 0)
											{
												$arItem["EDIT_PAGE_URL"] = CIBlock::GetAdminElementEditLink($arProductInfo["IBLOCK_ID"], $arItem["PRODUCT_ID"], array(
													"find_section_section" => $arProductInfo["IBLOCK_SECTION_ID"],
													'WF' => 'Y',
												));
											}
										}
										?>
										<td class="COLUMN_NAME">

											<div class='bx-adm-bigdata-icon-medium-inner' <?php 
echo !$arItem['RECOMMENDATION'] ? 'style="visibility: hidden"' : '';
?>
></div>

											<?
											$linkClass = (CSaleBasketHelper::isSetItem($arItem)) ? "set-item-link-name" : "";

											if (strlen($arItem["EDIT_PAGE_URL"]) > 0):
Esempio n. 20
0
 } elseif ($prop['PROPERTY_TYPE'] == 'S') {
     $arViewHTML[] = $prop["VALUE"];
 } elseif ($prop['PROPERTY_TYPE'] == 'L') {
     $arViewHTML[] = $prop["VALUE_ENUM"];
 } elseif ($prop['PROPERTY_TYPE'] == 'F') {
     $arViewHTML[] = CFileInput::Show('NO_FIELDS[' . $prop['PROPERTY_VALUE_ID'] . ']', $prop["VALUE"], array("IMAGE" => "Y", "PATH" => "Y", "FILE_SIZE" => "Y", "DIMENSIONS" => "Y", "IMAGE_POPUP" => "Y", "MAX_SIZE" => $maxImageSize, "MIN_SIZE" => $minImageSize), array('upload' => false, 'medialib' => false, 'file_dialog' => false, 'cloud' => false, 'del' => false, 'description' => false));
 } elseif ($prop['PROPERTY_TYPE'] == 'G') {
     if (intval($prop["VALUE"]) > 0) {
         $rsSection = CIBlockSection::GetList(array(), array("ID" => $prop["VALUE"]), false, array('ID', 'NAME', 'IBLOCK_ID'));
         if ($arSection = $rsSection->GetNext()) {
             $arViewHTML[] = $arSection['NAME'] . ' [<a href="' . htmlspecialcharsbx(CIBlock::GetAdminSectionEditLink($arSection['IBLOCK_ID'], $arSection['ID'])) . '" title="' . GetMessage("IBEL_A_SEC_EDIT") . '">' . $arSection['ID'] . '</a>]';
         }
     }
 } elseif ($prop['PROPERTY_TYPE'] == 'E') {
     if ($t = GetElementName($prop["VALUE"])) {
         $arViewHTML[] = $t['NAME'] . ' [<a href="' . htmlspecialcharsbx(CIBlock::GetAdminElementEditLink($t['IBLOCK_ID'], $t['ID'], array('WF' => 'Y'))) . '" title="' . GetMessage("IBEL_A_EL_EDIT") . '">' . $t['ID'] . '</a>]';
     }
 }
 //Edit Part
 $bUserMultiple = $prop["MULTIPLE"] == "Y" && array_key_exists("GetPropertyFieldHtmlMulty", $arUserType);
 if ($bUserMultiple) {
     if ($last_property_id != $prop["ID"]) {
         $VALUE_NAME = 'FIELDS[' . $f_ID . '][PROPERTY_' . $prop['ID'] . ']';
         $arEditHTML[] = call_user_func_array($arUserType["GetPropertyFieldHtmlMulty"], array($prop, $arProperties[$prop["ID"]], array("VALUE" => $VALUE_NAME, "MODE" => "iblock_element_admin", "FORM_NAME" => "form_" . $sTableID)));
     }
 } elseif (array_key_exists("GetPropertyFieldHtml", $arUserType)) {
     $arEditHTML[] = call_user_func_array($arUserType["GetPropertyFieldHtml"], array($prop, array("VALUE" => $prop["VALUE"], "DESCRIPTION" => $prop["DESCRIPTION"]), array("VALUE" => $VALUE_NAME, "DESCRIPTION" => $DESCR_NAME, "MODE" => "iblock_element_admin", "FORM_NAME" => "form_" . $sTableID)));
 } elseif ($prop['PROPERTY_TYPE'] == 'N' || $prop['PROPERTY_TYPE'] == 'S') {
     if ($prop["ROW_COUNT"] > 1) {
         $html = '<textarea name="' . $VALUE_NAME . '" cols="' . $prop["COL_COUNT"] . '" rows="' . $prop["ROW_COUNT"] . '">' . $prop["VALUE"] . '</textarea>';
     } else {
Esempio n. 21
0
				'IBLOCK_SECTION_ID' => $find_section_section,
				'find_section_section' => $find_section_section,
				'from' => 'iblock_list_admin'
			)
		);
		if (!empty($arCatalogBtns))
			$aContext = $arCatalogBtns;
	}
	if (empty($aContext))
	{
		$aContext[] = array(
			"TEXT" => htmlspecialcharsbx($arIBlock["ELEMENT_ADD"]),
			"ICON" => "btn_new",
			"LINK" => CIBlock::GetAdminElementEditLink($IBLOCK_ID, 0, array(
				'IBLOCK_SECTION_ID'=>$find_section_section,
				'find_section_section'=>$find_section_section,
				'from' => 'iblock_list_admin'
			)),
		);
	}
}

if(CIBlockSectionRights::UserHasRightTo($IBLOCK_ID, $find_section_section, "section_section_bind") && $arIBTYPE["SECTIONS"]!="N")
{
	$aContext[] = array(
		"TEXT" => htmlspecialcharsbx($arIBlock["SECTION_ADD"]),
		"ICON" => ($boolBtnNew ? "" : "btn_new"),
		"LINK" => CIBlock::GetAdminSectionEditLink($IBLOCK_ID, 0, array(
			'IBLOCK_SECTION_ID'=>$find_section_section,
			'find_section_section'=>$find_section_section,
			'from' => 'iblock_list_admin',
Esempio n. 22
0
            }
        }
    }
    $lAdmin->ShowChain($chain);
}
$aContext = array();
if ($boolIBlockElementAdd) {
    if (!empty($arCatalog)) {
        CCatalogAdminTools::setProductFormParams();
        $arCatalogBtns = CCatalogAdminTools::getIBlockElementMenu($IBLOCK_ID, $arCatalog, array('IBLOCK_SECTION_ID' => $find_section_section, 'find_section_section' => $find_section_section));
        if (!empty($arCatalogBtns)) {
            $aContext = $arCatalogBtns;
        }
    }
    if (empty($aContext)) {
        $aContext[] = array("ICON" => "btn_new", "TEXT" => htmlspecialcharsbx($arIBlock["ELEMENT_ADD"]), "LINK" => CIBlock::GetAdminElementEditLink($IBLOCK_ID, 0, array('IBLOCK_SECTION_ID' => $find_section_section, 'find_section_section' => $find_section_section)), "LINK_PARAM" => "", "TITLE" => GetMessage("IBEL_A_ADDEL_TITLE"));
    }
}
if (strlen($sLastFolder) > 0) {
    $aContext[] = array("TEXT" => GetMessage("IBEL_A_UP"), "LINK" => CIBlock::GetAdminElementListLink($IBLOCK_ID, array('find_section_section' => $lastSectionId[count($lastSectionId) - 2])), "LINK_PARAM" => "", "TITLE" => GetMessage("IBEL_A_UP_TITLE"));
}
if ($bBizproc && IsModuleInstalled("bizprocdesigner")) {
    $bCanDoIt = CBPDocument::CanUserOperateDocumentType(CBPCanUserOperateOperation::CreateWorkflow, $USER->GetID(), array("iblock", "CIBlockDocument", "iblock_" . $IBLOCK_ID));
    if ($bCanDoIt) {
        $aContext[] = array("TEXT" => GetMessage("IBEL_BTN_BP"), "LINK" => 'iblock_bizproc_workflow_admin.php?document_type=iblock_' . $IBLOCK_ID . '&lang=' . LANGUAGE_ID . '&back_url_list=' . urlencode($REQUEST_URI), "LINK_PARAM" => "");
    }
}
$lAdmin->AddAdminContextMenu($aContext);
$lAdmin->CheckListMode();
$APPLICATION->SetTitle($arIBlock["NAME"] . ": " . $arIBlock["ELEMENTS_NAME"]);
$APPLICATION->AddHeadScript('/bitrix/js/iblock/iblock_edit.js');
Esempio n. 23
0
                    "LINK" => $sLastFolder,
                ));
            }
        }
    }
    $lAdmin->ShowChain($chain);
}

$aContext = array();

if ($boolIBlockElementAdd) {
    $aContext[] = array(
        "ICON" => "btn_new",
        "TEXT" => htmlspecialcharsbx($arIBlock["ELEMENT_ADD"]),
        "LINK" => CIBlock::GetAdminElementEditLink($IBLOCK_ID, 0, array(
            'IBLOCK_SECTION_ID' => $find_section_section,
            'find_section_section' => $find_section_section
        )),
        "LINK_PARAM" => "",
        "TITLE" => GetMessage("IBEL_A_ADDEL_TITLE")
    );
    if ($bCatalog) {
        CCatalogAdminTools::setProductFormParams();
        $arCatalogBtns = CCatalogAdminTools::getIBlockElementMenu(
                        $IBLOCK_ID, $arCatalog, array(
                    'IBLOCK_SECTION_ID' => $find_section_section,
                    'find_section_section' => $find_section_section
                        )
        );
        if (!empty($arCatalogBtns))
            $aContext[] = $arCatalogBtns;
    }
 }
 if (CModule::IncludeModule('sale')) {
     if (strlen($BASE_LANG_CURR) > 0 && $BASE_LANG_CURR != $arPrice["PRICE"]["CURRENCY"]) {
         $currentTotalPrice = roundEx(CCurrencyRates::ConvertCurrency($currentTotalPrice, $arPrice["PRICE"]["CURRENCY"], $BASE_LANG_CURR), SALE_VALUE_PRECISION);
         $currentPrice = roundEx(CCurrencyRates::ConvertCurrency($currentPrice, $arPrice["PRICE"]["CURRENCY"], $BASE_LANG_CURR), SALE_VALUE_PRECISION);
         $currentBasePrice = roundEx(CCurrencyRates::ConvertCurrency($currentBasePrice, $arPrice["PRICE"]["CURRENCY"], $BASE_LANG_CURR), SALE_VALUE_PRECISION);
         $currentDiscount = roundEx(CCurrencyRates::ConvertCurrency($currentDiscount, $arPrice["PRICE"]["CURRENCY"], $BASE_LANG_CURR), SALE_VALUE_PRECISION);
         $arPrice["PRICE"]["CURRENCY"] = $BASE_LANG_CURR;
     }
     $currentTotalPriceFormat = CurrencyFormatNumber($currentTotalPrice, $arPrice["PRICE"]["CURRENCY"]);
     $summaFormated = CurrencyFormatNumber($currentPrice * $QUANTITY, $arPrice["PRICE"]["CURRENCY"]);
 } else {
     $currentTotalPriceFormat = CurrencyFormatNumber($currentTotalPrice, $arPrice["PRICE"]["CURRENCY"]);
     $summaFormated = CurrencyFormatNumber($currentPrice * $QUANTITY, $arPrice["PRICE"]["CURRENCY"]);
 }
 $urlEdit = CIBlock::GetAdminElementEditLink($arItems["IBLOCK_ID"], $arItems["ID"], array("find_section_section" => $arItems["IBLOCK_SECTION_ID"]));
 $bCanBuy = true;
 if ($arCatalogProduct["CAN_BUY_ZERO"] != "Y" && ($arCatalogProduct["QUANTITY_TRACE"] == "Y" && doubleval($arCatalogProduct["QUANTITY"]) <= 0)) {
     $bCanBuy = false;
 }
 if ($addDefault == "Y" || $bCanBuy && $addDefault == "N") {
     $arParams = "{'id' : '" . $arItems["ID"] . "',\n\t\t\t\t'name' : '" . CUtil::JSEscape($arItems["NAME"]) . "',\n\t\t\t\t'url' : '" . CUtil::JSEscape($URL) . "',\n\t\t\t\t'urlEdit' : '" . CUtil::JSEscape($urlEdit) . "',\n\t\t\t\t'urlImg' : '" . CUtil::JSEscape($ImgUrl) . "',\n\t\t\t\t'price' : '" . CUtil::JSEscape($currentPrice) . "',\n\t\t\t\t'summaFormated' : '" . CUtil::JSEscape(0) . "',\n\t\t\t\t'quantity' : '" . CUtil::JSEscape($QUANTITY) . "',\n\t\t\t\t'reserved' : '" . CUtil::JSEscape($arCatalogProduct["QUANTITY_RESERVED"]) . "',\n\t\t\t\t'module' : 'catalog',\n\t\t\t\t'currency' : '" . CUtil::JSEscape('') . "',\n\t\t\t\t'weight' : '" . DoubleVal($arCatalogProduct["WEIGHT"]) . "',\n\t\t\t\t'vatRate' : '" . DoubleVal($vatRate) . "',\n\t\t\t\t'priceType' : '" . CUtil::JSEscape($PriceType) . "',\n\t\t\t\t'balance' : '" . CUtil::JSEscape('-') . "',\n\t\t\t\t'catalogXmlID' : '" . CUtil::JSEscape($arIBlock["XML_ID"]) . "',\n\t\t\t\t'productXmlID' : '" . CUtil::JSEscape($arItems["XML_ID"]) . "',\n\t\t\t\t'callback' : 'CatalogBasketCallback',\n\t\t\t\t'orderCallback' : 'CatalogBasketOrderCallback',\n\t\t\t\t'cancelCallback' : 'CatalogBasketCancelCallback',\n\t\t\t\t'isMultiBarcode' : '" . CUtil::JSEscape($arCatalogProduct["BARCODE_MULTI"]) . "',\n\t\t\t\t'barcode' : '" . CUtil::JSEscape($arCatalogProduct["BARCODE"]) . "',\n\t\t\t\t'payCallback' : 'CatalogPayOrderCallback'}";
     foreach (GetModuleEvents("sale", "OnProductSearchForm", true) as $arEvent) {
         $arParams = ExecuteModuleEventEx($arEvent, array($arItems["ID"], $arParams));
     }
     $arParams = "var el" . $arItems["ID"] . " = " . $arParams;
     $act = "<script type=\"text/javascript\">" . $arParams . "</script><input type='button' onClick=\"SelEl(el" . $arItems["ID"] . ", " . $arItems["ID"] . ")\" name='btn_select_" . $arItems["ID"] . "' id='btn_select_" . $arItems["ID"] . "' value='" . GetMessage("SPS_SELECT") . "' >";
     $countField = "<input type=\"text\" name=\"quantity_" . $arItems["ID"] . "\" id=\"quantity_" . $arItems["ID"] . "\" value=\"1\" size=\"3\" >";
     $active = GetMEssage('SPS_PRODUCT_ACTIVE');
 } else {
     $act = GetMessage("SPS_CAN_BUY_NOT_PRODUCT");