Exemple #1
0
		$productsWithBarCode = array();
		while ($product = $rsProducts->Fetch())
		{
			if (isset($arRows['E'.$product["ID"]]))
			{
				if ($product["BARCODE_MULTI"] == "Y")
					$arRows['E'.$product["ID"]]->arRes["CATALOG_BAR_CODE"] = GetMessage("IBLIST_A_CATALOG_BAR_CODE_MULTI");
				else
					$productsWithBarCode[] = $product["ID"];
			}
		}
		if (!empty($productsWithBarCode))
		{
			$arBarCodes = array();
			$rsProducts = CCatalogStoreBarCode::getList(array(), array(
				"PRODUCT_ID" => $productsWithBarCode,
			));
			while ($product = $rsProducts->Fetch())
			{
				$arBarCodes[$product["PRODUCT_ID"]][] = htmlspecialcharsEx($product["BARCODE"]);
			}
			foreach($arBarCodes as $productId => $barcode)
			{
				if (isset($arRows['E'.$productId]))
				{
					$arRows['E'.$productId]->arRes["CATALOG_BAR_CODE"] = implode(', ', $barcode);
				}
			}
		}
	}
	if (!empty($arProductGroupIDs))
Exemple #2
0
            ?>
"><?php 
            echo GetMessage("C2IT_STORE");
            ?>
</a></b><br><?php 
        }
    }
    if (!$bUseStoreControl) {
        echo "<br>" . GetMessage("C2IT_STORE_HINT");
    }
    if ($bUseStoreControl) {
        $tabControl1->BeginNextTab();
        $bUseMultiplyBarcode = $arBaseProduct['BARCODE_MULTI'] == "Y";
        $arBarcodes = array();
        if (!$bCopy) {
            $dbBarcode = CCatalogStoreBarCode::GetList(array(), array("PRODUCT_ID" => $PRODUCT_ID, "STORE_ID" => 0));
            while ($arBarcode = $dbBarcode->Fetch()) {
                $arBarcodes[$arBarcode["ID"]] = $arBarcode["BARCODE"];
            }
        }
        ?>
		<input type="hidden" name="CAT_ROW_BARCODE_COUNTER" id="CAT_ROW_BARCODE_COUNTER" value="<?php 
        echo $ind;
        ?>
">
		<input type="hidden" name="CAT_BARCODE_MULTIPLY" id="CAT_BARCODE_MULTIPLY_N" value="N" />
		<table border="0" cellspacing="0" cellpadding="0" width="100%" class="edit-table" id="catalog_barcode_table">

			<tr>
				<td width="40%"><label for="CAT_BARCODE_MULTIPLY"><?php 
        echo GetMessage('C2IT_BARCODE_MULTIPLY');
             unset($arSelectedProps[$aProp['ID']]["CACHE"]);
         }
     }
 } else {
     $fieldValue = "";
     $nearestQuantity = $QUANTITY;
     $amountToStore = 0;
     if ($storeFromId > 0) {
         $dbStoreProduct = CCatalogStoreProduct::GetList(array(), array("PRODUCT_ID" => $arItems["ID"], "STORE_ID" => $storeFromId));
         if ($arStoreProduct = $dbStoreProduct->Fetch()) {
             $amountToStore = $arStoreProduct["AMOUNT"];
         }
     }
     $arCatalogProduct["BARCODE"] = '';
     if ($arCatalogProduct["BARCODE_MULTI"] == 'N') {
         $dbBarCodes = CCatalogStoreBarCode::getList(array(), array("PRODUCT_ID" => $arItems["ID"]));
         while ($arBarCode = $dbBarCodes->Fetch()) {
             $arCatalogProduct["BARCODE"][] = $arBarCode["BARCODE"];
         }
     }
     if (is_array($arCatalogProduct["BARCODE"])) {
         $arCatalogProduct["BARCODE"] = implode(', ', $arCatalogProduct["BARCODE"]);
     }
     $balance = $storeFromId > 0 ? FloatVal($arCatalogProduct["QUANTITY"]) . " / " . FloatVal($amountToStore) : FloatVal($arCatalogProduct["QUANTITY"]);
     $row->AddField("BALANCE", $balance);
     $row->AddViewField("PREVIEW_PICTURE", CFileInput::Show('NO_FIELDS[' . $arItems['ID'] . '][PREVIEW_PICTURE]', $arItems['PREVIEW_PICTURE'], 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)));
     $row->AddViewField("DETAIL_PICTURE", CFileInput::Show('NO_FIELDS[' . $arItems['ID'] . '][DETAIL_PICTURE]', $arItems['DETAIL_PICTURE'], 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)));
     $bCanBuy = true;
     if ($arCatalogProduct["CAN_BUY_ZERO"] != "Y" && ($arCatalogProduct["QUANTITY_TRACE"] == "Y" && doubleval($arCatalogProduct["QUANTITY"]) <= 0)) {
         $bCanBuy = false;
     }
Exemple #4
0
 protected function getFilter()
 {
     $arFilter = array("IBLOCK_ID" => $this->getIblockId(), 'SECTION_ID' => $this->getSectionId() > 0 ? $this->getSectionId() : 0, 'ACTIVE' => empty($_REQUEST['filter_active']) ? 'Y' : $_REQUEST['filter_active'], "WF_PARENT_ELEMENT_ID" => false, "SHOW_NEW" => "Y");
     if ($arProps = $this->getProps()) {
         $filtered = null;
         foreach ($arProps as $arProp) {
             $value = $_REQUEST['filter_el_property_' . $arProp["ID"]];
             if (array_key_exists("AddFilterFields", $arProp["PROPERTY_USER_TYPE"])) {
                 call_user_func_array($arProp["PROPERTY_USER_TYPE"]["AddFilterFields"], array($arProp, array("VALUE" => "filter_el_property_" . $arProp["ID"]), &$arFilter, &$filtered));
             } elseif (is_array($value) || strlen($value)) {
                 if ($value === "NOT_REF") {
                     $value = false;
                 }
                 $arFilter["?PROPERTY_" . $arProp["ID"]] = $value;
             }
         }
     }
     $arSubQuery = array();
     if ($arSKUProps = $this->getSkuProps()) {
         $arCatalog = $this->getOffersCatalog();
         $arSubQuery = array("IBLOCK_ID" => $arCatalog['IBLOCK_ID']);
         $filtered = null;
         for ($i = 0, $intPropCount = count($arSKUProps); $i < $intPropCount; $i++) {
             if ('Y' == $arSKUProps[$i]["FILTRABLE"] && 'F' != $arSKUProps[$i]["PROPERTY_TYPE"] && $arCatalog['SKU_PROPERTY_ID'] != $arSKUProps[$i]["ID"]) {
                 if (array_key_exists("AddFilterFields", $arSKUProps[$i]["PROPERTY_USER_TYPE"])) {
                     call_user_func_array($arSKUProps[$i]["PROPERTY_USER_TYPE"]["AddFilterFields"], array($arSKUProps[$i], array("VALUE" => "filter_sub_el_property_" . $arSKUProps[$i]["ID"]), &$arSubQuery, &$filtered));
                 } else {
                     $value = $_REQUEST['filter_sub_el_property_' . $arSKUProps[$i]["ID"]];
                     if (is_array($value) || strlen($value)) {
                         if ($value === "NOT_REF") {
                             $value = false;
                         }
                         $arSubQuery["?PROPERTY_" . $arSKUProps[$i]["ID"]] = $value;
                     }
                 }
             }
         }
     }
     if (!empty($_REQUEST["filter_timestamp_from"])) {
         $arFilter["DATE_MODIFY_FROM"] = $_REQUEST["filter_timestamp_from"];
     }
     if (!empty($_REQUEST["filter_timestamp_to"])) {
         $arFilter["DATE_MODIFY_TO"] = $_REQUEST["filter_timestamp_to"];
     }
     if (!empty($_REQUEST["filter_code"])) {
         $arFilter["CODE"] = $_REQUEST["filter_code"];
     }
     $arSearchedIds = $arSearchedSectionIds = null;
     if (!empty($_REQUEST['QUERY'])) {
         $arFilter['QUERY'] = $_REQUEST['QUERY'];
         $arSearchedIds = $arSearchedSectionIds = array(0);
         if (preg_match('#^[0-9\\s]+$#', $_REQUEST['QUERY'])) {
             $barcode = preg_replace('#[^0-9]#', '', $_REQUEST['QUERY']);
             if (strlen($barcode) > 0) {
                 $rsBarCode = \CCatalogStoreBarCode::getList(array(), array("BARCODE" => $barcode), false, false, array('PRODUCT_ID'));
                 while ($res = $rsBarCode->Fetch()) {
                     $res2 = \CCatalogSKU::GetProductInfo($res["PRODUCT_ID"]);
                     $arSearchedIds[] = $res2 ? $res2['ID'] : $res['PRODUCT_ID'];
                 }
             }
         } elseif ($this->isAdvancedSearchAvailable()) {
             $arFilter['PARAM2'] = $this->getIblockId();
             if (!empty($arFilter['SECTION_ID'])) {
                 $arFilter['PARAMS'] = array('iblock_section' => $arFilter['SECTION_ID']);
             }
             $obSearch = new \CSearch();
             $obSearch->Search($arFilter);
             $cnt = 0;
             $activeSectionId = $this->getSectionId();
             while ($ar = $obSearch->Fetch()) {
                 if (strpos($ar['ITEM_ID'], 'S') === 0) {
                     $sectionId = preg_replace('#[^0-9]+#', '', $ar['ITEM_ID']);
                     if ($sectionId != $activeSectionId) {
                         $arSearchedSectionIds[] = $sectionId;
                     }
                 } else {
                     $arSearchedIds[] = $ar['ITEM_ID'];
                 }
                 if (++$cnt >= 100) {
                     break;
                 }
             }
         } else {
             $arSearchedIds = $arSearchedSectionIds = null;
             $arFilter['NAME'] = $_REQUEST['QUERY'];
         }
     }
     if (sizeof($arSubQuery) > 1) {
         $arFilteredIds = array(0);
         $db = \CIBlockElement::GetList(array(), $arSubQuery, false, false, array('PROPERTY_' . $arCatalog['SKU_PROPERTY_ID']));
         while ($res = $db->Fetch()) {
             $arFilteredIds[] = $res['PROPERTY_' . $arCatalog['SKU_PROPERTY_ID'] . '_VALUE'];
         }
         $arFilter['ID'] = is_array($arSearchedIds) ? array_intersect($arFilteredIds, $arSearchedIds) : $arFilteredIds;
     } elseif ($arSearchedIds) {
         $arFilter['ID'] = $arSearchedIds;
     }
     if ($arSearchedSectionIds) {
         $arFilter['S_ID'] = $arSearchedSectionIds;
     }
     unset($arFilter['PARAM1'], $arFilter['PARAM2'], $arFilter['PARAMS']);
     if ($this->isFiltering() || !empty($_REQUEST['QUERY'])) {
         $arFilter['INCLUDE_SUBSECTIONS'] = 'Y';
         if (isset($arFilter['SECTION_ID']) && $arFilter['SECTION_ID'] == 0) {
             unset($arFilter["SECTION_ID"]);
         }
     }
     return $arFilter;
 }
         }
         if ($isErrorSaveBarcode) {
             $strWarning .= GetMessage("C2IT_ERROR_SAVE_BARCODE");
             break;
         }
     }
     if (isset($_REQUEST["CAT_BARCODE_ADD"]) && is_array($_REQUEST["CAT_BARCODE_ADD"])) {
         foreach ($_REQUEST["CAT_BARCODE_ADD"] as $barcodeToAdd) {
             if (trim($barcodeToAdd) != '') {
                 $arBarCodeFieldsAdd[] = array("BARCODE" => trim($barcodeToAdd), "PRODUCT_ID" => $PRODUCT_ID, "CREATED_BY" => $userId, "MODIFIED_BY" => $userId, "STORE_ID" => 0);
             }
         }
     }
     if (count($arBarCodeFieldsAdd) > 0 && is_array($arBarCodeFieldsAdd)) {
         foreach ($arBarCodeFieldsAdd as $arCodeToAdd) {
             if (!CCatalogStoreBarCode::Add($arCodeToAdd)) {
                 $strWarning .= GetMessage("C2IT_ERROR_SAVE_BARCODE");
                 break;
             }
         }
     }
 }
 $arFields = array("ID" => $PRODUCT_ID, "QUANTITY_TRACE" => $quantityTrace, "WEIGHT" => $CAT_BASE_WEIGHT, "WIDTH" => $CAT_BASE_WIDTH, "LENGTH" => $CAT_BASE_LENGTH, "HEIGHT" => $CAT_BASE_HEIGHT, "VAT_ID" => $CAT_VAT_ID, "VAT_INCLUDED" => $CAT_VAT_INCLUDED, "CAN_BUY_ZERO" => $useStore, "NEGATIVE_AMOUNT_TRACE" => $negativeAmount, "PRICE_TYPE" => false, "RECUR_SCHEME_TYPE" => false, "RECUR_SCHEME_LENGTH" => false, "TRIAL_PRICE_ID" => false, "WITHOUT_ORDER" => false, "BARCODE_MULTI" => $barcodeMultiply, "MEASURE" => $CAT_MEASURE);
 if ($USER->CanDoOperation('catalog_purchas_info') && !$bUseStoreControl) {
     if (isset($_POST['CAT_PURCHASING_PRICE']) && trim($_POST['CAT_PURCHASING_PRICE']) != '' && isset($_POST['CAT_PURCHASING_CURRENCY']) && trim($_POST['CAT_PURCHASING_CURRENCY']) != '') {
         $arFields['PURCHASING_PRICE'] = $_POST['CAT_PURCHASING_PRICE'];
         $arFields['PURCHASING_CURRENCY'] = $_POST['CAT_PURCHASING_CURRENCY'];
     }
 }
 if (isset($_POST['SUBSCRIBE'])) {
     $arFields['SUBSCRIBE'] = strval($_POST['SUBSCRIBE']);
 protected function applyBarCode($arFields, $userId)
 {
     $barCode = $arFields["BARCODE"];
     $elementId = $arFields["PRODUCT_ID"];
     $storeToId = isset($arFields["STORE_ID"]) ? $arFields["STORE_ID"] : 0;
     $storeFromId = isset($arFields["STORE_FROM"]) ? $arFields["STORE_FROM"] : 0;
     $storeName = CCatalogStoreControlUtil::getStoreName($storeFromId);
     $productInfo = CCatalogStoreControlUtil::getProductInfo($elementId);
     $newStore = 0;
     $userId = intval($userId);
     $result = false;
     $rsProps = CCatalogStoreBarCode::GetList(array(), array("BARCODE" => $barCode), false, false, array('ID', 'STORE_ID', 'PRODUCT_ID'));
     if ($arBarCode = $rsProps->Fetch()) {
         if ($storeFromId > 0) {
             if ($storeToId > 0) {
                 if ($arBarCode["STORE_ID"] == $storeFromId && $arBarCode["PRODUCT_ID"] == $elementId) {
                     $newStore = $storeToId;
                 } else {
                     $GLOBALS["APPLICATION"]->ThrowException(GetMessage("CAT_DOC_WRONG_STORE_BARCODE", array("#STORE#" => '"' . $storeName . '"', "#PRODUCT#" => '"' . $productInfo["NAME"] . '"', "#BARCODE#" => '"' . $barCode . '"')));
                     return false;
                 }
             }
         } else {
             $GLOBALS["APPLICATION"]->ThrowException(GetMessage("CAT_DOC_BARCODE_ALREADY_EXIST", array("#PRODUCT#" => '"' . $productInfo["NAME"] . '"', "#BARCODE#" => '"' . $barCode . '"')));
             return false;
         }
         if ($newStore > 0) {
             $result = CCatalogStoreBarCode::update($arBarCode["ID"], array("STORE_ID" => $storeToId, "MODIFIED_BY" => $userId));
         } else {
             $result = CCatalogStoreBarCode::delete($arBarCode["ID"]);
         }
     } else {
         if ($storeFromId > 0) {
             $GLOBALS["APPLICATION"]->ThrowException(GetMessage("CAT_DOC_WRONG_STORE_BARCODE", array("#STORE#" => '"' . $storeName . '"', "#PRODUCT#" => '"' . $productInfo["NAME"] . '"', "#BARCODE#" => '"' . $barCode . '"')));
             return false;
         } elseif ($storeToId > 0) {
             $result = CCatalogStoreBarCode::Add(array("PRODUCT_ID" => $elementId, "STORE_ID" => $storeToId, "BARCODE" => $barCode, "MODIFIED_BY" => $userId, "CREATED_BY" => $userId));
         }
     }
     return $result;
 }
							{
								if (!CCatalogStoreBarCode::Delete($arId[0]))
									$strWarning .= GetMessage("C2IT_ERROR_SAVE_BARCODE");
							}
						}
						else
						{
							if(!CCatalogStoreBarCode::Update($arId[0], array("MODIFIED_BY" => $userId, "STORE_ID" => 0)))
								$strWarning .= GetMessage("C2IT_ERROR_SAVE_BARCODE");
						}
					}
					elseif(count($arId) == 0)
					{
						if(trim($_REQUEST["SUBCAT_BARCODE"]) != '')
						{
							if(!CCatalogStoreBarCode::Add($arBarCodeFields))
								$strWarning .= GetMessage("C2IT_ERROR_SAVE_BARCODE");
						}
					}
					else
					{
						$strWarning .= GetMessage("C2IT_ERROR_SAVE_MULTIBARCODE");
						$barcodeMultiply = 'Y';
					}
				}

				$arFields = array(
					"ID" => $PRODUCT_ID,
					"QUANTITY_TRACE" => $quantityTrace,
					"WEIGHT" => $SUBCAT_BASE_WEIGHT,
					"WIDTH" => $SUBCAT_BASE_WIDTH,
Exemple #8
0
 protected function getProductIdByBarcodeAction()
 {
     \Bitrix\Main\Loader::includeModule('catalog');
     $barcode = $this->request['barcode'];
     if (strlen($barcode) > 0) {
         $rsBarCode = \CCatalogStoreBarCode::getList(array(), array("BARCODE" => $barcode), false, false, array('PRODUCT_ID'));
         $arBarCode = $rsBarCode->Fetch();
     }
     $this->addResultData('RESULT', array("PRODUCT_ID" => isset($arBarCode["PRODUCT_ID"]) ? intval($arBarCode["PRODUCT_ID"]) : 0));
 }
	}

	foreach($arAllDocumentElement as $arDocumentElement)
	{
		$arElement = $arElementBarcode = array();
		$isMultiSingleBarcode = $selectedBarcode = false;
		foreach($arDocumentElement as $key => $value)
		{
			$arElement[$key] = $value;
		}

		if($arDocumentElement["IS_MULTIPLY_BARCODE"] == 'N')
		{
			if(isset($arElement["BARCODE"]))
				unset($arElement["BARCODE"]);
			$dbDocumentStoreBarcode = CCatalogStoreBarCode::getList(array(), array("PRODUCT_ID" => $arDocumentElement["ELEMENT_ID"]));
			while($arDocumentStoreBarcode = $dbDocumentStoreBarcode->Fetch())
			{
				$arElementBarcode[] = $arDocumentStoreBarcode["BARCODE"];
			}
			if(count($arElementBarcode) > 1)
			{
				$isMultiSingleBarcode = true;

				if($bReadOnly)
					$arElementBarcode = array();
			}
		}

		if($arDocumentElement["IS_MULTIPLY_BARCODE"] == 'Y' || $isMultiSingleBarcode)
		{
	function fEnableSub()
	{
		if (document.getElementById('tbl_sale_order_edit'))
			document.getElementById('tbl_sale_order_edit').style.zIndex  = 10000;
	}
	</script>
<?php 
if ($ID > 0) {
    $arSelect = array("ID", "DOC_ID", "STORE_FROM", "STORE_TO", "ELEMENT_ID", "AMOUNT", "PURCHASING_PRICE", "IS_MULTIPLY_BARCODE");
    $dbResult = CCatalogStoreDocsElement::GetList(array(), array('DOC_ID' => $ID), false, false, $arSelect);
    while ($product = $dbResult->GetNext()) {
        $docElementId = $product["ID"];
        $product = array_merge($product, CCatalogStoreControlUtil::getProductInfo($product["ELEMENT_ID"]));
        $product["BARCODE"] = '';
        if ($product["IS_MULTIPLY_BARCODE"] == 'N') {
            $dbBarCode = CCatalogStoreBarCode::getList(array(), array("PRODUCT_ID" => $product["ELEMENT_ID"]));
            if ($arBarCode = $dbBarCode->GetNext()) {
                $product["BARCODE"] = $arBarCode["BARCODE"];
            }
        } elseif ($product["IS_MULTIPLY_BARCODE"] == 'Y') {
            $dbBarCodes = CCatalogStoreDocsBarcode::getList(array(), array("DOC_ELEMENT_ID" => $docElementId));
            while ($arBarCode = $dbBarCodes->GetNext()) {
                $product["BARCODE"][] = $arBarCode["BARCODE"];
            }
        }
        $storeFromName = CCatalogStoreControlUtil::getStoreName($product["STORE_FROM"]);
        $storeToName = CCatalogStoreControlUtil::getStoreName($product["STORE_TO"]);
        ?>
		<script type="text/javascript">
			var arBarCodes = new Array();
			<?php 
Exemple #11
0
<?php

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
if (isset($_REQUEST["barcode"])) {
    $barcode = $_REQUEST["barcode"];
}
if (CModule::IncludeModule("catalog")) {
    $arFilter = array("BARCODE" => $barcode);
    $cache = new CPHPCache();
    $cache_path = '/eshopapp_cache/' . $action;
    $cache_time = 3600 * 24 * 365;
    $cache_id = 'barcode_' . $barcode;
    if ($cache->InitCache($cache_time, $cache_id, $cache_path)) {
        $arProduct = $cache->GetVars();
    } else {
        $arProduct = array();
        $dbProduct = CCatalogStoreBarCode::GetList(array(), array("BARCODE" => $barcode), false, false, array("PRODUCT_ID"));
        if ($arProduct = $dbProduct->GetNext()) {
            $cache->StartDataCache($cache_time, $cache_id, $cache_path);
            $cache->EndDataCache($arProduct);
        }
    }
    if ($arProduct) {
        $data["product_id"] = $arProduct["PRODUCT_ID"];
    } else {
        $data["error"] = "empty";
    }
}