/**
* Bitrix Framework
* @package bitrix
* @subpackage main
* @copyright 2001-2013 Bitrix
*/
/**
* Bitrix vars
* @global CUser $USER
* @global CMain $APPLICATION
*/
use Bitrix\Main\Application;
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_before.php");
require_once($_SERVER["DOCUMENT_ROOT"].BX_ROOT."/modules/main/prolog.php");
if(!defined('NOT_CHECK_PERMISSIONS') || NOT_CHECK_PERMISSIONS !== true)
{
if (!$USER->CanDoOperation('view_other_settings'))
$APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
}
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/classes/general/checklist.php");
IncludeModuleLangFile(__FILE__);
$APPLICATION->SetAdditionalCSS("/bitrix/themes/.default/check-list-style.css");
$APPLICATION->SetTitle(GetMessage("CL_TITLE_CHECKLIST"));
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_after.php");
CUtil::InitJSCore(Array('ajax','window','popup','fx'));
$arStates = array();
$showHiddenReports = CUserOptions::GetOption("checklist","show_hidden","N",false);
if ((($res = CCheckListResult::GetList(Array(),Array("REPORT"=>"N"))->Fetch()) || (isset($_POST["bx_start_test"]) && $_POST["bx_start_test"] == "Y") || !empty($_REQUEST["ACTION"])) && check_bitrix_sessid())
{
?>
if (isset($_REQUEST['report_id']))
{
$checklist = new CCheckList($_REQUEST['report_id']);
}
else
$checklist = new CCheckList();
$isFisrtTime = CUserOptions::GetOption("checklist","autotest_start","N",false);
CUserOptions::SetOption("checklist","autotest_start","Y");
$arStructure = $checklist->GetStructure();
$arPoints = $checklist->GetPoints();
if (isset($_POST["ACTION"]) && $_POST["ACTION"] == "update")
{
$arTestID = $_POST["TEST_ID"];
if (isset($_POST["autotest"]) && $_POST["autotest"]=="Y")//start autotest
{
$arStep = intval($_POST["STEP"]);
$arResult = $checklist->AutoCheck($arTestID,Array("STEP"=>$arStep));
}
else
{
$arPointFields = array();
if (isset($_POST["COMMENTS"]) && $_POST["COMMENTS"] == "Y")//update only comments
{
$arPointFields["COMMENTS"] = $arPoints[$arTestID]["STATE"]["COMMENTS"] ?? [];
if (!empty($_POST["perfomer_comment"]) && mb_strlen(trim($_POST["perfomer_comment"])) > 1)
$arPointFields["COMMENTS"]["PERFOMER"] = $_POST["perfomer_comment"];
else
unset($arPointFields["COMMENTS"]["PERFOMER"]);
if (!empty($_POST["custom_comment"]) && mb_strlen(trim($_POST["custom_comment"])) > 1)
$arPointFields["COMMENTS"]["CUSTOMER"] = $_POST["custom_comment"];
else
unset($arPointFields["COMMENTS"]["CUSTOMER"]);
if (strtoupper(SITE_CHARSET) != "UTF-8" && !empty($arPointFields["COMMENTS"]))
{
if (!empty($arPointFields["COMMENTS"]["PERFOMER"]))
$arPointFields["COMMENTS"]["PERFOMER"] = \Bitrix\Main\Text\Encoding::convertEncoding($arPointFields["COMMENTS"]["PERFOMER"],"UTF-8",SITE_CHARSET);
if(!empty($arPointFields["COMMENTS"]["CUSTOMER"]))
$arPointFields["COMMENTS"]["CUSTOMER"] = \Bitrix\Main\Text\Encoding::convertEncoding($arPointFields["COMMENTS"]["CUSTOMER"],"UTF-8",SITE_CHARSET);
}
$arPointFields["STATUS"] = $arPoints[$arTestID]["STATE"]["STATUS"];
}
if (!empty($_POST["STATUS"]))//update only status
$arPointFields["STATUS"] = $_POST["STATUS"];
$checklist->PointUpdate($arTestID, $arPointFields);
if ($checklist->Save())
{
$arResult = Array(
"STATUS"=>$arPointFields["STATUS"],
"IS_REQUIRE"=> $arPoints[$arTestID]["REQUIRE"] ?? null,
"COMMENTS_COUNT" => (isset($arPointFields["COMMENTS"]) && is_array($arPointFields["COMMENTS"])? count($arPointFields["COMMENTS"]) : 0),
);
}
else
$arResult = Array("RESULT"=>"ERROR");
}
$arTotal = $checklist->GetSectionStat();
$arCode = $checklist->checklist["CATEGORIES"][$arPoints[$arTestID]["PARENT"]]["PARENT"] ?? null;
if ($arCode)
{
$arParentCode = $arCode;
$arSubParentCode = $arPoints[$arTestID]["PARENT"];
}
else
$arParentCode = $arSubParentCode = $arPoints[$arTestID]["PARENT"];
$arSubParentStat = $checklist->GetSectionStat($arSubParentCode);
$arParentStat = $checklist->GetSectionStat($arParentCode);
//////////////////////////////////////////
//////////////JSON ANSWER/////////////////
//////////////////////////////////////////
$arParentStat["ID"] = $arParentCode;
$arSubParentStat["ID"] = $arSubParentCode;
$arResultAdditional = Array(
"PARENT"=>$arParentStat,
"SUB_PARENT"=>$arSubParentStat,
"TEST_ID"=>$arTestID,
"CAN_CLOSE_PROJECT"=> empty($_POST["CAN_SHOW_CP_MESSAGE"]) ? "N" : $arTotal["CHECKED"],
"TOTAL"=>$arTotal["TOTAL"],
"FAILED"=>$arTotal["FAILED"],
"SUCCESS"=>$arTotal["CHECK"],
"SUCCESS_R"=>$arTotal["CHECK_R"],
"REQUIRE"=>$arTotal["REQUIRE"],
"REQUIRE_CHECK"=>$arTotal["REQUIRE_CHECK"],
"WAITING"=>$arTotal["WAITING"],
"MAIN_STAT"=>Array(
"TOTAL"=>$arTotal["FAILED"]+$arTotal["CHECK"],
"SUCCESS"=>$arTotal["CHECK"],
"SUCCESS_R"=>$arTotal["CHECK_R"],
"FAILED"=>$arTotal["FAILED"],
"REQUIRE"=>$arTotal["REQUIRE"],
"REQUIRE_CHECK"=>$arTotal["REQUIRE_CHECK"]
)
);
$arResult = array_merge($arResultAdditional,$arResult);
$APPLICATION->RestartBuffer();
header("Content-Type: application/x-javascript; charset=".LANG_CHARSET);
echo CUtil::PhpToJsObject($arResult);
die();
}
elseif (isset($_REQUEST["ACTION"]) && $_REQUEST["ACTION"] == "SHOWHIDEELEMENTS")
{
if (isset($_REQUEST["report_action"]) && (isset($_REQUEST["report_id"]) && intval($_REQUEST["report_id"])))
{
$report_id = intval($_REQUEST["report_id"]);
CCheckListResult::Update($report_id, array('HIDDEN' => $_REQUEST['report_action'] == 'hide' ? 'Y' : 'N'));
}
LocalRedirect($APPLICATION->GetCurPage()."?lang=".LANG,true);
}
elseif (isset($_REQUEST["ACTION"]) && $_REQUEST["ACTION"] == "CHANGELISTPROP")
{
if (isset($_REQUEST["showHiddenReports"]) && $_REQUEST["showHiddenReports"] == "Y")
$showHiddenReports = "Y";
else
$showHiddenReports = "N";
CUserOptions::SetOption("checklist","show_hidden", $showHiddenReports);
LocalRedirect($APPLICATION->GetCurPage()."?lang=".LANG,true);
}
elseif (isset($_REQUEST["ACTION"]) && $_REQUEST["ACTION"] == "RESETBITRIXSTATUS")
{
$dbReport = CCheckListResult::GetList(Array(),Array("REPORT"=>"Y", "SENDED_TO_BITRIX" => 'Y'));
if ($arReport = $dbReport->Fetch())
{
CCheckListResult::Update($arReport['ID'], array('SENDED_TO_BITRIX' => 'N'));
}
LocalRedirect($APPLICATION->GetCurPage()."?lang=".LANG,true);
}
elseif (isset($_REQUEST["ACTION"]) && $_REQUEST["ACTION"] == "ADDREPORT")//add report
{
$arFields = array('REPORT' => 'Y');
if (!empty($_POST["TESTER"]))
$arFields["TESTER"] = $_POST["TESTER"];
if (!empty($_POST["COMPANY_NAME"]))
$arFields["COMPANY_NAME"] = $_POST["COMPANY_NAME"];
if (!empty($_POST["EMAIL"]))
$arFields["EMAIL"] = $_POST["EMAIL"];
$report_id = $checklist->AddReport($arFields);
// CCheckListResult::Update($report_id, $arFields);
LocalRedirect($APPLICATION->GetCurPage()."?lang=".LANG,true);
}
elseif (isset($_REQUEST["ACTION"]) && $_REQUEST["ACTION"] == "ADDSENDREPORT")//add report and send to bitrix
{
if (isset($_REQUEST['report_id']))
{
$report_id = intval($_REQUEST['report_id']);
$dbReport = CCheckListResult::GetList(Array(),Array("REPORT"=>"Y", "ID" => $report_id));
if ($arReport = $dbReport->Fetch())
{
$arFields = array();
if (!empty($_POST["COMPANY_NAME"]))
$arFields["COMPANY_NAME"] = $_POST["COMPANY_NAME"];
if (!empty($_POST["CLIENT"]))
$arFields["CLIENT"] = $_POST["CLIENT"];
if (!empty($_POST["CLIENT_POST"]))
$arFields["CLIENT_POST"] = $_POST["CLIENT_POST"];
if (!empty($_POST["CITY"]))
$arFields["CITY"] = $_POST["CITY"];
if (!empty($_POST["WARNED"]))
$arFields["WARNED"] = $_POST["WARNED"];
if (!empty($_POST["CALL_TIME_FROM"]))
$arFields["CALL_TIME_FROM"] = $_POST["CALL_TIME_FROM"];
if (!empty($_POST["CALL_TIME_TO"]))
$arFields["CALL_TIME_TO"] = $_POST["CALL_TIME_TO"];
if (!empty($_POST["PHONE"]))
$arFields["PHONE"] = $_POST["PHONE"];
if (!empty($_POST["PHONE_ADD"]))
$arFields["PHONE_ADD"] = $_POST["PHONE_ADD"];
if (!empty($_POST["EMAIL"]))
$arFields["EMAIL"] = $_POST["EMAIL"];
if (!empty($_POST["COMMENT"]))
$arFields["COMMENT"] = $_POST["COMMENT"];
CCheckListResult::Update($report_id, array('SENDED_TO_BITRIX' => 'Y'));
$res = $checklist->AddReport($arFields);
$arFields['STATE'] = base64_encode(serialize($checklist->current_result));
$arFields['CHECKLIST'] = base64_encode(serialize($checklist->checklist));
$arFields['SITE'] = $_SERVER['HTTP_HOST'] ?? '';
$arFields['SITES'] = $_POST["SITES"] ?? [];
$arFields['SITES'] = array_filter($arFields['SITES'], 'trim');
SendReportToBitrix($arFields);
require($_SERVER["DOCUMENT_ROOT"].BX_ROOT."/modules/main/include/epilog_admin.php");
die();
}
}
}
/////////////////////////////////////////////////////////
//////////////////////PARAMS_PREPARE/////////////////////
/////////////////////////////////////////////////////////
$arSections = $checklist->GetSections();
$arStat = $checklist->GetSectionStat();
$arCanClose = $arStat["CHECKED"];
$arAutoCheck = array();
foreach ($arPoints as $key=>$arFields)
{
$arStates["POINTS"][] = Array(
"TEST_ID" => $key,
"NAME"=> $arFields["NAME"] ?? '',
"STATUS" => $arFields["STATE"]["STATUS"] ?? null,
"IS_REQUIRE" => !empty($arFields["REQUIRE"]) ? $arFields["REQUIRE"] : "N",
"AUTO" => $arFields["AUTO"] ?? null,
"COMMENTS_COUNT" =>
isset($arFields["STATE"]["COMMENTS"]) && is_array($arFields["STATE"]["COMMENTS"])
? count($arFields["STATE"]["COMMENTS"])
: 0
,
);
if (isset($arFields["AUTO"]) && $arFields["AUTO"] == "Y")
{
$arAutoCheck["ID"][]=$key;
$arAutoCheck["NAME"][]=$arFields["NAME"];
}
}
foreach ($arSections as $key=>$arFields)
{
$arStats = $checklist->GetSectionStat($key);
$arStates["SECTIONS"][] = Array(
"ID" => $key,
"CHECKED" => $arStats["CHECKED"],
"TOTAL" => $arStats["TOTAL"],
"PARENT" => $arFields["PARENT"] ?? null,
"CHECK" => $arStats["CHECK"],
"FAILED"=> $arStats["FAILED"]
);
}
$arStates = CUtil::PhpToJsObject($arStates);
/////////////////////////////////////////////////////////
//////////////////////END_PREPARE////////////////////////
/////////////////////////////////////////////////////////
?>
Fatal error: Uncaught Error: Call to undefined function GetMessage() in D:\ktt\ttepla.com\public_html\bitrix\modules\main\admin\checklist.php:293
Stack trace:
#0 {main}
thrown in D:\ktt\ttepla.com\public_html\bitrix\modules\main\admin\checklist.php on line 293