{% extends "videotheque/base.html.twig" %}

{% block title %}
{% if titre is defined %}{{ parent() }} - {{ titre }}{% else %}{{ parent() }}{% endif %}
{% endblock %}

{% block titre %}
{% if titre is defined %}{{ titre }}{% else %}{{ parent() }}{% endif %}
{% endblock %}

{% block body %}
	<div class="row">
		{% if is_granted('IS_AUTHENTICATED_REMEMBERED') %}
		<p><a class="btn btn-primary" role="button" href="{{ path('videotheque_ajouter') }}"><i class="fa fa-plus-square fa-lg"></i> Ajouter un film</a></p>
		{% endif %}
		<p>Filtrer par film au dessus de
		<input class="rating"
			data-disabled="false"
			data-show-clear="true"
			data-show-caption="false"
			data-theme="krajee-fa"
			data-toggle="star-filter"
			data-path="#tableFilms"
			style="display:none;"
			min=0
			max=5
			data-step=1
			data-size="sm"
			value="0">
		</p>
	</div>
	<div class="row">
		<table
			class="table table-bordered table-hover table-sm align-middle">
			<thead class="">
				<tr>
					{% if is_granted('IS_AUTHENTICATED_REMEMBERED') %}
						<th style="width:1em;"></th>
						<th style="width:1em;"></th>
						<th>Ajouté par</th>
					{% endif %}
					<th>Titre</th>
					<th>Genre</th>
					<th>Réalisateur</th>
					<th style="width:5em;">Note</th>
					<th style="width:5em;">Année</th>
					<th style="width:6em;">Sortie</th>
				</tr>
			</thead>
			<tbody id="tableFilms">
				{% for film in listeFilms %}
				<tr data-auteur="{{ film.authered.nomComplet }}">
					{% if is_granted('IS_AUTHENTICATED_REMEMBERED') %}
						<td>
							{%  if app.user.wantToSee(film) %}
								{% set follow_icone = "fa fa-bookmark fa-lg" %}
								{% set follow_texte = "Supprimer ce film de votre liste à voir" %}
							{% else %}
								{% set follow_icone = "fa fa-bookmark-o text-secondary fa-lg" %}
								{% set follow_texte = "Ajouter ce film à votre liste à voir" %}
							{% endif %}
							<a href="#" type="button"
										data-fonction="switch"
										data-icone-actif="fa fa-bookmark fa-lg"
										data-icone-inactif="fa fa-bookmark-o text-secondary fa-lg"
										data-path="{{ path('maliste_modifier_a_voir') }}"
										data-bs-toggle="tooltip"
										title="{{ follow_texte }}"
										data-content="{{ film.id }}">
								<i class="{{ follow_icone }}"></i>
							</a>
						</td>
						<td>
							{%  if app.user.haveSeen(film) %}
								{% set vu_icone = '<i class="fa fa-eye fa-lg text-success"></i>' %}
							{% else %}
								{% set vu_icone = '<i class="fa fa-eye-slash fa-lg text-secondary"></i>' %}
							{% endif %}				
							<a href="#"	type="button"
										data-fonction="switch"
										data-path="{{ path('maliste_modifier_vus') }}"
										data-content="{{ film.id }}"
										data-icone-actif = "fa fa-eye fa-lg text-success"
										data-icone-inactif = "fa fa-eye-slash fa-lg text-secondary">
								{{ vu_icone | raw }}
							</a>
						</td>
						<td>
							{%  if film.authered is defined %}
								{% if film.authered.activeNow %}
									<i class="fa fa-user text-success" data-bs-toggle="tooltip" title="En ligne"></i>
								{% else %}
									<i class="fa fa-user-o text-secondary" data-bs-toggle="tooltip" title="Hors ligne"></i>
								{% endif %}
								{{ film.authered.username }}
							{% endif %}
						</td>
					{% endif %}
					<td>
						<a href="{{ path('videotheque_voirfilm', {'id': film.id}) }}"><span data-bs-toggle="tooltip" data-placement="right" title="{{ film.information }}">{{ film.titre }}</span></a>
						{% if film.new %}<span class="badge bg-success">New</span>{% endif %}
						{% if film.nbComs %}<span class="badge bg-warning rounded-pill" data-bs-toggle="tooltip" title="{{ film.nbComs }} commentaire(s)">{{ film.nbComs }}</span>{% endif %}

					</td>
					<td>
						{% if film.genres is defined %}
							{% for genre in film.genres %}
								<a href="{{ path("videotheque_listepargenre", {"id": genre.id}) }}"><span class="badge bg-secondary">{{ genre.name }}</span></a>
							{% endfor %}
						{% endif %}
					</td>
					<td>
					{% if film.realisateurs is defined %}
						{%  for realisateur in film.realisateurs %}
							<a href="{{ path('videotheque_listeparreal', {"id": realisateur.id}) }}"><span class="badge bg-info">{{ realisateur.nomComplet }}</span></a>
						{%  endfor %}
					{% endif %}
					</td>
					<td>
						{% if film.note > 0 %}
							<input class="rating"
								data-disabled="true"
								data-show-clear="false"
								data-show-caption="false"
								data-theme="krajee-fa"
								style="display:none;"
								min=0
								max=5
								data-step=0.5
								data-size="xs"
								value="{{ film.note }}">
						{% endif %}
					</td>
					<td>{{ film.annee | date('Y') }}</td>
					<td>{% if film.dateSortie %}{{ film.dateSortie | date('d/m/y')}}{% endif %}</td>
				</tr>
				{% endfor %}
			</tbody>
		</table>
	</div>
{% endblock %}