{% extends "./template.html" %}
{% block content %}
    <div class="card mt-4">
        <div class="card-header">
            <h2>Search NearBeach</h2>
        </div>
        <div class="card-body">
            <form action={% url 'search' %} method="post" class="search_for">
                {% csrf_token %}
                <div class="form-row">
                    <div class="form-group w-75">
                        <label for="id_search_for">Search</label>
                        {{ search_form.search_for }}
                    </div>
                    <div class="form-group w-25">
                        <label for="search_button">.</label>
                        <button type="submit" id="search_button" class="btn btn-primary form-control">Search</button>
                    </div>
                </div>
            </form>
        </div>
    </div>


    <div class="card mt-4">
        <div class="card-header">
            <h2>Projects</h2>
            <a href="{% url 'new_project' %}">New Project</a>
        </div>
        <div class="card-body">
            <table class="table table-hover table-striped">
                <thead>
                    <tr>
                        <td>Project ID</td>
                        <td>Project Name</td>
                        <td>Organisation</td>
                        <td>Project Status</td>
                        <td>Project End Date</td>
                    </tr>
                </thead>
                {% for row in project_results %}
                    <tr>
                        <td><a href="{% url 'project_information' row.project_id %}">PRO{{ row.project_id }}</a></td>
                        <td>{{ row.project_name }}</td>
                        <td>{{ row.organisation_id.organisation_name }}</td>
                        <td>{{ row.project_status }}</td>
                        <td>{{ row.project_end_date }}</td>
                    </tr>
                {% endfor %}
            </table>
        </div>
    </div>


    <div class="card mt-4">
        <div class="card-header">
            <h2>Tasks</h2>
            <a href="{% url 'new_task' %}">New Task</a>
        </div>
        <div class="card-body">
            <table class="table table-striped table-hover">
                <thead>
                    <tr>
                        <td>Task ID</td>
                        <td>Task Description</td>
                        <td>Organisation</td>
                        <td>Task Status</td>
                        <td>Task End Date</td>
                    </tr>
                </thead>
                {% for row in task_results %}
                    <tr>
                        <td><a href="{% url 'task_information' row.task_id %}">TASK{{ row.task_id }}</a></td>
                        <td>{{ row.task_short_description }}</td>
                        <td>{{ row.organisation_id.organisation_name }}</td>
                        <td>{{ row.task_status }}</td>
                        <td>{{ row.task_end_date }}</td>
                    </tr>
                {% endfor %}
            </table>
        </div>
    </div>


    <div class="card mt-4">
        <div class="card-header">
            <h2>Opportunities</h2>
            <a href="{% url 'new_opportunity' %}">New Opportunity</a>
        </div>
        <div class="card-body">
            <table class="table table-striped table-hover">
                <thead>
                    <tr>
                        <td>Opportunity ID</td>
                        <td>Opportunity Name</td>
                        <td>Opportunity Stage</td>
                        <td>Expected Close Date</td>
                    </tr>
                </thead>
                {% for row in opportunity_results %}
                    <tr>
                        <td><a href="{% url 'opportunity_information' row.opportunity_id %}">OPP{{ row.opportunity_id }}</a></td>
                        <td>{{ row.opportunity_name }}</td>
                        <td>{{ row.opportunity_stage }}</td>
                        <td>{{ row.opportunity_expected_close_date }}</td>
                    </tr>
                {% endfor %}
            </table>
        </div>
    </div>


    <div class="card mt-4">
        <div class="card-header">
            <h2>Requirements</h2>
            <a href="{% url 'new_requirement' %}">New Requirement</a>
        </div>
        <div class="card-body">
            <table class="table table-striped table-hover">
                <thead>
                    <tr>
                        <td>Requirement ID</td>
                        <td>Requirement Name</td>
                        <td>Requirement Type</td>
                    </tr>
                </thead>
                {% for row in requirement_results %}
                    <tr>
                        <td><a href="{% url 'requirement_information' row.requirement_id %}">REQ{{ row.requirement_id }}</a></td>
                        <td>{{ row.requirement_title }}</td>
                        <td>{{ row.requirement_type }}</td>
                    </tr>
                {% endfor %}
            </table>
        </div>
    </div>

    <div class="card mt-4">
        <div class="card-header">
            <h2>Request for Change</h2>
            <a href="{% url 'new_request_for_change' %}">New Request for Change</a>
        </div>
        <div class="card-body">
            <table class="table table-striped table-hover">
                <thead>
                    <tr>
                        <td>RFC ID</td>
                        <td>RFC Title</td>
                        <td>RFC Status</td>
                    </tr>
                </thead>
                {% for row in rfc_results %}
                    <tr>
                        <td><a href="{% url 'request_for_change_information' row.rfc_id %}">RFC{{ row.rfc_id }}</a></td>
                        <td>RFC{{ row.rfc_title }}</td>
                        <td>RFC{{ row.rfc_status }}</td>
                    </tr>
                {% endfor %}
            </table>
        </div>
    </div>
{% endblock %}
