<?php
if(isset($_GET['id']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `support_tickets` WHERE `id` = '".intval($_GET['id'])."'"),0) == true) {
$ticket = mysql_fetch_assoc(mysql_query("SELECT * FROM `support_tickets` WHERE `id` = $_GET[id] LIMIT 1"));
mysql_query("UPDATE `support_tickets` SET `new_for_admin` = '0' WHERE `id` = $_GET[id] LIMIT 1");
$_SESSION['ticket_id'] = $ticket['id'];
}else{
$_SESSION['err'] = "Запрос не найден!";
header('Location: /support');
exit();
}
if ($_SERVER['PHP_SELF']!='/support_dir_data/close_support_ticket_admin.php') {
$header = 'Запрос #'.$ticket[id].' | Admin-mode';
}Elseif ($_SERVER['PHP_SELF']=='/support_dir_data/close_support_ticket_admin.php') {
Echo "<div class='mini-line'></div><div class='player title'>Запрос #$ticket[id] | Admin-mode</div><div class='mini-line'></div>";
}
include_once '../core/head.php';
if ($user['prava'] >= '5') {
echo '<div class="player menuList">
<li><a href="close_ticket_admin?id='.$ticket[id].'"><img src="/images/icon/arrow.png" />Закрыть запрос</a></li>
</div>';
}
include 'ticket_status.php';
echo '<div class="mini-line"></div>
<div class="block_zero center"><form action="send_ticket_admin_message" method="post"><div>Сообщение:<br/><textarea name="message" class = "text large" rows="4" cols="55"></textarea><br/><div class="center"><span class="btn"><span class="end"><input class="label" type="submit" value="Отправить">Отправить</span></span></div></div></form></div>';
echo '<div class="mini-line"></div>
<div class="center"><b><font color="white">Статус:</font></b> '.$ticket_status.'</div> 
';
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `support_messages` WHERE `user_id` = '$user[id]'"),0);
$k_page = k_page($k_post,$set['p_str']);
$page = page($k_page);
$start = $set['p_str']*$page-$set['p_str'];
$q=mysql_query("SELECT * FROM `support_messages` WHERE `ticket_id` = '$ticket[id]' ORDER BY id DESC LIMIT $start, $set[p_str]");
echo "<div class='mini-line'></div>";

while($post = mysql_fetch_assoc($q)) {
$ank2 = mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = '$post[user_id]' LIMIT 1"));

echo '<div class="player">';
if ($post[admin_msg] == 1){
echo " Администратор ";
if ($user[prava] >= 5) {
echo '(<span style="color:red;">'.$ank2[nick].'</span>)';
}
}elseif ($post[admin_msg] == 0) {
if ($ank2['storona'] == '0') {echo '<img src="/images/icon/0.png" height="11" alt="a"/> '; }
    if ($ank2['storona'] == '1') {echo '<img src="/images/icon/1.png" height="11" alt="d"/> '; }
echo online($ank2[id]);
echo ' <a href="/user/'.$ank2[id].'/">'.$ank2[nick].'</a>';
}
echo '<span class="float-right grey">'.vremja($post[post_time]).'</span>
<br><span style="orange">'.$post[message].'</span><br>
</div><div class="dot-line"></div>';
}
echo '<div class="mini-line"></div>
<div class="player menuList">
<li><a href="/view_support_admin">Назад к запросам</a></li>
</div>';
?>