<?php
namespace JetApplicationModule\Admin\EventViewer\Web;

use Jet\Data_Array;
use Jet\Locale;
use Jet\UI_button;

use Jet\UI;
use Jet\MVC_View;
use Jet\Tr;

/**
 * @var MVC_View $this
 * @var Event     $event
 */

$event = $this->getRaw( 'event' );

$prev_item_url = $this->getRaw('prev_item_url');
$next_item_url = $this->getRaw('next_item_url');
?>



<div class="row toolbar" id="main-toolbar">
	<div class="col-md-12">
		<?=UI::button_goBack()->setUrl( $this->getString( 'list_url' ))?>
		
		<div style="width: 80px;display: inline-block;text-align: right">
		<?php if($prev_item_url): ?>
			<?=UI::button('')->setIcon('chevron-left')->setUrl($prev_item_url)->setClass(UI_button::CLASS_INFO)?>
		<?php endif; ?>
		</div>
		

		<?php if($next_item_url): ?>
			<?=UI::button('')->setIcon('chevron-right')->setUrl($next_item_url)->setClass(UI_button::CLASS_INFO)?>
		<?php endif; ?>
	</div>
</div>

<div class="row">
	<div class="col-md-12" id="main-col">
		<table class="table">
			<tr>
				<td nowrap="" style="width: 200px;"><?=Tr::_('ID:')?></td>
				<td><?=$event->getId()?></td>
			</tr>
			<tr>
				<td nowrap=""><?=Tr::_('Date and time:')?></td>
				<td><?=Locale::dateAndTime($event->getDateTime())?></td>
			</tr>
			<tr>
				<td nowrap=""><?=Tr::_('Remote IP:')?></td>
				<td><?=$event->getRemoteIP()?></td>
			</tr>
			<tr>
				<td nowrap=""><?=Tr::_('User ID:')?></td>
				<td><?=$event->getUserId()?></td>
			</tr>
			<tr>
				<td nowrap=""><?=Tr::_('User name:')?></td>
				<td><?=$event->getUserUsername()?></td>
			</tr>
			<tr>
				<td nowrap=""></td>
				<td><?=$event->getEventClassReadable()?></td>
			</tr>
			<tr>
				<td nowrap=""><?=Tr::_('Event:')?></td>
				<td><?=$event->getEventMessage()?> - (<?=$event->getEvent()?>)</td>
			</tr>
			<tr>
				<td nowrap=""><?=Tr::_('Context object ID:')?></td>
				<td><?=$event->getContextObjectId()?></td>
			</tr>
			<?php if($event->getContextObjectName()): ?>
			<tr>
				<td nowrap=""><?=Tr::_('Context object name:')?></td>
				<td><?=$event->getContextObjectName()?></td>
			</tr>
			<?php endif; ?>

			<?php if(($context_data=json_decode($event->getContextObjectData(), true))) :?>
			<tr>
				<td nowrap=""><?=Tr::_('Context object:')?></td>
				<td><pre><?php echo (is_array($context_data)) ? (new Data_Array($context_data))->export() : $context_data;?></pre></td>
			</tr>
			<?php endif; ?>
		</table>

	</div>
</div>

