<?
$title = $l = "Выбор подарка";
$lBack = "/gifts?id=".$ank['id'];
require (CORE."head.php");
echo "<div class=\"app-block\">";
$cat_id = (int)abs($_GET['cat']);
//echo system :: back("/gifts?id=".$ank['id']."", "Назад");
$cat = DB :: $pdo -> queryFetch("SELECT * FROM `gifts_kat` WHERE `id` = ? LIMIT 1;", array($cat_id));
?>
<div class="list _gray _bg-gray"><?=language::text('name', $language,'gifts');?> <span class="_name"><?=profile :: goPage($ank, false)?>.</span></div>
<?php
if (!isset($cat) || $cat['id'] <= 0)
{
?>
<div class="list _gray _font-s _center">Категория не найдена!</div>
<?
} else {
if ($cat['admin'] == 0 || ($cat['admin'] == 1 && admin :: getAccess($user, array('a'=>3,'m'=>1))))
{
?>
<?
$total = DB :: $pdo -> querySingle("SELECT COUNT(*) FROM `gifts` WHERE `id_kat` = '".$cat_id."' AND (`do` = 0 OR `do` > '".time()."')");
if ($total == 0)
{
?>
<div class="list _gray _font-s _center">Подарки не найдены!</div>
<?
} else {
if ($total > 40)
{
$p = (($_GET['p']) ? intval($_GET['p']) : 1);
$pagination = new pagination(40, $total, $p);
$total_lin = $pagination -> limit;
} else {
$total_lin = '';
}
$query_gifts = DB :: $pdo -> query("SELECT * FROM `gifts` WHERE `id_kat` = '".$cat_id."' AND (`do` = 0 OR `do` > '".time()."') ORDER BY `id` DESC ".$total_lin."");
$style = " max-width: 100%;
vertical-align: top;
border: 0;
width: 96px;
height: 96px;";
?>
<div class="list _l-padd-n">
<div class="_padd-y _oh">
<?php
while($r = $query_gifts -> fetch())
{
?>
<div class="gifts-list-g">
<a href="/gifts?id=<?=$ank['id']?>&gift=<?=$r['id']?>">
<img style="<?=$style?>" src="<?=FILES_SERVER?>/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>
<?
}
?>
</div>
</div>
<?php
if ($total > 40)
{
echo $pagination -> printPages("/gifts?id=".$ank['id']."&cat=".$cat['id']."&");
}
}
} else {
?><div class="list _gray _font-s _center">Категория не найдена!</div><?php
}
}
$total_cat = DB :: $pdo -> querySingle("SELECT COUNT(*) FROM `gifts_kat` ".(admin :: getAccess($user, array('a'=>3,'m'=>1)) ? "" : "WHERE `admin` = '0' ")."");
if ($total_cat > 0)
{
?>
<div class="list tab">
<?php
$query_cat = DB :: $pdo -> query("SELECT * FROM `gifts_kat` ".(admin :: getAccess($user, array('a'=>3,'m'=>1)) ? "" : "WHERE `admin` = '0' ")." ORDER BY `id` ASC");
while($r_cat = $query_cat -> fetch())
{
?>
<a class="<?=($cat['id'] == $r_cat['id'] ? "tab_active" : '' )?>" href="/gifts?id=<?=$ank['id']?>&cat=<?=$r_cat['id']?>"><?=system :: check($r_cat['name'])?></a>
<?php
}
?>
</div>
<?php
}
echo "</div>";
require (CORE."foot.php");