{% extends 'base.html' %}
{% block content %}

<br>

{% if row_vals == 'new'%}
    <form method="post" action="/edit_cheltuieli/{{id_row}}">
    <div class="container text-left">
            {% for col_name, col_type in table_head.items() %}
            <div class="row" id="date-row_">
                <div class="col">
                    <label>{{col_name}}</label>
                        {% if col_type == 'varchar' or col_type == 'text'%}
                            <input type="text" name="{{col_name}}"/>
                        {% elif col_type == 'date' %}
                            <input type="date"  name="{{col_name}}"/>
                        {% elif col_type == 'int' or col_type == 'decimal' %}
                            <input type="number"  name="{{col_name}}"/>
                        {% elif col_type == 'tinyint' %}
                            <input value=1 name="{{col_name}}" type="checkbox">
                        {% else %}
                        {% endif %}

                </div>
            </div>
            {% endfor %}
    </div>
    <br>
    <div class="row" id="sub__mit-row">
        <div class="col">
            <input type="submit" name="copy_as"/>
        </div>
    </div>

</form>
{% else %}
    <form method="post" action="/edit_cheltuieli/{{id_row}}">
    <div class="container text-left">
            {% for col_name, col_type in table_head.items() %}
            <div class="row" id="date-row">
                <div class="col">
                    <label>{{col_name}}</label>
                        {% if col_type == 'varchar' or col_type == 'text'%}
                            <input type="text" value="{{ row_vals[loop.index - 1] }}" name="{{col_name}}"/>
                        {% elif col_type == 'date' %}
                            <input type="date" value="{{ row_vals[loop.index -1 ] }}" name="{{col_name}}"/>
                        {% elif col_type == 'int' or col_type == 'decimal' %}
                            <input type="number" value="{{ row_vals[loop.index -1] }}" name="{{col_name}}"/>
                        {% elif col_type == 'tinyint' %}
                            {% if row_vals[loop.index -1] == 1%}
                                <input checked="" value=1 name="{{col_name}}" type="checkbox">
                            {% else %}
                                <input value=1 name="{{col_name}}" type="checkbox">
                            {% endif %}
                        {% else %}
                        {% endif %}

                </div>
            </div>
            {% endfor %}
    </div>
    <br>
    <div class="row" id="None">
        <div class="col">
        <div class="col">
            <label>Cancel the auto_extension and  set valid to for the original</label>
            <input checked="" value=True name="cancel_auto_ext" type="checkbox">
        </div>

        </div>
    </div>
    <div class="row" id="submit-row">
        <div class="col">
            <input type="submit" name="copy_as"/>
        </div>
    </div>

</form>
{% endif %}



<br>


{% endblock %}