Exemplo n.º 1
0
    }
    $productID = isset($_REQUEST[$productIDParName]) ? intval($_REQUEST[$productIDParName]) : 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;
        }
Exemplo n.º 2
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.º 3
0
    $arSections[$arSection['ID']] = str_repeat(' . ', $arSection['DEPTH_LEVEL']) . $arSection['~NAME'];
}
$arResult['FILTER'] = array(array('id' => 'ID', 'name' => GetMessage('CRM_COLUMN_ID'), 'type' => 'string', 'default' => true), array('id' => 'NAME', 'name' => GetMessage('CRM_COLUMN_NAME'), 'type' => 'string', 'default' => true), array('id' => 'LIST_SECTION_ID', 'name' => GetMessage('CRM_COLUMN_SECTION'), 'type' => 'list', 'default' => true, 'items' => $arSections, 'value' => '0'), array('id' => 'ACTIVE', 'name' => GetMessage('CRM_COLUMN_ACTIVE'), 'type' => 'list', 'items' => array('' => GetMessage('CRM_NOT_SELECTED'), 'Y' => GetMessage('MAIN_YES'), 'N' => GetMessage('MAIN_NO'))), array('id' => 'DESCRIPTION', 'name' => GetMessage('CRM_COLUMN_DESCRIPTION')));
$arResult['FILTER_PRESETS'] = array();
//}
// Headers initialization -->
$arResult['HEADERS'] = array(array('id' => 'ID', 'name' => GetMessage('CRM_COLUMN_ID'), 'sort' => 'id', 'default' => false, 'editable' => false), array('id' => 'NAME', 'name' => GetMessage('CRM_COLUMN_NAME'), 'sort' => 'name', 'default' => true, 'editable' => true, 'params' => array('size' => 45)), array('id' => 'PRICE', 'name' => GetMessage('CRM_COLUMN_PRICE'), 'default' => true, 'editable' => true), array('id' => 'MEASURE', 'name' => GetMessage('CRM_COLUMN_MEASURE'), 'default' => true, 'editable' => array('items' => $arResult['MEASURE_LIST_ITEMS']), 'type' => 'list'));
if ($bVatMode) {
    $arResult['HEADERS'][] = array('id' => 'VAT_ID', 'name' => GetMessage('CRM_COLUMN_VAT_ID'), 'default' => true, 'editable' => array('items' => $arResult['VAT_RATE_LIST_ITEMS'], 'type' => 'list'));
    $arResult['HEADERS'][] = array('id' => 'VAT_INCLUDED', 'name' => GetMessage('CRM_COLUMN_VAT_INCLUDED'), 'default' => true, 'editable' => true, 'type' => 'checkbox');
}
$arResult['HEADERS'] = array_merge($arResult['HEADERS'], array(array('id' => 'SECTION_ID', 'name' => GetMessage('CRM_COLUMN_SECTION'), 'default' => true, 'editable' => array('items' => CCrmProductHelper::PrepareSectionListItems($catalogID, true)), 'type' => 'list'), array('id' => 'SORT', 'name' => GetMessage('CRM_COLUMN_SORT'), 'sort' => 'sort', 'default' => false, 'editable' => true), array('id' => 'ACTIVE', 'name' => GetMessage('CRM_COLUMN_ACTIVE'), 'sort' => 'active', 'default' => false, 'editable' => true, 'type' => 'checkbox'), array('id' => 'DESCRIPTION', 'name' => GetMessage('CRM_COLUMN_DESCRIPTION'), 'sort' => 'description', 'default' => true, 'editable' => true), array('id' => 'PREVIEW_PICTURE', 'name' => GetMessage('CRM_PRODUCT_FIELD_PREVIEW_PICTURE'), 'sort' => 'preview_picture', 'default' => false, 'editable' => false), array('id' => 'DETAIL_PICTURE', 'name' => GetMessage('CRM_PRODUCT_FIELD_DETAIL_PICTURE'), 'sort' => 'detail_picture', 'default' => false, 'editable' => false)));
// <-- Headers initialization
// Product properties
// <editor-fold defaultstate="collapsed" desc="Product properties">
$arPropUserTypeList = CCrmProductPropsHelper::GetPropsTypesByOperations(false, array('view', 'filter'));
$arResult['PROP_USER_TYPES'] = $arPropUserTypeList;
$arProps = CCrmProductPropsHelper::GetProps($catalogID, $arPropUserTypeList);
$arResult['PROPS'] = $arProps;
$arFilterable = array();
$arCustomFilter = array();
$arDateFilter = array();
CCrmProductPropsHelper::ListAddFilterFields($arPropUserTypeList, $arProps, $arResult['GRID_ID'], $arResult['FILTER'], $arFilterable, $arCustomFilter, $arDateFilter);
CCrmProductPropsHelper::ListAddHeades($arPropUserTypeList, $arProps, $arResult['HEADERS']);
// </editor-fold>
$bTree = false;
// check hit from section tree
if ($_SERVER['REQUEST_METHOD'] == 'GET' && isset($_REQUEST['tree'])) {
    $bTree = $_REQUEST['tree'] === 'Y';
    unset($_GET['tree'], $_REQUEST['tree']);
}
Exemplo n.º 4
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.º 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;
 }