{block name=rtboxrow}
<TR class="single-ticket {if $ticket.state == $smarty.const.RT_RESOLVED}blend{/if} highlight lms-ui-resource{if $ticket.deleted == 1 && $ticket.deltime != 0}-deleted{elseif $ticket.delcount && (ConfigHelper::checkPrivilege('helpdesk_advanced_operations'))}-partly-deleted{/if}"
		id="ticket-{$ticket.id}"
		data-target-url="?m=rtticketview&id={$ticket.id}"
		data-name="{$ticket.id|string_format:"%06d"}"
		data-popup-menu-title="{t a=$ticket.id|string_format:"#%06d"}Ticket $a{/t}"
		data-ticket-id="{$ticket.id}">
	<TD class="text-center">
		{if $ticket.unread}
			<a href="?m=rtticketview&id={$ticket.id}{if $ticket.firstunread}#rtmessage-{$ticket.firstunread}{/if}"
				class="lms-ui-hint-rollover" data-url="?m=rtticketinfo&id={$ticket.id}">
				<i class="lms-ui-icon-{if $ticket.priority == $smarty.const.RT_PRIORITY_CRITICAL && $ticket.state != $smarty.const.RT_RESOLVED}critical{else}unread{/if}"></i>
			</a>
		{elseif $ticket.messageid}
			<a href="?m=rtticketview&id={$ticket.id}&highlight[pattern]={$filter.body.pattern}{if isset($filter.body.regexp)}&highlight[regexp]={$filter.body.regexp}{/if}#rtmessage-{$ticket.messageid}"
				class="lms-ui-hint-rollover" data-url="?m=rtticketinfo&id={$ticket.id}">
				<i class="lms-ui-icon-{if $ticket.priority == $smarty.const.RT_PRIORITY_CRITICAL && $ticket.state != $smarty.const.RT_RESOLVED}priority{else}search{/if}"></i>
			</a>
		{/if}

		{if $ticket.watching}
			{icon name="watch"}
		{/if}
	</TD>
	<TD class="text-center" style="background:transparent; color:{$_RT_STATES[$ticket.state].color};">
		<span class="lms-ui-hint-toggle" data-url="?m=rtticketinfo&id={$ticket.id}">
			{$_RT_STATES[$ticket.state].label}<br>
			{if $ticket.priority != 0}
				<span {if $ticket.state != $smarty.const.RT_RESOLVED}style="color:black"{/if}>{$_RT_PRIORITIES[$ticket.priority]}</span>
			{/if}
			{if !empty($ticket.verifiername) && !empty($ticket.state) && $ticket.state == $smarty.const.RT_VERIFIED}
				({$ticket.verifiername})
			{/if}
		</span>
	</TD>
	<TD class="nobr">
		<span class="lms-ui-hint-rollover" data-url="?m=rtticketinfo&id={$ticket.id}">
			<span class="bold" style="{$_RT_PRIORITY_STYLES[$ticket.priority]}">&nbsp;{$ticket.id|string_format:"%06d"}&nbsp;</span>
			<span>{if (is_array($filter.ids) && count($filter.ids) != 1) || !isset($filter.ids)}{$ticket.name}{/if}</span>
			{if !ConfigHelper::checkConfig('rt.hide_ticket_row_create_time')}
				<br>{$ticket.createtime|date_format:"Y-m-d H:i:s"}
			{/if}
		</span>
	</TD>
	<TD class="text-center">
		<span>{$_SERVICETYPES[$ticket.service]}</span>
		<span><br>{trans($_RT_TYPES[$ticket.type].label)}</span>
	</TD>
	<TD class="valign-middle">
		<span class="bold" {tip text=$ticket.subject}>{$ticket.subject|trunescape:100|default:"&nbsp;"}</span>
		{foreach $ticket.categories as $tc}
			<a href="?m=rtqueueview&persistent-filter=-1&catid={$tc.categoryid}&s=-1&priority=all&unread=-1&o=lastmodified,desc">
				<div class="lms-ui-category-label" style="{$tc.style}">
					{$tc.name}
				</div>
			</a>
		{/foreach}
		{if $ticket.customerid}
			<br>
			<A href="?m=customerinfo&id={$ticket.customerid}">{$ticket.customername|trunescape:60}</A>
		{/if}
		{if !$ticket.customerid && $ticket.requestor_userid}<br>{/if}
		{if $ticket.requestor_userid}
			<a href="?m=userinfo&id={$ticket.requestor_userid}">{$ticket.requestor_name|escape}</a>
		{elseif $ticket.req || $ticket.requestor_mail || $ticket.requestor_phone}
			<br>{$ticket.req|escape}{if $ticket.requestor_phone} <a href="tel:{$ticket.requestor_phone|escape}">{$ticket.requestor_phone|escape}</a>{/if}
			{if $ticket.requestor_mail}<a href="mailto:{$ticket.requestor_mail}"> {$ticket.requestor_mail|escape}</a>{/if}
		{/if}
	</TD>
	<TD class="valign-middle ticket-location">
		{if $ticket.netnodeid}
			{button type="link" href="?m=netnodeinfo&id={$ticket.netnodeid}" icon="netnode" label=$ticket.netnode_name}
		{/if}
		{if $ticket.netdevid && $ticket.netnodeid }<br>{/if}
		{if $ticket.netdevid}
			{button type="link" href="?m=netdevinfo&id={$ticket.netdevid}" icon="netdevice" label=$ticket.netdev_name}
		{/if}
		{if $ticket.netdevid || $ticket.netnodeid }<br>{/if}
		{if $ticket.address_id}
			{$ticket.vacity}, {$ticket.street} {$ticket.house}{if $ticket.flat}/{$ticket.flat}{/if}
		{else}
			{$ticket.address}<br>{$ticket.city}
		{/if}
	</TD>
	<TD class="nobr text-center ticket-deadline">
		{if $ticket.deadline}
			{if $ticket.deadline_diff < 0 && $ticket.state != $smarty.const.RT_RESOLVED}
				<span class="lms-ui-important-box" {tip text="{$ticket.deadline_days} {trans("days")} {$ticket.deadline_hours} {trans("<!rt>hours")}"}>{trans("<!rt>Expired")}</span>
			{else}
				{$ticket.deadline_days} {trans("days")} {$ticket.deadline_hours} {trans("<!rt>hours")}
			{/if}
		{else}
			-
		{/if}
	</TD>
	<TD class="nobr">
		{if $ticket.ownername}{$ticket.ownername|trunescape:25}{else}-{/if}<br>
		{$ticket.lastmodified|date_format:"Y-m-d H:i:s"|default:"-"}
	</TD>
	<TD class="text-center nobr ticket-events">
		{if $ticket.eventcountopened}<A href="?m=eventsearch&ticketid={$ticket.id}&closed=0">{$ticket.eventcountopened}</A> {else}- {/if}/
		{if $ticket.eventcountclosed}<A href="?m=eventsearch&ticketid={$ticket.id}&closed=1">{$ticket.eventcountclosed}</A>{else} -{/if}
	</TD>
	<TD class="lms-ui-buttons nobr text-right">
		{buttons}
			{if $ticket.state != $smarty.const.RT_RESOLVED}
				{if !$ticket.unread}
					{button type='link' icon="read" class="ticket-read" tip="Mark as unread" onclick="location.href = '?m=rtticketedit&id={$ticket.id}&action=unread'"}
				{else}
					{button type='link' icon="unread" class="ticket-unread" tip="Mark as read" onclick="location.href = '?m=rtticketedit&id={$ticket.id}&action=read'"}
				{/if}
			{/if}
			{button type='link' class="lms-ui-button-clipboard" icon="clipboard" clipboard="{$url}/?m=rtticketview&id={$ticket.id}" tip="Copy to clipboard"}
			{if !empty($ticket.imagecount)}
				{button type="link" icon="gallery" class="ticket-image-gallery" tip="Show ticket attached image gallery"}
			{/if}
			{if $ticket.state != $smarty.const.RT_RESOLVED}
				{button type="link" icon="add" class="ticket-add-event" tip="Add event assigned to ticket" href="?m=eventadd&ticketid={$ticket.id}"}
			{/if}
			{if !$ticket.ownerid && Auth::GetCurrentUser() != $ticket.verifierid}
				{button type="link" icon="owner" class="ticket-assign-to-me" tip="Assign to me as owner" href="?m=rtqueueview&ticketid={$ticket.id}&action=assign"}
			{/if}
			{if $ticket.state != $smarty.const.RT_RESOLVED && $ticket.priority != $smarty.const.RT_PRIORITY_NORMAL}
				{button type="link" icon="priority" class="ticket-reset-priority" tip="Reset ticket priority" href="?m=rtticketedit&id={$ticket.id}&action=resetpriority"}
			{/if}
			{if ($ticket.state != $smarty.const.RT_RESOLVED && !$ticket.verifierid && Auth::GetCurrentUser() != $ticket.ownerid)}
				{button type="link" icon="verifier" class="ticket-assign2-to-me" tip="Assign to me as verifier" href="?m=rtqueueview&ticketid={$ticket.id}&action=assign2"}
			{/if}
			{if $ticket.state != $smarty.const.RT_RESOLVED}
				{if $ticket.verifierid && $ticket.verifierid != Auth::GetCurrentUser() &&  $ticket.state != $smarty.const.RT_VERIFIED}
					{button type="link" icon="verifier" tip="Transfer to verifier" href="?m=rtticketedit&id={$ticket.id}&action=verify"}
				{elseif ConfigHelper::checkConfig('rt.block_ticket_close_with_open_events', ConfigHelper::checkConfig('phpui.helpdesk_block_ticket_close_with_open_events'))
					&& !empty($ticket.eventcountopened)}
					{button type="link" icon="close" tip="Resolve" href="?m=rtticketedit&id={$ticket.id}&action=resolve" disabled=true tip="Ticket has open assigned events!"}
				{else}
					{button type="link" icon="close" tip="Resolve" href="?m=rtticketedit&id={$ticket.id}&action=resolve"}
				{/if}
			{/if}

			{button type="link" icon="print" class="ticket-print" tip="Print" href="?m=rtticketprint&id={$ticket.id}"}
			{button type="link" icon="clone" href="?m=rtticketadd&ticketid={$ticket.id}" tip="Clone"}

			{if ($ticket.state != $smarty.const.RT_RESOLVED || ($ticket.state == $smarty.const.RT_RESOLVED && $aet && ($smarty.now - $ticket.resolvetime) < $aet)) || (ConfigHelper::checkPrivilege('superuser'))}
				{button type="link" icon="edit" href="?m=rtticketedit&id={$ticket.id}" tip="Edit"}
			{/if}
			{button type="link" icon="note" href="?m=rtnoteadd&ticketid={$ticket.id}" tip="New Note"}
			{if ($ticket.state != $smarty.const.RT_RESOLVED || ($ticket.state == $smarty.const.RT_RESOLVED && $aet && ($smarty.now - $ticket.resolvetime) < $aet)) || (ConfigHelper::checkPrivilege('superuser'))}
				{button type="link" icon="message" href="?m=rtmessageadd&ticketid={$ticket.id}" tip="New Message"}
			{/if}
			{if $ticket.state != $smarty.const.RT_RESOLVED}
				{button type="link" icon="childticket" href="?m=rtticketadd&parentid={$ticket.id}" tip="Create secondary ticket"}
			{/if}
			{if $ticket.deleted == 1 && $ticket.deltime != 0 && (ConfigHelper::checkPrivilege('helpdesk_advanced_operations'))}
				{button type="link" icon="reload" href="?m=rtrestore&id={$ticket.id}&taction=restore" tip="Restore<!RT>"}
				{button type="link" icon="delete" href="?m=rtremove&id={$ticket.id}&taction=delperm" tip="Delete permanently"}
			{else}
				{button type="link" icon="delete" href="?m=rtticketdel&id={$ticket.id}&taction=delete" tip="Delete"}
			{/if}
		{/buttons}
		<input type="checkbox" class="lms-ui-multi-check" name="ticketid[]" value="{$ticket.id}"
			data-deleted="{if $ticket.deleted == 1 && $ticket.deltime != 0}1{else}0{/if}"
			data-unread="{if $ticket.unread}1{else}0{/if}">
	</TD>
</TR>

{/block}
