{if $pm_stat.mess>=$_cfg.current.max_inbox}
<div class="alert alert-error">
	<button type="button" class="close" data-dismiss="alert">&times;</button>
    <a href="{url}" class="alert-error">{t}Ваша почта переполнена - вы не можете получать новые сообщения.{/t}</a>
</div>
{/if}
<div>
	{if $box_id}
		<div class="alert alert-info">{t var1=$pager.total_items var2=$_cfg.current.max_outbox}В папке "отправленные" занято %d из %d{/t} ({intval(($pager.total_items)/$_cfg.current.max_outbox*100)}%)</div>
	{else}
		<div class="alert alert-info">{t var1=$pm_stat.mess var2=$_cfg.current.max_inbox}В папке "принятые" занято %d из %d{/t} ({intval($pm_stat.mess/$_cfg.current.max_inbox*100)}%)</div>
	{/if}
</div>

<div>
	<h1>{if $smarty.get.action==''}{t}Принятые{/t}{elseif $smarty.get.action=='sended'}{t}Отправленные{/t}{/if}</h1>
	<div id="pmessages">
		{include file="lc_pm/po_tools.tpl"}					
		{if $messages}
			<form method="post" action="#">
				<div><input type="hidden" name="token" value="{$_user->token}" /></div>
				<table class="table table-striped">
					<thead>
						<tr>
							<td>{if $smarty.get.action=='sended'}{t}Кому{/t}{else}{t}От{/t}{/if}</td><td>{t}Тема{/t}</td><td>{t}Дата{/t}</td><td><input id="all" name="all" type="checkbox" onclick="srchGroup.check(this)" /></td>
						</tr>
					</thead>
					<tbody>
						{foreach $messages as $msg}
						<tr{if $msg->unread} class="warning"{/if}>
							<td>
							{if $smarty.get.action=='sended'}
								{$msg->receiver->login|escape}
								</td>
								<td><a href="{url action="sended_msg" var1=$msg->id}">{$msg->subj|escape}</a>
							{else}
								{if $msg->sender_id}{$msg->sender->login|escape}{else}системное{/if}
							</td>
							<td><a href="{url action="msg" var1=$msg->mess_id}">{$msg->subj|escape}</a>
							{/if}
							</td>
							<td>{$msg->putdate}</td>
							<td><input class="del" name="delete[{$msg->mess_id}]"  onclick="srchGroup.check(this)" type="checkbox" /></td>
						</tr>
						{/foreach}
						<tr><td colspan="4"><input class="btn btn-default" type="submit" value="Удалить" /></td></tr>
					</tbody>
				</table>
			</form>
		{else}
			<div id="no_messages">{t}Пока нет ни одного сообщения{/t}</div>
		{/if}
		
		
	</div>
	{if $pager.pages}
		<div class="pagination" id="pagination">
			{foreach $pager.labels as $key=>$label}
				{if !$label} ... {elseif $pager.pages.$key==$pager.current} 
					<b>{$label}</b>
				{else}
					<a href="{url action=$smarty.get.action var1=$pager.pages.$key}">{$label}</a>
				{/if}
			{/foreach}
		</div>
	{/if}

</div>

<script type="text/javascript">
	var srchGroup = new CheckBoxGroup();
	srchGroup.addToGroup("delete*");
	srchGroup.setControlBox("all");
	srchGroup.setMasterBehavior("all");
</script>