View file account/notifications.php

File size: 2.74Kb
<?php
$page_name = 'Уведомления';
$page_keys = 'уведомления';
$page_desc = 'Ваши уведомления. Новые расположены выше.';
$online_title = 'На странице просмотра уведомлений';
$online_url = '/account/notifications';
$page_right = '<div class="header-buttons"><div class="collapse" id="header-buttons"><div class="well"><div class="btn-group"><a href="javascript://" id="n_clear" class="btn btn-primary" data-loading-text="<i class=\'icon-spinner7 spin\'></i> Очищаем">Очистить уведомления</a></div></div></div></div>';
include('../wu-engine/wu_header.php');
include('../wu-engine/wu_account_menu.php');
include('../wu-engine/wu-functions/wu_pagination.php');
include('../wu-engine/wu-functions/wu_functions.php');
if(!USER_LOGGED) { header ("Location: /"); exit; }
mysqli_query($connect_db, "UPDATE ".DB_PREFIX."_notif SET new = '0' WHERE usr='$u_id' AND new = '1'");
?>

<?php
$num = 20; //Сколько выводить на странице
if (isset($_GET['page'])) { $page = intval($_GET['page']); if ($page == 0) { $page = 1; } } else { $page = 1; }
$qu = mysqli_fetch_assoc(mysqli_query($connect_db, "SELECT count(`id`) AS `cnt` FROM ".DB_PREFIX."_notif WHERE usr = '$u_id'"));
$co = $qu['cnt'];
$total = intval(($co - 1) / $num) + 1;
$page = intval($page);
if(empty($page) or $page < 0) $page = 1;
if($page > $total) $page = $total;
$start = $page * $num - $num;
$qr = mysqli_query($connect_db, "SELECT id,msg,st,dt FROM ".DB_PREFIX."_notif WHERE usr = '$u_id' ORDER BY id DESC LIMIT $start, $num");
if ($co > 0) {
while($row = mysqli_fetch_assoc($qr)) {
$st = $row['st'];
?>
<div class="fulln">
<span class="alert-notice"><?php echo wudatenorm($row['dt']); ?></span>
<div class="alert alert-<?php if($st == 0) { echo 'danger'; } if($st == 1) { echo 'success'; } if($st == 2) { echo 'info'; } if($st == 3) { echo 'success'; } ?> fade in block-inner">
<i class="icon-<?php if($st == 0) { echo 'warning'; } if($st == 1) { echo 'checkmark3'; } if($st == 2) { echo 'info'; } if($st == 3) { echo 'plus'; } ?>"></i> <?php echo $row['msg']; ?>
</div></div>
<?php }
$pageNav = new SimPageNav();
$pages = ceil($co/$num);
echo $pageNav->getLinks($pages, 1, $page, 10, 'page');
} else { echo '<div class="alert alert-info fade in"><i class="icon-info"></i> Уведомлений нет</div>'; }
?>

<script type='text/javascript'>
$(function() {
$('#n_clear').click(function(){
var data = {'с': 'с'};
wu_response('/wu-engine/wu-actions/acc_notif_clear.php', data, 'n_clear', '1', function(wu_result) {
if (wu_result == '1') {
$(location).attr('href','/account/notifications');
}
if (wu_result == 'wu-error') {
wu_err();
}
});
});
});
</script>

<?php include('../wu-engine/wu_footer.php'); ?>