<!-- $Id$ -->
{include file="header.html"}
{$xajax}

<style>

	.notice-attachments {
		margin-top: 0.5em;
		margin-bottom: 0.5em;
	}

	.notice-attachments ul {
		margin-block-start: 0;
		margin-block-end: 0;
		list-style-type: none;
		padding-inline-start: 0;
	}

	.notice-confirm {
		margin-top: 0.5em;
	}

</style>

{if $warning}
<table width="100%" cellpadding="10">
    <tr>
       <td>
						{box title="Warning to you"}

						<table width="100%">
						 <tr>
				      <td align="center">
									{$warning}
				      </td>
						 </tr>
						 <tr>
						   <td align="right">
										<a href="?m=notices&amp;confirm_old=1">{trans("I confirm reading")} {img src="save.gif" alt=""}</a>
						   </td>
						 </tr>
						</table>
						{/box}
       </td>
    </tr>
</table>
{/if}
<table width="100%" cellpadding="10">
    <tr>
       <td>
						{box title="Notice to you"}
						{if $notices}
						<table style="width: 100%;" cellpadding="3" class="light">
								<tr class="darkest bold">
									<td width="2%">{trans("Date:")}</td>
									<td width="8%">{trans("Status:")}</td>
									<td width="80%">{trans("Subject:")}</td>
									<td width="10%">{trans("Read status:")}</td>
								</tr>
								{cycle values="light,lucid" print=false name=messages}
								{foreach $notices as $items}
								<tr class="dark hand {cycle name=messages}{if $items.status == $smarty.const.MSG_ERROR} alert{elseif $items.status == $smarty.const.MSG_SENT} blend{elseif $items.status == $smarty.const.MSG_DELIVERED} green{/if}" onCLick="ReadNotice('{$items.id}');">
									<td width="2%" class="nobr">{$items.cdate|date_format:"Y-m-d H:i"}</td>
									<td width="8%" >{if $items.type == $smarty.const.MSG_USERPANEL_URGENT}<strong>{trans("Urgent")}</strong>{else}{trans("Casual")}{/if}</td>
									<td width="80%" style="word-break:break-all;">{$items.subject}</td>
									<td width="10%" style="border: 0px solid;">
										{if $items.type == $smarty.const.MSG_USERPANEL_URGENT || $items.type == $smarty.const.MSG_USERPANEL}
											{if $items.status == $smarty.const.MSG_SENT && !$items.lastreaddate}
												{trans("Unread")}
											{elseif $items.status == $smarty.const.MSG_SENT || $items.status == $smarty.const.MSG_DELIVERED}
												{trans("Was read on:")}<br />
												{$items.lastreaddate|date_format:"Y-m-d H:i"}
											{/if}
										{/if}
									</td>
								</tr>
								<tr id="{$items.id}"  style="display:none;">
									<td width="10%" align="center" colspan="4" >
										<h3>{trans("Body")}</h3>
										<div class="notice-body">
											{if $items.mibody}
												{if $items.contenttype == 'text/plain'}
													{nl2br(htmlspecialchars($items.mibody), false)}
												{elseif $items.contenttype == 'text/html'}
													{$items.mibody}
												{else}
													{nl2br($items.mibody, false)}
												{/if}
											{else}
												{if $items.contenttype == 'text/plain'}
													{nl2br(htmlspecialchars($items.body), false)}
												{elseif $items.contenttype == 'text/html'}
													{$items.body}
												{else}
													{nl2br($items.body, false)}
												{/if}
											{/if}
										</div>
										{if !empty($items.attachments)}
											<div class="notice-attachments">
												{icon name="attachment"}
												<strong>{trans("Attachments")}</strong>
												<ul>
													{foreach $items.attachments as $attachmentid => $attachment}
														<li>
															<a href="?m=notices&f=attachmentview&id={$attachmentid}">
																{$attachment.filename|escape}
																{if preg_match('/pdf/', $attachment.contenttype)}
																	{$icon = "pdf"}
																{elseif preg_match('/csv|excel|spreadsheet/', $attachment.contenttype)}
																	{$icon = "xls"}
																{/if}
																{icon name="lms-ui-icon-view" class=$icon}
															</a>
														</li>
													{/foreach}
												</ul>
											</div>
										{/if}
										{if $items.status != $smarty.const.MSG_DELIVERED}
											<div class="notice-confirm">
												<a href="?m=notices&confirm={$items.id}">{trans("I confirm reading")} {img src="save.gif" alt=""}</a>
											</div>
										{/if}
									</td>
								</tr>
								<SCRIPT type="text/javascript">
								<!--
								function ReadNotice(elem){
									xajax_setNoticeRead(elem);
									showOrHide(elem);
								}
								if (getCookie('{$items.id}') == '1')
									document.getElementById('{$items.id}').style.display = '';
								//-->
								</SCRIPT>
							 {/foreach}
						</table>
						{else}
			       <p>&nbsp;</p>
			       <p align="center"><strong>{trans("We don't have any notices to you.")}</strong></p>
			       <p>&nbsp;</p>
						{/if}
						{/box}
					</td>
    </tr>
</table>
{include file="footer.html"}
