<?
//
//
require_once($_SERVER['DOCUMENT_ROOT']."/jquery/inc/system.php"); 
//
//
if(!$user){
header('location:/login/');
exit();
}
//
//
if($user['notif'] != 0){
DB::$dbs->query('UPDATE `users` SET `notif` = ? WHERE `id` = ? LIMIT 1', array(0,$user['id']));
header('location:?');
exit();    
}
//
//
head([]);
//
//
                $coll = DB::$dbs->querySingle('SELECT COUNT(id) FROM `notification` WHERE `id_user` = "'.$user['id'].'"');
		$num = 10;
		$total = intval(($coll - 1) / $num) + 1;
		$page = isset($_GET['page'])?intval($_GET['page']):1;
		if(empty($page) or $page < 0) $page = 1;
		if($page > $total) $page = $total;
		$start = $page * $num - $num; 

$sql = DB::$dbs->query("SELECT `id`,`text`,`time`,`id_user` FROM `notification` WHERE `id_user` = '".$user['id']."' ORDER BY `time` DESC LIMIT $start, $num")->fetchAll(PDO::FETCH_BOTH);
		?>
<div class="poster -gas">
		    <div class="start">
		        <center>
		            <span class="title-wqi">Уведомления</span>
		        </center>

		<?
				if($coll < 1){
		 ?>
		 <div class="menu-not">
		    Уведомлений еще нет
		   </div>
		 <?   
		}
			foreach ($sql as $sqlls => $im): ?>


<div class="menu-us">
<font color="#999999">
<?=bbcode($im['text']);?>
</font>
<br>
<span style="float: right;"><?=times($im['time']);?></span>
<br></div>


			<?php endforeach;
			?>
			</div>
			<?
			echo page('?',$page,$total); ?>
			</div>
<?
//
//
foot([]);
//
//
?>