<?
$title = 'Почта';
include_once '../../sys/fnc.php';
include_once '../../sys/head.php';
echo '<div id="page-wrapper"><div class="main-page"><h3 class="title1">Входящие</h3><div class="blank-page widget-shadow scroll" id="style-2 div1"><p>';
if (!isset($user)){header("Location: /");exit;}
// `ank` ASC,
$q=mysql_query("SELECT DISTINCT (`ank`) FROM `mail` WHERE `user` = '$user->id' ORDER BY `time` ASC");
while ($f=mysql_fetch_assoc($q))
{
if($f['ank']!=$ank['id'])
{
$ank = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$f[ank]' LIMIT 1"));
if($ank==NULL)$ank['login']='System';
$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `mail` WHERE `user` = '$user->id' AND `ank` = '$ank[id]' AND `read` = '0'"), 0);
echo "<a href='/scripts/mail/dialog.php?id=$ank[id]'><div class='menu'><b><img width='32' height='32' src='$ank[imguser]' /> ".html($ank['login'])."</a>".($count>0?" <font color='red'>+$count</font>":null)."</b></div><hr>";
}
}
if (mysql_num_rows($q)==0)echo "<div class='err'>Диалогов нет.</div>";
echo "<div class='menu'>»  <a href='".$HOME."/scripts/mail/new.php'>Создать диалог</a></div>";
// echo "<div class='menu'> <a href='?act=closed'>Мои закрытые тикеты</a></div>";
echo '</p></div></div></div>';
include_once '../../sys/foot.php';
?>