$arErrors = $imp->GetErrors(); foreach ($arErrors as $err) { $arResult['ERROR_MESSAGE'] .= $err[1] . '<br />'; } } } } if (empty($arResult['ERROR_MESSAGE'])) { if (!$CCrmBizProc->StartWorkflow($arResult['ELEMENT']['ID'], $arBizProcParametersValues)) { $arResult['ERROR_MESSAGE'] = $CCrmBizProc->LAST_ERROR; } } $ID = isset($arResult['ELEMENT']['ID']) ? $arResult['ELEMENT']['ID'] : 0; if (!empty($arResult['ERROR_MESSAGE'])) { ShowError($arResult['ERROR_MESSAGE']); $arResult['ELEMENT'] = CCrmComponentHelper::PrepareEntityFields(array_merge(array('ID' => $ID), $arFields), CCrmDeal::GetFields()); } else { if (intval($_POST['SYNC_ORDER_ID']) > 0) { LocalRedirect(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_DEAL_SHOW'], array('deal_id' => $ID))); } if (isset($_POST['apply'])) { if (CCrmDeal::CheckUpdatePermission($ID)) { LocalRedirect(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_DEAL_EDIT'], array('deal_id' => $ID))); } } elseif (isset($_POST['saveAndAdd'])) { LocalRedirect(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_DEAL_EDIT'], array('deal_id' => 0))); } elseif (isset($_POST['saveAndView'])) { if (CCrmDeal::CheckReadPermission($ID)) { LocalRedirect(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_DEAL_SHOW'], array('deal_id' => $ID))); } }