Esempio n. 1
0
// если была нажата кнопка "save" на текущей странице
if ((strlen($save) > 0 || strlen($apply) > 0) && $REQUEST_METHOD == "POST" && $bAdmin == "Y" && check_bitrix_sessid()) {
    $arFields = array('C_TYPE' => symbolsAndNumbers($_REQUEST['C_TYPE']), 'SID' => $_REQUEST['SID'], 'SET_AS_DEFAULT' => $SET_AS_DEFAULT, 'C_SORT' => $_REQUEST['C_SORT'], 'NAME' => $_REQUEST['NAME'], 'DESCR' => $_REQUEST['DESCR'], 'RESPONSIBLE_USER_ID' => $_REQUEST['RESPONSIBLE_USER_ID'], 'arrSITE' => $_REQUEST['arrSITE']);
    if (is_array($_REQUEST['arrSITE']) && count($_REQUEST['arrSITE']) > 0) {
        $arFields['FIRST_SITE_ID'] = reset($_REQUEST['arrSITE']);
        $_SESSION['SESS_TICKET_DIC_SITE'] = $_REQUEST['arrSITE'];
    }
    if (CModule::IncludeModule('statistic') && $_REQUEST['C_TYPE'] == 'C') {
        $arFields['EVENT1'] = $_REQUEST['EVENT1'];
        $arFields['EVENT2'] = $_REQUEST['EVENT2'];
        $arFields['EVENT3'] = $_REQUEST['EVENT3'];
    }
    $bOK = false;
    $new = false;
    if ($ID > 0) {
        $bOK = CTicketDictionary::Update($ID, $arFields);
    } else {
        if ($ID = CTicketDictionary::Add($arFields)) {
            $new = true;
            $bOK = true;
        }
    }
    if ($bOK) {
        if (strlen($save) > 0) {
            LocalRedirect("/bitrix/admin/ticket_dict_list.php?lang=" . LANGUAGE_ID . "&find_type=" . symbolsAndNumbers($_REQUEST['C_TYPE']));
        } elseif ($new) {
            LocalRedirect("/bitrix/admin/ticket_dict_edit.php?ID=" . $ID . "&lang=" . LANGUAGE_ID . "&find_type=" . symbolsAndNumbers($_REQUEST['C_TYPE']) . "&tabControl_active_tab=" . urlencode($tabControl_active_tab));
        }
    } else {
        if ($e = $APPLICATION->GetException()) {
            $message = new CAdminMessage(GetMessage("SUP_ERROR"), $e);
//инициализация фильтра
InitBVar($find_id_exact_match);
InitBVar($find_name_exact_match);
InitBVar($find_sid_exact_match);
InitBVar($find_responsible_exact_match);
$arFilter = array("ID" => $find_id, "ID_EXACT_MATCH" => $find_id_exact_match, "SITE" => $find_site, "TYPE" => $find_type, "NAME" => $find != "" && $find_type_ex == "name" ? $find : $find_name, "NAME_EXACT_MATCH" => $find_name_exact_match, "DESCR" => $find != "" && $find_type_ex == "descr" ? $find : $find_descr, "DESCR_EXACT_MATCH" => $find_descr_exact_match, "SID" => $find_sid, "SID_EXACT_MATCH" => $find_sid_exact_match, "RESPONSIBLE_ID" => $find_responsible_id, "RESPONSIBLE" => $find_responsible, "RESPONSIBLE_EXACT_MATCH" => $find_responsible_exact_match, "DEFAULT" => $find_default);
if ($bAdmin == "Y" && $lAdmin->EditAction()) {
    foreach ($FIELDS as $ID => $arFields) {
        $ID = intval($ID);
        if (!$lAdmin->IsUpdated($ID)) {
            continue;
        }
        $arFields["C_SORT"] = intval($arFields["C_SORT"]);
        if (strlen(trim($arFields["NAME"])) > 0) {
            $arUpdate = array('C_SORT' => $arFields['C_SORT'], 'NAME' => $arFields['NAME']);
            if (!CTicketDictionary::Update($ID, $arUpdate)) {
                $lAdmin->AddUpdateError(str_replace("#ID#", $ID, GetMessage("SUP_ERROR_SAVE")), $ID);
            }
        } else {
            $lAdmin->AddUpdateError(str_replace("#ID#", $ID, GetMessage("SUP_FORGOT_NAME")), $ID);
        }
    }
}
if ($bAdmin == "Y" && ($arID = $lAdmin->GroupAction())) {
    if ($_REQUEST['action_target'] == 'selected') {
        $rsData = CTicketDictionary::GetList($by, $order, $arFilter);
        while ($arRes = $rsData->Fetch()) {
            $arID[] = $arRes['ID'];
        }
    }
    foreach ($arID as $ID) {