Example #1
0
            }
            if ($ID > 0 && strlen($strError) <= 0) {
                $arZipList = $_REQUEST["ZIP"];
                CSaleLocation::SetLocationZIP($ID, $arZipList);
            }
            //			die();
            if (strlen($strError) <= 0) {
                LocalRedirect(isset($_POST['apply']) || strlen($strError) > 0 ? CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_LOCATIONS_EDIT'], array('loc_id' => $ID)) : CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_LOCATIONS_LIST'], array('loc_id' => $ID)));
            }
        }
        if (strlen($strError) > 0) {
            ShowError($strError);
        }
    } elseif ($_SERVER['REQUEST_METHOD'] == 'GET' && isset($_GET['delete'])) {
        $locID = isset($arParams['LOC_ID']) ? intval($arParams['LOC_ID']) : 0;
        $arLoc = $locID > 0 ? CCrmLocations::GetByID($locID) : null;
        if ($arLoc) {
            if (!CSaleLocation::Delete($locID)) {
                $errorMsg = '';
                if ($ex = $APPLICATION->GetException()) {
                    $errorMsg = $ex->GetString();
                } else {
                    $errorMsg = GetMessage('CRM_LOC_DELETE_UNKNOWN_ERROR');
                }
                ShowError($errorMsg);
            } else {
                LocalRedirect(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_LOCATIONS_LIST'], array()));
            }
        }
    }
}
Example #2
0
global $USER, $APPLICATION;
$arParams['PATH_TO_LOCATIONS_LIST'] = CrmCheckPath('PATH_TO_LOCATIONS_LIST', $arParams['PATH_TO_LOCATIONS_LIST'], '');
$arParams['PATH_TO_LOCATIONS_ADD'] = CrmCheckPath('PATH_TO_LOCATIONS_ADD', $arParams['PATH_TO_LOCATIONS_ADD'], '?add');
$arParams['PATH_TO_LOCATIONS_EDIT'] = CrmCheckPath('PATH_TO_LOCATIONS_EDIT', $arParams['PATH_TO_LOCATIONS_EDIT'], '?loc_id=#loc_id#&edit');
$arParams['PATH_TO_LOCATIONS_IMPORT'] = CrmCheckPath('PATH_TO_LOCATIONS_IMPORT', $arParams['PATH_TO_LOCATIONS_IMPORT'], '?import');
if (!isset($arParams['TYPE'])) {
    $arParams['TYPE'] = 'list';
}
$arResult['BUTTONS'] = array();
$locID = isset($arParams['LOC_ID']) ? strval($arParams['LOC_ID']) : '';
$CrmPerms = new CCrmPerms($USER->GetID());
$locAdd = $locEdit = $locDelete = $locImport = $CrmPerms->HavePerm('CONFIG', BX_CRM_PERM_CONFIG, 'WRITE');
if (CSaleLocation::isLocationProMigrated()) {
    $exists = intval($locID > 0) && CCrmLocations::CheckLocationExists($locID);
} else {
    $exists = intval($locID > 0) && is_array(CCrmLocations::GetByID($locID));
}
########################
########################
########################
// LIST
if ($arParams['TYPE'] == 'list') {
    $parentId = false;
    // STEP UP IN LIST
    if (CSaleLocation::isLocationProEnabled()) {
        $filterParentId = false;
        if (isset($_REQUEST['PARENT_ID'])) {
            $filterParentId = intval($_REQUEST['PARENT_ID']);
        } else {
            $gridOpts = new CCrmGridOptions('CRM_LOC_LIST');
            $filter = $gridOpts->GetFilter(array());