mirror of
https://github.com/Sosokker/Inventory-Management-System.git
synced 2025-12-19 15:34:04 +01:00
Add filter to warehouse table
This commit is contained in:
parent
2774d15378
commit
9ebf8268fc
7
inventory/filters.py
Normal file
7
inventory/filters.py
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import django_filters
|
||||||
|
from inventory.models import Warehouse
|
||||||
|
|
||||||
|
class WarehouseFilter(django_filters.FilterSet):
|
||||||
|
class Meta:
|
||||||
|
model = Warehouse
|
||||||
|
fields = ['name', 'address', 'have_freeze']
|
||||||
@ -1,6 +1,8 @@
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.views.generic import TemplateView
|
from django.views.generic import TemplateView
|
||||||
|
from django_filters.views import FilterView
|
||||||
|
from inventory.filters import WarehouseFilter
|
||||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
|
|
||||||
@ -25,8 +27,10 @@ class OverviewView(TemplateView, LoginRequiredMixin):
|
|||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
class WarehouseView(TemplateView, LoginRequiredMixin):
|
class WarehouseView(FilterView, LoginRequiredMixin):
|
||||||
|
model = Warehouse
|
||||||
template_name = "inventory/warehouse.html"
|
template_name = "inventory/warehouse.html"
|
||||||
|
filterset_class = WarehouseFilter
|
||||||
|
|
||||||
def get_context_data(self, **kwargs: Any) -> dict[str, Any]:
|
def get_context_data(self, **kwargs: Any) -> dict[str, Any]:
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
|
|||||||
89
templates/inventory/inventory.html
Normal file
89
templates/inventory/inventory.html
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
{% 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 Tables</h1>
|
||||||
|
<p class="mb-4">Warehouse Table</p>
|
||||||
|
|
||||||
|
<!-- DataTales Example -->
|
||||||
|
<div class="card shadow mb-4">
|
||||||
|
<div class="card-header py-3">
|
||||||
|
<h6 class="m-0 font-weight-bold text-primary">Warehouse</h6>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Address</th>
|
||||||
|
<th>Stock Level</th>
|
||||||
|
<th>Number of Inventory</th>
|
||||||
|
<th>Have Freezer</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Address</th>
|
||||||
|
<th>Stock Level</th>
|
||||||
|
<th>Number of Inventory</th>
|
||||||
|
<th>Have Freezer</th>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
<tbody>
|
||||||
|
{% for warehouse in warehouse_list %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ warehouse.name }}</td>
|
||||||
|
<td>{{ warehouse.address }}</td>
|
||||||
|
<td>{{ warehouse.stock_percentage|floatformat:3 }}</td>
|
||||||
|
<td>{{ warehouse.inventory_count }}</td>
|
||||||
|
<td>{{ warehouse.have_freeze }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</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 %}
|
||||||
@ -22,6 +22,41 @@
|
|||||||
<!-- Page Heading -->
|
<!-- Page Heading -->
|
||||||
<h1 class="h3 mb-2 text-gray-800">Warehouse Tables</h1>
|
<h1 class="h3 mb-2 text-gray-800">Warehouse Tables</h1>
|
||||||
<p class="mb-4">Warehouse Table</p>
|
<p class="mb-4">Warehouse 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">
|
||||||
|
<div class="col-auto">
|
||||||
|
Name
|
||||||
|
{{ filter.form.name }}
|
||||||
|
</div>
|
||||||
|
<div class="col-auto">
|
||||||
|
Address
|
||||||
|
{{ filter.form.address }}
|
||||||
|
</div>
|
||||||
|
<div class="col-auto">
|
||||||
|
{{ filter.form.have_freeze }}
|
||||||
|
</div>
|
||||||
|
<div class="col-auto">
|
||||||
|
<button type="submit" class="btn btn-primary">Filter</button>
|
||||||
|
</div>
|
||||||
|
<div class="col-auto">
|
||||||
|
<a href="{% url 'warehouse' %}" class="btn btn-danger">
|
||||||
|
<i class="fas fa-trash"></i> Clear Filter
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- End Filter -->
|
||||||
|
|
||||||
<!-- DataTales Example -->
|
<!-- DataTales Example -->
|
||||||
<div class="card shadow mb-4">
|
<div class="card shadow mb-4">
|
||||||
@ -35,6 +70,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th>Address</th>
|
<th>Address</th>
|
||||||
|
<th>Stock Level</th>
|
||||||
<th>Number of Inventory</th>
|
<th>Number of Inventory</th>
|
||||||
<th>Have Freezer</th>
|
<th>Have Freezer</th>
|
||||||
</tr>
|
</tr>
|
||||||
@ -43,19 +79,33 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th>Address</th>
|
<th>Address</th>
|
||||||
|
<th>Stock Level</th>
|
||||||
<th>Number of Inventory</th>
|
<th>Number of Inventory</th>
|
||||||
<th>Have Freezer</th>
|
<th>Have Freezer</th>
|
||||||
</tr>
|
</tr>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for warehouse in warehouse_list %}
|
{% if filter.is_bound %}
|
||||||
<tr>
|
{% for warehouse in filter.qs %}
|
||||||
<td>{{ warehouse.name }}</td>
|
<tr>
|
||||||
<td>{{ warehouse.address }}</td>
|
<td>{{ warehouse.name }}</td>
|
||||||
<td>{{ warehouse.inventory_count }}</td>
|
<td>{{ warehouse.address }}</td>
|
||||||
<td>{{ warehouse.have_freeze }}</td>
|
<td>{{ warehouse.stock_percentage|floatformat:3 }}</td>
|
||||||
</tr>
|
<td>{{ warehouse.inventory_count }}</td>
|
||||||
{% endfor %}
|
<td>{{ warehouse.have_freeze }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
|
{% for warehouse in warehouse_list %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ warehouse.name }}</td>
|
||||||
|
<td>{{ warehouse.address }}</td>
|
||||||
|
<td>{{ warehouse.stock_percentage|floatformat:3 }}</td>
|
||||||
|
<td>{{ warehouse.inventory_count }}</td>
|
||||||
|
<td>{{ warehouse.have_freeze }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user