{% load i18n %}
{% load humanize %}
{% load static %}

<div role="tabpanel" class="tab-pane fade" id="tab-assets">
    <div class="card">
        <div class="card-header bg-primary rounded-top px-2"><h3>Information Blatt</h3></div>
        <div class="card-body">
            Hier findest du alle Assets deiner Corporation die zum Verkauf stehen solltest du etwas davon kaufen wollen, wende dich bitte an den Direktoren bzw. Industrie Offizier.
        </div>
    </div>
    <br><br>
    <div class="table-responsive">
        <table class="table table-striped table-hover assets" id="assets" style="width: 100%;">
            <thead>
                <tr>
                    <th class="col-itemid" style="width: 5%;"></th>
                    <th class="col-name" style="width: 20%;">Name</th>
                    <th class="col-quantity" style="width: 5%;">{% translate "Quantity" %}</th>
                    <th class="col-location" style="width: 20%;">{% translate "Location" %}</th>
                    <th class="col-price" style="width: 20%;">{% translate "Price" %}</th>
                    <th class="col-action" style="width: 20%;">{% translate "Action" %}</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td class="col-itemid"></td>
                    <td class="col-name"></td>
                    <td class="col-quantity"></td>
                    <td class="col-location"></td>
                    <td class="col-price"></td>
                    <td class="col-action"></td>
                </tr>
            </tbody>
            <tfoot>
                <tr>
                    <td colspan="0">
                        <button type="button" class="btn btn-primary text-nowrap" data-bs-toggle="modal" data-bs-target="#buyModal" data-action="all">
                            {% translate "Specific Buy" %}
                        </button>
                    </td>
                </tr>
            </tfoot>
        </table>
    </div>
</div>

<!-- Buy Modal -->
<div class="modal fade" id="buyModal" tabindex="-1" role="dialog" aria-labelledby="buyModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="buyModalLabel">{% translate "Buy Items" %}</h5>
                <button type="button" class="btn-close py-3 px-3" data-bs-dismiss="modal" aria-label="Close">
                </button>
            </div>
            <div class="modal-body">
                <form id="buyForm" method="post" action="{% url 'assets:create_order' %}">
                    {% csrf_token %}
                    <div id="itemsList"></div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">{% translate "Close" %}</button>
                <button type="button" class="btn btn-primary" onclick="setMaxQuantities()">{% translate "Buy All" %}</button>
                <button type="button" class="btn btn-primary" id="confirmBuyButton">{% translate "Buy" %}</button>
            </div>
        </div>
    </div>
</div>

<!-- Confirmation Modal -->
<div class="modal fade" id="confirmModal" tabindex="-1" role="dialog" aria-labelledby="confirmModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="confirmModalLabel">{% translate "Confirm Purchase" %}</h5>
                <button type="button" class="btn-close py-3 px-3" data-bs-dismiss="modal" aria-label="Close">
                </button>
            </div>
            <div class="modal-body">
                <p>{% translate "Are you sure you want to proceed with the purchase?" %}</p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">{% translate "Cancel" %}</button>
                <button type="button" class="btn btn-primary" id="finalizeBuyButton">{% translate "Confirm" %}</button>
            </div>
        </div>
    </div>
</div>
