<form method="post" enctype="multipart/form-data">

	<!-- Page header -->
    {include file="components/group-buttons.tpl" url="{$adminUrl}/bannergroups"}

    {capture name="breadcrumb"}
		<a href="{$adminUrl}/bannergroups" class="breadcrumb-item">{if isset($title)}{$title}{/if}</a>
		<span class="breadcrumb-item active">{general:add}</span>
    {/capture}

    {capture name="showBy"}{/capture}

    {include file="components/page-header.tpl" buttons=$smarty.capture.buttons breadcrumb=$smarty.capture.breadcrumb showBy=$smarty.capture.showBy}
	<!-- /page header -->

    <div class="content">
        <div class="row"> 
            <div class="col-md-8">
    		    <div class="card border shadow-sm">
			        <div class="card-header d-flex flex-wrap">
				        <h6 class="mb-0">{general:card:general}</h6>
				        <div class="d-inline-flex ms-auto">
					        <a class="text-body" data-card-action="collapse"><i class="ph-caret-down"></i></a>
				        </div>
			        </div>
			        <div class="collapse show">
	                    <div class="card-body">
	                        <div class="row">
					            <div class="col-md-12">
						            <div class="form-group mb-3">
							            <label class="form-label is-visible {if isset($errors.sectionId)}text-danger{/if}">{general:section}</label>
	                                    {html_options options=$sections name="sectionIds[]" id="sectionId" selected=$group.pages|default:'' class="form-control select-search form-control-sm select" multiple="multiple"}
						            </div>
					            </div>
	                            <div class="col-md-12">
	                                <div class="form-group mb-3">
	                                    <label class="form-label is-visible {if isset($errors.name)}text-danger{/if}">Название</label>
	                                    <input type="text" class="form-control" autocomplete="off" name="group[name]" value="{if isset($group.name)}{$group.name}{/if}" />
	                                </div>
	                            </div>

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

            </div>

            <div class="col-md-4">
        		{* STATUS *}
                <div class="card border shadow-sm">
	                <div class="card-header d-flex flex-wrap">
		                <h6 class="mb-0">{general:card:statusAndVisibility}</h6>
		                <div class="d-inline-flex ms-auto">
			                <a class="text-body" data-card-action="collapse"><i class="ph-caret-down"></i></a>
		                </div>
	                </div>
	                <div class="collapse show">
	                    <div class="card-body border-top-0">
                            {* field status *}
                            {include file="components/fields/select.tpl" id="status" title="{general:status}" field="group[status]" array=$statuses selected=$group.status|default:'V' class="form-group mb-3"}
                            {* /field status *}
	                    </div>
	                </div>
    			</div>
            </div>

	        <div class="col-md-12 main main_buttons text-center">
                {if isset($group.groupId)}<input type="hidden" class="form-control" id="id" name="id" value="{$group.groupId|default:''}">{/if}
                {$smarty.capture.buttons nofilter}
	        </div>

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

<script>
    $(document).ready(function () {
        {if isset($messages.saved)} new Noty({ text: 'Группа баннеров сохранена', type: 'success' }).show(); {/if}
        {if isset($errors.name)} new Noty({ text: 'Введите название группы', type: 'error' }).show(); {/if}
        {if isset($errors.not_saved)} new Noty({ text: 'Группа баннеров не сохранена', type: 'error', timeout: 1500 }).show(); {/if}
        {if isset($errors.group_not_found)} new Noty({ text: 'Группа баннеров не найдена', type: 'error' }).show(); {/if}
    });
</script>
