{% extends "base.html" %}

{% block content %}

<link rel="stylesheet" href="{{ url_for('static', filename='css/flags/flags.css') }}"/>

<div class="container">
<div class="panel panel-success">
<div class="panel-heading"><h3 class="panel-title">Airports</h3></div>
<div class="panel-body">

<form>
<div class="well">
<select name="country" onchange="this.form.submit();">
	<option value="">(none)</option>
    {% for country in countries %}
    <option value="{{ country.iso2 }}"{% if sel_country == country.iso2 %} SELECTED{% endif %}>{{ country.iso2 }}</option>
    {% endfor %}
</select>
</div>
</form>

  <table class="datatable table table-striped table-bordered">
    <tr>
      <th>#</th>
   	  <th>Name</th>
   	  <th>Logbook (takeoff and landings)</th>
    </tr>

    {% for airport in airports %}
	<tr>
	  <td>{{ loop.index }}
	  <td><img src="{{ url_for('static', filename='img/Transparent.gif') }}" class="flag flag-{{ sel_country|lower }}" alt="{{ sel_country }}"/> <a href="{{ url_for('main.airport_detail', airport=airport.id) }}">{{ airport.name }}</a></td>
	  <td><a href="{{ url_for('main.logbook', country=sel_country, airport=airport.id) }}">Logbook</a></td>
	</tr>
	{% endfor %}
  </table>
</div>
</div>

{% endblock %}