{% extends "./template.html" %}
{% block content %}
{% load static %}
<form action="{% url 'assign_customer_project_task' customer_results.customer_id %}" method="POST">
    {% csrf_token %}
    <script type="text/javascript" src="{% static 'NearBeach/javascript/assign_customer_project_task.js' %}"></script>
    <div class="card mt-4">
        <div class="card-header">
            <h1>Search Projects and Tasks</h1>
        </div>
        <div class="card-body">
            <div class="form-group">
                <label for="filter_tables">The following list of projects/tasks are currently opened. Can not assigned resolved tasks to customer.</label>
                <input type="text" onkeyup="update_filter()" placeholder="Filter" id="filter_tables" class="form-control">
            </div>
        </div>
    </div>


    <div class="card mt-4">
        <div class="card-header">
            <h3>Projects</h3>
        </div>
        <div class="card-body">
            {% if project_results %}
                <table class="table table-striped table-hover">
                    <thead>
                        <tr>
                            <td>Assign</td>
                            <td>Project Name</td>
                            <td>Project End Date</td>
                            <td>Project Status</td>
                        </tr>
                    </thead>
                    {% for row in project_results %}
                        <tr>
                            <td><input type="checkbox" name="project_checkbox" value="{{ row.project_id }}">PRO{{ row.project_id }}</td>
                            <td>{{ row.project_name }}</td>
                            <td>{{ row.project_end_date }}</td>
                            <td>{{ row.project_status }}</td>
                        </tr>
                    {% endfor %}
                </table>
            {% else %}
                Sorry. There are currently no projects for this customer.
            {% endif %}
        </div>
    </div>


    <div class="card mt-4">
        <div class="card-header">
            <h3>Tasks</h3>
        </div>
        <div class="card-body">
            {% if task_results %}
                <table class="table table-striped table-hover">
                    <thead>
                        <tr class="header">
                            <td>Assign</td>
                            <td>Task Name</td>
                            <td>Task End Date</td>
                            <td>Task Status</td>
                        </tr>
                    </thead>
                    {% for row in task_results %}
                        <tr>
                            <td><input type="checkbox" name="task_checkbox" value="{{ row.task_id }}">TASK{{ row.task_id }}</td>
                            <td>{{ row.task_short_description }}</td>
                            <td>{{ row.task_end_date }}</td>
                            <td>{{ row.task_status }}</td>
                        </tr>
                    {% endfor %}
                </table>
            {% else %}
                <p>Sorry. There are currently no tasks for this customer.</p>
            {% endif %}
        </div>
    </div>
    <div class="form-row mt-4">
        <div class="form-group col-md-6">
            <input type="submit" value="Submit Assigned Projects/Tasks" class="btn btn-primary form-control">
        </div>
        <div class="form-group col-md-6">
            <a href="{% url 'customer_information' customer_results.customer_id %}" class="btn btn-danger form-control">Cancel</a>
        </div>
    </div>
</form>

{% endblock %}
