<?
$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: /");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=domains'>Домены</a> (".mysql_result(mysql_query("SELECT COUNT(*) FROM `tickets` WHERE `type_of_question` = '3' 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=Reselling'>Реселлинг</a> (".mysql_result(mysql_query("SELECT COUNT(*) FROM `tickets` WHERE `type_of_question` = '6' AND `closed` = '0' AND `user_read` = '1'"), 0).") </div>";
//echo "<div class='post'>» <a href='?act=Dedicated'>Dedicated</a> (".mysql_result(mysql_query("SELECT COUNT(*) FROM `tickets` WHERE `type_of_question` = '7' 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 "<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']=='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 "<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']=='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 "<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']=='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 "<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']=='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 "<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']=='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 "<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']=='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 "<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']=='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 "<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']=='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';
?>