{% extends "base.html" %}

{% block content %}
<body id="page-top">

    <!-- Page Wrapper -->
    <div id="wrapper">

        {% include "nav.html" %}

        <!-- Content Wrapper -->
        <div id="content-wrapper" class="d-flex flex-column">


            <!-- Main Content -->
            <div id="content">


                <!-- Begin Page Content -->
                <div class="container-fluid">

                    <!-- Page Heading -->
                    <h1 class="h3 mb-2 text-gray-800">{{ warehouse_name }}</h1>
                        <p class="mb-4">Inventory Table</p>
                        <!-- Filter -->
                        <div class="card shadow mb-4">
                            <!-- Card Header - Accordion -->
                            <a class="d-block card-header py-3">
                                <h6 class="m-0 font-weight-bold text-primary">Filter</h6>
                            </a>
                            <!-- Card Content - Collapse -->
                            <form method="get">
                                <div class="row g-3 align-items-center mx-2 my-4">
                                        {{ filter.form.as_p }}
                                    <div class="col-auto">
                                        <button type="submit" class="btn btn-primary">Filter</button>
                                    </div>
                                    <div class="col-auto">
                                        <a href={{ request.path }} class="btn btn-danger">
                                            <i class="fas fa-trash"></i> Clear Filter
                                        </a>
                                    </div>
                                </div>
                            </form>
                        </div>
                        
                        

                        <!-- End Filter -->

                    <!-- DataTales Example -->
                    <div class="card shadow mb-4">
                        <div class="card-header py-3">
                            <h6 class="m-0 font-weight-bold text-primary">Inventory</h6>
                        </div>
                        <div class="card-body">
                            <div class="table-responsive">
                                <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
                                    <thead>
                                        <tr>
                                            <th>Inventory Name</th>
                                            <th>Current Stock</th>
                                            <th>Max Stock</th>
                                            <th>Stock Percentage</th>
                                        </tr>
                                    </thead>
                                    <tfoot>
                                        <tr>
                                            <th>Inventory Name</th>
                                            <th>Current Stock</th>
                                            <th>Max Stock</th>
                                            <th>Stock Percentage</th>
                                        </tr>
                                    </tfoot>
                                    <tbody>
                                        {% if filter.is_bound %}
                                            {% for inventory in filter.qs %}
                                            <tr>
                                                <td><a href={% url "inventory"  wid=warehouse_id iid=inventory.id %}>{{ inventory.stock_identifier }}<a/></td>
                                                <td>{{ inventory.current_stock }}</td>
                                                <td>{{ inventory.max_stock }}</td>
                                                <td>{{ inventory.stock_percentage|floatformat:3 }}</td>
                                            </tr>
                                            {% endfor %}
                                        {% else %}
                                            {% for inventory in inventory_list %}
                                            <tr>
                                                <td><a href={% url "inventory" wid=warehouse_id iid=inventory.id %}>{{ inventory.stock_identifier }}<a/></td>
                                                <td>{{ inventory.current_stock }}</td>
                                                <td>{{ inventory.max_stock }}</td>
                                                <td>{{ inventory.stock_percentage|floatformat:3 }}</td>
                                            </tr>
                                            {% endfor %}
                                        {% endif %}
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>

                </div>
                <!-- /.container-fluid -->

            </div>
            <!-- End of Main Content -->


        </div>
        <!-- End of Content Wrapper -->

    </div>
    <!-- End of Page Wrapper -->

    <!-- Scroll to Top Button-->
    <a class="scroll-to-top rounded" href="#page-top">
        <i class="fas fa-angle-up"></i>
    </a>

    {% include "footer.html" %}

</body>
{% endblock content %}