Пример #1
0
		"ACTIVE"					=> isset($_POST['ACTIVE'])? $_POST['ACTIVE'] : 'N',
		"ACTIVATE"				=> isset($_POST['ACTIVATE'])? $_POST['ACTIVATE'] : 'N',
		"DEACTIVATE"			=> isset($_POST['DEACTIVATE'])? $_POST['DEACTIVATE'] : 'N',
		"NAME"					=> $_POST['NAME'],
		"ENTITY_TYPE_ID"		=> $_POST['ENTITY_TYPE_ID'],
		"CONDITION_NAME"		=> $_POST['CONDITION_NAME'],
		"CONDITION_CONFIG"	=> $_POST['CONDITION_CONFIG'],
	);
	if (isset($_POST['ACTION_NAME']) && isset($_POST['ACTION_NAME']))
	{
		$arFields["ACTION_NAME"] = $_POST['ACTION_NAME'];
		$arFields["ACTION_CONFIG"] = $_POST['ACTION_CONFIG'];
	}

	if($ID>0)
		$res = CRatingRule::Update($ID, $arFields);
	else
	{
		$ID = CRatingRule::Add($arFields);
		$res = ($ID>0);
	}

	if($res)
	{
		if($apply <> "")
		{
			$_SESSION["SESS_ADMIN"]["RATING_RULE_EDIT_MESSAGE"]=array("MESSAGE"=>GetMessage("RATING_RULE_EDIT_SUCCESS"), "TYPE"=>"OK");
			LocalRedirect("rating_rule_edit.php?ID=".$ID."&lang=".LANG);
		}
		else
			LocalRedirect(($_REQUEST["addurl"]<>""? $_REQUEST["addurl"]:"rating_rule_list.php?lang=".LANG));
}
$FilterArr = array("find_name", "find_active", "find_id", "find_entity_type_id");
$lAdmin->InitFilter($FilterArr);
$arFilter = array();
if (CheckFilter()) {
    $arFilter = array("NAME" => $find_name, "ACTIVE" => $find_active, "ID" => $find_id, "ENTITY_TYPE_ID" => $find_entity_type_id);
}
if ($lAdmin->EditAction()) {
    foreach ($FIELDS as $ID => $arFields) {
        $ID = IntVal($ID);
        if ($ID <= 0) {
            continue;
        }
        $arUpdate['NAME'] = $arFields['NAME'];
        $arUpdate['ACTIVE'] = $arFields['ACTIVE'] == 'Y' ? 'Y' : 'N';
        if (!CRatingRule::Update($ID, $arUpdate)) {
            $e = $APPLICATION->GetException();
            $lAdmin->AddUpdateError($e ? $e->GetString() : GetMessage("RATING_RULE_LIST_ERR_EDIT"), $ID);
        }
    }
}
if ($arID = $lAdmin->GroupAction()) {
    if ($_REQUEST['action_target'] == 'selected') {
        $rsData = CRatingRule::GetList(array($by => $order), $arFilter);
        while ($arRes = $rsData->Fetch()) {
            $arID[] = $arRes['ID'];
        }
    }
    foreach ($arID as $ID) {
        $ID = IntVal($ID);
        if ($ID <= 0) {