{% extends "base.html" %}
{% block title %} New MovieStar Details {% endblock %}
{% block content %} 
{% block script %}
<script type="text/javascript" src="{{ url_for('static', filename='delete.js') }}"></script>
{% endblock %}
	<div class="search-container">
		<form method="post" action="{{ url_for('moviestars.search') }}">
			<input id="text" type="text" placeholder="Search for Moviestar.." name="keyword">
			<button class="w3-button w3-black" type="submit">Search</button>
		</form>
	</div>

<h1> Moviestar {{ star.Star_Name  }} </h1>

  {% 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 %}
		<span id="delete">
		<div class="w3-container w3-light-grey w3-teal w3-border w3-padding-32">
				<h3> MovieStar ID: {{ star.Star_ID }} </h1>
		
				<h3> MovieStar's Name: {{ star.Star_Name }} </h3>
				
				<p> <a href="{{ url_for('moviestars.editMoviestar', Id=star.Star_ID) }}"> Edit Moviestar </a> </p>
				
				{% set count = namespace(value=0) %}
				
				<div class="w3-panel w3-padding-32 w3-pale-green w3-teal w3-border">
					<h4 class="header">Movies Featuring {{ star.Star_Name }} </h4>
					{% if star.movie|length == 0 %}
						<p>{{ star.Star_Name }} has not featured in any movies</p>
					{% else %}
						<ul class="w3-ul">
							<table class="tabledata">
								{% for _movie in star.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('moviestars.removeMovie',Id=star.Star_ID, movieId=_movie.Movie_ID) }}'
										,'{{ star.Star_Name }}','{{ _movie.Movie_Title }}')">
										Remove Movie {{ _movie.Movie_Title }} from list</a></td>
									</tr>
								{% endfor %}
							</table>
						</ul>
					{% endif %}
					
					<p><a class="alink" href="{{ url_for('moviestars.addMovie', Id=star.Star_ID) }}"> 
					Add Movie for {{ star.Star_Name }} </a> </p>
				</div>
		</div>

 <ul class="breadcrumb">
  <li><a href="{{ url_for('moviestars.index', page=1) }}">MovieStars List</a></li>
  <li><a href="{{ url_for('moviestars.editMoviestar', Id=star.Star_ID) }}"> 
  Edit {{ star.Star_Name }} </a></li>
    <li><a href="#" onclick="deleteEntity('delete','{{ url_for('moviestars.delete',Id=star.Star_ID) }}','{{ star.Star_Name }}')"> 
  Delete {{ star.Star_Name }} </a></li>
</ul> 
</span>
{% endblock %}