{% load nearbeach_extras %}
{% if active_group_opportunities %}
    <table class="table table-hover">
        <thead>
            <tr>
                <td>Opportunity Name</td>
                <td>Organisation's Name</td>
                <td>Customer Name</td>
                <td>Opportunity Stage</td>
                <td>Expected Close Date</td>
            </tr>
        </thead>
        {% for row in active_group_opportunities %}
            <tr
                    {% if row.opportunity_expected_close_date|hours_ago:24 %}
                        class="table-danger"
                    {% endif %}
            >
                <td><a href="{% url 'opportunity_information' row.opportunity_id %}">{{ row.opportunity_name }}</a></td>
                {% if row.organisation_id %}
                    <td><a href="{% url 'organisation_information' row.organisation_id.organisation_id %}">{{ row.organisation_id.organisation_name }}</a></td>
                {% else %}
                    <td>-----</td>
                {% endif %}
                {% if row.customer_id %}
                    <td><a href="{% url 'customer_information' row.customer_id.customer_id %}">{{ row.customer_id.customer_first_name }} {{ row.customer_id.customer_last_name }}</a></td>
                {% else %}
                    <td>-----</td>
                {% endif %}
                <td>{{ row.opportunity_stage_id.opportunity_stage_description }}</td>
                <td>{{ row.opportunity_expected_close_date }}</td>
            </tr>
        {% endfor %}
    </table>
{% else %}
    <p>Sorry, there are no opportunities assigned to your group</p>
{% endif %}