<!-- $Id$ -->
{include file="header.html"}
{$allow_reopen_tickets_newer_than = intval(ConfigHelper::getConfig('userpanel.allow_reopen_tickets_newer_than', 0))}
{$allow_message_add_to_closed_tickets = intval(ConfigHelper::getConfig('userpanel.allow_message_add_to_closed_tickets', 1))}

<table style="width: 100%;" cellpadding="10">
    <tr>
	<td>
{box title=$title}

<table class="width: 100%;" cellpadding="3">
	{foreach from=$ticket.messages item=message}
        <tr class="darkest">
		<td width="1%" align="right">
			<strong>{$message.createtime|date_format:"Y-m-d<br/>H:i"}</strong>
		</td>
		<td width="1%" align="right">
			<strong>{trans("From:")}<br/>{trans("Subject:")}</strong>
		</td>
		<td width="96%" class="nobr">
			    {if $message.customerid}
				    {$message.customername}
			    {elseif $message.userid}
				    {$message.username}
			    {elseif $message.mailfrom}
				    {$message.mailfrom|escape}
			    {else}
				    {$ticket.requestor|escape}
				    {if $ticket.requestoremail}
					    &lt;{$ticket.requestoremail|escape}&gt;
				    {/if}
			    {/if}
			    <br />
			    {$message.subject|escape}
		</td>
		<td width="1%" nowrap>
			{if $message.attachments}
			{foreach $message.attachments as $attachment}
			{if !$attachment@first}<br>{/if}<a href="?m=helpdesk&f=attachment&msgid={$message.id}&file={$attachment.filename}">{$attachment.filename} {img src="attach.gif" alt=""}</a>
			{/foreach}
			{/if}
		</td>
		<td width="1%">
			{if ($ticket.state != $smarty.const.RT_RESOLVED || $allow_message_add_to_closed_tickets)
				&& (!$allow_reopen_tickets_newer_than || $smarty.now - $allow_reopen_tickets_newer_than <= $ticket.lastmod)}
				<a href="?m=helpdesk&op=message&id={$ticket.id}&msgid={$message.id}">{trans("Reply")}</a>
			{else}
				&nbsp;
			{/if}
		</td>
	</tr>
	<tr>
		<td colspan="5">
			{if $message.contenttype == 'text/plain'}
				{$message.body|trim|escape|regex_replace:"/\r?\n/":'<br/>'}
			{else}
				{$message.body}
			{/if}
		</td>
	</tr>
	{/foreach}
</table>
{/box}
	</td>
    </tr>
</table>
{include file="footer.html"}
