<?php
require_once('../../wu-engine/wu_init.php');
$page_name = 'Модерация товаров';
$page_keys = 'Модерация товаров';
$page_desc = 'Модерация товаров';
$prevurl_1 = '/'.ADMINPATH.'/';
$prevname_1 = 'Панель управления';
$online_title = 'В панели управления';
$online_url = '/';
include('../../wu-engine/wu_header.php');
include('../../wu-engine/wu-functions/wu_pagination.php');
include('../../wu-engine/wu-functions/wu_functions.php');
if(!USER_LOGGED) { header ("Location: /"); exit; }

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
$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 = '0'"));
$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;
if ($page != 1) $pervpage = '<li><a href="/'.ADMINPATH.'/eshop/moderation?page='. ($page - 1).'">Предыдущая страница</a></li>';
if ($page != $total) $nextpage = '<li><a href="/'.ADMINPATH.'/eshop/moderation?page='. ($page + 1).'">Следующая страница</a></li>';
$qr = mysqli_query($connect_db, "SELECT ".DB_PREFIX."_es.id,usr,inf,ty,siz,fi,cat,co,ti,ts,sec,col,buy,st,reas,dt,v,vo,va,log FROM ".DB_PREFIX."_es INNER JOIN ".DB_PREFIX."_users ON ".DB_PREFIX."_es.usr = ".DB_PREFIX."_users.uid WHERE st = '0' GROUP BY ".DB_PREFIX."_es.id ORDER BY ".DB_PREFIX."_es.id ASC LIMIT $start, $num");
if ($co > 0) {
while($row = mysqli_fetch_array($qr)) {
list($cat, $caturl) = cat($row['cat']);
?>
<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="/<?php echo ADMINPATH; ?>/eshop/view/<?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 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']; ?>" target="_blank" class="btn btn-link btn-icon tip" data-placement="bottom" data-original-title="Все товары пользователя <?php echo $row['log']; ?>"><i class="icon-user2"></i></a>
<div class="dropdown panel-icons-group">
<a href="#" class="dropdown-toggle btn btn-link btn-icon" data-toggle="dropdown">
<i class="icon-cog3"></i> 
<b class="caret"></b>
</a>
<ul class="dropdown-menu icons-right dropdown-menu-right" style="display: none;">
<li><a href="/<?php echo ADMINPATH; ?>/eshop/edit/<?php echo $row['id']; ?>"><i class="icon-pencil4"></i> Редактировать</a></li>
</ul>
</div>
</div>
</div>
<div class="panel-body">
<div class="media">
<div class="media-body cpn marnone">
<div class="col-lg-6 col-md-4 col-sm-4 emarg padnone">
<?php echo nl2br(htmlspecialchars($row['ts'])); ?>
</div>
<div class="col-lg-3 col-md-4 col-sm-4 emarg">
<center>
<?php if ($row['inf'] == 0 && $row['ty'] == 0 && empty($row['siz'])) { ?><a href="javascript://" class="btn btn-danger marbsm">Товар не загружен</a><br /><?php } ?>
<?php if ($row['inf'] == 1) { $unitsa = mysqli_fetch_assoc(mysqli_query($connect_db, "SELECT count(`id`) AS `c` FROM ".DB_PREFIX."_es_u WHERE m = '$row[id]'")); $unitsi = mysqli_fetch_assoc(mysqli_query($connect_db, "SELECT count(`id`) AS `c` FROM ".DB_PREFIX."_es_u WHERE m = '$row[id]' AND st = '0'")); ?><a href="/pages/eshop_units/<?php echo $row['id']; ?>" class="btn btn-<?php if ($unitsi['c'] == 0) { echo 'danger tip'; } else { echo 'default'; } ?> marbsm"<?php if ($unitsi['c'] == 0) { echo ' data-placement="bottom" data-original-title="Нет экземпляров"'; } ?>>Экземпляры</a><br /><?php } ?>
<a href="/<?php echo ADMINPATH; ?>/eshop/images/<?php echo $row['id']; ?>" class="btn btn-<?php $imgs = mysqli_fetch_assoc(mysqli_query($connect_db, "SELECT count(`id`) AS `c` FROM ".DB_PREFIX."_es_i WHERE m = '$row[id]'")); if ($imgs['c'] == 0) { echo 'danger tip'; } else { echo 'default'; } ?> marbsm"<?php if ($imgs['c'] == 0) { echo ' data-placement="bottom" data-original-title="Необходимо добавить скриншоты товара"'; } ?>>Скриншоты<?php if ($imgs['c'] > 0) { echo " ($imgs[c])"; }?></a><br />
</center>
</div>
<div class="col-lg-3 col-md-4 col-sm-4 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>
<?php if ($row['inf'] == 0 && $row['ty'] == 0) { ?>
<li>Имя файла: <font class="flright"><?php if (empty($row['siz'])) { echo 'Не загружен'; } else { echo $row['fi']; } ?></font></li>
<li>Размер файла: <font class="flright"><?php echo number_format($row['siz'],2,'.',',');?> Мб</font></li>
<?php } ?>
<li>Количество: <font class="flright"><?php if ($row['inf'] == 0) { echo 'Бесконечно'; } if ($row['inf'] == 1) { echo '<font class="tip" data-placement="left" data-original-title="Продаётся">'.$unitsi['c'].'</font>/<font class="tip" data-placement="left" data-original-title="Всего">'.$unitsa['c'].'</font>'; } ?></font></li>
<li>Покупок: <font class="flright"><?php echo $row['buy']; ?></font></li>
</ul>
</div>
</div>
</div>
</div>
</div>
<?php }
if ($total>1) { echo '<ul class="pager">'.$pervpage.$nextpage.'</ul>'; } ?>
<?php } 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() {
$('.lightgallerys').lightGallery();
});
</script>

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