View file eshop_viewed.php

File size: 9.38Kb
<?php
$page_name = 'Последние просмотренные';
$page_keys = 'eshop';
$page_desc = 'Последние просмотренные';
$online_title = 'На странице просмотренных товаров';
$online_url = '/';
$page_right = '<div class="header-buttons"><div class="collapse" id="header-buttons"><div class="well"><div class="btn-group"><a href="javascript://" id="unewitem" class="btn btn-primary">Добавить товар</a></div></div></div></div>';
include('wu-engine/wu_header.php');
include ('wu-engine/wu-functions/wu_functions.php');
include('wu-engine/wu-functions/wu_pagination.php');
function cat($id) {
switch ($id) {
case '1': $cat = 'Скрипты порталов'; $caturl = 'port_script'; break;
case '2': $cat = 'Скрипты казино'; $caturl = 'kazino_script'; break;
case '3': $cat = 'Доски объявлений'; $caturl = 'doska_script'; break;
case '4': $cat = 'Интернет магазины'; $caturl = 'shop_script'; break;
case '5': $cat = 'Скрипты буксов,CAP'; $caturl = 'cap_script'; break;
case '6': $cat = 'Скрипты хайпов'; $caturl = 'hayp_script'; break;
case '7': $cat = 'Экономические игры'; $caturl = 'games_script'; break;
case '8': $cat = 'Модули для CMS'; $caturl = 'moduls_cms'; break;
case '9': $cat = 'Остальное'; $caturl = 'other'; break;
default: $cat = 'Ошибка категории'; $caturl = '';
}
return Array($cat, $caturl);
}
?>

<?php
if (isset($_COOKIE['viewed'])) {
$vi = urldecode($_COOKIE['viewed']);
$viewed = explode(',', $vi);
foreach($viewed AS $key)
{
if ($key > 0) {
$sortin .= intval($key).', ';
}
}
$sortin = substr($sortin, 0, -2);
}
$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 WHERE st = '1' AND ".DB_PREFIX."_es.id IN($sortin)"));
$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.id,inf,ty,cat,co,ti,ts,col,dt,v,vo,va,log,rat,img FROM ".DB_PREFIX."_es INNER JOIN ".DB_PREFIX."_es_i ON ".DB_PREFIX."_es.id = ".DB_PREFIX."_es_i.m INNER JOIN ".DB_PREFIX."_users ON ".DB_PREFIX."_es.usr = ".DB_PREFIX."_users.uid WHERE st = '1' AND ".DB_PREFIX."_es.id IN($sortin) GROUP BY ".DB_PREFIX."_es.id ORDER BY FIELD(".DB_PREFIX."_es.id, $sortin) LIMIT $start, $num");
if ($co > 0) {
while($row = mysqli_fetch_array($qr)) {
list($cat, $caturl) = cat($row['cat']);
if (USER_LOGGED) {
$fav = mysqli_num_rows(mysqli_query($connect_db, "SELECT id FROM ".DB_PREFIX."_es_f WHERE usr='$u_id' AND f='$row[id]' LIMIT 1"));
}
?>
<div class="panel panel-<?php if ($row['col'] == 1) { echo 'info'; } else { echo 'default'; } ?>">
<div class="panel-heading">
<h6 class="panel-title<?php if ($row['col'] == 1) { echo ' esinf'; } ?>"><a href="/eshop_show/<?php echo $row['id']; ?>"><?php echo $row['ti']; ?></a></h6>
<div class="panel-icons-group<?php if ($row['col'] == 1) { echo ' esinf'; } ?>">
<a href="javascript://" class="btn btn-link ptext tip" data-placement="bottom" data-original-title="Количество просмотров товара">Просмотров: <?php echo $row["v"]; ?></a>
<a href="javascript://" class="btn btn-link ptext tip" data-placement="bottom" data-original-title="Количество комментариев к товару">Комментариев: <?php $sumc = mysqli_fetch_assoc(mysqli_query($connect_db, "SELECT count(`id`) AS `cnt` FROM ".DB_PREFIX."_es_c WHERE m='$row[id];'")); echo $sumc['cnt']; ?></a>
<a href="javascript://" class="btn btn-link btn-icon tip" data-placement="bottom" data-original-title="Рейтинг товара: <?php if ($row['vo'] > 0) { $rt = $row['va']/$row['vo']; $rt = number_format($rt,2,'.',''); } else { $rt = "Голосов нет"; } echo $rt; ?>"><i class="icon-star<?php if ($rt >=2.5 && $rt < 4) { echo '2'; } if ($rt >=4) { echo '3'; } ?>"></i></a>
<a href="javascript://" class="btn btn-link btn-icon tip" data-placement="bottom" data-original-title="Размещено <?php echo wudate($row['dt']); ?>"><i class="icon-clock3"></i></a>
<a href="/user/<?php echo $row['log']; ?>" class="btn btn-link btn-icon tip" data-placement="bottom" data-original-title="Все товары пользователя <?php echo $row['log']; ?>"><i class="icon-user2"></i></a>
<a href="javascript://" onclick="fav('<?php echo $row['id']; ?>');" id="fav_<?php echo $row['id']; ?>"<?php if ($fav > 0) { echo ' 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-heart2"></i></a>
<a href="javascript://" onclick="favb('<?php echo $row['id']; ?>');" id="favb_<?php echo $row['id']; ?>"<?php if (!USER_LOGGED || $fav == 0) { echo ' 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-heart"></i></a>
</div>
</div>
<div class="panel-body">
<div class="media">
<div class="lightgallerys pull-left marnone">
<a href="/eshop/images/<?php echo $row['img']; ?>" data-sub-html="<?php echo $row['ti']; ?>"><img class="imgeshop" src="/eshop/images/<?php echo $row['img']; ?>" border="0" alt="<?php echo $row['ti']; ?>" title="<?php echo $row['ti']; ?>" /></a>
</div>
<div class="clearh"></div>
<div class="media-body cpn marnone">
<div class="col-lg-9 col-md-6 col-sm-6 emarg">
<?php echo nl2br(htmlspecialchars($row['ts'])); ?>
</div>
<div class="col-lg-3 col-md-6 col-sm-6 well einf">
<ul>
<li>Стоимость: <font class="flright fbold"><?php echo $row['co']; ?> руб.</font></li>
<li>Категория: <font class="flright"><a href="/category/<?php echo $caturl; ?>"><?php echo $cat; ?></a></font></li>
<li>Тип товара: <font class="flright"><?php if ($row['ty'] == 0) { echo 'Файл'; } if ($row['ty'] == 1) { echo 'Текст'; } ?></font></li>
<li>Количество: <font class="flright"><?php if ($row['inf'] == 0) { echo 'Бесконечно'; } if ($row['inf'] == 1) { $units = mysqli_fetch_assoc(mysqli_query($connect_db, "SELECT count(`id`) AS `c` FROM d_es_u WHERE m = '$row[id]' AND st = '0'")); if ($units['c'] > 0) { echo $units['c'].' шт.'; } else { echo 'Всё продано'; } } ?></font></li>
<li>Рейтинг продавца: <font class="flright"><?php echo $row['rat']; ?></font></li>
</ul>
</div>
</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'>
function fav(id){
<?php if(USER_LOGGED){ ?>
$('#fav_'+id).button('loading');
$.ajax({
type: 'POST',
url: '/wu-engine/wu-actions/eshop_fav_add.php',
data: {'id': id, 'token': token},
cache: false,
success: function(result){
$('#fav_'+id).button('reset');
if (result == '0') {
$.jGrowl('Товар уже в избранном', { theme: 'growl-error' });
}
if (result == '1') {
$.jGrowl('Добавлено в избранное', { theme: 'growl-success' });
$('#fav_'+id).hide();
$('#favb_'+id).show();
}
if (result == '3') {
jerr();
}
},
error: function(){
$('#fav_'+id).button('reset');
serr();
}
});
<?php } else { ?>
$.jGrowl('Авторизуйтесь для добавления в избранное', { theme: 'growl-error' });
<?php } ?>
};
function favb(id){
<?php if(USER_LOGGED){ ?>
$('#favb_'+id).button('loading');
$.ajax({
type: 'POST',
url: '/wu-engine/wu-actions/eshop_fav_back.php',
data: {'id': id, 'token': token},
cache: false,
success: function(result){
$('#favb_'+id).button('reset');
if (result == '0') {
$.jGrowl('Товар не в избранном', { theme: 'growl-error' });
}
if (result == '1') {
$.jGrowl('Удалено из избранного', { theme: 'growl-success' });
$('#fav_'+id).show();
$('#favb_'+id).hide();
}
if (result == '3') {
jerr();
}
},
error: function(){
$('#fav_'+id).button('reset');
serr();
}
});
<?php } else { ?>
$.jGrowl('Необходимо авторизоваться', { theme: 'growl-error' });
<?php } ?>
};
$(function() {
$('.lightgallerys').lightGallery();
$('#unewitem').click(function(){
<?php if (USER_LOGGED) { echo "$(location).attr('href','/account/eshop_new');"; } else { echo "$.jGrowl('Авторизуйтесь для добавления товара', { theme: 'growl-error' });"; } ?>
});
});
</script>

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