{% extends 'main.html' %}
{% load static %}
{% block content %}

<!--context['bap_club', 'bgp', 'categories', 'selected_category', 'available_species'] + genus_bap_species_list context_object -->
<!-- genus_bap_species_list may be empty this is a normal case where no overrides have been set -->
<!-- available_species contains all species in the genus that are not overriden -->

<div class="container">
    <h3>{{ bap_club.name }}</h3>
    <p>By default species are assigned BAP Points by genus.</p>
    <div style="display: flex; justify-content: space-between; align-items: center;">
        <p>You can optionally set individual species BAP Points using <b><i>species exceptions</i></b>.</p>
        <span><a class="btn btn-secondary" href="{% url 'bapGenus' bap_club.id %}" role="button">&nbsp;BAP Genus List&nbsp;</a></span>
    </div>
    <small>&nbsp;</small> 
    <div class="card mb-4">
        <div class="card-header d-flex justify-content-between align-items-center">
            <h4><b>{{ bgp.name }}</b> Species Exceptions</h4>
        </div>
        <div class="card-body">
            {% if genus_bap_species_list %}
                <div class="table-responsive">
                    <table class="table table-striped table-hover">                    
                        <thead>
                            <tr>
                                <!-- th style="width: 40%">Species</th-->
                                <th style="width: 40%">Species</th>
                                <th style='text-align:center'>Category</th> 
                                <th style='text-align:center'>CARES</th> 
                                <th style='text-align:center'>Points</th> 
                            </tr>
                        </thead>
                        <tbody>
                            {% for species_entry in genus_bap_species_list %}
                                <tr>
                                    <td><a href="{% url 'species' species_entry.species.id %}">{{species_entry.name}}</a></td>
                                    <td style='text-align:center'>{{ species_entry.species.get_category_display }}</td>  
                                    {% if userCanEdit %}
                                        {% if species_entry.species.render_cares %}
                                            <td style='text-align:center'>Yes</td>  
                                            <td style='text-align:center'><a href="{% url 'editBapSpecies' species_entry.id %}">{{species_entry.points}}</a> x {{bap_club.cares_muliplier}}</td>  
                                        {% else %}
                                            <td style='text-align:center'>No</td>  
                                            <td style='text-align:center'><a href="{% url 'editBapSpecies' species_entry.id %}">{{species_entry.points}}</a></td>  
                                        {% endif %}
                                    {% else %}
                                        <td></td>  
                                        {% if species_entry.species.render_cares %}
                                            <td style='text-align:center'>{{species_entry.points}} x {{bap_club.cares_muliplier}}</td>  
                                        {% else %}
                                            <td style='text-align:center'>{{ species_entry.points }}</td>  
                                        {% endif %}
                                    {% endif %}
                                </tr>
                            {% endfor %}
                        </tbody>
                    </table>
                </div>
            {% else %}
                <p>None</p>
            {% endif %}
        </div>
    </div>
    <div class="card mb-4">
        <div class="card-header d-flex justify-content-between align-items-center">
            <h4><b>{{ bgp.name }}</b> Species without exceptions <i>(Genus points applied)</i></h4>
        </div>
        <div class="card-body">
            {% if available_species %}
                <div class="table-responsive">
                    <table class="table table-striped table-hover">                    
                        <thead>
                            <tr>
                                <th style="width: 40%">Species</th>
                                <th style='text-align:center'>Category</th> 
                                <th style='text-align:center'>CARES</th> 
                                <th style='text-align:center'>Points</th> 
                            </tr>
                        </thead>
                        <tbody>
                            {% for species in available_species %}
                                <tr>
                                    <td><a href="{% url 'species' species.id %}">{{species.name}}</a></td>
                                    <td style='text-align:center'>{{ species.get_category_display }}</td> 
                                    {% if userCanEdit %}
                                        {% if species.render_cares %}
                                            <td style='text-align:center'>Yes</td>  
                                            <td style='text-align:center'><a href="{% url 'createBapSpecies' species.id %}">{{bgp.points}}</a> x {{bap_club.cares_muliplier}}</td>  
                                        {% else %}
                                            <td style='text-align:center'>No</td>
                                            <td style='text-align:center'><a href="{% url 'createBapSpecies' species.id %}">{{bgp.points}}</a></td>  
                                        {% endif %}
                                    {% else %}
                                        {% if species.render_cares %}
                                            <td style='text-align:center'>Yes</td>  
                                            <td style='text-align:center'>{{ bgp.points }} x {{ bap_club.cares_muliplier }}</td>  
                                        {% else %}
                                            <td></td>  
                                            <td style='text-align:center'>{{ bgp.points }}</td>  
                                        {% endif %}
                                    {% endif %}
                                </tr>
                            {% endfor %}
                        </tbody>
                    </table>
                </div>
            {% else %}
                <p>None</p>
            {% endif %}            
        </div>
    </div>
</div>

{% endblock content %}

