<style>
	.left_block {width:100%;}
</style>
<div class="r_block">
	<div class="r_block_head">
		Настройка форума
	</div>
	<div class="r_block_c">
		{if(is_worthy("t"))}
		<center><a data-target="#add_section" data-toggle="modal" class="btn2 btn-cancel btn-lg w-100"> + Добавить раздел</a></center><br>
		<center><a data-target="#add_forum" onclick="load_sections_list();" data-toggle="modal" class="btn2 btn-cancel btn-lg w-100"> + Добавить форум</a></center><br>
		{/if}

		<div id="sections">
			<br>
			<center><img src="{site_host}templates/{template}/img/loader.gif"></center>
		</div>
		<script>load_sections();</script>
	</div>
</div>

<script>$('#add_section').modal('hide');</script>
<div id="add_section" class="modal fade">
	<div class="modal-dialog modal-lg">
		<div class="modal-content">
			<div class="modal-header">
				<h4>Добавить раздел</h4>
				</div>
				<div class="modal-body">
					<form id="section_settings">
						<div class="form-group">
							<label for="section_name">
								<h4>Название</h4>
							</label>
							<input type="text" class="form-control" name="section_name" id="section_name" maxlength="255" autocomplete="off">
						</div>
						<div class="form-group">
							<label>
								<h4>Доступ</h4>
							</label>
							<div class="btn-toolbar" data-toggle="buttons" id="access">
								{groups}
							</div>
						</div>
						<hr>
						<button onclick="add_section();" type="button" class="btn btn-default">Создать</button><br>
					</form>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">Закрыть</button>
				</div>
			</div>
		</div>
	</div>

	<script>$('#add_forum').modal('hide');</script>
	<div id="add_forum" class="modal fade">
		<div class="modal-dialog modal-lg">
			<div class="modal-content">
				<div class="modal-header">
					<h4>Добавить форум</h4>
					</div>
					<div class="modal-body">
						<div class="form-group">
							<label for="section_name">
								<h4>
									Изображение
								</h4>
							</label>
							<div class="row">
								<div class="col-md-3">
									<img id="image" src="../files/forums_imgs/none.jpg" class="w-100">
								</div>
								<div class="col-md-9">
									<div class="input-group">
										<form enctype="multipart/form-data" action="ajax/actions_c.php" method="POST" id="img_form">
											<input type="hidden" id="token" name="token" value="{token}">
											<input type="hidden" id="id" name="id" value="">
											<input type="hidden" id="load_forum_img" name="load_forum_img" value="1">
											<input type="hidden" id="phpaction" name="phpaction" value="1">
											<input class="input-file" type="file" id="img" accept="image/*" name="img"/>
											<input class="btn btn-default" type="submit" value="Загрузить">
											<img class="disp-n" id="img_loader" src="{site_host}templates/{template}/img/loader.gif">
											<div id="img_result"></div>
										</form>
										<script>
											$("#img_form").submit(function (event){
												event.preventDefault();
												var data = new FormData($('#img_form')[0]);
												$.ajax({
													type: "POST",
													url: "../ajax/actions_c.php",
													data: data,
													contentType: false,
													processData: false,
													beforeSend: function() {
														$('#img_loader').show();
													}
												}).done(function (html) {
													$("#img_result").empty();
													$("#img_result").append(html);
													$('#img_loader').hide();
													$('#img_form')[0].reset();
												});
											});
										</script>
									</div>
								</div>
							</div>
						</div>
						<div class="form-group">
							<label for="section_name">
								<h4>
									Название
								</h4>
							</label>
							<input type="text" class="form-control" id="forum_name" maxlength="255" autocomplete="off">
						</div>
						<div class="form-group">
							<label for="section_name">
								<h4>
									Описание
								</h4>
							</label>
							<input type="text" class="form-control" id="forum_description" maxlength="255" autocomplete="off">
						</div>
						<div class="form-group">
							<label for="section_name">
								<h4>
									Раздел
								</h4>
							</label>
							<div id="sections_list"></div>
						</div>
						<div id="add_forum_result" class="mt-10"></div>
						<button onclick="add_forum();" type="button" class="btn btn-default">Создать</button><br>
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal">Закрыть</button>
					</div>
				</div>
			</div>
		</div>