Example #1
0
}
$siteID = $arParams["site_id"];
if (strlen($arParams["site_id"]) <= 0) {
    $siteID = "s1";
}
$dbSite = CSite::GetByID($siteID);
if ($arSite = $dbSite->Fetch()) {
    $lang = $arSite["LANGUAGE_ID"];
}
if (strlen($lang) <= 0) {
    $lang = "ru";
}
$bRus = false;
if ($lang == "ru") {
    $bRus = true;
}
__IncludeLang(GetLangFileName(dirname(__FILE__) . "/lang/", "/" . basename(__FILE__), $lang));
$dbLocation = CSaleLocation::GetList(array("ID" => "ASC"), array("LID" => $lang));
if ($arLocation = $dbLocation->Fetch()) {
    $arLocationArr = array();
    $arLocation4Delivery = array();
    do {
        $arLocationArr[] = $arLocation["ID"];
    } while ($arLocation = $dbLocation->Fetch());
    //Location group
    $groupLang = array(array("LID" => "en", "NAME" => "Group 1"));
    if ($bRus) {
        $groupLang[] = array("LID" => "ru", "NAME" => GetMessage("SALE_WIZARD_GROUP"));
    }
    $locationGroupID = CSaleLocationGroup::Add(array("SORT" => 150, "LOCATION_ID" => $arLocationArr, "LANG" => $groupLang));
}
        if (strlen(${"NAME_" . $arSysLangs[$i]}) <= 0) {
            $strError .= GetMessage("ERROR_EMPTY_NAME") . " [" . $arSysLangs[$i] . "] " . $arSysLangNames[$i] . ".<br>";
        }
    }
    if (strlen($strError) <= 0) {
        $arFields = array("SORT" => $SORT, "LOCATION_ID" => $LOCATION_ID);
        $langCnt = count($arSysLangs);
        for ($i = 0; $i < $langCnt; $i++) {
            $arFields["LANG"][] = array("LID" => $arSysLangs[$i], "NAME" => ${"NAME_" . $arSysLangs[$i]});
        }
        if ($ID > 0) {
            if (!CSaleLocationGroup::Update($ID, $arFields)) {
                $strError .= GetMessage("ERROR_EDIT_GROUP") . "<br>";
            }
        } else {
            $ID = CSaleLocationGroup::Add($arFields);
            if (IntVal($ID) <= 0) {
                $strError .= GetMessage("ERROR_ADD_GROUP") . "<br>";
            }
        }
    }
    if (strlen($strError) > 0) {
        $bInitVars = True;
    }
    if (strlen($save) > 0 && strlen($strError) <= 0) {
        LocalRedirect("sale_location_group_admin.php?lang=" . LANG . GetFilterParams("filter_", false));
    }
}
if ($ID > 0) {
    $db_location = CSaleLocationGroup::GetList(array("NAME" => "ASC"), array("ID" => $ID));
    if (!$db_location->ExtractFields("str_")) {