{% extends "base.html" %}
{% block title %} New Director Details {% endblock %}
{% block script %}
<script type="text/javascript" src="{{ url_for('static', filename='delete.js') }}"></script>
{% endblock %} 
{% block content %} 

	<div class="search-container">
		<form method="post" action="{{ url_for('directors.search') }}">
			<input id="text" type="text" placeholder="Search for Director.." name="keyword">
			<button class="w3-button w3-black" type="submit">Search</button>
		</form>
	</div>

<h1> {{ director.Director_Name }}  </h1>

<span id="delete">
  {% set messages = get_flashed_messages() %}
  {% if messages %}
	<div class="w3-panel w3-pale-green w3-border">
				{% for message in messages %}
					<h3> {{ message }} </h3>
				{% endfor %}
	</div>	
  {% endif %}


		<div class="w3-container w3-light-grey w3-teal w3-border w3-padding-32">
				<h3> Director ID: {{ director.Director_ID }} </h1>
		
				<h3> Director's Name: {{ director.Director_Name }} </h3>
				
				<p> <a href="{{ url_for('directors.editDirector', Id=director.Director_ID) }}"> Edit Director </a> </p>
				
				<div class="w3-panel w3-padding-32 w3-pale-green w3-teal w3-border">
					<h4 class="header">Movies Directed by {{ director.Director_Name }} </h4>
					
					{% if director.movie|length == 0 %}
						<p> There are no movies currently directed by {{ director.Director_Name }} </p>
					{% else %}
					
					{% set count = namespace(value=0) %}
					
						<ul = class="w3-ul">
							<table class="tabledata">
								{% for _movie in director.movie %}
									{% set count.value = count.value + 1 %}
									{% set rowid = 'row' + count.value|string %}
									<tr id="{{ rowid }}">
										<td><li><a href="{{ url_for('movies.movieDetails',Id=_movie.Movie_ID) }}">
										{{ _movie.Movie_Title }} </a></li></td>
										
										<td><a class="alink" href="{{ url_for('movies.editMovie',Id=_movie.Movie_ID) }}">
										Edit Movie {{ _movie.Movie_Title }} </a></td>
										
										<td><a class="alink" href="#"
										onclick="deleteAndHideRow('{{ rowid }}',
										'{{ url_for('directors.removeMovie',Id=director.Director_ID, movieId=_movie.Movie_ID) }}'
										,'{{ director.Director_Name }}','{{ _movie.Movie_Title }}')">
										Remove Movie {{ _movie.Movie_Title }} from list</a></td>
									<tr>
								{% endfor %}
							</table>
						</ul>
					{% endif %}
					
					<p><a href="{{ url_for('directors.addMovie', Id=director.Director_ID) }}">
					Add Movies for Director {{ director.Director_Name }} </a></p>
				</div>
		</div>

 <ul class="breadcrumb">
  <li><a href="{{ url_for('directors.index', page=1) }}">Directors List</a></li>
  <li><a href="{{ url_for('directors.editDirector', Id=director.Director_ID) }}"> 
  Edit {{ director.Director_Name }} </a></li>
  <li><a href="#" onclick="deleteEntity('delete','{{ url_for('directors.delete',Id=director.Director_ID) }}','{{ director.Director_Name }}')">
  Delete {{ director.Director_Name }}</a>
</ul> 
</span>
{% endblock %}