{* 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 && $feedbacks_count}
                                    По запросу "{$keyword}" {$feedbacks_count|plural:'нашлась':'нашлись':'нашлось'} {$feedbacks_count|plural:'заявка':'заявок':'заявки'}
            					{elseif $feedbacks_count}
                                    {$feedbacks_count|plural:'заявка':'заявок':'заявки'}
            					{else}
            						Нет заявок.
            					{/if}
            				</h5>
            			</div>

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

            					{* Search *}
            					{if $feedbacks || $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}

            					{* Sort *}
            					<li class="btn-toolbar-sep"></li>
            					<li>
            						<div class="dropdown">
            							<a href="#" class="btn btn-trigger btn-icon dropdown-toggle" data-toggle="dropdown">
            								<em class="icon ti ti-filter"></em>
            							</a>
            							<div class="dropdown-menu dropdown-menu-md dropdown-menu-right">
                                            <ul class="link-check">
            									<li><span>Группировать</span></li>
            									<li {if !$filter}class="active"{/if}>
            										<a href='{url module=FeedbacksAdmin type=null}'>Все группы</a>
            									</li>
            									<li {if $filter == 'contact'}class="active"{/if}>
            										<a href="{url module=FeedbacksAdmin type=contact}">Обратная связь</a>
            									</li>
            									<li {if $filter == 'callback'}class="active"{/if}>
            										<a href="{url module=FeedbacksAdmin type=callback}">Обратный звонок</a>
            									</li>
            									<li {if $filter == 'lowprice'}class="active"{/if}>
            										<a href="{url module=FeedbacksAdmin type=lowprice}">Нашли дешевле</a>
            									</li>
            								</ul>
            								<ul class="link-check">
            									<li><span>Сортировать</span></li>
            									<li {if $sort == 'date'}class="active"{/if}>
            										<a href='{url module=FeedbacksAdmin sort=added}'>По дате</a>
            									</li>
            									<li {if $sort == 'name'}class="active"{/if}>
            										<a href='{url module=FeedbacksAdmin sort=name}'>По имени</a>
            									</li>
            								</ul>
            							</div>
            						</div>
            					</li>

            				</ul>
            			</div>

            			{* Search *}
            			{if $feedbacks || $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="FeedbacksAdmin">
            						<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 $feedbacks}
                <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">Контактные данные</span>
                                </div>
                                <div class="nk-tb-col tb-col-xxl w-440px">
                                    <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 js-list">

                            {* Users *}
                            {foreach $feedbacks as $feedback}
                            <div class="nk-tb-item js-list-item feedback-item {if !$feedback->visible}invisible{/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="{$feedback->id}" class="custom-control-input" id="uid_{$feedback->id}">
                                        <label class="custom-control-label" for="uid_{$feedback->id}"></label>
                                    </div>
                                </div>

                                {* Order *}
                                <div class="nk-tb-col">
                                    <div class="user-card">
                                        <div class="user-info">

                                            {* ID *}
                                            <span class="tb-lead text-primary">
                                                Заявка №{$feedback->id}
                                            </span>

                                            {* Date *}
                                            <span class="sub-text">
                                                Дата: {$feedback->date|date} в {$feedback->date|time}
                                            </span>

                                            {* IP *}
                                            <span class="sub-text ff-italic">IP: {$feedback->ip}</span>

                                            {* Type *}
                                            <span class="badge badge-dim badge-feedback-{$feedback->type}">
                                                {if $feedback->type == "contact"}Обратная связь{/if}
                                                {if $feedback->type == "callback"}Обратный звонок{/if}
                                                {if $feedback->type == "lowprice"}Нашли дешевле{/if}
                                            </span>
                                        </div>
                                    </div>
                                </div>

                                {* Contacts *}
                                <div class="nk-tb-col">
                                	<span class="sub-text">
                                        {if $feedback->name}
                                        <span class="tb-lead">
                                        	Имя:
                                        	<span class="text-reset fw-normal">{$feedback->name|escape}</span>
                                        </span>
                                        {/if}

                                        {if $feedback->email}
                                    	<span class="tb-lead">
                                    		Email:
                                    		<span class="text-reset fw-normal">
                                    			<a href="mailto:{$feedback->email|escape}?subject={$settings->site_name}" data-toggle="tooltip" data-placement="top" data-original-title="Написать email">{$feedback->email|escape}</a>
                                    		</span>
                                    	</span>
                                    	{/if}

                                    	{if $feedback->phone}
                                    	<span class="tb-lead">
                                    		Телефон:
                                    		<span class="text-reset fw-normal">
                                    			<a href="tel:{$feedback->phone|escape}" data-toggle="tooltip" data-placement="top" data-original-title="Позвонить">{$feedback->phone|escape}</a>
                                    		</span>
                                    	</span>
                                    	{/if}
                                    </span>
                                </div>

                                {* Comment *}
                                <div class="nk-tb-col tb-col-xxl w-440px">

                                    {if $feedback->message}
                                    <span class="sub-text mb-2">
                                        <span class="tb-lead">Сообщение:</span>
                                    	<p>{$feedback->message|escape|nl2br}</p>
                                    </span>
                                    {/if}

                                    {if $feedback->url}
                                    <span class="sub-text {if $feedback->type == "lowprice" && $feedback->link}mb-2{/if}">
                                        <span class="tb-lead">Отправлено со страницы:</span>
                                        <span class="text-reset fw-normal">
                                            <a href="{$feedback->url}" target="_blank" data-toggle="tooltip" data-placement="top" data-original-title="Перейти">{$feedback->url}</a>
                                        </span>
                                    </span>
                                    {/if}

                                    {if $feedback->type == "lowprice" && $feedback->link}
                                    <span class="sub-text">
                                        <span class="tb-lead">Ссылка на товар другого магазина:</span>
                                        <span class="text-reset fw-normal">
                                            <a href="{$feedback->link}" target="_blank" data-toggle="tooltip" data-placement="top" data-original-title="Перейти">{$feedback->link}</a>
                                        </span>
                                    </span>
                                    {/if}

                                </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="feedback" data-mark-type="visible" data-mark-toogle-class="invisible" data-toggle="tooltip" data-placement="top" data-original-title="Обработка">
                                                <em class="icon ti ti-circle"></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="disable">Пометить как "Не обработанное"</option>
                                            <option value="enable">Пометить как "Обработанное"</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='FeedbacksAdmin'}
                            </div>

                        </div>
                    </div>
                </form>
                {else}
                <div class="card-inner">
                    <div class="nk-tb-item">
                        <p>Заявки не найдены.</p>
                    </div>
                </div>
                {/if}
            </div>
        </div>
    </div>

</div>
