<div class="alert-primary">Click on the object you wish to link to the current requirement. Please note if there are no results then it is not possible to link anything.</div>
{% if requirement_id %}
    <h5 class="mt-4">Project Links - or <a href="{% url 'new_project' requirement_id 'requirement' %}">create a new project</a></h5>
{% elif requirement_item_id %}
    <h5 class="mt-4">Project Links - or <a href="{% url 'new_project' requirement_item_id 'requirement_item' %}">create a new project</a></h5>
{% endif %}
{% if project_results %}
    <table class="table table-striped table-hover">
        <thead>
            <tr>
                <td class="w-25"><b>Project ID</b></td>
                <td class="w-75">Project Name</td>
            </tr>
        </thead>
        {% for row in project_results %}
            <tr>
                <td><a href="javascript:void(0)" onclick="post_requirement_links({{ row.project_id }},'project')">Project - {{ row.project_id }}</a></td>
                <td><a href="javascript:void(0)" onclick="post_requirement_links({{ row.project_id }},'project')">{{ row.project_name }}</a></td>
            </tr>
        {% endfor %}
    </table>
{% else %}
    Sorry - no projects can be linked
{% endif %}

{% if requirement_id %}
    <h5 class="mt-4">Task Links - or <a href="{% url 'new_task' requirement_id 'requirement' %}">create a new task</a></h5>
{% elif requirement_item_id %}
    <h5 class="mt-4">Task Links - or <a href="{% url 'new_task' requirement_item_id 'requirement_item' %}">create a new task</a></h5>
{% endif %}
{% if task_results %}
    <table class="table table-striped table-hover">
        <thead>
            <tr>
                <td class="w-25"><b>Task ID</b></td>
                <td class="w-75">Task Name</td>
            </tr>
        </thead>
        {% for row in task_results %}
            <tr>
                <td><a href="javascript:void(0)" onclick="post_requirement_links({{ row.task_id }},'task')">Task - {{ row.task_id }}</a></td>
                <td><a href="javascript:void(0)" onclick="post_requirement_links({{ row.task_id }},'task')">{{ row.task_short_description }}</a></td>
            </tr>
        {% endfor %}
    </table>
{% else %}
    Sorry - no tasks can be linked
{% endif %}


<h5 class="mt-4">Opportunity Links</h5>
{% if opportunity_results %}
    <table class="table table-striped table-hover">
        <thead>
            <tr>
                <td class="w-25"><b>Opportunity ID</b></td>
                <td class="w-75">Task Name</td>
            </tr>
        </thead>
        {% for row in opportunity_results %}
            <tr>
                <td><a href="javascript:void(0)" onclick="post_requirement_links({{ row.opportunity_id }},'opportunity')">Opp - {{ row.opportunity_id }}</a></td>
                <td><a href="javascript:void(0)" onclick="post_requirement_links({{ row.opportunity_id }},'opportunity')">{{ row.opportunity_name }}</a></td>
            </tr>
        {% endfor %}
    </table>
{% else %}
    Sorry - no opportunities can be linked
{% endif %}
