<?


if (isset($_GET['ban'])) {
  $system['title'] = 'Товары Заблокированные';
  $WHERE = ' WHERE `active` = "2" ';
  $AND = ' AND `unlink` = "0" ';
  $ORDER = ' `id` ';
  $LINK = '&amp;ban';
} elseif (isset($_GET['prod'])) {
  $system['title'] = 'Последние Продажи';
  $WHERE = ' WHERE `time_pays` > "0" ';
  $AND = '  AND `unlink` != "1" AND `active` = "1" ';
  $ORDER = ' `time_pays` ';
  $LINK = '&amp;prod';
} elseif (isset($_GET['mod'])) {
  $system['title'] = 'На Модерации';
  $WHERE = ' WHERE `active` = "0" ';
  $AND = ' AND `unlink` = "0" ';
  $ORDER = ' `id` ';
  $LINK = '&amp;mod';
} else {
  $system['title'] = 'Новые Товары';
  $WHERE = ' WHERE `active` != "2" ';
  $AND = ' AND `active` != "0" AND `unlink` = "0" ';
  $ORDER = ' `id` ';
  $LINK = '&amp;new';
}

if (isset($_GET['ban']) && $level < 3) {
$system['title'] = 'Доступ Запрещен';
require SYS . 'header.php';
?><div class='nav1'>Ошибка: Данный Раздел Для Администрации</div><?  
require SYS . 'end.php';
exit;
}

if (isset($_GET['mod']) && $level < 3) {
$system['title'] = 'Доступ Запрещен';
require SYS . 'header.php';
?><div class='nav1'>Ошибка: Данный Раздел Для Администрации</div><?  
require SYS . 'end.php';
exit;
}

require SYS . 'header.php';

?>
<div class="nav1">
<ul class="nav nav-pills">
  <li <?= ($LINK == '&amp;new' ? 'class="disabled"' : '')?>><a href="?func=<?= $func?>">Новые Товары</a></li>
  <li <?= ($LINK == '&amp;prod' ? 'class="disabled"' : '')?>><a href="?func=<?= $func?>&amp;prod">Последние Продажи</a></li>
  <?if ($level >= 2) { ?><li <?= ($LINK == '&amp;ban' ? 'class="disabled"' : '')?>><a href="?func=<?= $func?>&amp;ban">Заблокированные</a></li><?}?>
  <?if ($level >= 2) { ?><li <?= ($LINK == '&amp;mod' ? 'class="disabled"' : '')?>><a href="?func=<?= $func?>&amp;mod">На Модерации</a></li><?}?>
</ul>
</div>
<?

$k_post = $sql -> selectCount("SELECT COUNT(*) FROM `shop_goods` $WHERE  $AND  ");

  $k_page = k_page($k_post, $system['page_str']);
  $page = page($k_page);
  $start =  $system['page_str'] * $page -  $system['page_str'];



$array = $sql -> select("SELECT * FROM `shop_goods` $WHERE  $AND  ORDER BY $ORDER DESC LIMIT $start, $system[page_str]");

if (is_array($array)) {
  
  foreach ($array AS $post) {
    $num++;
    if ($post['screens']) {
      $screen = unserialize($post['screens']);
      if (is_file(SRC . 'screen/shop/' . $screen[0] . '.png')) {
        $_src = '/_src/img.php?link=' . base64_encode(SRC.'screen/shop/' . $screen[0] . '.png') . '&amp;width=64&amp;height=64';
      }
    } else {
      $_src = '/_src/img.php?link=' . base64_encode(ROOT.'_images/images/no_image.png') . '&amp;width=64&amp;height=64';
    }
$category = $sql -> fetch('SELECT * FROM `shop_category` WHERE `id` = ' . $post['id_category']);




  ?>



    <div class="nav1">
      <div class="tov-screen">
        <img class="img-polaroid" src="<?= $_src?>" alt="<?= text($post['name'])?>"/></a>
      </div>


        <a href="/goods/<?= $post['id']?>"><?= text($post['name'])?></a> 
		   
	  ( <?if($post['active']==2)echo '<font color="red"><b>Заблокирован</b></font>';?>
       <?if($post['active']==1)echo '<font color="green"><b>Активен</b></font>';?>
       <?if($post['active']==0)echo '<font color="blue"><b>На Модерации</b></font>';?>
	  )<br />
	  <a href="/shop/<?= $category['links']?>"><?= text($category['name'])?></a>
		<br />
		
        <font color="blue">Цена</font> <font color="red"><b><?= $post['wmr']?> ₽</b></font><br />

       <!-- <span style="font-size:10px;"> </span> <a href="/shop/<?= $category['links']?>"><?= text($category['name'])?></a>  -->
	  
     <br />
    </div>
  <?
  }  

  if ($k_page > 1) { 
    str('?func=' . $func . $LINK . '&amp;', $k_page, $page);
  }  
}
