<?
$title = 'Список тикетов';
include_once '../../sys/fnc.php';
include_once '../../sys/head.php';
echo '<div class="menu_link"> Управление тикетами </div>
<div class="post0">';
if (!isset($user)){header("Location: /");exit;}

if ($user->position == 'admin' || $user->position == 'mod')
{
echo "<div class='post'>» <a href='?act=other'>Ожидается ответ оператора</a> (".mysql_result(mysql_query("SELECT COUNT(*) FROM `tickets` WHERE `user` = '$user->id' AND `user_read` = '1' AND `closed` = '0'"), 0).") </div>";
echo "<div class='post'>» <a href='?act=closed'>Закрытые</a> (".mysql_result(mysql_query("SELECT COUNT(*) FROM `tickets` WHERE `closed` = '1'"), 0).") </div>";

echo "<div class='post'>» <a href='?act=General_questions'>Общие вопросы</a> (".mysql_result(mysql_query("SELECT COUNT(*) FROM `tickets` WHERE `type_of_question` = '0' AND `closed` = '0' AND `read` = '0'"), 0).") </div>";
echo "<div class='post'>» <a href='?act=Tech_reasons'>Тех. причины</a> (".mysql_result(mysql_query("SELECT COUNT(*) FROM `tickets` WHERE `type_of_question` = '1' AND `read` = '0' AND `closed` = '0'"), 0).") </div>";
echo "<div class='post'>» <a href='?act=Complaints_Violations'>Жалобы/Нарушения</a> (".mysql_result(mysql_query("SELECT COUNT(*) FROM `tickets` WHERE `type_of_question` = '2' AND `closed` = '0' AND `user_read` = '1'"), 0).") </div>";
echo "<div class='post'>» <a href='?act=payment'>Оплата</a> (".mysql_result(mysql_query("SELECT COUNT(*) FROM `tickets` WHERE `type_of_question` = '4' AND `closed` = '0' AND `user_read` = '1'"), 0).") </div>";
echo "<div class='post'>» <a href='?act=hosting'>Хостинг</a> (".mysql_result(mysql_query("SELECT COUNT(*) FROM `tickets` WHERE `type_of_question` = '5' AND `closed` = '0' AND `user_read` = '1'"), 0).") </div>";
echo "<div class='post'>» <a href='?act=Game-Hosting'>Игровой хостинг</a> (".mysql_result(mysql_query("SELECT COUNT(*) FROM `tickets` WHERE `type_of_question` = '8' AND `closed` = '0' AND `user_read` = '1'"), 0).") </div>";
if ($user->position == 'admin')echo "<div class='post'>» <a href='?act=peredany_adm'>Переданы Гл.Администраторам</a> (".mysql_result(mysql_query("SELECT COUNT(*) FROM `tickets` WHERE `adm_transferred` = '1' AND `closed` = '0'"), 0).")</div>";

if (isset($_GET['act']) && $_GET['act']=='closed'){
$q=mysql_query("SELECT `name`, `id` FROM `tickets` WHERE `closed` = '1' 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 (isset($_GET['act']) && $_GET['act']=='General_questions'){
$q=mysql_query("SELECT `name`, `id` FROM `tickets` WHERE `type_of_question` = '0' AND `closed` = '0' AND `read` = '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>";
}
}
if (isset($_GET['act']) && $_GET['act']=='Tech_reasons'){
$q=mysql_query("SELECT `name`, `id` FROM `tickets` WHERE `type_of_question` = '1' AND `read` = '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></div>";
}
}
if (isset($_GET['act']) && $_GET['act']=='Complaints_Violations'){
$q=mysql_query("SELECT `name`, `id` FROM `tickets` WHERE `type_of_question` = '2' AND `closed` = '0' AND `user_read` = '1' 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 (isset($_GET['act']) && $_GET['act']=='peredany_adm' && $user->position == 'admin'){
$q=mysql_query("SELECT `name`, `id` FROM `tickets` WHERE `type_of_question` = '1' AND `closed` = '0' 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]&act=transfer_the_administration_of_Chapter_ok'><font color='red'>".html($f['name'])."</font></a></b> [Передали для Гл.Администраторам]</div>";
}
}
if (isset($_GET['act']) && $_GET['act']=='other'){
$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='red'>".html($f['name'])." [Ожидается ответ оператора]</font></span></a>";
}
}
/* Домены */
if (isset($_GET['act']) && $_GET['act']=='domains'){
$q=mysql_query("SELECT `name`, `id` FROM `tickets` WHERE `type_of_question` = '3' AND `closed` = '0' 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 (isset($_GET['act']) && $_GET['act']=='Game-Hosting'){
$q=mysql_query("SELECT `name`, `id` FROM `tickets` WHERE `type_of_question` = '8' 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>";
}
}
/* Оплата */
if (isset($_GET['act']) && $_GET['act']=='payment'){
$q=mysql_query("SELECT `name`, `id` FROM `tickets` WHERE `type_of_question` = '4' 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>";
}
}
/* Хостинг */
if (isset($_GET['act']) && $_GET['act']=='hosting'){
$q=mysql_query("SELECT `name`, `id` FROM `tickets` WHERE `type_of_question` = '5' 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>";
}
}
/* Реселлинг */
if (isset($_GET['act']) && $_GET['act']=='Reselling'){
$q=mysql_query("SELECT `name`, `id` FROM `tickets` WHERE `type_of_question` = '6' AND `closed` = '0' 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>";
}
}
/* Dedicated */
if (isset($_GET['act']) && $_GET['act']=='Dedicated'){
$q=mysql_query("SELECT `name`, `id` FROM `tickets` WHERE `type_of_question` = '7' AND `closed` = '0' 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> [Dedicated]</div>";
}
}
if (mysql_num_rows($q)==0)echo "<div class='post'>Тикетов нет.</div>";
}else{
echo "<div class='err'>Доступ закрыт</div>";
}
echo '</p></div></div></div>';
include_once '../../sys/foot.php';
?>