{% extends "base.html" %}
{% load manager_extras %}
{% load i18n %}

{% block title %}{% trans "Preview imported CSV entries" %}{% endblock %}



{% block content %}
<h3>{% trans "Sucessfully converted values" %}</h3>
<div class="box success">{% trans "The following values could be converted." %}</div>
<table class="narrow">
<tr>
    <th>{% trans "Date" %}</th>
    <th>{% trans "Weight" %}</th>
</tr>
{% for entry in weight_list %}
    <tr>
        <td>{{ entry.creation_date|date:"SHORT_DATE_FORMAT" }}</td>
        <td>{{ entry.weight }}</td>
    </tr>
{% endfor %}
</table>



<h3>{% trans "Errors" %}</h3>

{% if error_list %}
    <div  class="box error">{% trans "The following values could not be converted." %}</div>

    <p>{% blocktrans %}These values could not be converted to a weight log entry.
    The reasons for this could be anything from an unrecognised date or number
    format, a problem with the encoding or something else. Please check that
    there are no obvious errors in the list (and correct them if there are!)
    and try to import the list again.{% endblocktrans %}</p>

    <p>{% blocktrans %}Remember that the expected structure is <strong>date</strong>
    on the first columns and <strong>weight</strong> on the second.{% endblocktrans %}</p>

    <table class="narrow">
    <tr>
        <th>{% trans "Date" %}</th>
        <th>{% trans "Weight" %}</th>
    </tr>
    {% for entry in error_list %}
        <tr>
            <td>{{ entry.0 }}</td>
            <td>{{ entry.1 }}</td>
        </tr>
    {% endfor %}
</table>

{% else %}
    <p>{% blocktrans %}There were no errors, all entries could be converted!{% endblocktrans %}</p>
{% endif %}


<h2>{% trans "Import all successfully converted entries" %}</h2>
<p>{% blocktrans %}Continue here if you want to import into your weight log all
entries that were sucessfully converted. All entries that produced an error
will simply be ignored. It's up to you to decide whether they are useful
(unrecognised entries) or not (e.g. headers, comments, etc.).{% endblocktrans %}</p>

<form action="{{form_action}}"
      method="post"
      class="ym-form">
{% csrf_token %}
{% for field in form %}{{ field.as_hidden }}{% endfor %}

<input type="hidden" name="{{ stage_field }}" value="2" />
<input type="hidden" name="{{ hash_field }}" value="{{ hash_value }}" />
<p><input type="submit" value="{% trans 'Import' %}" /></p>
</form>



<h2>{% trans "Or try it again" %}</h2>

<p>{% blocktrans %}You can correct the list here and re-submit it as often as
you want.{% endblocktrans %}</p>

<form action="{{form_action}}"
      method="post"
      class="ym-form">
{% csrf_token %}
{{ form.non_field_errors }}
<input type="hidden" name="{{ stage_field }}" value="1" />
<table>
    {% yaml_form_field form.csv_input %}
    {% yaml_form_field form.date_format "ym-fbox-select" %}
    <tr>
        <td colspan="2">
            <input type="submit" value="{% trans 'Re-Submit' %}" id="form-save">
        </td>
    </tr>
</table>
</form>

{% endblock %}
