$errors[] = $exception->GetString(); } else { $errors[] = GetMessage('CRM_MEASURE_ERR_CREATE'); } } } $fields['ID'] = $elementID; $arResult['ELEMENT'] = $fields; } if (!empty($errors)) { ShowError(implode("\n", $errors)); } else { LocalRedirect(isset($_POST['apply']) ? CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_MEASURE_EDIT'], array('measure_id' => $elementID)) : CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_MEASURE_LIST'])); } } elseif ($_SERVER['REQUEST_METHOD'] === 'GET' && isset($_GET['delete']) && $elementID > 0) { CCatalogMeasure::delete($elementID); LocalRedirect(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_MEASURE_LIST'])); } } $arResult['FORM_ID'] = !empty($arParams['FORM_ID']) ? $arParams['FORM_ID'] : 'CRM_MEASURE_EDIT'; $arResult['GRID_ID'] = 'CRM_MEASURE_LIST'; $arResult['BACK_URL'] = $arParams['PATH_TO_MEASURE_LIST']; $arResult['FIELDS'] = array(); $arResult['FIELDS']['tab_1'][] = array('id' => 'section_measure_info', 'name' => GetMessage('CRM_SECTION_MEASURE_INFO'), 'type' => 'section'); if ($isEditMode) { $arResult['FIELDS']['tab_1'][] = array('id' => 'ID', 'name' => GetMessage('CRM_MEASURE_FIELD_ID'), 'value' => isset($arResult['ELEMENT']['ID']), 'type' => 'label'); } $arResult['FIELDS']['tab_1'][] = array('id' => 'IS_DEFAULT', 'name' => GetMessage('CRM_MEASURE_FIELD_IS_DEFAULT'), 'value' => isset($arResult['ELEMENT']['IS_DEFAULT']) ? $arResult['ELEMENT']['IS_DEFAULT'] : 'N', 'type' => 'checkbox'); $arResult['FIELDS']['tab_1'][] = array('id' => 'CODE', 'name' => GetMessage('CRM_MEASURE_FIELD_CODE'), 'value' => isset($arResult['ELEMENT']['CODE']) ? $arResult['ELEMENT']['CODE'] : '', 'type' => 'text', 'required' => true); $arResult['FIELDS']['tab_1'][] = array('id' => 'MEASURE_TITLE', 'name' => GetMessage('CRM_MEASURE_FIELD_MEASURE_TITLE'), 'value' => isset($arResult['ELEMENT']['MEASURE_TITLE']) ? $arResult['ELEMENT']['MEASURE_TITLE'] : '', 'type' => 'text', 'required' => true); $arResult['FIELDS']['tab_1'][] = array('id' => 'SYMBOL_RUS', 'name' => GetMessage('CRM_MEASURE_FIELD_SYMBOL_RUS'), 'value' => isset($arResult['ELEMENT']['SYMBOL_RUS']) ? $arResult['ELEMENT']['SYMBOL_RUS'] : '', 'type' => 'text');
if (isset($arHead['editable']) && $arHead['editable'] == true && isset($arSrcData[$arHead['id']])) { $arUpdateData[$arHead['id']] = $arSrcData[$arHead['id']]; } } if (!empty($arUpdateData)) { CCatalogMeasure::update($ID, $arUpdateData); } } } } if (!$actionData['AJAX_CALL']) { LocalRedirect($arParams['PATH_TO_MEASURE_LIST']); } } else { if ($actionData['NAME'] === 'delete' && isset($actionData['ID'])) { CCatalogMeasure::delete($actionData['ID']); } if (!$actionData['AJAX_CALL']) { LocalRedirect($arParams['PATH_TO_MEASURE_LIST']); } } } // <-- POST & GET actions processing if (intval($arParams['MEASURE_COUNT']) <= 0) { $arParams['MEASURE_COUNT'] = 20; } $arNavParams = array('nPageSize' => $arParams['MEASURE_COUNT']); $arNavigation = CDBResult::GetNavParams($arNavParams); $gridOptions = new CCrmGridOptions($arResult['GRID_ID']); $gridSorting = $gridOptions->GetSorting(array('sort' => array('CODE' => 'asc'), 'vars' => array('by' => 'by', 'order' => 'order'))); $arResult['SORT'] = $gridSorting['sort'];