{% extends 'ftp_deploy/notification/notification.html' %}
{% load crispy_forms_tags %}

{% block title %}
    {% if notification %} <h2>{{notification.name}} <small>Edit</small></h2> {% else %} <h2>Notification <small>Add</small></h2> {% endif %}
{% endblock title %}

{% block content_notification %}

    <form action="{% if notification %}{% url 'ftpdeploy_notification_edit' notification.pk %}{% else %}{% url 'ftpdeploy_notification_add' %} {% endif %}" method="post" class="" id="notifications-form">
        {% crispy form form.helper_header %}
            
        <table class="table table-condensed">
            <thead>
                <tr>
                    <th width="15%">Success</th>
                    <th width="15%">Fail</th>
                    <th></th>
                    <th width="5%"></th>
                </tr>
            </thead>
            <tbody>
                {% for email,values in emails.items %}
                    {% if email %}
                        <tr>
                            <td><input type="checkbox" name="_success" value="{{email}}" {% if values.success %} checked {% endif %}></td>
                            <td><input type="checkbox" name="_fail" value="{{email}}" {% if values.fail %} checked {% endif %}></td>
                            <td>{{email}}</td>
                            <td><a href="#" class="remove"><i class="fa fa-times c-remove"></i></a></td>
                        </tr>
                    {% endif %}
                {% endfor %}
                <tr>
                    <td colspan="2"></td>
                    <td colspan="2">
                        <div class="row">
                            <div class="col-sm-9">
                                <input type="email" class="form-control input-sm" id="email" placeholder="Enter email">
                            </div>
                            <div class="col-sm-3">
                                <a href="#" id="add" type="button" class="btn btn-success btn-xs pull-right" style="margin-top:3px">Add Email</a>
                            </div>
                        </div>
                    </td>
                </tr>
                {% crispy form form.helper_user %}
            </tbody>
        </table>
        <button type="submit" class="btn btn-primary pull-right">Save</button>
    </form>

    {% include "ftp_deploy/pagination.html" %}

{% endblock content_notification %}