3namespace Bitrix\Catalog\v2\Integration\UI\EntitySelector;
5use Bitrix\Catalog\Access\AccessController;
6use Bitrix\Catalog\Access\ActionDictionary;
7use Bitrix\Catalog\Access\Permission\PermissionDictionary;
8use Bitrix\Catalog\ProductTable;
9use Bitrix\Catalog\StoreProductTable;
10use Bitrix\Catalog\StoreTable;
11use Bitrix\Iblock\Component\Tools;
12use Bitrix\Main\Localization\Loc;
13use Bitrix\Main\Text\HtmlFilter;
14use Bitrix\UI\EntitySelector\BaseProvider;
15use Bitrix\UI\EntitySelector\Dialog;
16use Bitrix\UI\EntitySelector\Item;
17use Bitrix\UI\EntitySelector\SearchQuery;
21 private const STORE_LIMIT = 10;
22 private const ENTITY_ID =
'store';
26 $this->options[
'searchDisabledStores'] =
$options[
'searchDisabledStores'] ??
true;
27 $this->options[
'useAddressAsTitle'] =
$options[
'useAddressAsTitle'] ??
true;
28 $this->options[
'productId'] = (int)(
$options[
'productId'] ?? 0);
30 if ($this->options[
'productId'] > 0)
33 'filter' => [
'=ID' => $this->options[
'productId']],
34 'select' => [
'MEASURE']
37 $this->options[
'measureSymbol'] = $this->getMeasureSymbol((
int)$product[
'MEASURE']);
41 $this->options[
'measureSymbol'] =
'';
44 parent::__construct();
47 private function getMeasureSymbol(
int $measureId =
null): string
49 $measureResult = \CCatalogMeasure::getList(
50 array(
'CODE' =>
'ASC'),
54 array(
'CODE',
'SYMBOL_RUS',
'SYMBOL_INTL',
'IS_DEFAULT',
'ID')
58 while ($measureFields = $measureResult->Fetch())
60 $symbol = $measureFields[
'SYMBOL_RUS'] ?? $measureFields[
'SYMBOL_INTL'];
61 if ($measureId === (
int)$measureFields[
'ID'])
66 if ($measureFields[
'IS_DEFAULT'] ===
'Y')
77 return $this->
getOptions()[
'searchDisabledStores'];
82 return $this->
getOptions()[
'useAddressAsTitle'];
92 return $GLOBALS[
"USER"]->IsAuthorized();
97 return $this->getStores([
'ID' => $ids]);
102 return $this->getStores([
'=ID' => $ids]);
135 if ($recentItemsCount < self::STORE_LIMIT)
137 foreach ($this->getStores() as $store)
146 $allowedStores = AccessController::getCurrent()->getPermissionValue(ActionDictionary::ACTION_STORE_VIEW);
147 if (empty($allowedStores))
152 if (!in_array(PermissionDictionary::VALUE_VARIATION_ALL, $allowedStores,
true))
154 $filter[
'=ID'] = $allowedStores;
164 'select' => [
'STORE_ID',
'AMOUNT',
'QUANTITY_RESERVED'],
167 while ($storeProduct = $storeProductRaw->fetch())
169 $storeProducts[$storeProduct[
'STORE_ID']] = [
170 'RESERVED' => $storeProduct[
'QUANTITY_RESERVED'],
171 'AMOUNT' => $storeProduct[
'AMOUNT'],
176 $storeRaw = StoreTable::getList([
177 'select' => [
'ID',
'TITLE',
'ADDRESS',
'IMAGE_ID'],
182 while ($store = $storeRaw->fetch())
185 $store[
'PRODUCT_AMOUNT'] = $storeProducts[$store[
'ID']][
'AMOUNT'] ?? 0;
186 $store[
'PRODUCT_RESERVED'] = $storeProducts[$store[
'ID']][
'RESERVED'] ?? 0;
188 if ($store[
'IMAGE_ID'] !==
null)
190 $store[
'IMAGE_ID'] = (int)$store[
'IMAGE_ID'];
191 if ($store[
'IMAGE_ID'] <= 0)
193 $store[
'IMAGE_ID'] =
null;
197 $store[
'IMAGE_ID'] !==
null
198 ? $this->getImageSource($store[
'IMAGE_ID'])
209 static function (
$first, $second)
211 return (
$first[
'PRODUCT_AMOUNT'] > $second[
'PRODUCT_AMOUNT']) ? -1 : 1;
217 foreach ($stores as
$key => $store)
219 $store[
'SORT'] = 100 *
$key;
220 $items[] = $this->makeItem($store);
226 private function getImageSource(
int $id): ?string
233 $file = \CFile::GetFileArray($id);
239 return Tools::getImageSrc($file,
false) ?:
null;
242 private function makeItem($store): Item
244 $title = trim((
string)$store[
'TITLE']);
249 : Loc::getMessage(
'STORE_SELECTOR_EMPTY_TITLE')
254 'id' => $store[
'ID'],
255 'sort' => $store[
'SORT'],
256 'entityId' => self::ENTITY_ID,
258 'subtitle' => $store[
'ADDRESS'],
259 'avatar' => $store[
'IMAGE'],
263 ? $store[
'PRODUCT_AMOUNT'] .
' ' . $this->
getOptions()[
'measureSymbol']
269 'amount' => (
float)$store[
'PRODUCT_AMOUNT'],
270 'availableAmount' => (
float)$store[
'PRODUCT_AMOUNT'] - (
float)$store[
'PRODUCT_RESERVED'],
if(isset( $_REQUEST["mode"]) &&$_REQUEST["mode"]=="ajax") if(isset($_REQUEST["mode"]) && $_REQUEST["mode"]=="save_lru" &&check_bitrix_sessid()) $first
__construct(array $options=[])
fillDialog(Dialog $dialog)
getSelectedItems(array $ids)
doSearch(SearchQuery $searchQuery, Dialog $dialog)
static getRow(array $parameters)
static getList(array $parameters=array())
static encode($string, $flags=ENT_COMPAT, $doubleEncode=true)
loadPreselectedItems($preselectedMode=true)
addRecentItem(Item $item)
setCacheable(bool $flag=true)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
$GLOBALS['____1690880296']
if(empty($signedUserToken)) $key
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"