<?

session_start();

header( 'Content-type: text/html; charset=windows-1251' );

define( 'ROOT', 'http://' . $_SERVER['HTTP_HOST'] );
define( 'ROOT_DIR', $_SERVER['DOCUMENT_ROOT'] );

if ( $_SERVER['HTTP_X_REQUESTED_WITH'] != 'XMLHttpRequest' ) { exit(); }

if ( !isset( $_SESSION['iduser'] ) ) exit();

if ( $_SERVER['HTTP_REFERER'] != ROOT . '/mtasks' ) exit();

include_once ROOT_DIR . '/engine/config.php';

$id = ( int ) $_POST['id'];

$black_list = mysql_query( "SELECT * FROM tasks_black_list_user WHERE ident = '" . ( int ) $_POST['id'] . "' and from_user = '" . $_SESSION['iduser'] . "'" );
if ( mysql_num_rows( $black_list ) > 0 ) {
    ?>
    <script type="text/javascript">
    function remove_user_black_list(e) {
        $.post('ajax.php?func=remove_user_black_list', {
            id: e
        }, function(data) {
            if (data == 1) {
                $('#bl'+e).remove();
                $('.js_titleRemove').remove();
            }
        });
        return false;
    }
    </script>
    <?
    while ( $black_list_row = mysql_fetch_array( $black_list ) ) {
        $user = mysql_fetch_array( mysql_query( "SELECT id, username, avatar FROM user WHERE id = '" . $black_list_row['to_user'] . "'" ) );
        
        $month = array( 'янв', 'фев', 'мар', 'апр', 'май', 'июн', 'июл', 'авг', 'сен', 'окт', 'ноя', 'дек' );
        $mess_time = ( int ) date( 'd', $black_list_row['date'] ) . ' ' . $month[( int ) date( 'm', $black_list_row['date'] ) - 1] . ' ' . date( 'Y', $black_list_row['date'] )  . ' в ' . date( 'H:i', $black_list_row['date'] );
        ?>
        <div style="margin-left: 15px;" id="bl<?=$black_list_row['id']?>">
            
			<div style=""><img src="<?=ROOT?>/temp/avatar/<?=$user['avatar']?>" class="avatar" width="30" height="30" style="border-radius: 50px; border: 1px solid #333;" /></div>
            
			<div style=" color: #333; margin-left: 50px; margin-top: -38px; font-size: 10px;">
				<?=$user['username']?><div style="color: #999999; font-weight: normal; margin-top: -7px;"><?=$mess_time?></div><div style="margin-top: -28px; margin-left: 35px;"><a href="#" onclick="remove_user_black_list(<?=$black_list_row['id']?>);return false;" class="del_black_list" id="tbdel<?=$black_list_row['id']?>" title="Исключить из списка">Исключить</a></div>
			</div>
            
			
        
		</div><br>
        <?
    }
} else {
    echo '<div style="height:280px; line-height:260px; color:#999999; font-size:12px; text-align:center">Черный список исполнителей пуст.</div>';
}
?>