<!DOCTYPE html>
<html>

<%- include("../includes/head") %>

<body class="hold-transition skin-red sidebar-mini">

	<div class="wrapper">

		<!-- The header is the topbar -->
		<%- include("../includes/header") %>

		<!-- The sidebar includes the menu -->
		<%- include("../includes/sidebar") %>

		<!-- Content Wrapper. Contains page content -->
		<div class="content-wrapper">

			<!-- Content Header (Page header) -->
			<section class="content-header">
				<h1> <%= translate("common:CONFIGURATION") %> <small> Dashboard v1.1 </small> </h1>
				<ol class="breadcrumb">
					<li><a href="/"><i class="fa fa-home"></i> <%= translate("dashboard:SELECTOR") %></a></li>
					<li class="active"><%= guild.name %></li>
				</ol>
			</section>

			<section class="content">
				<!-- Info boxes -->
				<div class="row">
					<div class="col-md-2 col-sm-6 col-xs-12">
						<div class="info-box">
							<span class="info-box-icon bg-red"><i class="fa fa-area-chart"></i></span>
							<div class="info-box-content">
								<span class="info-box-text"><%= translate("common:LEVEL") %></span>
								<span class="info-box-number"><%= memberData.level %></span>
							</div>
							<!-- /.info-box-content -->
						</div>
						<!-- /.info-box -->
					</div>
					<!-- /.col -->
					<div class="col-md-2 col-sm-6 col-xs-12">
						<div class="info-box">
							<span class="info-box-icon bg-red"><i class="fa fa-line-chart"></i></span>
							<div class="info-box-content">
								<span class="info-box-text"><%= translate("economy/profile:EXP").substr(2) %></span>
								<span class="info-box-number"><%= memberData.exp %> / <%= 5 * (memberData.level * memberData.level) + 80 * memberData.level + 100 %></span>
							</div>
							<!-- /.info-box-content -->
						</div>
						<!-- /.info-box -->
					</div>
					<!-- /.col -->
					<div class="col-md-2 col-sm-6 col-xs-12">
						<div class="info-box">
							<span class="info-box-icon bg-green"><i class="fa fa-money"></i></span>
							<div class="info-box-content">
								<span class="info-box-text"><%= translate("economy/profile:CASH").substr(2) %> / <%= translate("economy/profile:BANK").substr(2) %></span>
								<span class="info-box-number"><%= memberData.money %> / <%= memberData.bankSold %></span>
							</div>
							<!-- /.info-box-content -->
						</div>
						<!-- /.info-box -->
					</div>
					<!-- /.col -->
				</div>
				<!-- /.row -->
				<div class="row">
					<div class="col-md-6">
						<div class="box box-widget widget-user">
							<div class="widget-user-header bg-red">
								<h3 class="widget-user-username"><%= guild.name %> (<%= guild.id %>)</h3>
							</div>
							<div class="widget-user-image">
								<img class="img-circle" src="<%= guild.iconURL %>" alt="Server icon">
							</div>
							<div class="box-footer">
								<div class="row">
									<div class="col-sm-12 border-right">
										<div class="description-block">
											<h5 class="description-header"><%= guild.memberCount %></h5>
											<span class="description-text"><%= translate("common:MEMBERS") %></span>
										</div>
										<!-- /.description-block -->
									</div>
									<!-- /.col -->
								</div>
								<!-- /.row -->
							</div>
							<!-- /.box-footer -->
						</div>
						<!-- BASIC CONFIGURATION -->
						<div class="box box-warning">
							<div class="box-header with-border">
								<h3 class="box-title"><%= translate("dashboard:BASIC_CONF") %></h3>
							</div>
							<form role="form" action="/manage/<%= guild.id %>/" method="POST">
								<!-- /.box-header -->
								<div class="box-body">
									<!-- text input -->
									<div class="form-group">
										<label><%= translate("common:PREFIX") %></label>
										<input type="text" name="prefix" class="form-control"
											placeholder="<%= guild.prefix %>">
									</div>
									<!-- select -->
									<div class="form-group">
										<label><%= translate("common:LANGUAGE") %></label>
										<select class="form-control" name="language">
											<% bot.languages.forEach((language) => { %>
												<% if (guild.language === language.name) { %>
													<option selected="selected"><%= language.nativeName %></option>
												<% } else { %>
													<option><%= language.nativeName %></options>
												<% } %>
											<% }) %>
										</select>
									</div>
								</div>
								<!-- /.box-body -->
								<div class="box-footer">
									<button type="submit"
										class="btn btn-primary"><%= translate("common:UPDATE") %></button>
								</div>
							</form>
						</div>
						<!-- /.box -->
						<!-- SPECIAL CHANNELS -->
						<div class="box box-warning">
							<div class="box-header with-border">
								<h3 class="box-title"><%= translate("dashboard:CHANNELS_CONF") %></h3>
							</div>
							<form role="form" action="/manage/<%= guild.id %>/" method="POST">
								<!-- /.box-header -->
								<div class="box-body">
									<!-- select -->
									<div class="form-group">
										<label><%= translate("common:SUGGESTIONS") %></label>
										<select class="form-control" name="suggestions">
											<% if (guild.plugins.suggestions && bot.channels.cache.has(guild.plugins.suggestions)) { %>
											<option selected="selected">
												#<%= bot.channels.cache.get(guild.plugins.suggestions).name %></option>
											<% guild.channels.cache.filter((ch) => ch.type === "GUILD_TEXT" && ch.id !== guild.plugins.suggestions).forEach((ch) => { %>
											<option>#<%= ch.name %></option>
											<% }); %>
											<option><%= translate("common:NO_CHANNEL") %></option>
											<% } else { %>
											<option selected="selected"><%= translate("common:NO_CHANNEL") %></option>
											<% guild.channels.cache.filter((ch) => ch.type === "GUILD_TEXT").forEach((ch) => { %>
											<option>#<%= ch.name %></option>
											<% }); %>
											<% } %>
										</select>
									</div>
									<div class="form-group">
										<label><%= translate("common:REPORTS") %></label>
										<select class="form-control" name="reports">
											<% if (guild.plugins.reports && bot.channels.cache.has(guild.plugins.reports)) { %>
											<option selected="selected">
												#<%= bot.channels.cache.get(guild.plugins.reports).name %></option>
											<% guild.channels.cache.filter((ch) => ch.type === "GUILD_TEXT" && ch.id !== guild.plugins.reports).forEach((ch) => { %>
											<option>#<%= ch.name %></option>
											<% }); %>
											<option><%= translate("common:NO_CHANNEL") %></option>
											<% } else { %>
											<option selected="selected"><%= translate("common:NO_CHANNEL") %></option>
											<% guild.channels.cache.filter((ch) => ch.type === "GUILD_TEXT").forEach((ch) => { %>
											<option>#<%= ch.name %></option>
											<% }); %>
											<% } %>
										</select>
									</div>
									<div class="form-group">
										<label><%= translate("common:MODLOGS") %></label>
										<select class="form-control" name="modlogs">
											<% if (guild.plugins.modlogs && bot.channels.cache.has(guild.plugins.modlogs)) { %>
											<option selected="selected">
												#<%= bot.channels.cache.get(guild.plugins.modlogs).name %></option>
											<% guild.channels.cache.filter((ch) => ch.type === "GUILD_TEXT" && ch.id !== guild.plugins.modlogs).forEach((ch) => { %>
											<option>#<%= ch.name %></option>
											<% }); %>
											<option><%= translate("common:NO_CHANNEL") %></option>
											<% } else { %>
											<option selected="selected"><%= translate("common:NO_CHANNEL")%></option>
											<% guild.channels.cache.filter((ch) => ch.type === "GUILD_TEXT").forEach((ch) => { %>
											<option>#<%= ch.name %></option>
											<% }); %>
											<% } %>
										</select>
									</div>
									<div class="form-group">
										<label><%= translate("common:BIRTHDAYS") %></label>
										<select class="form-control" name="birthdays">
											<% if (guild.plugins.birthdays && bot.channels.cache.has(guild.plugins.birthdays)) { %>
											<option selected="selected">
												#<%= bot.channels.cache.get(guild.plugins.birthdays).name %></option>
											<% guild.channels.cache.filter((ch) => ch.type === "GUILD_TEXT" && ch.id !== guild.plugins.birthdays).forEach((ch) => { %>
											<option>#<%= ch.name %></option>
											<% }); %>
											<option><%= translate("common:NO_CHANNEL") %></option>
											<% } else { %>
											<option selected="selected"><%= translate("common:NO_CHANNEL") %></option>
											<% guild.channels.cache.filter((ch) => ch.type === "GUILD_TEXT").forEach((ch) => { %>
											<option>#<%= ch.name %></option>
											<% }); %>
											<% } %>
										</select>
									</div>
								</div>
								<!-- /.box-body -->
								<div class="box-footer">
									<button type="submit"
										class="btn btn-primary"><%= translate("common:UPDATE") %></button>
								</div>
							</form>
						</div>
						<!-- /.box -->
					</div>
					<div class="col-md-6">
						<!-- WELCOME CONFIGURATION -->
						<div class="box box-success">
							<div class="box-header with-border">
								<h3 class="box-title"><%= translate("dashboard:WELCOME_CONF") %></h3>
							</div>
							<form role="form" action="/manage/<%= guild.id %>/" method="POST">
								<!-- /.box-header -->
								<div class="box-body">
									<!-- text input -->
									<div class="form-group">
										<label><%= translate("common:MESSAGE") %></label>
										<textarea rows="3" name="message" class="form-control"
											required><%= (guild.plugins.welcome.message || translate("administration/welcome:DEFAULT_MESSAGE")) %></textarea>
									</div>
									<!-- select -->
									<div class="form-group">
										<label><%= translate("common:CHANNEL") %></label>
										<select class="form-control" name="channel">
											<% if (guild.plugins.welcome.enabled && bot.channels.cache.has(guild.plugins.welcome.channel)) { %>
											<option selected="selected">
												#<%= bot.channels.cache.get(guild.plugins.welcome.channel).name %>
											</option>
											<% guild.channels.cache.filter((ch) => ch.id !== guild.plugins.welcome.channel && ch.type === "GUILD_TEXT").forEach((ch) => { %>
											<option>#<%= ch.name %></option>
											<% }); } else { %>
											<option selected="selected">
												#<%= guild.channels.cache.filter((ch) => ch.type === "GUILD_TEXT").first().name %>
											</option>
											<% guild.channels.cache.filter((ch) => ch.id !== guild.channels.cache.first().id && ch.type === "GUILD_TEXT").forEach((ch) => { %>
											<option>#<%= ch.name %></option>
											<% }); %>
											<% } %>
										</select>
									</div>
									<!-- select -->
									<div class="form-group">
										<div class="checkbox">
											<label>
												<% if (guild.plugins.welcome.withImage || !guild.plugins.welcome.enabled) { %>
												<input type="checkbox" name="withImage"
													checked><%= translate("dashboard:WELCOME_IMG") %>
												<% } else { %>
												<input type="checkbox"
													name="withImage"><%= translate("dashboard:WELCOME_IMG") %>
												<% } %>
											</label>
										</div>
									</div>
								</div>
								<!-- /.box-body -->
								<div class="box-footer">
									<% if (guild.plugins.welcome.enabled) { %>
									<button type="submit" name="welcomeDisable"
										class="btn btn-danger"><%= translate("dashboard:DISABLE_MESSAGES") %></button>
									<button type="submit" name="welcomeUpdate"
										class="btn btn-primary pull-right"><%= translate("common:UPDATE") %></button>
									<% } else { %>
									<button type="submit" name="welcomeEnable"
										class="btn btn-success"><%= translate("dashboard:ENABLE_MESSAGES") %></button>
									<% } %>
								</div>
							</form>
						</div>
						<!-- GOODBYE CONFIGURATION -->
						<div class="box box-danger">
							<div class="box-header with-border">
								<h3 class="box-title"><%= translate("dashboard:GOODBYE_CONF") %></h3>
							</div>
							<form role="form" action="/manage/<%= guild.id %>/" method="POST">
								<!-- /.box-header -->
								<div class="box-body">
									<!-- text input -->
									<div class="form-group">
										<label><%= translate("common:MESSAGE") %></label>
										<textarea rows="3" name="message" class="form-control"
											required><%= (guild.plugins.goodbye.message || translate("administration/goodbye:DEFAULT_MESSAGE")) %></textarea>
									</div>
									<!-- select -->
									<div class="form-group">
										<label><%= translate("common:CHANNEL") %></label>
										<select class="form-control" name="channel">
											<% if (guild.plugins.goodbye.enabled && bot.channels.cache.has(guild.plugins.goodbye.channel)) { %>
											<option selected="selected">
												#<%= bot.channels.cache.get(guild.plugins.goodbye.channel).name %>
											</option>
											<% guild.channels.cache.filter((ch) => ch.id !== guild.plugins.goodbye.channel && ch.type === "GUILD_TEXT").forEach((ch) => { %>
											<option>#<%= ch.name %></option>
											<% }); } else { %>
											<option selected="selected">
												#<%= guild.channels.cache.filter((ch) => ch.type === "GUILD_TEXT").first().name %>
											</option>
											<% guild.channels.cache.filter((ch) => ch.id !== guild.channels.cache.first().id && ch.type === "GUILD_TEXT").forEach((ch) => { %>
											<option>#<%= ch.name %></option>
											<% }); %>
											<% } %>
										</select>
									</div>
									<!-- select -->
									<div class="form-group">
										<div class="checkbox">
											<label>
												<% if (guild.plugins.goodbye.withImage || !guild.plugins.goodbye.enabled) { %>
												<input type="checkbox" name="withImage"
													checked><%= translate("dashboard:GOODBYE_IMG") %>
												<% } else { %>
												<input type="checkbox"
													name="withImage"><%= translate("dashboard:GOODBYE_IMG") %>
												<% } %>
											</label>
										</div>
									</div>
								</div>
								<!-- /.box-body -->
								<div class="box-footer">
									<% if (guild.plugins.goodbye.enabled) { %>
									<button type="submit" name="goodbyeDisable"
										class="btn btn-danger"><%= translate("dashboard:DISABLE_MESSAGES") %></button>
									<button type="submit" name="goodbyeUpdate"
										class="btn btn-primary pull-right"><%= translate("common:UPDATE") %></button>
									<% } else { %>
									<button type="submit" name="goodbyeEnable"
										class="btn btn-success"><%= translate("dashboard:ENABLE_MESSAGES") %></button>
									<% } %>
								</div>
							</form>
						</div>
						<!-- AUTOROLE CONFIGURATION -->
						<div class="box box-warning">
							<div class="box-header with-border">
								<h3 class="box-title"><%= translate("dashboard:AUTOROLE_CONF") %></h3>
							</div>
							<form role="form" action="/manage/<%= guild.id %>/" method="POST">
								<!-- /.box-header -->
								<div class="box-body">
									<!-- select -->
									<div class="form-group">
										<label><%= translate("common:ROLE") %></label>
										<select class="form-control" name="role">
											<% if (guild.plugins.autorole.enabled && guild.roles.cache.has(guild.plugins.autorole.role)) { %>
											<option selected="selected">
												@<%= guild.roles.cache.get(guild.plugins.autorole.role).name %></option>
											<% guild.roles.cache.filter((r) => r.id !== guild.plugins.autorole.role && r.name !== "@everyone").forEach((r) => { %>
											<option>@<%= r.name %></option>
											<% }); } else { %>
											<option selected="selected">
												@<%= guild.roles.cache.filter((r) => r.name !== "@everyone").first().name %>
											</option>
											<% guild.roles.cache.filter((r) => r.id !== guild.roles.cache.filter((r) => r.name !== "@everyone").first().id && r.name !== "@everyone").forEach((r) => { %>
											<option>@<%= r.name %></option>
											<% }); %>
											<% } %>
										</select>
									</div>
								</div>
								<!-- /.box-body -->
								<div class="box-footer">
									<% if (guild.plugins.autorole.enabled) { %>
									<button type="submit" name="autoroleDisable"
										class="btn btn-danger"><%= translate("dashboard:DISABLE_AUTOROLE") %></button>
									<button type="submit" name="autoroleUpdate"
										class="btn btn-primary pull-right"><%= translate("common:UPDATE") %></button>
									<% } else { %>
									<button type="submit" name="autoroleEnable"
										class="btn btn-success"><%= translate("dashboard:ENABLE_AUTOROLE") %></button>
									<% } %>
								</div>
							</form>
						</div>
						<!-- /.box -->
					</div>
					<div>
			</section>

			<!-- Footer includes credits and version -->
		</div>
		<!-- /.content-wrapper -->

		<%- include("../includes/footer") %>
	</div>
	<!-- ./wrapper -->
</body>

</html>