{% set title = 'Active Guilds on ' ~ config.lua.serverName %}
{% set content %}
<table style="width:100%;">
	<tbody>
		<tr>
			<td>
				<div class="TableShadowContainerRightTop">
					<div class="TableShadowRightTop" style="background-image:url({{ template_path }}/images/content/table-shadow-rt.gif);"></div>
				</div>
				<div class="TableContentAndRightShadow" style="background-image:url({{ template_path }}/images/content/table-shadow-rm.gif);">
					<div class="TableContentContainer">
						<table class="TableContent" width="100%">
							<tbody>
								{% if guilds|length > 0 %}
								<tr bgcolor="{{ config.darkborder }}">
									<td width="64"><b>Logo</b></td>
									<td><b>Description</b></td>
									<td width="12%"><b>&nbsp;</b></td>
								</tr>

									{% set i = 0 %}
									{% for guild in guilds %}
									{% set i = i + 1 %}
									<tr bgcolor="{{ getStyle(i) }}">
										<td>
											<img src="{{ constant('GUILD_IMAGES_DIR') }}{{ guild.logo }}" width="64" height="64">
										</td>

										<td style="word-break: break-all">
											<span{% if guild.description is not empty %} valign="top"{% endif %}>
												<b>{{ guild.name }}</b>{% if isAdmin %}<a href="{{ getLink('guilds') }}?action=delete_by_admin&guild={{ guild.name }}"> - Delete this guild (for ADMIN only!)</a>{% endif %}
											</span>

											{% if guild.description is not empty %}
											<br>
											<span>{{ guild.description }}</span>
											{% endif %}
										</td>

										<td>
											<table border="0" cellspacing="0" cellpadding="0" width="100%">
												<tbody>
													<tr>
														<td style="border:0;">
															<form action="{{ guild.link }}" method="post">
																{{ csrf() }}
																{{ include('buttons.view.html.twig') }}
															</form>
														</td>
													</tr>
												</tbody>
											</table>
										</td>
									</tr>
									{% endfor %}
								{% else %}
								<tr bgcolor="{{ config.darkborder }}">
									<td valign="top">
										<b>Create Guild</b>
										<br/>
										Actually there is no guild on server.{% if logged %} Create first! Press button "Create Guild"{% endif %}
									</td>

									{% if logged %}
									<td>
										<table border="0" cellpadding="0" cellspacing="0" width="100%">
											<form action="{{ getLink('guilds') }}?action=create" method="post">
												{{ csrf() }}
												{% set button_name = 'Found Guild' %}
												{% set button_image = '_sbutton_foundguild' %}
												{% include('buttons.base.html.twig') %}
											</form>
										</table>
									</td>
									{% endif %}
								</tr>
								{% endif %}
							</tbody>
						</table>
					</div>
				</div>
				<div class="TableShadowContainer">
					<div class="TableBottomShadow" style="background-image:url(https://static.tibia.com/images/global/content/table-shadow-bm.gif);">
						<div class="TableBottomLeftShadow" style="background-image:url({{ template_path }}/images/content/table-shadow-bl.gif);"></div>
						<div class="TableBottomRightShadow" style="background-image:url({{ template_path }}/images/content/table-shadow-br.gif);"></div>
					</div>
				</div>
			</td>
		</tr>
	</tbody>
</table>
{% endset %}
{% include 'tables.headline.html.twig' %}
<br>

<table border="0" cellspacing="1" cellpadding="4" width="100%">
	<tbody>
		<tr>
			<td align="center">
				<img src="{{ template_path }}images/general/blank.gif" width="80" height="1" border="0">
			</td>

			<td align="center">
				<table border="0" cellspacing="0" cellpadding="0">
					<tbody>
						{% if logged %}
						No guild found that suits your needs?
						<form action="{{ getLink('guilds') }}?action=create" method="post">
							{{ csrf() }}
							{% set button_name = 'Found Guild' %}
							{% set button_image = '_sbutton_foundguild' %}
							{% include('buttons.base.html.twig') %}
						</form>
						{% else %}
						<b>Before you can create a guild you must login.</b>
						<br/>
						<form action="{{ getLink('account/manage') }}?redirect={{ getLink('guilds') }}" method="post">
							{{ csrf() }}
							{% include('buttons.login.html.twig') %}
						</form>
						{% endif %}
					</tbody>
				</table>

				{% if logged %}
					<br/>
					If you have any problem with guilds try:
					<br/>
					<a href="{{ getLink('guilds') }}?action=cleanup_players">Cleanup players</a> - can't join guild/be invited? Can't create guild? Try cleanup players.
					<br/>
					<a href="{{ getLink('guilds') }}?action=cleanup_guilds">Cleanup guilds</a> - made guild, you are a leader, but you are not on players list? Cleanup guilds!
				{% endif %}
			</td>

			<td align="center">
				<img src="{{ template_path }}/images/general/blank.gif" width="80" height="1" border="0">
			</td>
		</tr>
	</tbody>
</table>




