{#**
 * _             _       _
 * | |____      _| | __ _| |__
 * | '_ \ \ /\ / / |/ _` | '_ \
 * | |_) \ V  V /| | (_| | |_) |
 * |_.__/ \_/\_/ |_|\__,_|_.__/.
 *
 * @author    Bwlab di Luigi Massa <info@bwlab.it>
 * @copyright since 2014 Bwlab
 * @license   proprietary
 *#}
{% extends '@PrestaShop/Admin/layout.html.twig' %}

{% set layoutTitle = ('Withdrawal Request #' ~ withdrawal_request.id)|trans({}, 'Modules.Bwwithdrawal.Admin') %}

{% set layoutHeaderToolbarBtn = {
    back: {
        href: path('admin_bwwithdrawal_requests_index'),
        desc: 'Back to list'|trans({}, 'Admin.Actions'),
        icon: 'arrow_back',
    }
} %}

{% block content %}
<div class="card">
    <div class="card-body">
        <table class="table">
            <tr><th>{{ 'ID'|trans({}, 'Admin.Global') }}</th><td>#{{ withdrawal_request.id }}</td></tr>
            <tr><th>{{ 'Order'|trans({}, 'Admin.Global') }}</th>
                <td>
                    <a href="{{ path('admin_orders_view', {orderId: withdrawal_request.idOrder}) }}">
                        {{ withdrawal_request.orderReference }}
                    </a>
                </td>
            </tr>
            <tr><th>{{ 'Customer'|trans({}, 'Admin.Global') }}</th><td>{{ withdrawal_request.customerName }}</td></tr>
            <tr><th>{{ 'Email'|trans({}, 'Admin.Global') }}</th><td>{{ withdrawal_request.customerEmail }}</td></tr>
            <tr><th>{{ 'Status'|trans({}, 'Admin.Global') }}</th><td><span class="badge">{{ withdrawal_request.status }}</span></td></tr>
            <tr><th>{{ 'Date'|trans({}, 'Admin.Global') }}</th><td>{{ withdrawal_request.dateAdd|date('d/m/Y H:i') }}</td></tr>
            <tr><th>{{ 'Deadline'|trans({}, 'Modules.Bwwithdrawal.Admin') }}</th><td>{{ withdrawal_request.withdrawalDeadline|date('d/m/Y') }}</td></tr>

            {% if withdrawal_request.notes %}
            <tr><th>{{ 'Notes'|trans({}, 'Admin.Global') }}</th><td><pre>{{ withdrawal_request.notes }}</pre></td></tr>
            {% endif %}
        </table>
    </div>
</div>

<div class="card mt-2">
    <div class="card-header"><h3>{{ 'Update status'|trans({}, 'Modules.Bwwithdrawal.Admin') }}</h3></div>
    <div class="card-body">
        <form method="post" action="{{ path('admin_bwwithdrawal_requests_update_status', {requestId: withdrawal_request.id}) }}">
            <input type="hidden" name="_token" value="{{ csrf_token('admin') }}">
            <div class="form-group">
                <label>{{ 'Status'|trans({}, 'Admin.Global') }}</label>
                <select name="status" class="form-control">
                    {% for s in ['pending', 'processing', 'completed', 'rejected'] %}
                        <option value="{{ s }}" {{ withdrawal_request.status == s ? 'selected' }}>{{ s }}</option>
                    {% endfor %}
                </select>
            </div>
            <div class="form-group">
                <label>{{ 'Internal note'|trans({}, 'Modules.Bwwithdrawal.Admin') }}</label>
                <textarea name="note" class="form-control" rows="2"></textarea>
                <small class="form-text text-muted">{{ 'Operator log only — not sent to the customer.'|trans({}, 'Modules.Bwwithdrawal.Admin') }}</small>
            </div>
            <div class="form-group">
                <label>{{ 'Note for customer'|trans({}, 'Modules.Bwwithdrawal.Admin') }}</label>
                <textarea name="customer_note" class="form-control" rows="3"></textarea>
                <small class="form-text text-muted">{{ 'Included in the status update email sent to the customer.'|trans({}, 'Modules.Bwwithdrawal.Admin') }}</small>
            </div>
            <button type="submit" class="btn btn-primary">{{ 'Save'|trans({}, 'Admin.Actions') }}</button>
        </form>
    </div>
</div>
{% endblock %}
