?> "><?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');
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; }
<?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"; } }
} else { $negativeAmount = $_POST['NEGATIVE_AMOUNT']; if (!$negativeAmount || $negativeAmount == '') { $negativeAmount = 'D'; } } $barcodeMultiply = $_POST["CAT_BARCODE_MULTIPLY"]; if (!$barcodeMultiply || $barcodeMultiply == '') { $barcodeMultiply = 'N'; } if (isset($_REQUEST["AR_BARCODE_ID"]) && $barcodeMultiply == 'Y') { $countBarCode = 0; $arBarCodeResult = array(); $dbAmount = CCatalogStoreControlUtil::getQuantityInformation($PRODUCT_ID); if (is_object($dbAmount) && ($arAmount = $dbAmount->Fetch())) { $dbBarCode = CCatalogStoreBarCode::GetList(array(), array("PRODUCT_ID" => $PRODUCT_ID), false, false, array("ID", "BARCODE", "PRODUCT_ID", "STORE_ID")); while ($arBarCode = $dbBarCode->Fetch()) { $arBarCodeResult[] = $arBarCode; if ($arBarCode["STORE_ID"] != 0) { $countBarCode++; } } if ($arAmount["SUM"] + $arAmount["RESERVED"] != 0 || $countBarCode > 0) { $strWarning .= GetMessage("C2IT_ERROR_USE_MULTIBARCODE", array("#COUNT#" => $arAmount["SUM"] - $countBarCode)); $barcodeMultiply = 'N'; unset($_REQUEST["AR_BARCODE_ID"]); } else { foreach ($arBarCodeResult as $barCode) { CCatalogStoreBarCode::Delete($barCode["ID"]); } }
$res .= '>' . str_repeat(" . ", $ar["DEPTH_LEVEL"]) . $ar["NAME"] . '</option>'; } $result .= '<select name="' . $name . '[]" size="' . ($property_fields["MULTIPLE"] == "Y" ? "5" : "1") . '" ' . ($property_fields["MULTIPLE"] == "Y" ? "multiple" : "") . '>'; $result .= '<option value=""' . (!$bWas ? ' selected' : '') . '>' . GetMessage("SPS_A_PROP_NOT_SET") . '</option>'; $result .= $res; $result .= '</select>'; return $result; } if ($_SERVER["REQUEST_METHOD"] == "POST" && $_REQUEST["ORDER_AJAX"] === 'Y' && check_bitrix_sessid()) { $barcode = isset($_REQUEST["BARCODE"]) ? htmlspecialcharsbx($_REQUEST["BARCODE"]) : ""; $arBarCode = array(); $arElement = array(); $result = ""; $elementId = 0; if (strlen($barcode) > 0) { $rsBarCode = CCatalogStoreBarCode::GetList(array(), array("BARCODE" => $barcode)); $arBarCode = $rsBarCode->Fetch(); } if (count($arBarCode) > 0 && isset($arBarCode["PRODUCT_ID"])) { $elementId = intval($arBarCode["PRODUCT_ID"]); $rsElement = CCatalogProduct::GetList(array(), array("ID" => $elementId)); $arElement = $rsElement->Fetch(); } if ($elementId <= 0) { exit; } $arFilter = array("WF_PARENT_ELEMENT_ID" => false, "IBLOCK_ID" => $arElement["ELEMENT_IBLOCK_ID"], "SHOW_NEW" => "Y", "ID" => $elementId); $dbResultList = CIBlockElement::GetList(array($_REQUEST["by"] => $_REQUEST["order"]), $arFilter, false, false, ${"filter_count_for_show"}); $dbResultList = new CAdminResult($dbResultList, $sTableID); $arItems = $dbResultList->Fetch(); $URL = CIBlock::ReplaceDetailUrl($arItems["DETAIL_PAGE_URL"], $arItems, true);