Exemplo n.º 1
0
}
$arResult['PRODUCT_ID'] = $productID;
$product = $productID > 0 ? CCrmProduct::GetByID($productID, true) : false;
$arResult['CATALOG_ID'] = $catalogID = isset($product['CATALOG_ID']) ? intval($product['CATALOG_ID']) : CCrmCatalog::EnsureDefaultExists();
if (!$product) {
    ShowError(GetMessage('CRM_PRODUCT_NOT_FOUND'));
    @define('ERROR_404', 'Y');
    if ($arParams['SET_STATUS_404'] === 'Y') {
        CHTTP::SetStatus("404 Not Found");
    }
    return;
}
// Product properties
$arPropUserTypeList = CCrmProductPropsHelper::GetPropsTypesByOperations(false, 'view');
$arResult['PROP_USER_TYPES'] = $arPropUserTypeList;
$arProps = CCrmProductPropsHelper::GetProps($catalogID, $arPropUserTypeList);
$arResult['PROPS'] = $arProps;
$arResult['PRODUCT'] = $product;
$arResult['FORM_ID'] = 'CRM_PRODUCT_SHOW';
$arResult['GRID_ID'] = 'CRM_PRODUCT_LIST';
// Product properties values
/*$arResult['PRODUCT_PROPS'] = array();*/
$arPropertyValues = array();
if ($productID > 0) {
    $rsProperties = CIBlockElement::GetProperty($catalogID, $productID, array('sort' => 'asc', 'id' => 'asc', 'enum_sort' => 'asc', 'value_id' => 'asc'), array('ACTIVE' => 'Y', 'EMPTY' => 'N', 'CHECK_PERMISSIONS' => 'N'));
    while ($arProperty = $rsProperties->Fetch()) {
        if (isset($arProperty['USER_TYPE']) && !empty($arProperty['USER_TYPE']) && !array_key_exists($arProperty['USER_TYPE'], $arPropUserTypeList)) {
            continue;
        }
        $propID = 'PROPERTY_' . $arProperty['ID'];
        if (!isset($arPropertyValues[$propID])) {
Exemplo n.º 2
0
    $catalogID = CCrmCatalog::EnsureDefaultExists();
}
$catalogDefaultImportLevels = intval(COption::GetOptionString('catalog', 'num_catalog_levels', '3'));
$catalogMaxImportLevels = 30;
$catalogImportLevels = isset($_POST['IMPORT_FILE_SECTION_LEVELS']) ? intval($_POST['IMPORT_FILE_SECTION_LEVELS']) : $catalogDefaultImportLevels;
if ($catalogImportLevels < 0) {
    $catalogImportLevels = $catalogDefaultImportLevels;
}
if ($catalogImportLevels > $catalogMaxImportLevels) {
    $catalogImportLevels = 30;
}
// Product properties
// <editor-fold defaultstate="collapsed" desc="Product properties">
$arPropUserTypeList = CCrmProductPropsHelper::GetPropsTypesByOperations(false, 'import');
$arProps = CCrmProductPropsHelper::GetProps($catalogID, $arPropUserTypeList, 'import');
CCrmProductPropsHelper::ListAddHeades($arPropUserTypeList, $arProps, $arResult['HEADERS']);
// </editor-fold>
$arRequireFields = array();
$arRequireFields['NAME'] = GetMessage('CRM_PRODUCT_IMP_COL_NAME');
$arResult['LIST_SECTION_ID'] = isset($_REQUEST['list_section_id']) ? intval($_REQUEST['list_section_id']) : 0;
$arParams['PATH_TO_PRODUCT_LIST'] = CrmCheckPath('PATH_TO_PRODUCT_LIST', $arParams['PATH_TO_PRODUCT_LIST'], '?#section_id#');
$arParams['PATH_TO_PRODUCT_IMPORT'] = CrmCheckPath('PATH_TO_PRODUCT_IMPORT', $arParams['PATH_TO_PRODUCT_IMPORT'], $APPLICATION->GetCurPage() . '?import');
if (isset($_REQUEST['getSample']) && $_REQUEST['getSample'] == 'csv') {
    $APPLICATION->RestartBuffer();
    Header("Content-Type: application/force-download");
    Header("Content-Type: application/octet-stream");
    Header("Content-Type: application/download");
    Header("Content-Disposition: attachment;filename=products.csv");
    Header("Content-Transfer-Encoding: binary");
    // add UTF-8 BOM marker
    if (defined('BX_UTF') && BX_UTF) {
Exemplo n.º 3
0
} else {
    $arProperty = $arDefPropInfo;
    $arProperty["IBLOCK_ID"] = $iblockID;
}
$arProperty['USER_TYPE'] = trim($arProperty['USER_TYPE']);
$arResult['PROPERTY'] = $arProperty;
if ('L' == $arProperty['PROPERTY_TYPE']) {
    $arDefPropInfo['MULTIPLE'] = $arProperty['MULTIPLE'];
}
$arResult['LIST_VALUE_ID_CELL'] = __AddListValueIDCell('ntmp_xxx', $arDefPropInfo);
$arResult['LIST_VALUE_XMLID_CELL'] = __AddListValueXmlIDCell('ntmp_xxx', $arDefPropInfo);
$arResult['LIST_VALUE_VALUE_CELL'] = __AddListValueValueCell('ntmp_xxx', $arDefPropInfo);
$arResult['LIST_VALUE_SORT_CELL'] = __AddListValueSortCell('ntmp_xxx', $arDefPropInfo);
$arResult['LIST_VALUE_DEF_CELL'] = __AddListValueDefCell('ntmp_xxx', $arDefPropInfo);
$arTypesList = array("S" => GetMessage("CRM_PRODUCT_PE_PROP_TYPE_S"), "N" => GetMessage("CRM_PRODUCT_PE_PROP_TYPE_N"), "L" => GetMessage("CRM_PRODUCT_PE_PROP_TYPE_L"), "F" => GetMessage("CRM_PRODUCT_PE_PROP_TYPE_F"), "E" => GetMessage("CRM_PRODUCT_PE_PROP_TYPE_E"));
$arUserType = '' != $arProperty['USER_TYPE'] ? CCrmProductPropsHelper::GetPropsTypesByOperations($arProperty['USER_TYPE']) : array();
$arPropertyFields = array();
$userTypeSettingsHTML = "";
if (isset($arUserType["GetSettingsHTML"])) {
    $userTypeSettingsHTML = call_user_func_array($arUserType["GetSettingsHTML"], array($arProperty, array("NAME" => "PROPERTY_USER_TYPE_SETTINGS"), &$arPropertyFields));
}
$arResult['PROPERTY_TYPE'] = $arProperty['PROPERTY_TYPE'] . ($arProperty['USER_TYPE'] ? ':' . $arProperty['USER_TYPE'] : '');
$arResult['FIELDS'] = array();
$arResult['HIDDEN_FIELDS_HTML'] = '';
$customFieldHTML = '<input type="hidden" name="PROPERTY_FILE_TYPE" value="' . htmlspecialcharsbx($arProperty['FILE_TYPE']) . '">' . (0 < intval($arProperty['ID']) ? $arProperty['ID'] : GetMessage("CRM_PRODUCT_PE_PROP_NEW"));
$arResult['FIELDS']['tab_params'][] = array('id' => 'PROP_ID', 'name' => GetMessage('CRM_PRODUCTPROP_FIELD_ID'), 'params' => array('size' => 10), 'value' => $customFieldHTML, 'type' => 'custom');
if (intval($arProperty['ID']) <= 0) {
    $boolUserPropExist = false;
    $customFieldHTML = '<input type="hidden" id="PROPERTY_PROPERTY_TYPE" name="PROPERTY_PROPERTY_TYPE" value="' . htmlspecialcharsbx($arResult['PROPERTY_TYPE']) . '">';
    $customFieldHTML .= '<select name="PROPERTY_PROPERTY_TYPE" onchange="reloadForm();">';
    if ($boolUserPropExist) {
Exemplo n.º 4
0
$CrmPerms = new CCrmPerms($USER->GetID());
if (!$CrmPerms->HavePerm('CONFIG', BX_CRM_PERM_CONFIG, 'READ')) {
    ShowError(GetMessage('CRM_PERMISSION_DENIED'));
    return;
}
/** @global CDatabase $DB */
global $DB;
$arResult['CAN_DELETE'] = $arResult['CAN_EDIT'] = $CrmPerms->HavePerm('CONFIG', BX_CRM_PERM_CONFIG, 'WRITE');
$arParams['PATH_TO_PRODUCTPROPS_LIST'] = CrmCheckPath('PATH_TO_PRODUCTPROPS_LIST', $arParams['PATH_TO_PRODUCTPROPS_LIST'], '');
$arParams['PATH_TO_PRODUCTPROPS_ADD'] = CrmCheckPath('PATH_TO_PRODUCTPROPS_ADD', $arParams['PATH_TO_PRODUCTPROPS_ADD'], '?add');
$arParams['PATH_TO_PRODUCTPROPS_EDIT'] = CrmCheckPath('PATH_TO_PRODUCTPROPS_EDIT', $arParams['PATH_TO_PRODUCTPROPS_EDIT'], '?prop_id=#prop_id#&edit');
$arResult['GRID_ID'] = 'CRM_PRODUCTPROPS_LIST';
$arResult['FORM_ID'] = isset($arParams['FORM_ID']) ? $arParams['FORM_ID'] : '';
$arResult['TAB_ID'] = isset($arParams['TAB_ID']) ? $arParams['TAB_ID'] : '';
$arPropType = array('' => GetMessage('CRM_PRODUCT_PROP_IBLOCK_ALL'), 'S' => GetMessage('CRM_PRODUCT_PROP_IBLOCK_PROP_S'), 'N' => GetMessage('CRM_PRODUCT_PROP_IBLOCK_PROP_N'), 'L' => GetMessage('CRM_PRODUCT_PROP_IBLOCK_PROP_L'), 'F' => GetMessage('CRM_PRODUCT_PROP_IBLOCK_PROP_F'), 'E' => GetMessage('CRM_PRODUCT_PROP_IBLOCK_PROP_E'));
$arUserTypeList = CCrmProductPropsHelper::GetPropsTypesByOperations(false, 'edit');
\Bitrix\Main\Type\Collection::sortByColumn($arUserTypeList, array('DESCRIPTION' => SORT_STRING));
foreach ($arUserTypeList as $arUserType) {
    $arPropType[$arUserType['PROPERTY_TYPE'] . ':' . $arUserType['USER_TYPE']] = $arUserType['DESCRIPTION'];
}
$arResult['HEADERS'] = array(array('id' => 'ID', 'name' => GetMessage('CRM_PRODUCT_PROP_PL_ID'), 'sort' => 'id', 'align' => 'right', 'default' => true, 'editable' => false), array('id' => 'NAME', 'name' => GetMessage('CRM_PRODUCT_PROP_PL_NAME'), 'sort' => 'name', 'default' => true, 'editable' => true), array('id' => 'PROPERTY_TYPE', 'name' => GetMessage('CRM_PRODUCT_PROP_PL_PROPERTY_TYPE'), 'default' => true, 'editable' => false, 'type' => 'list'), array('id' => 'SORT', 'name' => GetMessage('CRM_PRODUCT_PROP_PL_SORT'), 'sort' => 'sort', 'align' => 'right', 'default' => true, 'editable' => true), array('id' => 'ACTIVE', 'name' => GetMessage('CRM_PRODUCT_PROP_PL_ACTIVE'), 'sort' => 'active', 'align' => 'center', 'default' => true, 'editable' => true, 'type' => 'checkbox'), array('id' => 'IS_REQUIRED', 'name' => GetMessage('CRM_PRODUCT_PROP_PL_IS_REQUIRED'), 'align' => 'center', 'default' => true, 'editable' => true, 'type' => 'checkbox'), array('id' => 'MULTIPLE', 'name' => GetMessage('CRM_PRODUCT_PROP_PL_MULTIPLE'), 'align' => 'center', 'default' => true, 'editable' => true, 'type' => 'checkbox'), array('id' => 'XML_ID', 'name' => GetMessage('CRM_PRODUCT_PROP_PL_XML_ID'), 'editable' => true));
$arResult['FILTER_PRESETS'] = array();
$arResult['FILTER'] = array(array('id' => 'NAME', 'name' => GetMessage('CRM_PRODUCT_PROP_PL_NAME'), 'default' => true), array('id' => 'ACTIVE', 'name' => GetMessage('CRM_PRODUCT_PROP_PL_ACTIVE'), 'type' => 'list', 'items' => array('' => GetMessage('CRM_PRODUCT_PROP_IBLOCK_ALL'), 'Y' => GetMessage('MAIN_YES'), 'N' => GetMessage('MAIN_NO'))), array('id' => 'IS_REQUIRED', 'name' => GetMessage('CRM_PRODUCT_PROP_PL_IS_REQUIRED'), 'type' => 'list', 'items' => array('' => GetMessage('CRM_PRODUCT_PROP_IBLOCK_ALL'), 'Y' => GetMessage('MAIN_YES'), 'N' => GetMessage('MAIN_NO'))), array('id' => 'MULTIPLE', 'name' => GetMessage('CRM_PRODUCT_PROP_PL_MULTIPLE'), 'type' => 'list', 'items' => array('' => GetMessage('CRM_PRODUCT_PROP_IBLOCK_ALL'), 'Y' => GetMessage('MAIN_YES'), 'N' => GetMessage('MAIN_NO'))), array('id' => 'XML_ID', 'name' => GetMessage('CRM_PRODUCT_PROP_PL_XML_ID')), array('id' => 'PROPERTY_TYPE', 'name' => GetMessage('CRM_PRODUCT_PROP_PL_PROPERTY_TYPE'), 'type' => 'list', 'items' => $arPropType));
$CGridOptions = new CCrmGridOptions($arResult['GRID_ID']);
$arFilter = $CGridOptions->GetFilter($arResult['FILTER']);
$arStrFilters = array('NAME', 'CODE');
foreach ($arFilter as $k => $v) {
    if (in_array($k, $arStrFilters, true)) {
        $arFilter['?' . $k] = $v;
        unset($arFilter[$k]);
    }
Exemplo n.º 5
0
 protected function innerDelete($id, &$errors)
 {
     /** @global CMain $APPLICATION */
     global $APPLICATION;
     if (!CModule::IncludeModule('iblock')) {
         throw new RestException('Could not load iblock module.');
     }
     /** @var CCrmPerms $userPerms */
     $userPerms = CCrmPerms::GetCurrentUserPermissions();
     if (!$userPerms->HavePerm('CONFIG', BX_CRM_PERM_CONFIG, 'WRITE')) {
         $errors[] = 'Access denied.';
         return false;
     }
     $iblockId = intval(CCrmCatalog::EnsureDefaultExists());
     $userTypes = CCrmProductPropsHelper::GetPropsTypesByOperations(false, 'rest');
     $res = CIBlockProperty::GetByID($id, $iblockId);
     $result = false;
     if (is_object($res)) {
         $result = $res->Fetch();
     }
     unset($res);
     if (!is_array($result) || isset($result['USER_TYPE']) && !empty($result['USER_TYPE']) && !array_key_exists($result['USER_TYPE'], $userTypes)) {
         $errors[] = 'Not found';
         return false;
     }
     if (!CIBlockProperty::Delete($id)) {
         if ($e = $APPLICATION->GetException()) {
             $errors[] = $e->GetString();
         } else {
             $errors[] = 'Error on deleting product property.';
         }
         return false;
     }
     return true;
 }