<?

$gift_id = (int)abs($_GET['dell_gift']);
$gift = DB :: $pdo -> queryFetch("SELECT * FROM `gifts` WHERE `id` = ? LIMIT 1;", array($gift_id));
if (!isset($gift) || $gift['id'] <= 0)
{
?>
    <div class="list _gray _font-s _center">Подарок не найден!</div>
<?
} else {
    $kat = DB :: $pdo -> queryFetch("SELECT * FROM `gifts_kat` WHERE `id` = ? LIMIT 1;", array($gift['id_kat']));
    if (isset($_POST['cfms']))
    {
        if (is_file("".$_SERVER['DOCUMENT_ROOT']."/template/gifts/".$gift['id'].".jpg"))
        {
            unlink("".$_SERVER['DOCUMENT_ROOT']."/template/gifts/".$gift['id'].".jpg");
        }
        DB :: $pdo -> query("DELETE FROM `user_gifts` WHERE `id_gift` = '".$gift['id']."'");
        DB :: $pdo -> query("DELETE FROM `gifts` WHERE `id` = '".$gift['id']."' LIMIT 1");
        system :: redirect("Подарок успешно удален.", "/gifts?admin&adm_kat=".$kat['id']."");
    }
    ?>
    <div class="list _bg-blue">
    <form method="post" class="post-add" data-type="arbour" action="/gifts?admin&amp;dell_gift=<?echo $gift['id'];?>">
    <b><center>Вы уверены, что хотите удалить этот подарок?</center></b><br />
    <div class="_center" style="margin-top: 3px;">
    <input type="submit" class="main-btn _w-100" name="cfms" value="Да, продолжить" />
    </div>
    </form>
    <div class="p-error"></div>
    </div>
    <?
}
if (isset($gift) && $gift['id'] > 0)
{
    echo system :: touch("/gifts?admin&adm_gift=".$gift['id']."", system :: icon("arr-l")."Назад");
} else {
    echo system :: touch("/gifts?admin", system :: icon("arr-l")."Назад");
}
echo $back;
require (CORE."foot.php");
?>