title = "Archive"
url = "/archive"
layout = "default"
is_hidden = 0

[viewBag]
localeTitle[ru] = "Архив"
localeTitle[en] = "Archive"
localeUrl[ru] = "/archive"
localeUrl[en] = "/archive"
==
<?php
function onStart(){
    if(input("date")){
        $this['todayNews'] = \Indikator\News\Models\Posts::whereDate('published_at', '=', input("date"))
            ->where("locale", App::getLocale())->where("status", 1)
            ->where("category_id", "!=", $this->theme->colleagues_news)
            ->orderBy('created_at', 'desc')->get();
    }else{
        $this['todayNews'] = \Indikator\News\Models\Posts::where("locale", App::getLocale())
            ->where("status", 1)->where("category_id", "!=", $this->theme->colleagues_news)
            ->orderBy('published_at', 'desc')
            ->take(6)->get();
    }
    $this['dateToday'] = input("date");

}
?>
==
<section class="section" id="intro">
    <div class="auto_container">
        <div class="which_page">
            <a href="{{ 'index'|page}}">
                <div class="page_name">
                    {{'Главная'|_}}
                </div>
            </a>
            <div class="slash">\</div>
            <div class="page_name">
                {{'Архив'|_}}
            </div>
        </div>
        <div class="section_wrapper">
            <div class="center">
                <div class="title">
                    {{'Архив'|_}}
                </div>
                <div class="main_news">

                {% for item in todayNews %}
                    <div class="main_news-item">
                        <div class="main_news-date">
                            <span>
                                {{ item.published_at| date("d.m") }}
                            </span>
                            <span>
                                {{ item.published_at| date("Y") }}
                            </span>
                        </div>
                        <div class="main_news-content">
                            <div class="main_news-title">
                                <a href="{{ 'post'|page ({id: item.id, slug: item.slug})}}">
                                    {{item.title}}</a>
                            </div>
                            <div class="main_news-text">

                                {{item.introductory|raw}}
                            </div>
                        </div>
                    </div>
                {% endfor %}

                </div>
            </div>
            <div class="right_side half full">
                <div class="title">
                    {{'Календарь'|_}}
                </div>

                <div class="cal">
                    <div class="calendar">
                        <input type="text" name="cal" id="calendar" />
                    </div>
                    <img src="{{ 'assets/images/left.svg'|theme }}" class="prev_btn" alt="">
                    <img src="{{ 'assets/images/right.svg'|theme }}" class="next_btn" alt="">
                </div>

            </div>
        </div>
    </div>
</section>

<script src="{{ 'assets/js/moment.min.js'|theme }}"></script>
<script src="{{ 'assets/js/lightpick.js'|theme }}"></script>
<script>

    let picker = new Lightpick({
        inline: true,
        selectBackward: true,
        selectForward: false,
        singleDate: true,
        startDate: moment('{{dateToday}}', "Y-M-D"),
        maxDate: moment().endOf("day"),
        lang: 'ru',
        field: document.getElementById('calendar'),
        onSelect:function(date){
            window.location.replace("{{ ''| page}}?date=" + date.format("Y-M-D"));
        }
    });
</script>
