<?
$title = 'Мои тикеты';
include_once '../../sys/fnc.php';
include_once '../../sys/head.php';
echo '<div id="page-wrapper"><div class="main-page"><div class="blank-page widget-shadow scroll" id="style-2 div1"><p>';
if (!isset($user)){header("Location: /scripts/ticketsindex.php");exit;}

// Мои закрытые тикеты
if (isset($_GET['act']) && $_GET['act']=='closed'){
$q=mysql_query("SELECT `name`, `id` FROM `tickets` WHERE `closed` = '1' AND `user` = '".$user->id."' ORDER BY `time` DESC");
while ($f=mysql_fetch_assoc($q)){
echo "<div class='post'><b><img src='".$HOME."/style/img/link2.png'> <a href='/scripts/tickets/ticket.php?id=$f[id]'><font color='red'>".html($f['name'])."</font></a></b> [Закрыт]</div>";
}
if (mysql_num_rows($q)==0)echo "<div class='err'>Тикетов нет.</div>";
echo "<div class='menu'> <a href='".$HOME."/scripts/tickets/'>Мои тикеты</a></div>";
include_once '../../sys/foot.php';
}
/* -- */
if (isset($_GET['create']))echo "<div class='menu'>Тикет успешно создан!</div>";
$q=mysql_query("SELECT `name`, `id` FROM `tickets` WHERE `user` = '$user->id' AND `user_read` = '0' AND `closed` = '0' ORDER BY `time` DESC");
while ($f=mysql_fetch_assoc($q)){
echo "<div class='menu'><b>.: <a href='/scripts/tickets/ticket.php?id=$f[id]'><font color='red'>".html($f['name'])."</font></a></b> [Ожидается Ваш ответ]</div>";
}
$q=mysql_query("SELECT `name`, `id` FROM `tickets` WHERE `user` = '$user->id' AND `user_read` = '1' AND `closed` = '0' ORDER BY `time` DESC");
while ($f=mysql_fetch_assoc($q)){
echo "<div class='menu'><b>.: <a href='/scripts/tickets/ticket.php?id=$f[id]'><font color='green'>".html($f['name'])."</font></a></b> [Ожидается ответ оператора]</div>";
}
if (mysql_num_rows($q)==0)echo "<div class='err'>Тикетов нет.</div>";
echo "<div class='menu'>»  <a href='".$HOME."/scripts/tickets/new.php'>Создать тикет</a></div>";
$adm = mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `time_last` > ". (time()-600) ." AND `position` != 'user'"), 0);
if ($adm != 0)echo "<div class='menu'> Сейчас на сайте ".$adm." менеджер(ов).</div>";
echo "<div class='menu'> <a href='?act=closed'>Мои закрытые тикеты</a></div>";
echo '</p></div></div></div>';
include_once '../../sys/foot.php';
?>