{* Title *}
{$meta_title = "Отзыв`$comment->name`" scope=root}

{* Tabs *}
{$tabs = "tabs" scope=root}

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


    {* Head *}
    <div class="nk-block-head nk-block-head-sm">
        <div class="nk-block-between">

        	{* Title *}
            <div class="nk-block-head-content">
                <h3 class="nk-block-title page-title">
                	{if $comment->id}
					Редактирования отзыва от: {$comment->name}
					{/if}
                </h3>
                <div class="nk-block-des text-soft">
                    <p>Управление отзывами.</p>
                </div>
            </div>

            {* Buttons *}
            <div class="nk-block-head-content">
    			<div class="toggle-wrap nk-block-tools-toggle">

    				{* Mobile toogle btn *}
    				<a href="#" class="btn btn-icon btn-trigger toggle-expand mr-n1" data-target="pageMenu">
    					<em class="icon ti ti-menu"></em>
    				</a>

    				{* Buttons *}
    				<div class="toggle-expand-content" data-content="pageMenu">
    					<ul class="nk-block-tools g-3">

    						{* Return *}
    						{if $smarty.get.return}
    						<li>
    							<a href="{$smarty.get.return}" class="btn btn-white btn-outline-light">
    								<em class="icon ti ti-arrow-back-up"></em>
    								<span>Вернуться</span>
    							</a>
    						</li>
    						{/if}

    						{* Preview *}
    						{if $comment->id}
    						<li>
                                <a href="{$config->root_url}/reviews#comment_{$comment->id}" target="_blank" class="btn btn-light btn-icon btn-outline-light" data-toggle="tooltip" data-placement="top" title="Просмотр">
    								<em class="icon ti ti-external-link"></em>
    							</a>
    						</li>
    						{/if}

    					</ul>
    				</div>
    			</div>
    		</div>

        </div>
    </div>

    {* Success *}
    {if $smarty.get.message_success}
    <div class="pb-2">
    	<div class="alert alert-fill alert-success alert-icon">
    		<em class="icon ti ti-circle-check"></em>
    		Отзыв обновлен.
    	</div>
    </div>
    {/if}

    {* Error *}
    {if $message_error}
    <div class="pb-2">
    	<div class="alert alert-fill alert-danger alert-icon">
    		<em class="icon ti ti-circle-x"></em>
    		{$message_error}.
    	</div>
    </div>
    {/if}

    {* Main block *}
    <div class="nk-block">
    	<div class="card card-bordered">
    		<div class="card-content">

    			{* Form *}
    			<form method="post" enctype="multipart/form-data">

    				{* ID *}
    				<input name="id" type="hidden" value="{$comment->id}"/>

                    {* Tabs items *}
					{assign tabs array(
						"tabCommentGeneral"=>["icon"=>"ti-edit", "name"=>"Основные данные"],
						"tabCommentImages"=>["icon"=>"ti-photo", "name"=>"Изображения"]
					)}

                    {* Tabs component *}
                    {assign var=new value=($comment->id) ? false : true}
                    {include "components/tabs.tpl" tabs=$tabs new=$new}

        			{* Сontent *}
        			<div class="card-inner">
                        <div class="tab-content">

                            {* General *}
                            <div class="tab-pane {if $smarty.cookies.tab == tabCommentGeneral || !$tab || $new == true}active{/if}" id="tabCommentGeneral">
                                <div class="nk-block">
                                    <div class="nk-block-head">
                                        <h5 class="title">Основные данные</h5>
                                    </div>
                                    <div class="gy-3">
                                        <div class="row g-3 align-center">
                                            <div class="col-lg-5">
                                                <div class="form-group">
                                                    <label class="form-label" for="comment_name">Автор</label>
                                                    <span class="form-note">Автор отзыва.</span>
                                                </div>
                                            </div>
                                            <div class="col-lg-7">
                                                <div class="form-group">
                                                    <input type="text" class="form-control" id="comment_name" name="name" value="{$comment->name|escape}">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="row g-3 align-center">
                                            <div class="col-lg-5">
                                                <div class="form-group">
                                                    <label class="form-label" for="comment_email">Email</label>
                                                    <span class="form-note">Email автора.</span>
                                                </div>
                                            </div>
                                            <div class="col-lg-7">
                                                <div class="form-group">
                                                    <input type="text" class="form-control" id="comment_email" name="email" value="{$comment->email|escape}">
                                                </div>
                                            </div>
                                        </div>

										<div class="row g-3 align-center">
                                            <div class="col-lg-5">
                                                <div class="form-group">
                                                    <label class="form-label" for="comment_date">Дата</label>
                                                    <span class="form-note">Дата публикации отзыва.</span>
                                                </div>
                                            </div>
                                            <div class="col-lg-7">
                                                <div class="form-group">
                                                    <input type="text" class="form-control date-picker-lang" id="comment_date" name="date" value="{$comment->date|date:'d.m.Y'}">
                                                </div>
                                            </div>
                                        </div>

                                        <div class="row g-3 align-center">
                                            <div class="col-lg-5">
                                                <div class="form-group">
                                                    <label class="form-label" for="comment_approved">Активность</label>
                                                    <span class="form-note">Включение или отключение.</span>
                                                </div>
                                            </div>
                                            <div class="col-lg-7">
                                                <div class="form-group">
                                                    <div class="custom-control custom-switch">
                                                        <input type="checkbox" name="approved" value="1" class="custom-control-input" id="comment_approved" {if $comment->approved}checked{/if}>
                                                        <label class="custom-control-label" for="comment_approved"></label>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="row g-3">
                                            <div class="col-lg-7 offset-lg-5">
                                                <div class="form-group mt-2">
                                                    <button type="submit" class="btn btn-success">Сохранить</button>
                                                </div>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="nk-divider divider md"></div>
            						<div class="nk-block-head">
            							<h5 class="title">Рейтинг</h5>
            						</div>
            						<div class="gy-3">
            							<div class="row g-3 align-center js-comment-rating">
            								<div class="col-lg-5">
            									<div class="form-group">
            										<label class="form-label" for="comment_rating">Значение рейтинга</label>
            										<span class="form-note">Диапазон от 1 до 5, с возможностью указать до сотых или оставить поле пустым.</span>
            									</div>
            								</div>
            								<div class="col-lg-7">
            									<div id="js-comment-rating-slider" class="mb-2" data-rating="{$comment->rating}"></div>
            									<div class="form-group">
            										<input type="text" class="form-control" id="comment_rating" name="rating" value="{$comment->rating}">
            									</div>
            								</div>
            							</div>
            							<div class="row g-3">
            								<div class="col-lg-7 offset-lg-5">
            									<div class="form-group mt-2">
            										<button type="submit" class="btn btn-success">Сохранить</button>
            									</div>
            								</div>
            							</div>
            						</div>

                                    {* Text *}
                                    <div class="nk-divider divider md"></div>
                                    <div class="nk-block">
                                        <div class="nk-block-head">
                                            <h5 class="title">Текст отзыва</h5>
                                            <p>Полный текст отзыва.</p>
                                        </div>
                                        <div class="form-group">
                                            <textarea name="text" id="text" class="form-control">{$comment->text|escape}</textarea>
                                        </div>
                                        <div class="form-group mt-2">
                                            <button type="submit" class="btn btn-success">Сохранить</button>
                                        </div>
                                    </div>

                                    {* Disadvantages *}
                                    <div class="nk-divider divider md"></div>
                                    <div class="nk-block">
                                        <div class="nk-block-head">
                                            <h5 class="title">Преимущества и недостатки</h5>
                                        </div>
                                        <div class="row">
                                            <div class="col-md-6 col-sm-12">
                                                <div class="form-group">
                                                    <label class="form-label" for="comment_advantages">Преимущества</label>
                                                    <textarea name="advantages" id="comment_advantages" class="form-control">{$comment->advantages|escape}</textarea>
                                                </div>
                                            </div>
                                            <div class="col-md-6 col-sm-12">
                                                <div class="form-group">
                                                    <label class="form-label" for="comment_disadvantages">Недостатки</label>
                                                    <textarea name="disadvantages" id="comment_disadvantages" class="form-control">{$comment->disadvantages|escape}</textarea>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-group mt-2">
                                            <button type="submit" class="btn btn-success">Сохранить</button>
                                        </div>
                                    </div>

                                    {* Full description *}
                                    <div class="nk-divider divider md"></div>
                                    <div class="nk-block">
                                        <div class="nk-block-head">
                                            <h5 class="title">Ответ</h5>
                                            <p>Ответ администрации сайта.</p>
                                        </div>
                                        <div class="form-group">
                                            <textarea name="answer" id="answer" class="form-control">{$comment->answer|escape}</textarea>
                                        </div>
                                        <div class="form-group mt-2">
                                            <button type="submit" class="btn btn-success">Сохранить</button>
                                        </div>
                                    </div>

                                </div>
                            </div>

                            {* Images *}
                            <div class="tab-pane {if $smarty.cookies.tab == tabCommentImages && $new == false}active{/if}" id="tabCommentImages">
                                {* Images component *}
                                {include "components/images.tpl" images=$comment->images dir='comments'}
                            </div>

                        </div>
        			</div>
        		</form>
    		</div>
    	</div>
    </div>
</div>
