{% if order.status == 'active' %}
<div class="card mb-4">
    <div class="card-header">
        <h1>{{ order.title }}</h1>
    </div>
    <div class="card-body">
        <h2>{{ 'License Details'|trans }}</h2>
        <table class="table table-striped table-bordered table-sm">
            <tbody>
            <tr>
                <td>{{ 'Key'|trans }}</td>
                <td>
                    <strong>{{ service.license_key }}</strong>
                </td>
            </tr>

            {% if service.validate_ip %}
            <tr>
                <td>
                    {{ 'Valid IPs'|trans }}
                </td>
                <td>
                    {% for ip in service.ips %}
                    {{ ip }} <br/>
                    {% else %}
                    {{ 'All IPs'|trans }}
                    {% endfor %}
                </td>
            </tr>
            {% endif %}

            {% if service.validate_host %}
            <tr>
                <td>
                    {{ 'Valid Domains'|trans }}
                </td>
                <td>
                    {% for host in service.hosts %}
                    {{ host }} <br/>
                    {% else %}
                    {{ 'All Hosts'|trans }}
                    {% endfor %}
                </td>
            </tr>
            {% endif %}

            {% if service.validate_version %}
            <tr>
                <td>
                    {{ 'Valid Versions'|trans }}
                </td>
                <td>
                    {% for version in service.versions %}
                    {{ version }} <br/>
                    {% else %}
                    {{ 'All Versions'|trans }}
                    {% endfor %}
                </td>
            </tr>
            {% endif %}

            {% if service.validate_path %}
            <tr>
                <td>
                    {{ 'Valid Installation Paths'|trans }}
                </td>
                <td>
                    {% for path in service.paths %}
                    {{ path }} <br/>
                    {% else %}
                    {{ 'All Paths'|trans }}
                    {% endfor %}
                </td>
            </tr>
            {% endif %}

            </tbody>
        </table>

        <h2>{{ 'Reset License'|trans }}</h2>
        <p>{{ 'You can reset your license parameters if you have changed your server'|trans }}</p>
        <div class="block">
            <p><button class="btn btn-primary" type="button" id="license-reset">{{ 'Reset'|trans }}</button></p>
        </div>
    </div>
</div>

{% block js %}
<script>
    document.querySelector('#license-reset').addEventListener('click', (event) => {
        event.preventDefault();

        if (confirm("{{ 'Are you sure?'|trans }}")) {
            FOSSBilling.api.client.post('servicelicense/reset', { order_id: {{ order.id }} },
                (result) => {
                    FOSSBilling.message("{{ 'License was reset'|trans }}");
                });
        }
    });
</script>
{% endblock %}
{% endif %}
