<?php
$_getDataStickers = false;
if ($_actionGetId >= -1 && ($_getDataStickers = DB::$pdo->queryFetch("SELECT *, (SELECT CONCAT(IF(`info_first_name` = '', 'Имя', `info_first_name`), ' ', `info_last_name`) 
                  FROM `users` WHERE `id` = `stickers_cat`.`id_user` LIMIT 1) as author 
                  FROM `stickers_cat` WHERE `id` = :id LIMIT 1",
        [':id' => $_actionGetId])) === false) {
    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 class="tab_active"
                       href="/stickers/?tab=admin&amp;func=show&amp;id=<?= $_actionGetId ?>">Просмотр</a>
                    <a href="/stickers/?tab=admin&amp;func=edit&amp;id=<?= $_actionGetId ?>">Редактировать</a>
                    <a href="/stickers/?tab=admin&amp;func=delete&amp;id=<?= $_actionGetId ?>">Удалить</a>
                </div>
            </div>
        </div>
    </div>
    <div class="owner_panel" style="background: #fff">
        <div class="stickers_thumb">
            <img src="<?= filesServerStickers . $_getDataStickers['cover'] ?>" height="64" class="th_img">
        </div>
        <div class="stickers_body">
            <h2 class="op_header">
                <div class="stickers_name"><?= $_getDataStickers['title'] ?></div>
            </h2>
            <div class="pp_online">
                <div class="stickers_author"><?= $_getDataStickers['author'] ?></div>
            </div>
        </div>
        <div class="op_block explain"><?= $_getDataStickers['description'] ?></div>
        <?php
        if ($_actionGetId !== -1) {
            $query = (array)DB::$pdo->query("SELECT id, image FROM `stickers` WHERE `id_cat` = ? ORDER BY `id` DESC", [
                $_actionGetId
            ])->fetchAll();
            if (count($query) > 0) {
                ?>
                <div style="padding: 10px">
                    <hr style="border: solid .5px #b9b9b9;"/>
                </div>
                <div class="stickers_tt_wrap">
                    <div class="stickers_block_cont">
                        <div class="stickers_list_cont">
                            <div class="stickers_list_scroll">
                                <div class="stickers__row">
                                    <?php foreach ($query as $item) { ?>
                                        <div class="sticker_item">
                                            <label class="sticker_thumb">
                                                <img src="<?= filesServerStickers . $item['image'] ?>"
                                                     class="th_img">
                                            </label>
                                        </div>
                                    <?php } ?>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            <?php } else {
                ?>
                <div id="show_msg_box" class="service_msg_box" style="border: 0">
                    <div class="service_msg service_msg_null">Магазин стикеров пуст.</div>
                </div><?
            }
        } ?>
    </div>
</div>