{% extends "sysadmin/base.html" %}
{% load i18n %}

{% block cur_notice %}tab-cur{% endblock %}

{% block right_panel %}
<div class="hd ovhd">
    <h3 class="fleft">{% trans "All Notifications" %}</h3>
    <button id="add-n" class="fright btn-white">{% trans "Add new notification" %}</button>
</div>
<form action="{% url 'notification_add' %}" method="post" class="hide" id="add-n-form">{% csrf_token %}
    <h3>{% trans "Add new notification" %}</h3>
    <textarea name="message" class="textarea"></textarea><br />
    <input type="submit" value="{% trans "Submit" %}" class="submit" />
</form>

{% if notes %}
<table>
    <tr>
        <th width="75%">{% trans "Notification Detail" %}</th>
        <th width="25%">{% trans "Operations" %}</th>
    </tr>
    {% for note in notes %}
    <tr>
        <td>{{ note.message }}
        {% if note.primary == 1 %}
        <span class="cur-note">{% trans "(current notification)" %}</span>
        {% endif %}
        <td>
          {% if note.primary != 1 %}
          <a href="#" data="{{ SITE_ROOT }}notification/set-primary/{{ note.id }}/" class="note-change-btn op vh">{% trans "Set to current" %}</a>
          {% endif %}
          <a href="#" data-url="{{ SITE_ROOT }}notification/delete/{{ note.id }}/" data-target="{{ note.message }}" class="note-delete-btn op vh">{% trans "Delete" %}</a>
        </td>
    </tr>
    {% endfor %}
</table>
{% else %}
<p>{% trans "Empty" %}</p>
{% endif %}
{% endblock %}

{% block extra_script %}
<script type="text/javascript">
$('#add-n').click(function() {
    $('#add-n-form').modal();
    $('#simplemodal-container').css({'height':'auto'});
    return false;
});
addConfirmTo($('.note-delete-btn'), {
    'title':"{% trans "Delete Notification" %}",
    'con':"{% trans "Are you sure you want to delete %s ?" %}"
});

$('.note-change-btn').click(function() {
    window.location = $(this).attr('data');
})
</script>
{% endblock %}
 
