<?php
$page_name = 'Подписки на продавцов';
$page_keys = 'Подписки на продавцов';
$page_desc = 'Подписки на продавцов';
$online_title = 'На странице подписок';
$online_url = '/account/eshop_my';
include('../wu-engine/wu_header.php');
include('../wu-engine/wu-functions/wu_pagination.php');
if(!USER_LOGGED) { header ("Location: /"); exit; }
?>

<?php
$page = intval($_GET['page']);
$num = 20;
if ($page==0) $page=1;
$qu = mysqli_fetch_assoc(mysqli_query($connect_db, "SELECT count(`id`) AS `cnt` FROM ".DB_PREFIX."_es_s 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 ".DB_PREFIX."_es_s.id,uid,log,regdate,av,rat FROM ".DB_PREFIX."_es_s INNER JOIN ".DB_PREFIX."_users ON ".DB_PREFIX."_es_s.tou = ".DB_PREFIX."_users.uid WHERE ".DB_PREFIX."_es_s.usr = '$u_id' ORDER BY ".DB_PREFIX."_es_s.id ASC LIMIT $start, $num");
if ($co > 0) {
while($row = mysqli_fetch_array($qr)) {
?>
<div class="panel panel-default">
<div class="panel-heading">
<h6 class="panel-title"><a href="/user/<?php echo $row['log']; ?>">Продавец <?php echo $row['log']; ?></a></h6>
<div class="panel-icons-group">
<a href="javascript://" id="sub_<?php echo $row['uid']; ?>" onclick="sub('<?php echo $row['uid']; ?>');" style="display: none" class="btn btn-link btn-icon tip" data-placement="bottom" data-original-title="Подписаться. Вы будете получать уведомления при выходе новых товаров." data-loading-text="<i class='icon-spinner7 spin'></i>"><i class="icon-megaphone"></i></a>
<a href="javascript://" id="subb_<?php echo $row['uid']; ?>" onclick="subb('<?php echo $row['uid']; ?>');" class="btn btn-link btn-icon tip" data-placement="bottom" data-original-title="Отписаться" data-loading-text="<i class='icon-spinner7 spin'></i>"><i class="icon-undo"></i></a>
</div>
</div>
<div class="panel-body">
<div class="media">
<div class="lightgallerys pull-left"><a href="<?php if (empty($row['av'])) { $ava_link_thumb_my = '/wu-static/img/avatar_default.png'; $ava_link_full_my = '/wu-static/img/avatar_default.png'; } else { $ava_link_thumb_my = '/wu-uploads/avatars/thumbs/'.$row['av']; $ava_link_full_my = '/wu-uploads/avatars/full/'.$row['av']; } echo $ava_link_thumb_my; ?>" data-sub-html="Аватар пользователя <?php echo $row['log']; ?>"><img class="media-object" src="<?php echo $ava_link_full_my; ?>" border="0" alt="Аватар пользователя <?php echo $row['log']; ?>" title="Аватар пользователя <?php echo $row['log']; ?>" /></a></div>
<div class="media-body cpn">
Дата регистрации: <?php echo date("d.m.y H:i",$row['regdate']); ?><br />
Количество товаров: <?php $sumr = mysqli_fetch_assoc(mysqli_query($connect_db, "SELECT count(`id`) AS `cnt` FROM ".DB_PREFIX."_es WHERE usr='$row[uid]' AND st = '1'")); echo $sumr['cnt']; ?><br />
Рейтинг пользователя: <?php echo $row['rat']; ?>
</div>
</div>
</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>'; } ?>
<link href="/wu-static/js/lightgallery/css/lightgallery.min.css" rel="stylesheet">
<script src="/wu-static/js/lightgallery/js/picturefill.min.js"></script>
<script src="/wu-static/js/lightgallery/js/lightgallery.min.js"></script>
<script src="/wu-static/js/lightgallery/js/lg-fullscreen.js"></script>
<script src="/wu-static/js/lightgallery/js/lg-thumbnail.js"></script>
<script src="/wu-static/js/lightgallery/js/lg-video.js"></script>
<script src="/wu-static/js/lightgallery/js/lg-autoplay.js"></script>
<script src="/wu-static/js/lightgallery/js/lg-zoom.js"></script>
<script src="/wu-static/js/lightgallery/js/lg-pager.js"></script>
<script src="/wu-static/js/lightgallery/js/jquery.mousewheel.min.js"></script>
<script type='text/javascript'>
$(document).ready(function(){
$('.lightgallerys').lightGallery();
});
function sub(id){
$('#sub_'+id).button('loading');
$.ajax({
type: 'POST',
url: '/wu-engine/wu-actions/eshop_sub.php',
data: {'id': id, 'token': token},
cache: false,
success: function(result){
$('#sub_'+id).button('reset');
if (result == '0') {
$.jGrowl('Вы не можете подписаться на себя', { theme: 'growl-error' });
}
if (result == '1') {
$.jGrowl('Вы подписались', { theme: 'growl-success' });
$('#sub_'+id).hide();
$('#subb_'+id).show();
}
if (result == '3') {
jerr();
}
},
error: function(){
$('#sub_'+id).button('reset');
serr();
}
});
};
function subb(id){
$('#subb_'+id).button('loading');
$.ajax({
type: 'POST',
url: '/wu-engine/wu-actions/eshop_sub_back.php',
data: {'id': id, 'token': token},
cache: false,
success: function(result){
$('#subb_'+id).button('reset');
if (result == '0') {
$.jGrowl('Вы не подписаны на этого продавца', { theme: 'growl-error' });
}
if (result == '1') {
$.jGrowl('Вы отписались', { theme: 'growl-success' });
$('#sub_'+id).show();
$('#subb_'+id).hide();
}
if (result == '3') {
jerr();
}
},
error: function(){
$('#subb_'+id).button('reset');
serr();
}
});
};
</script>

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