Your IP : 216.73.216.86


Current Path : /var/www/homesaver/www/bitrix/modules/ram.calc/admin/
Upload File :
Current File : /var/www/homesaver/www/bitrix/modules/ram.calc/admin/list.php

<?
use Bitrix\Main;
use Bitrix\Main\Loader;
use Bitrix\Main\Entity;
use Bitrix\Main\Type;
use Bitrix\User;
use Bitrix\Highloadblock as HL;

require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_before.php");

$module_id = "ram.calc";

$MODULE_RIGHT = $APPLICATION->GetGroupRight($module_id);

if ($MODULE_RIGHT === "D")
{
	$APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
}

\Bitrix\Main\Loader::includeModule($module_id);

IncludeModuleLangFile(__FILE__);

$sTableID = "tbl_ram_calc";

$context = Bitrix\Main\Application::getInstance()->getContext();
$request = $context->getRequest();
	
$oSort = new CAdminSorting($sTableID, "ID", "asc");
$lAdmin = new CAdminList($sTableID, $oSort);

$arFilterFields = array();

$lAdmin->InitFilter($arFilterFields);

$SERVICES = \Ram\Calc\ServiceTable::getList(array("order" => array($by => $order), "select" => array("ID", "ACTIVE", "NAME", "CONDITIONS", "CALCULATIONS")));

$SERVICES = new CAdminResult($SERVICES, $sTableID);
$SERVICES->NavStart();

$lAdmin->NavText($SERVICES->GetNavPrint(GetMessage("RAM_CALC_NAV")));

$lAdmin->AddHeaders(array(
	array("id" => "ID", "content" => "ID", "sort" => "ID", "default" => true),
	array("id" => "ACTIVE", "content" => GetMessage("RAM_CALC_ACTIVE"), "sort" => "ACTIVE", "default" => true),
	array("id" => "NAME", "content" => GetMessage("RAM_CALC_NAME"), "sort" => "NAME", "default" => true),
	array("id" => "PROPERTIES", "content" => GetMessage("RAM_CALC_PROPERTIES"), "default" => true),
	array("id" => "CONDITIONS", "content" => GetMessage("RAM_CALC_CONDITIONS"), "default" => true),
	array("id" => "CALCULATIONS", "content" => GetMessage("RAM_CALC_CALCULATIONS"), "default" => true),
));

$arVisibleColumns = $lAdmin->GetVisibleHeaderColumns();

while ($SERVICE = $SERVICES->NavNext(true, "f_"))
{
	$row =& $lAdmin->AddRow($f_ID, $SERVICE);
	
	$row->AddField("ID", $f_ID);
	$row->AddViewField("ACTIVE", $f_ACTIVE==="Y"?GetMessage("RAM_CALC_Y"):GetMessage("RAM_CALC_N"));
	$row->AddField("NAME", $f_NAME);
	
	$properties = Array();
	$dbProperties = \Ram\Calc\PropertyTable::getList(Array("filter" => Array("=SERVICE_ID" => $f_ID)));
	while ($arProperty = $dbProperties -> fetch())
	{
		$properties[] = $arProperty["PROPERTIES"]["NAME"];
	}
	
	if (!empty($properties)) $row->AddViewField("PROPERTIES", implode(", ", $properties));
	else $row->AddViewField("PROPERTIES", "");
	
	$conditions = Array();
	if (!empty($f_CONDITIONS))
	{
		foreach ($f_CONDITIONS as $condition)
		{
			$conditions[] = $condition["NAME"];
		}
	}
	
	if (!empty($conditions)) $row->AddViewField("CONDITIONS", implode(", ", $conditions));
	else $row->AddViewField("CONDITIONS", "");
	
	$calculations = Array();
	if (!empty($f_CALCULATIONS))
	{
		foreach ($f_CALCULATIONS as $calculation)
		{
			$calculations[] = $calculation["NAME"];
		}
	}
	
	if (!empty($calculations)) $row->AddViewField("CALCULATIONS", implode(", ", $calculations));
	else $row->AddViewField("CALCULATIONS", "");
	
	if ($MODULE_RIGHT === "W")
	{
		$arActions = array(
			array("ICON" => "edit", "TEXT" => GetMessage("RAM_CALC_EDIT"), "ACTION" => $lAdmin->ActionRedirect("ram.calc_edit.php?ID=".$f_ID."&lang=".LANG), "DEFAULT" => true),
			array("ICON" => "copy", "TEXT" => GetMessage("RAM_CALC_COPY"), "ACTION" => $lAdmin->ActionRedirect("ram.calc_edit.php?ID=".$f_ID."&lang=".LANG."&action=copy")),
			array("SEPARATOR" => true),
			array("ICON" => "delete", "TEXT" => GetMessage("RAM_CALC_DELETE"), "ACTION" => "if(confirm('".GetMessage("RAM_CALC_DELETE_CONFIRM")."')) ".$lAdmin->ActionRedirect("ram.calc_edit.php?ID=".$f_ID."&lang=".LANG."&action=delete"))
		);
	}
	else
	{
		$arActions = array(
			array("ICON" => "view", "TEXT" => GetMessage("RAM_CALC_VIEW"), "ACTION" => $lAdmin->ActionRedirect("ram.calc_edit.php?ID=".$f_ID."&lang=".LANG), "DEFAULT" => true)
		);
	}
	
	$row->AddActions($arActions);
}

if ($MODULE_RIGHT === "W")
{
	$aContext = array(
		array(
			"TEXT" => GetMessage("RAM_CALC_ADD"),
			"LINK" => "ram.calc_edit.php?lang=".LANG,
			"TITLE" => GetMessage("RAM_CALC_ADD_TITLE"),
			"ICON" => "btn_new",
		),
	);
	$lAdmin->AddAdminContextMenu($aContext);
}

$lAdmin->CheckListMode();

$APPLICATION->SetTitle(GetMessage("RAM_CALC_TITLE"));

require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_after.php");

$lAdmin->DisplayList();

require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_admin.php");
?>