<?
echo "<div class='block'>";
if($ku['status']==1 || $ku['status']==3)
{
$x=mysql_query("SELECT * FROM `kolhoz_tikets` WHERE `id` = '".intval($_GET['id'])."' ORDER BY `id` DESC");
while($tiket=mysql_fetch_assoc($x)){
if(isset($_GET['id']))
{
if(isset($_GET['otvet']))
{
echo '<form action="?tikets&id='.$tiket['id'].'&otvet&save" method="post">';
echo 'Сообщение:<br/>';
echo '<textarea name="otvet"></textarea><br/>';
echo '<input type="submit" value="Отправить"/>';
echo '</form>';
if(isset($_GET['save'])){
$opis=htmlspecialchars(mysql_real_escape_string(trim($_POST['otvet'])));
if($opis==NULL)
{
echo 'Пустое сообщение!';
} else {
$msgmail='Вы писали: "'.$tiket['msg'].'"
--------------------------------------
'.$opis.'';
mysql_query("INSERT INTO `kolhoz_mail` (`id_user`,`id_kont`,`msg`,`time`,`type`,`read`)VALUES('$tiket[id_user]','$ku[id]','$msgmail','$time','to','0')");
mysql_query("UPDATE `kolhoz_tikets` SET `msg_otvet` = '$msgmail' WHERE `id` = '$tiket[id]'");
header("Location:?tikets&id=$tiket[id]");
}
}
include_once 'inc/foot.php';
}
if(isset($_GET['deltikets']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_tikets` WHERE `id` = '".intval($_GET['deltikets'])."'"),0)!=0){
mysql_query("DELETE FROM `kolhoz_tikets` WHERE `id` = '".intval($_GET['deltikets'])."'");
header("Location:?tikets");
}
echo "Автор: ";
echo on_k($tiket['id_user']);
echo " <a href='?user=$tiket[id_user]'>".nc($tiket['id_user'])."</a><br>";
echo "<b>Вопрос:<br></b> ".output_text($tiket['msg'])."<br>".($tiket['msg_otvet']!=NULL?"<b>Ответ:</b><br>".output_text($tiket['msg_otvet'])."<br>By ".nc($tiket['id_who'])."":null)."<br><img width='16' height='16' src='images/tikets/otvet.png' alt='o'> <a href='?tikets&id=$tiket[id]&otvet'>Ответить</a><br><img width='16' height='16' src='images/icons/cross.png' alt='o'> <a href='?tikets&id=$tiket[id]&deltiket=$tiket[id]'>Удалить</a><br><br><img width='16' height='16' src='images/tikets/tikets.png' alt='o'> <a href='?tikets'>Тикеты</a>";
mysql_query("UPDATE `kolhoz_tikets` SET `read` = '1' WHERE `id` = '$tiket[id]'");
if($tiket['id_who']==NULL)
{
mysql_query("UPDATE `kolhoz_tikets` SET `id_who` = '$ku[id]' WHERE `id` = '$tiket[id]'");
}
include_once 'inc/foot.php';
}
}
if(isset($_GET['arhiv']))
{
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_tikets` WHERE `read` = '1'"),0);
if ($k_post==0)
{
echo "Пусто...";
}
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
$xx=mysql_query("SELECT * FROM `kolhoz_tikets` WHERE `read` = '1'  ORDER BY `id` DESC LIMIT $start,$set[p_str]");
while($tikets=mysql_fetch_assoc($xx)){

if(isset($_GET['deletej']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_tikets` WHERE `id` = '".intval($_GET['deletej'])."'"),0)!=0){
mysql_query("DELETE FROM `kolhoz_jalob` WHERE `id` = '".intval($_GET['deletej'])."'");
header("Location:?tikets&arhiv");
}
echo "<div class='block'>";
echo "<img width='16' height='16' src='images/tikets/tikets.png' alt='o'> <a href='?tikets&id=$tikets[id]'>Тикет #$tikets[id]</a>";
echo "<br>";
echo "<img width='16' height='16' src='images/tikets/id.jpg' alt='o'> Автор: ".nc($tikets['id_user'])."<br><img width='16' height='16' src='images/icons/cross.png' alt='o'> <a href='?tikets&arhiv&deletej=$tikets[id]'>Удалить</a></div>";
}
if ($k_page>1)str("?jalob&",$k_page,$page); // Вывод страниц
include_once 'inc/foot.php';
}
echo "<img width='16' height='16' src='images/tikets/arhiv.jpg' alt='o'> <a href='?tikets&arhiv'>Архив</a><br>";
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_tikets` WHERE `read` = '0'"),0);
if ($k_post==0)
{
echo "Пусто...";
}
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
$xx=mysql_query("SELECT * FROM `kolhoz_tikets` WHERE `read` = '0'  ORDER BY `id` DESC LIMIT $start,$set[p_str]");
while($tikets=mysql_fetch_assoc($xx)){

if(isset($_GET['deletej']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_tikets` WHERE `id` = '".intval($_GET['deletej'])."'"),0)!=0){
mysql_query("DELETE FROM `kolhoz_jalob` WHERE `id` = '".intval($_GET['deletej'])."'");
header("Location:?tikets");
}
echo "<img width='16' height='16' src='images/tikets/tikets.png' alt='o'> <a href='?tikets&id=$tikets[id]'>Тикет #$tikets[id]</a>";
echo "<br><img width='16' height='16' src='images/tikets/id.jpg' alt='o'> Автор: ".nc($tikets['id_user'])."<br><img width='16' height='16' src='images/icons/cross.png' alt='o'> <a href='?tikets&deletej=$tikets[id]'>Удалить</a></div>";
}
if ($k_page>1)str("?jalob&",$k_page,$page); // Вывод страниц
} else {
echo "У вас нет прав доступа к этой странице";
}
include_once 'inc/foot.php';
?>