$filter = new CAdminFilter($sTableID . "_filter_id", $arFilterRows);
$arFilterFields = array("find_controller_group_id");
$lAdmin->InitFilter($arFilterFields);
if ($find_controller_group_id) {
    $arFilter = array("=CONTROLLER_GROUP_ID" => $find_controller_group_id);
} else {
    $arFilter = array();
}
if ($MOD_RIGHT >= "W" && $lAdmin->EditAction()) {
    foreach ($FIELDS as $ID => $arFields) {
        $ID = intval($ID);
        if (!$lAdmin->IsUpdated($ID)) {
            continue;
        }
        $DB->StartTransaction();
        if (!CControllerCounter::Update($ID, $arFields)) {
            $e = $APPLICATION->GetException();
            $lAdmin->AddUpdateError(GetMessage("CTRL_CNT_ADMIN_UPDATE_ERROR", array("#ID#" => $ID, "#ERROR#" => $e->GetString())), $ID);
            $DB->Rollback();
        }
        $DB->Commit();
    }
}
if ($MOD_RIGHT >= "W" && ($arID = $lAdmin->GroupAction())) {
    if ($_REQUEST['action_target'] == 'selected') {
        $rsData = CControllerCounter::GetList(array($by => $order), $arFilter);
        while ($arRes = $rsData->Fetch()) {
            $arID[] = $arRes['ID'];
        }
    }
    foreach ($arID as $ID) {
IncludeModuleLangFile(__FILE__);
$message = null;
$ID = intval($ID);
if ($_SERVER["REQUEST_METHOD"] == "POST" && check_bitrix_sessid() && (isset($_POST["save"]) || isset($_POST["apply"]) || isset($_POST["delete"]))) {
    if (isset($_POST["delete"]) && $_POST["delete"] === "y") {
        CControllerCounter::Delete($ID);
        if ($back_url == '') {
            LocalRedirect("controller_counter_admin.php?lang=" . LANGUAGE_ID);
        } else {
            LocalRedirect($back_url);
        }
    } else {
        $arFields = array("COUNTER_TYPE" => $_POST["COUNTER_TYPE"], "COUNTER_FORMAT" => $_POST["COUNTER_FORMAT"], "NAME" => $_POST["NAME"], "COMMAND" => $_POST["COMMAND"], "CONTROLLER_GROUP_ID" => $_POST["CONTROLLER_GROUP_ID"]);
        $obCounter = new CControllerCounter();
        if ($ID > 0) {
            $res = $obCounter->Update($ID, $arFields);
        } else {
            $res = $ID = $obCounter->Add($arFields);
        }
        if (!$res) {
            if ($e = $APPLICATION->GetException()) {
                $message = new CAdminMessage(GetMessage("CTRL_COUNTER_EDIT_ERROR"), $e);
            }
        } else {
            if (isset($_POST["save"])) {
                if ($back_url == '') {
                    LocalRedirect("controller_counter_admin.php?lang=" . LANGUAGE_ID);
                } else {
                    LocalRedirect($back_url);
                }
            } else {