Example #1
0
        if (!empty($result)) {
            echo CUtil::PhpToJSObject($result);
        }
        require_once $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/epilog_after.php';
        die;
    }
}
$curUserPrems = CCrmPerms::GetCurrentUserPermissions();
$action = isset($_REQUEST['ACTION']) ? $_REQUEST['ACTION'] : '';
if ($action === 'GET_SECTIONS') {
    if (!$curUserPrems->HavePerm('CONFIG', BX_CRM_PERM_CONFIG, 'READ')) {
        __CrmMobileCompanyEditEndResonse(array('ERROR' => 'Access denied.'));
    }
    $catalogID = isset($_REQUEST['CATALOG_ID']) ? intval($_REQUEST['CATALOG_ID']) : 0;
    if ($catalogID <= 0 || !CCrmCatalog::Exists($catalogID)) {
        __CrmMobileCompanyEditEndResonse(array('ERROR' => 'Catalog ID is not found.'));
    }
    $filter = array('IBLOCK_ID' => $catalogID, 'GLOBAL_ACTIVE' => 'Y', 'CHECK_PERMISSIONS' => 'N');
    CModule::IncludeModule('iblock');
    $sectionID = isset($_REQUEST['SECTION_ID']) ? intval($_REQUEST['SECTION_ID']) : 0;
    $parentSectionID = 0;
    $sectionName = '';
    if ($sectionID > 0) {
        $dbSections = CIBlockSection::GetList(array(), array('ID' => $sectionID), false, array('ID', 'NAME', 'IBLOCK_SECTION_ID'));
        $section = $dbSections->Fetch();
        if ($section) {
            $sectionName = $section['NAME'];
            $parentSectionID = intval($section['IBLOCK_SECTION_ID']);
        }
    }
    $filter['SECTION_ID'] = $sectionID;
Example #2
0
    if ($successed) {
        //$DB->Commit();
        __CrmMobileCompanyEditEndResonse(array('DELETED_ENTITY_ID' => $ID));
    } else {
        //$DB->Rollback();
        __CrmMobileCompanyEditEndResonse(array('ERROR' => GetMessage('CRM_COMPANY_COULD_NOT_DELETE')));
    }
} elseif ($action === 'GET_ENTITY') {
    __IncludeLang(dirname(__FILE__) . '/lang/' . LANGUAGE_ID . '/' . basename(__FILE__));
    $typeName = isset($_REQUEST['ENTITY_TYPE_NAME']) ? $_REQUEST['ENTITY_TYPE_NAME'] : '';
    if ($typeName !== 'COMPANY') {
        __CrmMobileCompanyEditEndResonse(array('ERROR' => GetMessage('CRM_ENTITY_TYPE_NOT_SUPPORTED', array('#ENTITY_TYPE#' => $typeName))));
    }
    $ID = isset($_REQUEST['ENTITY_ID']) ? intval($_REQUEST['ENTITY_ID']) : 0;
    if ($ID <= 0) {
        __CrmMobileCompanyEditEndResonse(array('ERROR' => GetMessage('CRM_ENTITY_ID_NOT_FOUND')));
    }
    if (!CCrmCompany::CheckReadPermission($ID)) {
        __CrmMobileCompanyEditEndResonse(array('ERROR' => GetMessage('CRM_ACCESS_DENIED')));
    }
    $dbRes = CCrmCompany::GetListEx(array(), array('=ID' => $ID, 'CHECK_PERMISSIONS' => 'N'));
    $item = $dbRes ? $dbRes->GetNext() : null;
    if (!is_array($item)) {
        __CrmMobileCompanyEditEndResonse(array('ERROR' => GetMessage('CRM_COMPANY_NOT_FOUND', array('#ID#' => $ID))));
    }
    $formatParams = isset($_REQUEST['FORMAT_PARAMS']) ? $_REQUEST['FORMAT_PARAMS'] : array();
    CCrmMobileHelper::PrepareCompanyItem($item, $formatParams);
    __CrmMobileCompanyEditEndResonse(array('ENTITY' => CCrmMobileHelper::PrepareCompanyData($item)));
} else {
    __CrmMobileCompanyEditEndResonse(array('ERROR' => 'Action is not supported in current context.'));
}