Example #1
0
function fGetFormatedProduct($USER_ID, $LID, $arData, $currency, $type = '')
{
	global $crmMode;
	$result = "";
	$arSet = array();

	if (!is_array($arData["ITEMS"]) || count($arData["ITEMS"]) <= 0)
		return $result;

	$result = "<table width=\"100%\">";
	if (CModule::IncludeModule('catalog') && CModule::IncludeModule('iblock'))
	{
		$arProductId = array();
		$arDataTab = array();

		$arSkuParentChildren = array();
		$arSkuParentId = array();
		$arSkuParent = array();

		foreach ($arData["ITEMS"] as $item)
		{
			if (!empty($item["CURRENCY"]) && $item["CURRENCY"] != $currency)
			{
				if (floatval($item["PRICE"]) > 0)
					$item["PRICE"] = CCurrencyRates::ConvertCurrency($item["PRICE"], $item["CURRENCY"], $currency);

				if (floatval($item["DISCOUNT_PRICE"]) > 0)
					$item["DISCOUNT_PRICE"] = CCurrencyRates::ConvertCurrency($item["DISCOUNT_PRICE"], $item["CURRENCY"], $currency);

				$item["CURRENCY"] = $currency;
			}

			/** @var $productProvider IBXSaleProductProvider */
			if ($productProvider = CSaleBasket::GetProductProvider($item))
			{
				if (method_exists($productProvider, "GetSetItems"))
				{
					$itemInfo = (isset($item['ID']) ? array('BASKET_ID' => $item['ID']) : array());
					$arSets = $productProvider::GetSetItems($item["PRODUCT_ID"], CSaleBasket::TYPE_SET, $itemInfo);
					unset($itemInfo);

					if (is_array($arSets))
					{
						foreach ($arSets as $arSetData)
						{
							foreach ($arSetData["ITEMS"] as $setItem)
							{
								$setItem["FUSER_ID"] = $item["FUSER_ID"];
								$setItem["LID"] = $item["LID"];
								$setItem["MODULE"] = $item["MODULE"];
								$setItem["PRODUCT_PROVIDER_CLASS"] = $productProvider;
								$setItem["SET_PARENT_ID"] = $item["ID"];

								$arSet[$item["PRODUCT_ID"]][] = $setItem;
							}
						}
					}
				}
			}

			if ($item["MODULE"] == "catalog")
			{
				$arProductId[$item["PRODUCT_ID"]] = $item["PRODUCT_ID"];
				$arDataTab[$item["PRODUCT_ID"]] = $item;

				$arParent = CCatalogSku::GetProductInfo($item["PRODUCT_ID"]);
				if ($arParent)
				{
					$arSkuParentChildren[$item["PRODUCT_ID"]] = $arParent["ID"];
					$arSkuParentId[$arParent["ID"]] = $arParent["ID"];
				}
			}
		}

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

		if(!empty($arProductId))
		{
			$dbProduct = CIBlockElement::GetList(array(), array("ID" => $arProductId), false, false, array('ID', 'IBLOCK_ID', 'IBLOCK_SECTION_ID', 'DETAIL_PICTURE', 'PREVIEW_PICTURE', 'IBLOCK_TYPE_ID'));
			while($arProduct = $dbProduct->Fetch())
			{
				$imgCode = 0;
				$arImgProduct = false;
				$arFile = false;
				$imgUrl = '';
				$imgProduct = '';
				$arDataTab[$arProduct['ID']]['IBLOCK_ID'] = $arProduct['IBLOCK_ID'];
				$arDataTab[$arProduct['ID']]['IBLOCK_SECTION_ID'] = $arProduct['IBLOCK_SECTION_ID'];
				$arDataTab[$arProduct['ID']]['DETAIL_PICTURE'] = $arProduct['DETAIL_PICTURE'];
				$arDataTab[$arProduct['ID']]['PREVIEW_PICTURE'] = $arProduct['PREVIEW_PICTURE'];
				$arDataTab[$arProduct['ID']]['IBLOCK_TYPE_ID'] = $arProduct['IBLOCK_TYPE_ID'];
				$item = $arDataTab[$arProduct['ID']];

				if ($item["PREVIEW_PICTURE"] == "" && $item["DETAIL_PICTURE"] == "" && is_set($arSkuParentChildren[$item["PRODUCT_ID"]]))
				{
					$idTmp = $arSkuParentChildren[$item["PRODUCT_ID"]];
					$item["DETAIL_PICTURE"] = $arSkuParent[$idTmp]["DETAIL_PICTURE"];
					$item["PREVIEW_PICTURE"] = $arSkuParent[$idTmp]["PREVIEW_PICTURE"];
				}

				if ($item["DETAIL_PICTURE"] > 0)
					$imgCode = $item["DETAIL_PICTURE"];
				elseif ($item["PREVIEW_PICTURE"] > 0)
					$imgCode = $item["PREVIEW_PICTURE"];

				$arSkuProperty = CSaleProduct::GetProductSkuProps($item["PRODUCT_ID"], $item["IBLOCK_ID"]);

				$item["NAME"] = htmlspecialcharsex($item["NAME"]);
				$item["EDIT_PAGE_URL"] = htmlspecialcharsex($item["EDIT_PAGE_URL"]);
				$item["CURRENCY"] = htmlspecialcharsex($item["CURRENCY"]);

				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"];
					$imgProduct = "<a href=\"".$item["EDIT_PAGE_URL"]."\" target=\"_blank\"><img src=\"".$imgUrl."\" alt=\"\" title=\"".$item["NAME"]."\" ></a>";
				}
				else
					$imgProduct = "<div class='no_foto'>".GetMessage('NO_FOTO')."</div>";

				$arCurFormat = CCurrencyLang::GetCurrencyFormat($item["CURRENCY"]);
				$priceValutaFormat = str_replace("#", '', $arCurFormat["FORMAT_STRING"]);

				$currentTotalPrice = ($item["PRICE"] + $item["DISCOUNT_PRICE"]);

				$discountPercent = 0;
				if ($item["DISCOUNT_PRICE"] > 0)
					$discountPercent = intval(($item["DISCOUNT_PRICE"] * 100) / $currentTotalPrice);

				$arProduct = CCatalogProduct::GetByID($item["PRODUCT_ID"]);
				$balance = floatval($arProduct["QUANTITY"]);

				$result .= "<tr id='more_".$type."_".$item["ID"]."'>
								<td class=\"tab_img\" >".$imgProduct."</td>
								<td class=\"tab_text\">
									<div class=\"order_name\"><a href=\"".$item["EDIT_PAGE_URL"]."\" target=\"_blank\" title=\"".$item["NAME"]."\">".$item["NAME"]."</a></div>
									<div class=\"order_price\">
										".GetMessage('NEWO_SUBTAB_PRICE').": <b>".SaleFormatCurrency($item["PRICE"], $currency)."</b>";

				if (!empty($arSet) && array_key_exists($arProduct["ID"], $arSet)) // show/hide set item link
				{
					$result .= '<br/>
						<div>
							<a id="set_toggle_link_b'.$arProduct["ID"].'"
								href="javascript:void(0);"
								class="dashed-link show-set-link"
								title="'.GetMessage("SOE_SHOW_SET").'"
								onclick="fToggleSetItems(\'b'.$arProduct["ID"].'\');">'.GetMessage("SOE_SHOW_SET").'</a>
						</div>';
				}

				$result .= "</div>";

				$arResult = CSaleProduct::GetProductSku($USER_ID, $LID, $item["PRODUCT_ID"], $item["NAME"], $currency, $arProduct);

				if (count($arResult["SKU_ELEMENTS"]) > 0)
				{
					foreach ($arResult["SKU_ELEMENTS"] as $key => $val)
					{
						$arTmp = array();
						foreach ($val as $k => $v)
						{
							if (is_numeric($k))
							{
								$arTmp[$arResult["SKU_PROPERTIES"][$k]["NAME"]] = $v;
							}
						}
						$arResult["SKU_ELEMENTS"][$key]["SKU_PROPS"] = CUtil::PhpToJSObject($arTmp);
					}
				}

				$arResult["POPUP_MESSAGE"] = array(
					"PRODUCT_ADD" => GetMessage('NEWO_POPUP_TO_BASKET'),
					"PRODUCT_ORDER" => GetMessage('NEWO_POPUP_TO_ORDER'),
					"PRODUCT_NOT_ADD" => GetMessage('NEWO_POPUP_DONT_CAN_BUY'),
					"PRODUCT_PRICE_FROM" => GetMessage('NEWO_POPUP_FROM')
				);

				if (count($arResult["SKU_ELEMENTS"]) <= 0)
					$result .= "<a href=\"javascript:void(0);\" class=\"get_new_order\" onClick=\"fAddToBasketMoreProduct('".$type."', ".$item["PRODUCT_ID"].");return false;\"><span></span>".GetMessage('NEWO_SUBTAB_ADD_BASKET')."</a><br>";
				else
					$result .= "<a href=\"javascript:void(0);\" class=\"get_new_order\" onClick=\"fAddToBasketMoreProductSku(".CUtil::PhpToJsObject($arResult['SKU_ELEMENTS']).", ".CUtil::PhpToJsObject($arResult['SKU_PROPERTIES']).", 'basket', ".CUtil::PhpToJsObject($arResult["POPUP_MESSAGE"]).");\"><span></span>".GetMessage('NEWO_SUBTAB_ADD_BASKET')."</a><br>";

				if (!$crmMode)
				{
					if (count($arResult["SKU_ELEMENTS"]) > 0)
					{
						$result .= "<a href=\"javascript:void(0);\" class=\"get_new_order\" onClick=\"fAddToBasketMoreProductSku(".CUtil::PhpToJsObject($arResult['SKU_ELEMENTS']).", ".CUtil::PhpToJsObject($arResult['SKU_PROPERTIES']).", 'neworder', ".CUtil::PhpToJsObject($arResult["POPUP_MESSAGE"]).");\"><span></span>".GetMessage('NEWO_SUBTAB_ADD_ORDER')."</a>";
					}
					else
					{
						$cntProd = (floatval($item["QUANTITY"]) > 0) ? floatval($item["QUANTITY"]) : 1;
						$url = "/bitrix/admin/sale_order_new.php?lang=".LANGUAGE_ID."&user_id=".$USER_ID."&LID=".$LID."&product[".$item["PRODUCT_ID"]."]=".$cntProd;
						$result .= "<a href=\"".$url."\" target=\"_blank\" class=\"get_new_order\"><span></span>".GetMessage('NEWO_SUBTAB_ADD_ORDER')."</a>";
					}
				}

				$result .= "</td></tr>";

				// show set items
				if (!empty($arSet) && array_key_exists($arProduct["ID"], $arSet))
				{
					foreach ($arSet[$arProduct["ID"]] as $set)
					{
						$editUrl = CIBlock::GetAdminElementEditLink($set["IBLOCK_ID"], $set["ITEM_ID"], array(
							"find_section_section" => $set["IBLOCK_SECTION_ID"],
							'WF' => 'Y',
						));

						if ($set["PREVIEW_PICTURE"] > 0)
							$imgCode = $set["PREVIEW_PICTURE"];
						elseif ($set["DETAIL_PICTURE"] > 0)
							$imgCode = $set["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"];
								$img = '<a href="'.$editUrl.'" target="_blank"><img src="'.$arImgProduct["src"].'" alt="" title="'.$set["NAME"].'" ></a>';
							}
						}
						else
							$img = '<div class="no_foto">'.GetMessage('SOD_NO_FOTO')."</div>";

						$result .= '
							<tr style="display:none" class="set_item_b'.$arProduct["ID"].'">
								<td class="tab_img">'.$img.'</td>
								<td class="tab_text">
									<div class="order_name">
										<a href="'.$editUrl.'" style="font-style:italic" target="_blank" title="'.$set["NAME"].'">'.$set["NAME"].'</a>
									</div>
									<div class="order_price">'.GetMessage('NEWO_SUBTAB_PRICE').': <b>'.SaleFormatCurrency($set["PRICE"], $currency).'</b></div>
								</td>
							</tr>';
					}
				}

			}//end foreach
		}
	}//end if

	if ($arData["CNT"] > 2 && $arData["CNT"] != count($arData["ITEMS"]))
	{
		$result .= "<tr><td colspan='2' align='right' class=\"more_product\">";
		if ($type == "basket")
			$result .= "<a href='javascript:void(0);' onClick='fGetMoreBasket(\"Y\");' class=\"get_more\">".GetMessage('NEWO_SUBTAB_MORE')."<span></span></a>";
		elseif ($type == "viewed")
			$result .= "<a href='javascript:void(0);' onClick='fGetMoreViewed(\"Y\");' class=\"get_more\">".GetMessage('NEWO_SUBTAB_MORE')."<span></span></a>";
		else
			$result .= "<a href='javascript:void(0);' onClick='fGetMoreRecom();' class=\"get_more\">".GetMessage('NEWO_SUBTAB_MORE')."<span></span></a>";
		$result .= "</td></tr>";
	}

	$result .= "</table>";

	return $result;
}
 $lAdmin->NavText($dbResultList->GetNavPrint(GetMessage("sale_prod_search_nav")));
 $arHeaders = array(array("id" => "ID", "content" => "ID", "sort" => "id", "default" => true), array("id" => "ACTIVE", "content" => GetMessage("SOPS_ACTIVE"), "sort" => "ACTIVE", "default" => true), array("id" => "NAME", "content" => GetMessage("SPS_NAME"), "sort" => "name", "default" => true), array("id" => "QUANTITY", "content" => GetMessage("SOPS_QUANTITY"), "default" => true), array("id" => "BALANCE", "content" => GetMessage("SOPS_BALANCE"), "sort" => "", "default" => true, "align" => "right"), array("id" => "PRICE", "content" => GetMessage("SOPS_PRICE"), "default" => true, "align" => "right"), array("id" => "ACT", "content" => "&nbsp;", "default" => true));
 $lAdmin->AddHeaders($arHeaders);
 $arDiscountCoupons = array();
 if (CModule::IncludeModule("sale") && strlen($LID) > 0) {
     $BASE_LANG_CURR = CSaleLang::GetLangCurrency($LID);
     $arCurFormat = CCurrencyLang::GetCurrencyFormat($BASE_LANG_CURR);
     $priceValutaFormat = str_replace("#", '', $arCurFormat["FORMAT_STRING"]);
 }
 $arSku = array();
 $OfferIblockId = "";
 $aReplace = array("
", "\\", "'", "\"", "\r\n", "\r", "\n", "
");
 $aSearch = array(" ", "\\\\", "\\'", '\\"', "\n", "\n", "\\n'+\n'", "\\n'+\n'");
 while ($arItems = $dbResultList->Fetch()) {
     $row =& $lAdmin->AddRow($arItems["ID"], $arItems);
     $arResult = CSaleProduct::GetProductSku($BUYER_ID, $LID, $arItems["ID"], $arItems["NAME"]);
     if (count($arResult["SKU_ELEMENTS"]) > 0) {
         $OfferIblockId = $arResult["OFFERS_IBLOCK_ID"];
         $row->AddField("PRICE", GetMessage("SPS_PROCE_FROM") . " " . $arResult["SKU_ELEMENTS"][0]["MIN_PRICE"]);
         $row->AddField("ACTIVE", '&nbsp;');
         $skuTmp = array();
         foreach ($arResult["SKU_ELEMENTS"] as $val) {
             $skuTmp[] = array("ID" => $val["ID"]);
         }
         $row->AddField("ACT", "<input type='button' onClick=\"fShowSku(this, " . CUtil::PhpToJSObject($skuTmp) . ");\" name='btn_show_sku_" . $arItems["ID"] . "' value='" . GetMessage("SPS_SKU_SHOW") . "' >");
         // echo "<pre>"; print_r($arResult["SKU_ELEMENTS"]); echo "</pre>";
         foreach ($arResult["SKU_ELEMENTS"] as $val) {
             $skuProperty = "";
             $arSkuProperty = array();
             foreach ($val as $kk => $vv) {
                 if (is_int($kk) && strlen($vv) > 0) {
Example #3
0
function fGetFormatedProduct($USER_ID, $LID, $arData, $currency, $type = '')
{
    global $crmMode;
    $result = "";
    if (!is_array($arData["ITEMS"]) || count($arData["ITEMS"]) <= 0) {
        return $result;
    }
    $result = "<table width=\"100%\">";
    if (CModule::IncludeModule('catalog') && CModule::IncludeModule('iblock')) {
        $arProductId = array();
        $arDataTab = array();
        $arSkuParentChildren = array();
        $arSkuParentId = array();
        $arSkuParent = array();
        foreach ($arData["ITEMS"] as $items) {
            if ($items["MODULE"] == "catalog") {
                $arProductId[$items["PRODUCT_ID"]] = $items["PRODUCT_ID"];
                $arDataTab[$items["PRODUCT_ID"]] = $items;
                $arParent = CCatalogSku::GetProductInfo($items["PRODUCT_ID"]);
                if ($arParent) {
                    $arSkuParentChildren[$items["PRODUCT_ID"]] = $arParent["ID"];
                    $arSkuParentId[$arParent["ID"]] = $arParent["ID"];
                }
            }
        }
        $res = CIBlockElement::GetList(array(), array("ID" => $arSkuParentId), false, false, array("ID", "IBLOCK_ID", "IBLOCK_SECTION_ID", "PREVIEW_PICTURE", "DETAIL_PICTURE", "NAME", "DETAIL_PAGE_URL"));
        while ($arItems = $res->GetNext()) {
            $arSkuParent[$arItems["ID"]] = $arItems;
        }
        $dbProduct = CIBlockElement::GetList(array(), array("ID" => $arProductId), false, false, array('ID', 'IBLOCK_ID', 'IBLOCK_SECTION_ID', 'DETAIL_PICTURE', 'PREVIEW_PICTURE', 'IBLOCK_TYPE_ID'));
        while ($arProduct = $dbProduct->Fetch()) {
            $imgCode = 0;
            $arDataTab[$arProduct['ID']]['IBLOCK_ID'] = $arProduct['IBLOCK_ID'];
            $arDataTab[$arProduct['ID']]['IBLOCK_SECTION_ID'] = $arProduct['IBLOCK_SECTION_ID'];
            $arDataTab[$arProduct['ID']]['DETAIL_PICTURE'] = $arProduct['DETAIL_PICTURE'];
            $arDataTab[$arProduct['ID']]['PREVIEW_PICTURE'] = $arProduct['PREVIEW_PICTURE'];
            $arDataTab[$arProduct['ID']]['IBLOCK_TYPE_ID'] = $arProduct['IBLOCK_TYPE_ID'];
            $items = $arDataTab[$arProduct['ID']];
            if ($items["PREVIEW_PICTURE"] == "" && $items["DETAIL_PICTURE"] == "" && is_set($arSkuParentChildren[$items["PRODUCT_ID"]])) {
                $idTmp = $arSkuParentChildren[$items["PRODUCT_ID"]];
                $items["DETAIL_PICTURE"] = $arSkuParent[$idTmp]["DETAIL_PICTURE"];
                $items["PREVIEW_PICTURE"] = $arSkuParent[$idTmp]["PREVIEW_PICTURE"];
            }
            if ($items["DETAIL_PICTURE"] > 0) {
                $imgCode = $items["DETAIL_PICTURE"];
            } elseif ($items["PREVIEW_PICTURE"] > 0) {
                $imgCode = $items["PREVIEW_PICTURE"];
            }
            $arSkuProperty = CSaleProduct::GetProductSkuProps($items["PRODUCT_ID"]);
            $items["NAME"] = htmlspecialcharsex($items["NAME"]);
            $items["EDIT_PAGE_URL"] = htmlspecialcharsex($items["EDIT_PAGE_URL"]);
            $items["CURRENCY"] = htmlspecialcharsex($items["CURRENCY"]);
            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"];
                $imgProduct = "<a href=\"" . $items["EDIT_PAGE_URL"] . "\" target=\"_blank\"><img src=\"" . $imgUrl . "\" alt=\"\" title=\"" . $items["NAME"] . "\" ></a>";
            } else {
                $imgProduct = "<div class='no_foto'>" . GetMessage('NO_FOTO') . "</div>";
            }
            $arCurFormat = CCurrencyLang::GetCurrencyFormat($items["CURRENCY"]);
            $priceValutaFormat = str_replace("#", '', $arCurFormat["FORMAT_STRING"]);
            $currentTotalPrice = $items["PRICE"] + $items["DISCOUNT_PRICE"];
            $discountPercent = 0;
            if ($items["DISCOUNT_PRICE"] > 0) {
                $discountPercent = IntVal($items["DISCOUNT_PRICE"] * 100 / $currentTotalPrice);
            }
            $ar_res = CCatalogProduct::GetByID($items["PRODUCT_ID"]);
            $balance = FloatVal($ar_res["QUANTITY"]);
            $arParams = array();
            $arParams["id"] = $items["PRODUCT_ID"];
            $arParams["name"] = $items["NAME"];
            $arParams["url"] = $items["DETAIL_PAGE_URL"];
            $arParams["urlEdit"] = $items["EDIT_PAGE_URL"];
            $arParams["urlImg"] = $imgUrl;
            $arParams["price"] = FloatVal($items["PRICE"]);
            $arParams["priceBase"] = FloatVal($currentTotalPrice);
            $arParams["priceBaseFormat"] = CurrencyFormatNumber(FloatVal($currentTotalPrice), $items["CURRENCY"]);
            $arParams["priceFormated"] = CurrencyFormatNumber(FloatVal($items["PRICE"]), $items["CURRENCY"]);
            $arParams["valutaFormat"] = $priceValutaFormat;
            $arParams["priceDiscount"] = FloatVal($items["DISCOUNT_PRICE"]);
            $arParams["priceTotalFormated"] = SaleFormatCurrency($currentTotalPrice, $items["CURRENCY"]);
            $arParams["discountPercent"] = $discountPercent;
            $arParams["summaFormated"] = CurrencyFormatNumber($items["PRICE"], $items["CURRENCY"]);
            $arParams["quantity"] = 1;
            $arParams["module"] = $items["MODULE"];
            $arParams["currency"] = $items["CURRENCY"];
            $arParams["weight"] = 0;
            $arParams["vatRate"] = 0;
            $arParams["priceType"] = "";
            $arParams["balance"] = $balance;
            $arParams['skuProps'] = CUtil::PhpToJSObject($arSkuProperty);
            $arParams["catalogXmlID"] = "";
            $arParams["productXmlID"] = "";
            $arParams["callback"] = "CatalogBasketCallback";
            $arParams["orderCallback"] = "CatalogBasketOrderCallback";
            $arParams["cancelCallback"] = "CatalogBasketCancelCallback";
            $arParams["payCallback"] = "CatalogPayOrderCallback";
            $result .= "<tr id='more_" . $type . "_" . $items["ID"] . "'>\n\t\t\t\t\t\t\t<td class=\"tab_img\" >" . $imgProduct . "</td>\n\t\t\t\t\t\t\t<td class=\"tab_text\">\n\t\t\t\t\t\t\t\t<div class=\"order_name\"><a href=\"" . $items["EDIT_PAGE_URL"] . "\" target=\"_blank\" title=\"" . $items["NAME"] . "\">" . $items["NAME"] . "</a></div>\n\t\t\t\t\t\t\t\t<div class=\"order_price\">\n\t\t\t\t\t\t\t\t\t" . GetMessage('NEWO_SUBTAB_PRICE') . ": <b>" . SaleFormatCurrency($items["PRICE"], $currency) . "</b>\n\t\t\t\t\t\t\t\t</div>";
            $arResult = CSaleProduct::GetProductSku($USER_ID, $LID, $items["PRODUCT_ID"], $items["NAME"]);
            if (count($arResult["SKU_ELEMENTS"]) > 0) {
                foreach ($arResult["SKU_ELEMENTS"] as $key => $val) {
                    $arTmp = array();
                    foreach ($val as $k => $v) {
                        if (is_numeric($k)) {
                            $arTmp[$arResult["SKU_PROPERTIES"][$k]["NAME"]] = $v;
                        }
                    }
                    $arResult["SKU_ELEMENTS"][$key]["SKU_PROPS"] = CUtil::PhpToJSObject($arTmp);
                }
            }
            $arResult["POPUP_MESSAGE"] = array("PRODUCT_ADD" => GetMEssage('NEWO_POPUP_TO_BUSKET'), "PRODUCT_ORDER" => GetMEssage('NEWO_POPUP_TO_ORDER'), "PRODUCT_NOT_ADD" => GetMEssage('NEWO_POPUP_DONT_CAN_BUY'), "PRODUCT_PRICE_FROM" => GetMessage('NEWO_POPUP_FROM'));
            if (count($arResult["SKU_ELEMENTS"]) <= 0) {
                $result .= "<a href=\"javascript:void(0);\" class=\"get_new_order\" onClick=\"fAddToBusketMoreProduct('" . $type . "', " . CUtil::PhpToJSObject($arParams) . ");return false;\"><span></span>" . GetMessage('NEWO_SUBTAB_ADD_BUSKET') . "</a><br>";
            } else {
                $result .= "<a href=\"javascript:void(0);\" class=\"get_new_order\" onClick=\"fAddToBusketMoreProductSku(" . CUtil::PhpToJsObject($arResult['SKU_ELEMENTS']) . ", " . CUtil::PhpToJsObject($arResult['SKU_PROPERTIES']) . ", 'busket', " . CUtil::PhpToJsObject($arResult["POPUP_MESSAGE"]) . ");\"><span></span>" . GetMessage('NEWO_SUBTAB_ADD_BUSKET') . "</a><br>";
            }
            if (!$crmMode) {
                if (count($arResult["SKU_ELEMENTS"]) > 0) {
                    $result .= "<a href=\"javascript:void(0);\" class=\"get_new_order\" onClick=\"fAddToBusketMoreProductSku(" . CUtil::PhpToJsObject($arResult['SKU_ELEMENTS']) . ", " . CUtil::PhpToJsObject($arResult['SKU_PROPERTIES']) . ", 'neworder', " . CUtil::PhpToJsObject($arResult["POPUP_MESSAGE"]) . ");\"><span></span>" . GetMessage('NEWO_SUBTAB_ADD_ORDER') . "</a>";
                } else {
                    $cntProd = floatval($items["QUANTITY"]) > 0 ? floatval($items["QUANTITY"]) : 1;
                    $url = "/bitrix/admin/sale_order_new.php?lang=" . LANG . "&user_id=" . $USER_ID . "&LID=" . $LID . "&product[" . $items["PRODUCT_ID"] . "]=" . $cntProd;
                    $result .= "<a href=\"" . $url . "\" target=\"_blank\" class=\"get_new_order\"><span></span>" . GetMessage('NEWO_SUBTAB_ADD_ORDER') . "</a>";
                }
            }
            $result .= "</td></tr>";
        }
        //end foreach
    }
    //end if
    if ($arData["CNT"] > 2 && $arData["CNT"] != count($arData["ITEMS"])) {
        $result .= "<tr><td colspan='2' align='right' class=\"more_product\">";
        if ($type == "busket") {
            $result .= "<a href='javascript:void(0);' onClick='fGetMoreBusket(\"Y\");' class=\"get_more\">" . GetMessage('NEWO_SUBTAB_MORE') . "<span></span></a>";
        } elseif ($type == "viewed") {
            $result .= "<a href='javascript:void(0);' onClick='fGetMoreViewed(\"Y\");' class=\"get_more\">" . GetMessage('NEWO_SUBTAB_MORE') . "<span></span></a>";
        } else {
            $result .= "<a href='javascript:void(0);' onClick='fGetMoreRecom();' class=\"get_more\">" . GetMessage('NEWO_SUBTAB_MORE') . "<span></span></a>";
        }
        $result .= "</td></tr>";
    }
    $result .= "</table>";
    return $result;
}
     }
     $row->AddField("NAME", $name);
     $QUANTITY = "&nbsp;";
     if (isset($arViews["QUANTITY"])) {
         $QUANTITY = $arViews["QUANTITY"];
     }
     $row->AddField("QUANTITY", $QUANTITY);
     $price = "&nbsp;";
     if (floatval($arViews["PRICE"]) > 0) {
         $price = SaleFormatCurrency($arViews["PRICE"], $arViews["CURRENCY"]);
     }
     $row->AddField("PRICE", $price);
     if (count($arSites) > 1) {
         $row->AddField("LID", "[" . $arViews["LID"] . "] " . htmlspecialcharsbx($arSites[$arViews["LID"]]["NAME"]) . "");
     }
     $arResult = CSaleProduct::GetProductSku($ID, $arViews['SITE_ID'], $arViews["PRODUCT_ID"], $arViews["NAME"]);
     $arResult["POPUP_MESSAGE"] = array("PRODUCT_ADD_TO_ORDER" => GetMessage('BUYER_PD_ORDER'), "PRODUCT_ADD_TO_BASKET" => GetMessage('BUYER_PD_DELAY_N'), "PRODUCT_NOT_TO_ORDER" => GetMessage('BUYER_DONT_CAN_BUY'), "PRODUCT_PRICE_FROM" => GetMessage('BUYERS_FROM'));
     if (count($arResult["SKU_ELEMENTS"]) > 0) {
         $linkOrder = "showOfferPopup(" . CUtil::PhpToJsObject($arResult['SKU_ELEMENTS']) . ", " . CUtil::PhpToJsObject($arResult['SKU_PROPERTIES']) . ", 'order', " . CUtil::PhpToJsObject($arResult["POPUP_MESSAGE"]) . ");";
         $linkBasket = "showOfferPopup(" . CUtil::PhpToJsObject($arResult['SKU_ELEMENTS']) . ", " . CUtil::PhpToJsObject($arResult['SKU_PROPERTIES']) . ", 'basket', " . CUtil::PhpToJsObject($arResult["POPUP_MESSAGE"]) . ");";
     } else {
         $linkOrder = 'BX.adminPanel.Redirect([], \'/bitrix/admin/sale_order_create.php?USER_ID=' . $ID . '&lang=' . LANG . '&SITE_ID=' . $arViews["SITE_ID"] . '&product[' . $arViews["PRODUCT_ID"] . ']=1\', event);';
         $linkBasket = 'fAddToBasketViewed(' . $arViews["PRODUCT_ID"] . ', \'' . $arViews["SITE_ID"] . '\')';
     }
     $arActions = array();
     $arActions[] = array("ICON" => "edit", "TEXT" => GetMessage("BUYER_PD_ORDER"), "ACTION" => $linkOrder, "DEFAULT" => true);
     $arActions[] = array("ICON" => "edit", "TEXT" => GetMessage("BUYER_PD_DELAY_N"), "ACTION" => $linkBasket);
     if (floatval($arViews["PRICE"]) > 0) {
         $row->AddActions($arActions);
     }
 }
function fGetFormatedProduct($USER_ID, $LID, $arData, $CNT, $currency, $type, $crmMode = false)
{
    $result = "";
    if (!is_array($arData) || count($arData) <= 0) {
        return $result;
    }
    $result = "<table width=\"100%\">";
    if (CModule::IncludeModule('catalog') && CModule::IncludeModule('iblock')) {
        $arProductId = array();
        $arDataTab = array();
        $arSkuParentChildren = array();
        $arSkuParentId = array();
        $arSkuParent = array();
        foreach ($arData as $items) {
            if ($items["MODULE"] == 'catalog') {
                $arProductId[] = $items["PRODUCT_ID"];
                $arDataTab[$items["PRODUCT_ID"]] = $items;
                $arParent = CCatalogSku::GetProductInfo($items["PRODUCT_ID"]);
                if ($arParent) {
                    $arSkuParentChildren[$items["PRODUCT_ID"]] = $arParent["ID"];
                    $arSkuParentId[$arParent["ID"]] = $arParent["ID"];
                }
            }
        }
        if (!empty($arSkuParentId)) {
            $res = CIBlockElement::GetList(array(), array("ID" => $arSkuParentId), false, false, array("ID", "IBLOCK_ID", "IBLOCK_SECTION_ID", "PREVIEW_PICTURE", "DETAIL_PICTURE", "NAME", "DETAIL_PAGE_URL"));
            while ($arItems = $res->GetNext()) {
                $arSkuParent[$arItems["ID"]] = $arItems;
            }
        }
        if (!empty($arProductId)) {
            $dbProduct = CIBlockElement::GetList(array(), array("ID" => $arProductId), false, false, array('ID', 'IBLOCK_ID', 'IBLOCK_SECTION_ID', 'DETAIL_PICTURE', 'PREVIEW_PICTURE', 'IBLOCK_TYPE_ID'));
            while ($arProduct = $dbProduct->GetNext()) {
                $imgCode = "";
                $arDataTab[$arProduct['ID']]['IBLOCK_ID'] = $arProduct['IBLOCK_ID'];
                $arDataTab[$arProduct['ID']]['IBLOCK_SECTION_ID'] = $arProduct['IBLOCK_SECTION_ID'];
                $arDataTab[$arProduct['ID']]['DETAIL_PICTURE'] = $arProduct['DETAIL_PICTURE'];
                $arDataTab[$arProduct['ID']]['PREVIEW_PICTURE'] = $arProduct['PREVIEW_PICTURE'];
                $arDataTab[$arProduct['ID']]['IBLOCK_TYPE_ID'] = $arProduct['IBLOCK_TYPE_ID'];
                $arProduct = $arDataTab[$arProduct['ID']];
                if ($arProduct["PREVIEW_PICTURE"] == "" && $arProduct["DETAIL_PICTURE"] == "" && is_set($arSkuParentChildren[$arProduct["PRODUCT_ID"]])) {
                    $idTmp = $arSkuParentChildren[$arProduct["PRODUCT_ID"]];
                    $arProduct["DETAIL_PICTURE"] = $arSkuParent[$idTmp]["DETAIL_PICTURE"];
                    $arProduct["PREVIEW_PICTURE"] = $arSkuParent[$idTmp]["PREVIEW_PICTURE"];
                }
                if ($arProduct["IBLOCK_ID"] > 0) {
                    $arProduct["EDIT_PAGE_URL"] = "/bitrix/admin/iblock_element_edit.php?ID=" . $arProduct["PRODUCT_ID"] . "&type=" . $arProduct["IBLOCK_TYPE_ID"] . "&lang=" . LANG . "&IBLOCK_ID=" . $arProduct["IBLOCK_ID"] . "&find_section_section=" . intval($arProduct["IBLOCK_SECTION_ID"]);
                }
                if ($arProduct["DETAIL_PICTURE"] > 0) {
                    $imgCode = $arProduct["DETAIL_PICTURE"];
                } elseif ($arProduct["PREVIEW_PICTURE"] > 0) {
                    $imgCode = $arProduct["PREVIEW_PICTURE"];
                }
                $arProduct["NAME"] = htmlspecialcharsex($arProduct["NAME"]);
                $arProduct["DETAIL_PAGE_URL"] = htmlspecialcharsex($arProduct["DETAIL_PAGE_URL"]);
                $arProduct["CURRENCY"] = htmlspecialcharsex($arProduct["CURRENCY"]);
                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"];
                        $imgProduct = "<a href=\"" . $arProduct["EDIT_PAGE_URL"] . "\" target=\"_blank\"><img src=\"" . $arImgProduct["src"] . "\" alt=\"\" title=\"" . $arProduct["NAME"] . "\" ></a>";
                    }
                } else {
                    $imgProduct = "<div class='no_foto'>" . GetMessage('SOD_NO_FOTO') . "</div>";
                }
                $result .= "<tr>\n\t\t\t\t\t\t\t\t<td class=\"tab_img\">" . $imgProduct . "</td>\n\t\t\t\t\t\t\t\t<td class=\"tab_text\">\n\t\t\t\t\t\t\t\t\t<div class=\"order_name\"><a href=\"" . $arProduct["EDIT_PAGE_URL"] . "\" target=\"_blank\" title=\"" . $arProduct["NAME"] . "\">" . $arProduct["NAME"] . "</a></div>\n\t\t\t\t\t\t\t\t\t<div class=\"order_price\">\n\t\t\t\t\t\t\t\t\t\t" . GetMessage('SOD_ORDER_RECOM_PRICE') . ": <b>" . SaleFormatCurrency($arProduct["PRICE"], $currency) . "</b>\n\t\t\t\t\t\t\t\t\t</div>";
                $arResult = CSaleProduct::GetProductSku($USER_ID, $LID, $arProduct["PRODUCT_ID"], $arProduct["NAME"]);
                $arResult["POPUP_MESSAGE"] = array("PRODUCT_ADD" => GetMEssage('SOD_POPUP_TO_BUSKET'), "PRODUCT_NOT_ADD" => GetMEssage('SOD_POPUP_TO_BUSKET_NOT'), "PRODUCT_PRICE_FROM" => GetMessage('SOD_POPUP_FROM'));
                if (!$crmMode) {
                    if (count($arResult["SKU_ELEMENTS"]) > 0) {
                        $result .= "<a href=\"javascript:void(0);\" class=\"get_new_order\" onClick=\"fAddToBusketMoreProductSku(" . CUtil::PhpToJsObject($arResult['SKU_ELEMENTS']) . ", " . CUtil::PhpToJsObject($arResult['SKU_PROPERTIES']) . ", '', " . CUtil::PhpToJsObject($arResult["POPUP_MESSAGE"]) . " );\"><span></span>" . GetMessage('SOD_SUBTAB_ADD_ORDER') . "</a>";
                    } else {
                        $cntProd = floatval($arProduct["QUANTITY"]) > 0 ? floatval($arProduct["QUANTITY"]) : 1;
                        $url = "/bitrix/admin/sale_order_new.php?lang=" . LANG . "&user_id=" . $USER_ID . "&LID=" . $LID . "&product[" . $arProduct["PRODUCT_ID"] . "]=" . $cntProd;
                        $result .= "<a href=\"" . $url . "\" target=\"_blank\" class=\"get_new_order\"><span></span>" . GetMessage('SOD_SUBTAB_ADD_ORDER') . "</a>";
                    }
                }
                $result .= "</td></tr>";
            }
        }
    }
    //end if
    $result .= "<tr><td colspan='2' align='right' class=\"more_product\">";
    if ($CNT > 2) {
        $result .= "<a href='javascript:void(0);' onClick=\"fGetMoreProduct('" . $type . "');\"  class=\"get_more\">" . GetMessage('SOD_SUBTAB_MORE') . "<span></span></a>";
    }
    $result .= "</td></tr>";
    $result .= "</table>";
    return $result;
}