{% extends "base.html" %}

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

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

        {% include "nav.html" %}

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

                    <!-- Page Heading -->
                    <div class="d-sm-flex align-items-center justify-content-between mb-4">
                        <h1 class="h3 mb-0 text-gray-800">Overview</h1>
                    </div>

                    <!-- Content Row -->
                    <div class="row">

                        <!-- Warehouse Count Card Example -->
                        <div class="col-xl-3 col-md-6 mb-4">
                            <div class="card border-left-primary shadow h-100 py-2">
                                <div class="card-body">
                                    <div class="row no-gutters align-items-center">
                                        <div class="col mr-2">
                                            <div class="text-xs font-weight-bold text-primary text-uppercase mb-1">
                                                Warehouse Count</div>
                                            <div class="h5 mb-0 font-weight-bold text-gray-800">{{ warehouse_count }}</div>
                                        </div>
                                        <div class="col-auto">
                                            <i class="fas fa-cube fa-2x text-gray-300"></i>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <!-- Customer Count Card Example -->
                        <div class="col-xl-3 col-md-6 mb-4">
                            <div class="card border-left-success shadow h-100 py-2">
                                <div class="card-body">
                                    <div class="row no-gutters align-items-center">
                                        <div class="col mr-2">
                                            <div class="text-xs font-weight-bold text-success text-uppercase mb-1">
                                                Customer Count</div>
                                            <div class="h5 mb-0 font-weight-bold text-gray-800">{{ customer_count }}</div>
                                        </div>
                                        <div class="col-auto">
                                            <i class="fas fa-dollar-sign fa-2x text-gray-300"></i>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <!-- Stock Level Card Example -->
                        <div class="col-xl-3 col-md-6 mb-4">
                            <div class="card border-left-info shadow h-100 py-2">
                                <div class="card-body">
                                    <div class="row no-gutters align-items-center">
                                        <div class="col mr-2">
                                            <div class="text-xs font-weight-bold text-info text-uppercase mb-1">Stock Level
                                            </div>
                                            <div class="row no-gutters align-items-center">
                                                <div class="col-auto">
                                                    <div class="h5 mb-0 mr-3 font-weight-bold text-gray-800">{{ stock_percentage|floatformat:3 }}%</div>
                                                </div>
                                                <div class="col">
                                                    <div class="progress progress-sm mr-2">
                                                        <div class="progress-bar bg-info" role="progressbar"
                                                            style="width: {{ stock_percentage }}%" aria-valuenow="50" aria-valuemin="0"
                                                            aria-valuemax="100"></div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-auto">
                                            <i class="fas fa-clipboard-list fa-2x text-gray-300"></i>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <!-- Pending Supply Card Example -->
                        <div class="col-xl-3 col-md-6 mb-4">
                            <div class="card border-left-warning shadow h-100 py-2">
                                <div class="card-body">
                                    <div class="row no-gutters align-items-center">
                                        <div class="col mr-2">
                                            <div class="text-xs font-weight-bold text-warning text-uppercase mb-1">
                                                Pending Supply</div>
                                            <div class="h5 mb-0 font-weight-bold text-gray-800">{{ pending_supply }}</div>
                                        </div>
                                        <div class="col-auto">
                                            <i class="fas fa-comments fa-2x text-gray-300"></i>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                    <!-- Inventory Count -->
                        <div class="col-xl-3 col-md-6 mb-4">
                            <div class="card border-left-success shadow h-100 py-2">
                                <div class="card-body">
                                    <div class="row no-gutters align-items-center">
                                        <div class="col mr-2">
                                            <div class="text-xs font-weight-bold text-success text-uppercase mb-1">
                                                Inventory Count</div>
                                            <div class="h5 mb-0 font-weight-bold text-gray-800">{{ inventory_count }}</div>
                                        </div>
                                        <div class="col-auto">
                                            <i class="fas fa-layer-group fa-2x text-gray-300"></i>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                    <!-- Order Count -->
                        <div class="col-xl-3 col-md-6 mb-4">
                            <div class="card border-left-warning shadow h-100 py-2">
                                <div class="card-body">
                                    <div class="row no-gutters align-items-center">
                                        <div class="col mr-2">
                                            <div class="text-xs font-weight-bold text-warning text-uppercase mb-1">
                                                Order Count</div>
                                            <div class="h5 mb-0 font-weight-bold text-gray-800">{{ order_count }}</div>
                                        </div>
                                        <div class="col-auto">
                                            <i class="fas fa-pen fa-2x text-gray-300"></i>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        
                        <!-- Item in Stock -->
                            <div class="col-xl-3 col-md-6 mb-4">
                                <div class="card border-left-info shadow h-100 py-2">
                                    <div class="card-body">
                                        <div class="row no-gutters align-items-center">
                                            <div class="col mr-2">
                                                <div class="text-xs font-weight-bold text-info text-uppercase mb-1">
                                                    Item in Stock</div>
                                                <div class="h5 mb-0 font-weight-bold text-gray-800">{{ item_count }}</div>
                                            </div>
                                            <div class="col-auto">
                                                <i class="fas fa-icons fa-2x text-gray-300"></i>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>

                    <!-- Transfer Count -->
                        <div class="col-xl-3 col-md-6 mb-4">
                            <div class="card border-left-primary  shadow h-100 py-2">
                                <div class="card-body">
                                    <div class="row no-gutters align-items-center">
                                        <div class="col mr-2">
                                            <div class="text-xs font-weight-bold text-primary  text-uppercase mb-1">
                                                Transfer Count</div>
                                            <div class="h5 mb-0 font-weight-bold text-gray-800">{{ transfer_count }}</div>
                                        </div>
                                        <div class="col-auto">
                                            <i class="fas fa-paste fa-2x text-gray-300"></i>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- Stock -->  
                    <div class="row">

                        <!-- Content Column -->
                        <div class="col-lg mb-4">

                            <!-- Project Card Example -->
                            <div class="card shadow mb-4">
                                <div class="card-header py-3">
                                    <h6 class="m-0 font-weight-bold text-primary">Warehouse Stock Level</h6>
                                </div>
                                <div class="card-body">
                                    {% if warehouse_list|length != 0 %}
                                        {% for warehouse in warehouse_list %}
                                        <h4 class="small font-weight-bold my-2">{{ warehouse.name }} <span class="float-right">
                                            {% if warehouse.stock_percentage == 100 %}Complete!{% else %}{{ warehouse.stock_percentage|floatformat:3 }}%{% endif %}
                                        </span></h4>
                                        <div class="progress">
                                            <div class="progress-bar bg-success" role="progressbar" style="width: {{ warehouse.stock_percentage }}%" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100"></div>
                                        </div>
                                        {% endfor %}
                                        {% else %}
                                        <h2>No Warehouse Available!</h2>
                                    {% endif %}
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- Inventory -->             
                    <div class="row">

                        <!-- Content Column -->
                        <div class="col-lg mb-4">

                            <!-- Project Card Example -->
                            <div class="card shadow mb-4">
                                <div class="card-header py-3">
                                    <h6 class="m-0 font-weight-bold text-primary">Inventory Stock Level</h6>
                                </div>
                                <div class="card-body">
                                    {% if inventory_list|length != 0 %}
                                        {% for inv in inventory_list %}
                                        <h4 class="small font-weight-bold my-2">{{ inv.stock_identifier }} <span class="float-right">
                                            {% if inv.stock_percentage == 100 %}Complete!{% else %}{{ inv.stock_percentage|floatformat:3 }}%{% endif %}
                                        </span></h4>
                                        <div class="progress">
                                            <div class="progress-bar bg-success" role="progressbar" style="width: {{ inv.stock_percentage }}%" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100"></div>
                                        </div>
                                        {% endfor %}
                                        {% else %}
                                        <h2>No Inventory Available!</h2>
                                    {% endif %}
                                </div>
                            </div>
                        </div>
                    </div>

                </div>

            </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 %}