{% extends request.ajax ? 'layout_blank.html.twig' : 'layout_default.html.twig' %}

{% import 'macro_functions.html.twig' as mf %}

{% block meta_title %}{{ 'Orders settings'|trans }}{% endblock %}

{% set active_menu = 'system' %}

{% block breadcrumbs %}
    <ol class="breadcrumb">
        <li class="breadcrumb-item">
            <a href="{{ '/'|alink }}">
                <svg class="icon">
                    <use xlink:href="#home" />
                </svg>
            </a>
        </li>
        <li class="breadcrumb-item">
            <a href="{{ 'system'|alink }}">{{ 'Settings'|trans }}</a>
        </li>
        <li class="breadcrumb-item active" aria-current="page">{{ 'Orders settings'|trans }}</li>
    </ol>
{% endblock %}

{% block content %}
<div class="card">
    <div class="card-body">
        <h3>{{ 'Orders settings'|trans }}</h3>

        {% set params = admin.extension_config_get({ 'ext': 'mod_order' }) %}
        <form method="post" action="{{ 'api/admin/extension/config_save'|link }}" class="api-form" data-api-msg="{{ 'Settings updated'|trans }}">
            <input type="hidden" name="CSRFToken" value="{{ CSRFToken }}"/>
            <div class="form-group mb-3 row">
                <label class="form-label col-3 col-form-label">{{ 'Expiration date'|trans }}</label>
                <div class="col">
                    <div class="form-check">
                        <input class="form-check-input" id="radioFromExpirationDay" type="radio" name="order_renewal_logic" value="from_expiration_date"{% if params.order_renewal_logic == "from_expiration_date" or not params.order_renewal_logic %} checked{% endif %}>
                        <label class="form-check-label" for="radioFromExpirationDay">{{ 'Next date is counted from last order expiration date'|trans }}</label>
                    </div>
                    <div class="form-check">
                        <input class="form-check-input" id="radioFromToday" type="radio" name="order_renewal_logic" value="from_today"{% if params.order_renewal_logic == "from_today" %} checked{% endif %}>
                        <label class="form-check-label" for="radioFromToday">{{ 'Next date is counted from renewal (payment) date'|trans }}</label>
                    </div>
                    <div class="form-check">
                        <input class="form-check-input" id="radioFromGreater" type="radio" name="order_renewal_logic" value="from_greater"{% if params.order_renewal_logic == "from_greater" %} checked{% endif %}>
                        <label class="form-check-label" for="radioFromGreater">{{ 'Next date is counted from last expiration date or renewal date whichever is greater'|trans }}</label>
                    </div>
                </div>
            </div>
            <div class="form-group mb-3 row">
                <label class="form-label col-3 col-form-label">{{ 'Show addon orders in orders list'|trans }}</label>
                <div class="col">
                    <div class="form-check form-check-inline">
                        <input class="form-check-input" id="radioShowAddonsYes" type="radio" name="show_addons" value="1"{% if params.show_addons %} checked{% endif %}>
                        <label class="form-check-label" for="radioShowAddonsYes">{{ 'Yes'|trans }}</label>
                    </div>
                    <div class="form-check form-check-inline">
                        <input class="form-check-input" id="radioShowAddonsNo" type="radio" name="show_addons" value="0"{% if not params.show_addons %} checked{% endif %}>
                        <label class="form-check-label" for="radioShowAddonsNo">{{ 'No'|trans }}</label>
                    </div>
                    <small class="form-hint">{{ 'If this is disabled they are shown in master order view "Addons" tab.'|trans }}</small>
                </div>
            </div>
            <div class="form-group mb-3 row">
                <label class="form-label col-3 col-form-label">{{ 'Auto suspend reason'|trans }}</label>
                <div class="col">
                    <input class="form-control" type="text" name="batch_suspend_reason" value="{{ params.batch_suspend_reason }}">
                </div>
            </div>
            <div class="form-group mb-3 row">
                <label class="form-label col-3 col-form-label">{{ 'Auto Cancellation'|trans }}</label>
                <div class="col">
                    <div class="input-group">
                        <select class="form-select" name="batch_cancel_suspended">
                            <option value="1" {{ params.batch_cancel_suspended ? 'selected' : '' }}>{{ 'Cancel Suspended Orders'|trans }}</option>
                            <option value="0" {{ params.batch_cancel_suspended ? '' : 'selected' }}>{{ 'Do Not Cancel Suspended Orders'|trans }}</option>
                        </select>
                        <input class="form-control" type="text" name="batch_cancel_suspended_after_days" value="{{ params.batch_cancel_suspended_after_days }}" placeholder="7">
                        <span class="input-group-text">{{ 'days after order suspension with reason'|trans }}</span>
                        <input class="form-control" type="text" name="batch_cancel_suspended_reason" value="{{ params.batch_cancel_suspended_reason }}">
                    </div>
                </div>
            </div>
            <div class="form-group mb-3 row">
                <label class="form-label col-3 col-form-label">{{ 'Suspension reasons'|trans }}</label>
                <div class="col">
                    <textarea class="form-control" name="suspend_reason_list" rows="2">{{ params.suspend_reason_list }}</textarea>
                </div>
            </div>

            <input type="hidden" name="ext" value="mod_order">
            <button class="btn btn-primary w-100" type="submit">{{ 'Update'|trans }}</button>
        </form>
    </div>
</div>
{% endblock %}