{extends file="layout.html"}
{block name=title}LMS: {$layout.pagetitle|striphtml}{/block}
{block name=module_content}
<script src="js/templates/event/eventlist.js"></script>
<!--// $Id$ //-->
<h1>{$layout.pagetitle}</h1>
<table class="lmsbox">
	<colgroup>
		<col style="width: 1%;">
		<col style="width: 1%;">
		<col style="width: 98%;">
	</colgroup>
	<thead>
		<tr>
			<td>
				{icon name="timetable"}
			</td>
			<td>
				<strong>{trans("Title")}</strong>
			</td>
			<td>
				<strong>{$event.title|escape}</strong>
			</td>
		</tr>
	</thead>
	<tbody>
			<tr>
				<td>
					{icon name="uptime"}
				</td>
				<td class="nobr">
					<strong>{trans("Begin time")}</strong>
				</td>
				<td>
					{sprintf("%s (%s) %s", $event.date|date_format:"Y-m-d", trans($event.date|date_format:"l"), ($event.date + $event.begintime)|date_format:"H:i")}
				</td>
			</tr>
			{if $event.begintime != $event.endtime || $event.enddate > $event.date}
			<tr>
				<td>
					{icon name="uptime"}
				</td>
				<td class="nobr">
					<strong>{trans("End time")}</strong>
				</td>
				<TD>
					{if $event.enddate}
						{sprintf("%s (%s) %s", $event.enddate|date_format:"Y-m-d", trans($event.enddate|date_format:"l"), ($event.enddate + $event.endtime)|date_format:"H:i")}
					{else}
						{sprintf("%s (%s) %s", $event.date|date_format:"Y-m-d", trans($event.date|date_format:"l"), ($event.date + $event.endtime)|date_format:"H:i")}
					{/if}
				</TD>
			</tr>
			{/if}
			{if $event.description}
				<tr>
					<td>
						{icon name="description"}
					</td>
					<td class="nobr">
						<strong>{trans("Description")}</strong>
					</td>
					<td>
						<table style="width: 95%;">
							<tr>
								<td class="fall superlight">
									{$event.description|replace:"\n":"<BR>"}
								</td>
							</tr>
						</table>
					</td>
				</tr>
			{/if}
			<tr>
				<td>
					{icon name="type"}
				</td>
				<td>
					<strong>{trans("Type")}</strong>
				</td>
				<td class="nobr">
					{trans($_EVENTTYPES[$event.type].label)}
				</td>
			</tr>
			<tr>
				<td>
					{icon name="status"}
				</td>
				<td>
					<strong>{trans("Availability")}</strong>
				</td>
				<td class="nobr">
					{if $event.private}
						{trans("private")}
					{else}
						{trans("public")}
					{/if}
				</td>
			</tr>
			<tr>
				<td>
					{icon name="user"}
				</td>
				<td class="nobr">
					<strong>{trans("Created by")}</strong>
				</td>
				<td class="nobr">
					<a href="?m=userinfo&id={$event.userid}">
						{$event.username|escape}
					</a>
				</td>
			</tr>
			{if $event.creationdate != 0}
				<tr>
					<td>
						{icon name="uptime"}
					</td>
					<td class="nobr">
						<strong>{trans("Creation time")}</strong>
					</td>
					<td>
						{$event.creationdate|date_format:"Y-m-d (H:i:s)"}
					</td>
				</tr>
			{/if}
			{if $event.moduserid != 0}
				<tr>
					<td>
						{icon name="user"}
					</td>
					<td class="nobr">
						<strong>{trans("Last modified by")}</strong>
					</td>
					<td class="nobr">
						<a href="?m=userinfo&id={$event.moduserid}">
							{$event.modusername|escape}
						</a>
					</td>
				</tr>
			{/if}
			{if $event.moddate != 0}
				<tr>
					<td>
						{icon name="uptime"}
					</td>
					<td class="nobr">
						<strong>{trans("Last modification")}</strong>
					</td>
					<td>
						{$event.moddate|date_format:"Y-m-d (H:i:s)"}
					</td>
				</tr>
			{/if}
			{if $event.closeduserid != 0}
				<tr>
					<td>
						{icon name="user"}
					</td>
					<td class="nobr">
						<strong>{trans("Closed by")}</strong>
					</td>
					<td class="nobr">
						<a href="?m=userinfo&id={$event.closeduserid}">
							{$event.closedusername|escape}
						</a>
					</td>
				</tr>
			{/if}
			{if $event.closeddate != 0}
				<tr>
					<td>
						{icon name="uptime"}
					</td>
					<td class="nobr">
						<strong>{trans("Closed time")}</strong>
					</td>
					<td>
						{$event.closeddate|date_format:"Y-m-d (H:i:s)"}
					</td>
				</tr>
			{/if}
			{if !empty($event.divisionid)}
				<tr>
					<td class="valign-top">
						{icon name="division"}
					</td>
					<td>
						<strong>{trans("Division")}</strong>
					</td>
					<td>
						<a href="?m=divisionedit&id={$event.divisionid}">
							{$event.div_label|escape} (#{$event.divisionid})
						</a>
					</td>
				</tr>
			{/if}
			{if $event.customerid}
				<tr>
					<td class="valign-top">
						{icon name="customer"}
					</td>
					<td class="valign-top">
						<strong>{trans("Customer")}</strong>
					</td>
					<td class="nobr">
						{button type="link" icon="customer" href="?m=customerinfo&id={$event.customerid}" label="{$event.customername} (#{$event.customerid})"}
						{if !empty($event.phones)}
							<br>
							{foreach $event.phones as $phone}
								{icon name="phone"}
								<a href="tel:{$phone.contact}">{$phone.fullname}</a>
								{if !$phone@last}
									<br>
								{/if}
							{/foreach}
						{/if}
					</td>
				</tr>
			{/if}
		<tr>
			<td>
				{icon name="location"}
			</td>
			<td>
				<strong>{trans("Location")}</strong>
			</td>
			<td class="nobr">
				{if $event.netnode_name}
					{button type='link' icon='netnode' href="?m=netnodeinfo&id={$event.netnodeid}" label=$event.netnode_name}
					{if !empty($event.netnode_location)}
						<br>{icon name='location' label=$event.netnode_location}
					{/if}
				{else}
					{if $event.customername}
						{button icon='customer' href="?m=customerinfo&amp;id={$event.customerid}" label="{$event.customername|trunescape:30}"}<br>
						{if !empty($event.address_id)}
							{icon name='location' label=$event.location}
						{elseif !empty($event.nodeid)}
							{button type='link' icon='node' href="?m=nodeinfo&id={$event.nodeid}" label=$event.nodelocation}
						{else}
							{icon name='location' label=$event.customerlocation}
						{/if}
					{/if}
				{/if}
			</td>
		</tr>
		{if !empty($event.netnodeid)}
			<tr>
				<td>
					{icon name='netnode'}
				</td>
				<td>
					<strong>{trans('Network node')}</strong>
				</td>
				<td class="nobr">
					{button type='link' href="?m=netnodeinfo&id={$event.netnodeid}"
						label="{$event.netnode_name|escape} ({$event.netnode_location|escape})"}
					</a>
				</td>
			</tr>
		{/if}
		{if !empty($event.netdevid)}
			<tr>
				<td class='nobr'>
					{icon name='netdev'}
				</td>
				<td class="nobr bold">{trans('Network device')}
				<td>
					{button
						type='link'
						href="?m=netdevinfo&id={$event.netdevid}"
						label=$event.netdevice_name}
				</td>
			</tr>
		{/if}
		{if !empty($event.nodeid)}
			<tr>
				<td>
					{icon name="node"}
				</td>
				<td>
					<strong>{trans("Node")}</strong>
				</td>
				<td class="nobr">
					<a href="?m=nodeinfo&id={$event.nodeid}">
						{$event.node_name|escape}: {$event.node_location|escape}
					</a>
				</td>
			</tr>
		{/if}
		{if $event.note}
			<tr>
				<td>
					{icon name="note"}
				</td>
				<td class="nobr">
					<strong>{trans("Note")}</strong>
				</td>
				<td>
					<table style="width: 95%;">
						<tr>
							<td class="fall superlight">
								{$event.note|escape|replace:"\n":"<BR>"}
							</td>
						</tr>
					</table>
				</td>
			</tr>
		{/if}
		{if $event.userlist}
			<tr>
				<td>
					{icon name="user"}
				</td>
				<td>
					<strong>{trans("Users")}</strong>
				</td>
				<td class="nobr">
					{foreach $event.userlist as $userid => $user}
						<a href="?m=userinfo&id={$userid}">{$user.rname|escape}</a>
						{if !$user@last}
							<br>
						{/if}
					{/foreach}
				</td>
			</tr>
		{/if}
		{if !empty($event.ticketid)}
			<tr>
				<td>
					{icon name="helpdesk"}
				</td>
				<td>
					<strong>{trans("Helpdesk assignment")}</strong>
				</td>
				<td>
					{hint icon="info" mode="toggle" url="?m=rtticketinfo&id={$event.ticketid}"}
					#{$event.ticketid}
					<a href="?m=rtticketview&id={$event.ticketid}">
						{$event.ticket.name}
					</a>
				</td>
			</tr>
		{/if}
		<tr>
			<td class="lms-ui-box-buttons" colspan="3">
				{if !$event.closed}
					{button type="link-button" href="?m=eventedit&id={$event.id}&action=close" icon="close" label="Close"}
				{else}
					{button type="link-button" href="?m=eventedit&id={$event.id}&action=open" icon="open" label="Open"}
				{/if}
				{if !$event.closed
					|| ($event.closed && ConfigHelper::getConfig('timetable.allow_modify_closed_events_newer_than', ConfigHelper::getConfig('phpui.allow_modify_closed_events_newer_than', 604800))
						&& ($smarty.now - $event.closeddate < ConfigHelper::getConfig('timetable.allow_modify_closed_events_newer_than', ConfigHelper::getConfig('phpui.allow_modify_closed_events_newer_than', 604800))))
					|| ConfigHelper::checkPrivilege('superuser')}
					{button type="link-button" href="?m=eventedit&id={$event.id}" icon="edit" label="Edit"}
					{button type="link-button" href="?m=eventdel&id={$event.id}" icon="delete" label="Delete" class="delete-event"}
				{/if}
			</td>
		</tr>
	</tbody>
</table>
{/block}
