<?php
$_getDataStickers = false;
if ($_actionGetId >= -1 && ($_getDataStickers = DB::$pdo->queryFetch("SELECT id FROM `stickers_cat` WHERE `id` = :id LIMIT 1",
        [':id' => $_actionGetId])) === false) {
    system:: redirect("Ошибка...<br/>Этой категории не существует", "/stickers/?tab=admin");
}
if (filter_has_var(INPUT_POST, 'confirm')) {
    $fetchQuery = (array)DB::$pdo->query(
        "SELECT id, image FROM `stickers` WHERE `id_cat` = ?", [
        $_actionGetId
    ])->fetchAll();
    DB::$pdo->query("DELETE FROM `stickers` WHERE `id_cat` = ?", [$_actionGetId]);
    foreach ($fetchQuery as $selected_sticker)
        is_file(filesPathStickers . $selected_sticker['image']) && unlink(filesPathStickers . $selected_sticker['image']);
    DB::$pdo->query("DELETE FROM `stickers_cat` WHERE `id` = ?", [$_actionGetId]);
    DB::$pdo->query("DELETE FROM `stickers_buy` WHERE `id_cat` = ?", [$_actionGetId]);
    system:: redirect("Успешно...<br/>Категория успешно удалена", "/stickers/?tab=admin");
}
$title = 'Админка стикеров';
require(CORE . 'head.php');
?>
<div class="app-block">
    <div class="list" style="border-bottom: 0">
        <div class="sw-block_">
            <div class="sw-cont sw-4">
                <div class="list tab">
                    <a href="/stickers/?tab=admin">Админка</a>
                    <a href="/stickers/?tab=admin&amp;func=show&amp;id=<?= $_actionGetId ?>">Просмотр</a>
                    <a href="/stickers/?tab=admin&amp;func=edit&amp;id=<?= $_actionGetId ?>">Редактировать</a>
                    <a class="tab_active" href="/stickers/?tab=admin&amp;func=delete&amp;id=<?= $_actionGetId ?>">Удалить</a>
                </div>
            </div>
        </div>
    </div>
    <div id="show_msg_box" class="service_msg_box" style="border: 0">
        <div class="service_msg service_msg_null">Вы действительно хотите удалить эту категорию?</div>
    </div>
    <div class="list" style="border-bottom: 0">
        <form method="post" action="/stickers/?tab=admin&amp;func=delete&amp;id=<?= $_actionGetId ?>">
            <div style="width: 45%;" class="_fl-r">
                <a href="/stickers/?tab=admin&amp;func=show&amp;id=<?= $_actionGetId ?>"
                   class="action-btn _dbl _center _oh" style="padding: 6px;">Нет</a>
            </div>
            <div style="width: 45%;">
                <input type="submit" name="confirm" class="main-btn _center _dbl _oh" style="width: 100%" value="Да">
            </div>
        </form>
    </div>
</div>