{% extends "base/module_base.html" %}

{% set active_page = info['display_string']+' dashboard' %}

{% block pagehead %}
<title></title>
<style>

</style>
{% endblock %}




{% block sidebar %}
  {%include info['module_name']+'/blocks/sidebar.html'%}
{%endblock%}




{% block content %}
<br>
<div>
    <div class="card">
        <div class="card-body">
            <form class="form" method="POST" action="{{ url_for('shopman.coupon_add') }}">
                <div>
                    <label>{{ form.string.label }}</label>
                    {{ form.string() }}
                    <label>{{ form.type.label }}</label>
                    {{ form.type() }}<br>
                    <label>{{ form.value.label }}</label>
                    {{ form.value() }}
                </div><br>

                {{ form.csrf_token }}
                <button type="submit" class="btn btn-primary">submit</button>
            </form>
        </div>
    </div>
</div>
<br>
<div>
    <div class="card">
        <div class="card-body">
            <table class="table table-responsive">
                
                <thead>
                    <th>String</th>
                    <th>Type</th>
                    <th>Value</th>
                    <th></th>
                </thead>
                <tbody>
                    {%for coupon in coupons%}
                        <tr>
                            <form method="POST" action="{{ url_for('shopman.coupon_update') }}">
                            <input type="hidden" name="id" value="{{ coupon.id }}">
                            <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
                            <td>
                                {{ form.string(value=coupon.string) }}
                            </td>
                            <td>
                                {% set z = form.type.process_data(coupon.type) %}
                                {{ form.type() }}
                            </td>
                            <td>
                                {{ form.value(value=coupon.value) }}
                            </td>
                            <td>
                                <div class="btn-group" role="group" aria-label="Basic example">
                                  <button class="btn btn-primary" type="submit">
                                    save
                                  </button>

                                  <button onclick="location.href='{{ url_for('shopman.coupon_delete', coupon_id=coupon.id) }}'" class="btn btn-danger" type="button">
                                    delete
                                  </button>
                                </div>
                            </td>
                            </form>
                        </tr>
                    {%endfor%}
                </tbody>
                
            </table>
        </div>
    </div>
</div>
<br>
{% endblock %}