<?

include_once '../../sys/inc/start.php';
include_once '../../sys/inc/compress.php';
include_once '../../sys/inc/sess.php';
include_once '../../sys/inc/home.php';
include_once '../../sys/inc/settings.php';
include_once '../../sys/inc/db_connect.php';
include_once '../../sys/inc/ipua.php';
include_once '../../sys/inc/fnc.php';
include_once '../../sys/inc/user.php';

$sid = $user['id'];
$ank = get_user($sid);
if (!isset($user)){header("Location: /index.php?".SID);exit;}

# Заголовок
$set['title']= 'Заявки в друзья';
include_once '../../sys/inc/thead.php';
title();
aut();

# Панель
echo '<table class="block_panel" cellspacing="0" cellpadding="0">';
echo '<td><a class="panel" href="index.php?id='.$ank[id].'">Все</a><td>';
echo '<td><a class="panel" href="online.php?id='.$ank[id].'">Онлайн</a></td>';
if ($ank['id'] == $user['id']){
echo '<td><a class="panel_ok" href="request.php">Заявки</a>';
}
echo '</table>';

$k_post=mysql_result(mysql_query("SELECT COUNT(id) FROM `frends_new` WHERE `to` = '$ank[id]' LIMIT 1"), 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 `frends_new` WHERE `to` = '$user[id]' ORDER BY time DESC");

if ($k_post==0){
echo '<div class="block2"><center>Нет заявок в друзья</center></div>';
}

# Вывод заявок в друзья
while ($frend = mysql_fetch_assoc($q)){
$frend=get_user($frend['user']);

echo '<table class="block2">';
echo '<td class="block_avatar">';
echo ''.avatar($frend['id']).'</a> <span class="avatar_icon">'.online($frend['id']).'</span>';
echo '</td>';
echo '<td class="block_info">';
echo '<span class="nick">'.user::nick($frend['id']).'</span>';
echo '<div style="margin-top: 5px;" class="block_msg">';
echo '<a style="background: #03a9f4; color: #ffffff; padding: 5px 20px; border-radius: 4px; margin: 0 5px 0 0;" href="/user/friends/create.php?ok='.$frend[id].'">Принять</a>';
echo '<a style="background: #e5ebf1; color: #55677d; padding: 5px 20px; border-radius: 4px; margin: 0 5px 0 0;" href="create.php?no='.$frend[id].'">Удалить</a>';
echo '</div>';
echo '</td>';
echo '</table>';

}

# Навигация
if ($k_page>1)str("?id=".$ank['id']."&",$k_page,$page);

include_once '../../sys/inc/tfoot.php';

?>