<? if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) die(); ?>

<div class="my_bulletins">
    <?php
    foreach ($arResult as $k => $arItem) { ?>
        <div class="my_bulletins_item">
            <img
                    class="my_bulletins_item_pict"
                    loading="lazy"
                    src="<?= $arItem["PREVIEW_PICTURE"]['src'] ?>"
            />
            <div class="my_bulletins_item_content">

                <? if ($arItem['ACTIVE'] === 'Y') { ?>
                    <a href="<?= $arItem["URL"] ?>" class="my_bulletins_item_content_name">
                        <? echo $arItem["NAME"] ?>
                        <strong>
                            &mdash; <?= $arItem['PRICE'] ?>
                        </strong>
                    </a>
                <?
                } else { ?>
                    <span class="my_bulletins_item_content_name">
                        <? echo $arItem["NAME"] ?>
                        <strong>
                            &mdash; <?= $arItem['PRICE'] ?>
                        </strong>
                    </span>
                <?
                } ?>

                <ul>
                    <li>
                        <strong>Создано:</strong>
                        <span><?= $arItem['DATE_CREATE'] ?></span>
                    </li>
                    <li>
                        <strong>Просмотров:</strong>
                        <span><? echo $arItem['SHOW_COUNTER'] ?? '0' ?></span>
                    </li>
                    <? if ($arItem['END_DAYS_LIMIT'] === 'Y') { ?>
                        <li class="is_end_of_days">
                            <strong>Истек срок активности:</strong>
                            <form action="" method="post" enctype="multipart/form-data">
                                <?= bitrix_sessid_post() ?>
                                <input type="hidden" name="ELEMENT_ID" value="<?=$arItem['ID']?>">
                                <button type="submit">Активировать</button>
                            </form>
                        </li>
                    <? } else { ?>
                        <? if ($arItem['ACTIVE'] === 'Y') { ?>
                            <li>
                                <strong>Активировано:</strong>
                                <span><?= $arItem['ACTIVE_FROM'] ?></span>
                            </li>
                            <li>
                                <strong>Осталось:</strong>
                                <span><?= $arItem['DAYS_TO_DEACTIVATE'] ?> дней</span>
                            </li>
                        <? } else { ?>
                            <li>
                                <strong class="in_checking">На проверке</strong>
                            </li>
                        <? } ?>
                    <? } ?>

                </ul>
                <a class="btn btn_colored" href="/personal/add_bulletin/?EDIT_ELEMENT=<?= $arItem['ID'] ?>">
                    <span>Отредактировать</span>
                </a>
            </div>
        </div>
        <?php
    }
    ?>
</div>