<?
    $kat_id = (int)abs($_GET['adm_cat']);
    $kat = DB :: $pdo -> queryFetch("SELECT * FROM `gifts_kat` WHERE `id` = ? LIMIT 1;", array($kat_id));
    if (!isset($kat) || $kat['id'] <= 0)
    {
    ?>
        <div class="list _gray _font-s _center">Категория не найдена!</div>
    <?
    } else {
    ?>
    <a href="<?=$thisLink?>&amp;add_gift=<?=$kat['id']?>" class="_action-link"><?=system :: icon("add")?> Добавить подарок</a>
   
 <?php
 echo system :: back("{$thisLink}&edit_cat=".$kat['id']."", "Изменить название"); 
        $total = DB :: $pdo -> querySingle("SELECT COUNT(*) FROM `gifts` WHERE `id_kat` = '".$kat_id."'");
        if ($total == 0)
        {
        ?>
            <div class="list _gray _font-s _center">Подарки не найдены!</div>
        <?
        } else {
            if ($total > 10)
            {
                $p = (($_GET['p']) ? intval($_GET['p']) : 1);
                $pagination = new pagination(10, $total, $p);
                $total_lin = $pagination -> limit;
            } else {
                $total_lin = '';
            }
            $query_gifts = DB :: $pdo -> query("SELECT * FROM `gifts` WHERE `id_kat` = '".$kat_id."' ORDER BY `id` DESC ".$total_lin."");
        echo'<div class="list _l-padd-n">
                <div class="_padd-y _oh">';
                $style = "    max-width: 100%;
    vertical-align: top;
    border: 0;
    width: 96px;
    height: 96px;";
            while($r = $query_gifts -> fetch()) {
            ?>
             <div class="gifts-list-g">
                        <a href="/gifts?admin&amp;adm_gift=<?echo $r['id'];?>">
                            <img style="<?=$style?>" src="http://files.vineti.ru/gifts/<?=$r['id']?>.jpg">
                            <span class="gifts-list-g-coin<?=($r['cena'] == 0 ? " gifts-list-g-coin-free" : '' )?>"><?=($r['cena'] == 0 ? "Бесплатно" : system :: coins($r['cena']))?></span>
                        </a>
                    </div>
                
            
                    
            <?
            }
            echo "</div></div>";
            if ($total > 10) {
                echo $pagination -> printPages("{$thisLink}&amp;adm_cat=".$kat['id']."&");
            }
             
        }
        
       
    }

    echo system :: back("{$thisLink}", "Назад");

    require (CORE."foot.php");
    ?>