{* Title *}
{$meta_title= "Комментарии" scope=root}

{* Container *}
<div class="container-fluid">

    {* Title *}
    <div class="nk-block-head nk-block-head-sm">
        <div class="nk-block-between">
            <div class="nk-block-head-content">
                <h3 class="nk-block-title page-title">
                    Комментарии
                </h3>
                <div class="nk-block-des text-soft">
                    <p>Управление Комментариями.</p>
                </div>
            </div>
        </div>
    </div>

    {* List *}
    <div class="nk-block js-list-footer-fixed">
        <div class="card card-bordered card-stretch">
            <div class="card-inner-group">

            	{* Filters *}
            	<div class="card-inner">
            		<div class="card-title-group">

            			{* Title *}
            			<div class="card-title">
            				<h5 class="title">
            					{if $keyword && $comments_count}
									По запросу "{$keyword}" {$comments_count|plural:'нашелся':'нашлось':'нашлись'} {$comments_count} {$comments_count|plural:'комментарий':'комментариев':'комментария'}
            					{else if $comments_count}
                                    {$comments_count|plural:'комментарий':'комментариев':'комментария'}
                                {else}
                                    Комментариев нет
            					{/if}
            				</h5>
            			</div>

            			{* Buttons *}
            			<div class="card-tools mr-n1">
            				<ul class="btn-toolbar gx-1">

            					{* Search *}
            					{if $comments || $keyword}
	            					<li>
	            						<a href="#" class="search-toggle toggle-search btn btn-icon" data-target="search">
	            							<em class="icon ti ti-search"></em>
	            						</a>
	            					</li>
	            					{if !empty($keyword)}
		            					<li>
		            						<a href="#" class="btn btn-icon js-list-search-reset" data-toggle="tooltip" data-placement="top" data-original-title="Сбросить поиск">
		            							<em class="icon ti ti-x"></em>
		            						</a>
		            					</li>
	            					{/if}
            					{/if}


            				</ul>
            			</div>

            			{* Search *}
            			{if $comments || $keyword}
            			<div class="card-search search-wrap" data-search="search">
            				<div class="search-content">
            					<a href="#" class="search-back btn btn-icon toggle-search" data-target="search">
            						<em class="icon ti ti-arrow-left"></em>
            					</a>
            					<form class="js-list-search" method="get">
            						<input type="hidden" name="module" value="CommentsAdmin">
            						<input type="text" name="keyword" value="{$keyword|escape}" class="form-control border-transparent form-focus-none" placeholder="Поиск по автору, email или содержанию..">
            						<button class="search-submit btn btn-icon"><em class="icon ti ti-search"></em></button>
            					</form>
            				</div>
            			</div>
                		{/if}

            		</div>
            	</div>

            	{* List *}
                {if $comments}
                <form class="js-list-form" method="post">
                    <div class="card-inner p-0">

                        {* Head list *}
                        <div class="nk-tb-list nk-tb-ulist">
                            <div class="nk-tb-item nk-tb-head">

                                {* Check all *}
                                <div class="nk-tb-col nk-tb-col-check">
                                    <div class="custom-control custom-control-sm custom-checkbox notext">
                                        <input type="checkbox" class="custom-control-input js-check-all" id="checkall">
                                        <label class="custom-control-label" for="checkall"></label>
                                    </div>
                                </div>

                                <div class="nk-tb-col">
                                    <span class="sub-text">Автор</span>
                                </div>
                                <div class="nk-tb-col tb-col-md">
                                    <span class="sub-text">Email</span>
                                </div>
                                <div class="nk-tb-col tb-col-lg">
                                    <span class="sub-text">Дата публикации</span>
                                </div>
                                <div class="nk-tb-col nk-tb-col-tools text-right">Действие</div>
                            </div>
                        </div>

                        {* Main list *}
                        <div class="nk-tb-list nk-tb-ulist is-compact js-list">

                            {* Users *}
                            {foreach $comments as $comment}
                            <div class="nk-tb-item js-list-item comment-item {if !$comment->approved}approved{/if}">

                                {* Checkbox *}
                                <div class="nk-tb-col nk-tb-col-check">
                                    <div class="custom-control custom-control-sm custom-checkbox notext">
                                        <input type="checkbox" name="check[]" value="{$comment->id}" class="custom-control-input" id="uid_{$comment->id}">
                                        <label class="custom-control-label" for="uid_{$comment->id}"></label>
                                    </div>
                                </div>

                                {* Name *}
                                <div class="nk-tb-col">
                                    <a href="{url module=CommentAdmin id=$comment->id return=$smarty.server.REQUEST_URI}">
                                        <span class="tb-lead">
                                            {$comment->name}
                                        </span>
                                    </a>
                                </div>

                                {* Email *}
                                <div class="nk-tb-col tb-col-md">
                                    <span class="text-reset fw-normal">
                                        {if $comment->email}
                                        <a href="mailto:{$comment->email|escape}" data-toggle="tooltip" data-placement="top" data-original-title="Написать email">
                                            {$comment->email|escape}
                                        </a>
                                        {else}
                                        <span class="sub-text">
                                            {'No value'}
                                        </span>
                                        {/if}
                                    </span>
                                </div>

                                {* Date *}
                                <div class="nk-tb-col tb-col-lg">
                                    <span class="sub-text">
                                    	{$comment->date|date}
                                    </span>
                                </div>


                                {* Tools *}
                                <div class="nk-tb-col nk-tb-col-tools">
                                    <ul class="nk-tb-actions gx-1">

                                        {* Active *}
                                        <li>
                                            <button type="button" class="btn btn-trigger btn-icon js-list-mark" data-mark-object="comment" data-mark-type="approved" data-mark-toogle-class="approved" data-toggle="tooltip" data-placement="top" data-original-title="Активность">
                                                <em class="icon ti ti-eye"></em>
                                            </button>
                                        </li>

                                        {* Delete *}
                                        <li>
                                            <button type="button" class="btn btn-trigger btn-icon text-danger js-list-delete" data-toggle="tooltip" data-placement="top" title="Удалить">
                                                <em class="icon ti ti-trash"></em>
                                            </button>
                                        </li>

                                    </ul>
                                </div>
                            </div>
                            {/foreach}

                        </div>
                    </div>

                    {* Pagination *}
                    <div class="card-inner js-list-footer card-inner-footer-fixed">
                        <div class="nk-block-between-md g-3">

                            {* Mass actions *}
                            <div class="g">
                                <div class="center form-inline flex-nowrap gx-3">
                                    <div class="form-wrap w-200px">
                                        <select name="action" class="form-select form-select-sm" data-placeholder="Массовые действия">
                                            <option value="">Массовые действия</option>
                                            <option value="approve">Сделать видимыми</option>
                                            <option value="unapprove">Сделать невидимыми</option>
                                            <option value="delete">Удалить</option>
                                        </select>
                                    </div>
                                    <div class="btn-wrap">
                                        <span class="d-none d-md-block">
                                            <button type="submit" class="btn btn-dim btn-outline-light">Применить</button>
                                        </span>
                                        <span class="d-md-none">
                                            <button type="submit" class="btn btn-dim btn-outline-light btn-icon">
                                                <em class="icon ti ti-arrow-right"></em>
                                            </button>
                                        </span>
                                    </div>
                                </div>
                            </div>

                            {* Pagination *}
                            <div class="g">
                                {include 'pagination.tpl' module='CommentsAdmin'}
                            </div>

                        </div>
                    </div>
                </form>
                {else}
                <div class="card-inner">
                    <div class="nk-tb-item">
                        <p>Комментарии не найдены.</p>
                    </div>
                </div>
                {/if}
            </div>
        </div>
    </div>

</div>
