if(isset($_REQUEST["SUBCAT_BARCODE"]) && ($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; $countBarCode++; } if((!empty($arBarCodeResult)) && ($countBarCode == 1) && (intval($arBarCodeResult["STORE_ID"]) == 0)) { if(CCatalogStoreBarCode::delete($arBarCode["ID"])) $countBarCode--; } if($arAmount["SUM"] != $countBarCode) { $strWarning .= GetMessage("C2IT_ERROR_USE_MULTIBARCODE", array("#COUNT#" => ($arAmount["SUM"] - $countBarCode))); $barcodeMultiply = 'N'; unset($_REQUEST["SUBCAT_BARCODE"]); } } } elseif(isset($_REQUEST["SUBCAT_BARCODE"]) && $barcodeMultiply != 'Y') { $arId = array(); $arBarCodeFields = array( "BARCODE" => $_REQUEST["SUBCAT_BARCODE"],
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; }
$barcodeMultiply = $_POST["CAT_BARCODE_MULTIPLY"]; if (!$barcodeMultiply || $barcodeMultiply == '') { $barcodeMultiply = 'N'; } if (isset($_REQUEST["CAT_BARCODE"]) && $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; $countBarCode++; } if (!empty($arBarCodeResult) && $countBarCode == 1 && intval($arBarCodeResult["STORE_ID"]) == 0) { if (CCatalogStoreBarCode::delete($arBarCodeResult["ID"])) { $countBarCode--; } } if ($arAmount["SUM"] != $countBarCode) { $strWarning .= GetMessage("C2IT_ERROR_USE_MULTIBARCODE", array("#COUNT#" => $arAmount["SUM"] - $countBarCode)); $barcodeMultiply = 'N'; unset($_REQUEST["CAT_BARCODE"]); } } } elseif (isset($_REQUEST["CAT_BARCODE"]) && $barcodeMultiply != 'Y') { $arId = array(); $arBarCodeFields = array("BARCODE" => $_REQUEST["CAT_BARCODE"], "PRODUCT_ID" => $PRODUCT_ID, "CREATED_BY" => $userId, "MODIFIED_BY" => $userId); $dbBarCode = CCatalogStoreBarCode::GetList(array(), array("PRODUCT_ID" => $PRODUCT_ID), false, false, array("ID", "BARCODE", "PRODUCT_ID")); while ($arBarCode = $dbBarCode->Fetch()) { $arId[] = $arBarCode["ID"];