{% extends "formunculous/base.html" %}
{% load i18n %}
{% block css %}{{ block.super }}
<link href="{{ MEDIA_URL }}formunculous/css/formunculous.css" rel="stylesheet" type="text/css" />
<link href="{{ MEDIA_URL }}formunculous/css/smoothness/jquery-ui-1.7.2.custom.css" rel="stylesheet" type="text/css">
{% endblock %}

{% block js %}{{ block.super }}
<script type="text/javascript" src="{{ MEDIA_URL }}formunculous/js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="{{ MEDIA_URL }}formunculous/js/jquery-ui-1.7.2.custom.min.js"></script>
<script type="text/javascript">
var delete_url = "{% url reviewer-delete ad.slug %}";
var app_id = 0

jQuery(document).ready(function($)
{
$('#del_dialog').dialog({
       autoOpen: false,
       modal: true,
       width: 400,
       buttons: {
             "OK": function() {
                 $.ajax( { url: delete_url,
                           type: "POST",
                           datatype: "html",
                           data: { id: app_id },
                           success: function() {
                                   $('#del_dialog').dialog('close');
                                   $('#ajax_results').html("<p>Form Successfully Deleted</p>");
                                   $('#ajax_results').effect('highlight',{},1500);
                                   $('#app_' + app_id).parent('tr').fadeOut(1000, function() {$(this).remove();});
                           },
                           error: function() {
                                   $('#del_dialog').dialog('close');
                                   $('#ajax_results').html("<p>Unable to delete the form</p>");
                                   $('#ajax_results').effect('highlight',{},1500);
                                   }
                        });

              },
             "Cancel": function() {
                 $(this).dialog("close");
             }
       },
       show: 'drop',
       bgiframe: true
});

});
function deleteApp(id) {
	app_id = id;
	jQuery('#del_dialog').dialog('open');
}

</script>
{% endblock %}

{% block title %}
{{ ad.name }} {% trans "Submissions" %}
{% endblock %}

{% block content_title %}
{{ ad.name }} {% trans "Submissions" %}
{% endblock %}

{% block content %}
<div id="del_dialog" title="{% trans "Confirm Form Deletion" %}">
  <p>
	Deleting the selected form cannot be undone.  Are you sure
	you want to delete this form?
  </p>
</div>
<div id="ajax_results">
</div>

<div class="formunculous_tab_bar">
  <ul>
	<li>
	  <a href="{% url reviewer-index ad.slug %}" class="formunculous_completelink">{% trans "Completed" %}</a>
	</li>
	<li class="here">
	  <a href="{% url reviewer-index-incomplete ad.slug %}" class="formunculous_incompletelink">{% trans "In Progress" %}</a>
	</li>
  </ul>
</div>

<div style="clear:both"></div>
<table class="formunculous_table formunculous_review_table">
<thead>
<tr>
  {% for header in headers %}
  <th>
	{{ header }}</a>
  </th>
  {% if forloop.last %}
    <th>
	  {% trans "Actions" %}
	</th>
  {% endif %}
  {% endfor %}
</tr>
</thead>
<tbody>
  {% for row in data %}
  <tr class="{% cycle 'odd' 'even' %}">
	{% for col in row %}

	{% if not forloop.last %}
	<td>
	  {{ col }}
	</td>
	{% else %}
	<td id="app_{{ col }}">
	  {% if perms.formunculous.can_delete_applications %}
	  <a href="#" class="formunculous_deletelink" style="padding-left: 20px;" onclick="deleteApp({{ col }});">{% trans "Delete" %}</a></td>
	  {% endif %}
	{% endif %}

	{% endfor %}
  </tr>
  {% endfor %}
</tbody>
</table>

{% endblock %}
