<?
$title = 'Мои тикеты';
include_once '../../sys/fnc.php';
include_once '../../sys/head.php';
echo '<div class="razdel">Тикеты</div>';
if (!isset($user)){header("Location: /");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 "<a class='link' href='/tickets/$f[id]'><span class='arrow'><img src='/style/img/icon1.png' alt='icon' /> <font color='red'>".html($f['name'])." [Закрыт]</font></span></a>";
}
if (mysql_num_rows($q)==0)echo "<a class='link' href='#'><span class='arrow'><img src='/style/img/icon1.png' alt='icon' />Нет тикетов</span></a>";
echo "<a class='link' href='/tickets/'><span class='arrow'><img src='/style/img/icon1.png' alt='icon' />Мои тикеты</span></a>";
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 "<a class='link' href='/tickets/$f[id]'><span class='arrow'><img src='/style/img/icon1.png' alt='icon' /> <font color='red'>".html($f['name'])." [Ожидается ваш ответ]</font></span></a>";
}
$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 "<a class='link' href='/tickets/$f[id]'><span class='arrow'><img src='/style/img/icon1.png' alt='icon' /> <font color='green'>".html($f['name'])." [Ожидается ответ оператора]</font></span></a>";
}
if (mysql_num_rows($q)==0)echo '<a class="link" href="#"><span class="arrow"><img src="/style/img/icon1.png" alt="icon" /> Нет тикетов!</span></a>';

echo "<a class='link' href='/tickets/new/'><span class='arrow'><img src='/style/img/icon1.png' alt='icon' />Создать тикет</span></a>";
$adm = mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `time_last` > ". (time()-600) ." AND `position` != 'user'"), 0);
if ($adm != 0)echo "<a class='link' href='#'><span class='arrow'><img src='/style/img/icon1.png' alt='icon' />Сейчас на сайте ".$adm." менеджер(ов).</span></a>";
echo "<a class='link' href='?act=closed'><span class='arrow'><img src='/style/img/icon1.png' alt='icon' />Мои закрытые тикеты</span></a>";
echo '</p></div></div></div>';
include_once '../../sys/foot.php';
?>