{% extends "admin/base_site.html" %}
{% load chimere_tags i18n admin_static %}

{% block extrahead %}
<link rel="stylesheet" type="text/css" href="{% static "admin/css/forms.css" %}" />
<script src="http://www.openlayers.org/api/OpenLayers.js"></script>
{% endblock %}


{% block content %}
<p class='errornote'>{% trans "Be careful: after validation, the modified item will be deleted. There is no roll-back." %}</p>
<fieldset class='module'>
<form method='POST' action='.'>
{% csrf_token %}
<input type='hidden' name='action' value='managed_modified'/>
<input type='hidden' name='rapprochement' value='1'/>
<input type='hidden' name='_selected_action' value='{{item.pk}}'/>
<table>
<thead>
<tr><th>&nbsp;</th><th>{% trans "Reference" %}</th><th>{% trans "Modified item" %}</th><th>{% trans "Accept modification" %}</th></tr>
</thead>
<tbody>
<tr><th>{% trans "Name" %}</th><td>{{item_ref}}</td><td>{{item}}</td><td><input type='checkbox' name='name'/></td></tr>
<tr>
    <th>{% trans "Categories" %}</th>
    <td>{% for cat in item_ref.categories.all %}{%if forloop.counter0 %}, {%endif%}{{cat}}{%endfor%}</td>
    <td>{% for cat in item.categories.all %}{%if forloop.counter0 %}, {%endif%}{{cat}}{%endfor%}</td>
    <td><input type='checkbox' name='categories'/></td>
</tr>
<tr><th>{% trans "Emplacement" %}</th><td>{{item_ref|ol_map:'map_ref_id'}}</td><td>{{item|ol_map:'map_id'}}</td><td><input type='checkbox' name='{{item.geom_attr}}'/></td></tr>
<tr><th>{% trans "Description" %}</th><td>{{item_ref.description|safe}}</td><td>{{item.description|safe}}</td><td><input type='checkbox' name='description'/></td></tr>
{% for property_ref in item_ref.getProperties %}
{% for property in item.getProperties %}
{% ifequal property_ref.propertymodel property.propertymodel %}
<tr><th>{{property.propertymodel.name}}</th><td>{{property_ref.value|safe}}</td><td>{{property.value|safe}}</td><td><input type='checkbox' name='property_{{property.propertymodel.pk}}'/></td></tr>
{% endifequal %}
{% endfor %}
{% endfor %}
</tbody>
</table>
</fieldset>
<div class='submit-row'>
<p class='deletelink-box'><a href="{% if item.point %}{% url admin:chimere_marker_changelist %}{%else%}{% url admin:chimere_route_changelist %}{%endif%}">{% trans "Back to list" %}</a></p>
<input class='default' type='submit' value='{% trans "Validate" %}'/>
</div>
</form>
{% endblock %}
