<?
$system['title'] = 'Последние Продажи';
require SYS . 'header.php';
$k_post = $sql -> selectCount("SELECT COUNT(*) FROM `shop_goods` WHERE `time_pays` > '0' AND `unlink` != '1' AND `active` = '1' ");

  $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 `time_pays` > '0' AND `unlink` != '1' AND `active` = '1' ORDER BY `time_pays` 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=60&amp;height=60';
      }
    } else {
      $_src = '/_src/img.php?link=' . base64_encode(ROOT.'_images/images/no_image.png') . '&amp;width=60&amp;height=60';
    }
$category = $sql -> fetch('SELECT * FROM `shop_category` WHERE `id` = ' . $post['id_category']);




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

      <div class="tov_fon">
        <a href="/goods/<?= $post['id']?>"><?= text($post['name'])?></a> <br />
       <font color="blue">Цена</font> <font color="red"><b><?= $post['wmr']?> wmr</b></font><br />
       <a href="/shop/<?= $category['links']?>"><?= text($category['name'])?></a>
      </div>
    </div>
  <?
  }  

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