mirror of
https://github.com/Sosokker/Inventory-Management-System.git
synced 2025-12-18 23:24:05 +01:00
Add order listing view
This commit is contained in:
parent
7c841cf5f6
commit
8fef2aa3e8
@ -4,7 +4,8 @@ from django.views.generic.base import RedirectView
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
path("accounts/", include("django.contrib.auth.urls")), # new
|
||||
path("accounts/", include("django.contrib.auth.urls")),
|
||||
path('', include('inventory.urls'), name='dashboard'),
|
||||
path('', include('transaction.urls'), name='transaction'),
|
||||
path('', RedirectView.as_view(url='/overview/')),
|
||||
]
|
||||
|
||||
@ -43,17 +43,9 @@ Storage
|
||||
Manage
|
||||
</div>
|
||||
|
||||
<!-- Nav Item - Customer -->
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">
|
||||
<i class="fas fa-fw fa-folder"></i>
|
||||
<span>Customer</span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<!-- Nav Item - Order -->
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="charts.html">
|
||||
<a class="nav-link" href={% url "customer-order" %}>
|
||||
<i class="fas fa-fw fa-chart-area"></i>
|
||||
<span>Order</span></a>
|
||||
</li>
|
||||
|
||||
128
templates/transaction/order_filter.html
Normal file
128
templates/transaction/order_filter.html
Normal file
@ -0,0 +1,128 @@
|
||||
{% 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">Order Listing</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" class="px-2">
|
||||
<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">Order</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Customer</th>
|
||||
<th>Item</th>
|
||||
<th>Order Date</th>
|
||||
<th>Quantity</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Customer</th>
|
||||
<th>Item</th>
|
||||
<th>Order Date</th>
|
||||
<th>Quantity</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
<tbody>
|
||||
{% if filter.is_bound %}
|
||||
{% for order in filter.qs %}
|
||||
<tr>
|
||||
{% comment %} <td><a href={% url "inventory" wid=warehouse_id iid=inventory.id %}>{{ inventory.stock_identifier }}<a/></td> {% endcomment %}
|
||||
<td>{{ order.id }}</td>
|
||||
<td>{{ order.customer }}</td>
|
||||
<td>{{ order.item }}</td>
|
||||
<td>{{ order.order_date }}</td>
|
||||
<td>{{ order.quantity }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
{% for order in order_list %}
|
||||
<tr>
|
||||
{% comment %} <td><a href={% url "inventory" wid=warehouse_id iid=inventory.id %}>{{ inventory.stock_identifier }}<a/></td> {% endcomment %}
|
||||
<td>{{ order.id }}</td>
|
||||
<td>{{ order.customer }}</td>
|
||||
<td>{{ order.item }}</td>
|
||||
<td>{{ order.order_date }}</td>
|
||||
<td>{{ order.quantity }}</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 %}
|
||||
12
transaction/filters.py
Normal file
12
transaction/filters.py
Normal file
@ -0,0 +1,12 @@
|
||||
from django import forms
|
||||
import django_filters
|
||||
from transaction.models import Order
|
||||
|
||||
class OrderFilter(django_filters.FilterSet):
|
||||
customer_name = django_filters.CharFilter(field_name='customer__name', lookup_expr='icontains', label='Customer Name')
|
||||
item_name = django_filters.CharFilter(field_name='item__name', lookup_expr='icontains', label='Item Name')
|
||||
order_date = django_filters.DateFilter(field_name='order_date', label='Order Date (YYYY-MM-DD)', widget=forms.DateInput(attrs={'type': 'date'}))
|
||||
|
||||
class Meta:
|
||||
model = Order
|
||||
fields = ['customer_name', 'item_name', 'order_date']
|
||||
7
transaction/urls.py
Normal file
7
transaction/urls.py
Normal file
@ -0,0 +1,7 @@
|
||||
from django.urls import path
|
||||
|
||||
from transaction.views import CustomerOrderView
|
||||
|
||||
urlpatterns = [
|
||||
path('order/', CustomerOrderView.as_view(), name='customer-order'),
|
||||
]
|
||||
@ -1,3 +1,19 @@
|
||||
from django.shortcuts import render
|
||||
from django_filters.views import FilterView
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from transaction.models import Order, Customer
|
||||
from transaction.filters import OrderFilter
|
||||
|
||||
# Create your views here.
|
||||
class CustomerOrderView(FilterView, LoginRequiredMixin):
|
||||
template_name = 'transaction/order_filter.html'
|
||||
model = Order
|
||||
filterset_class = OrderFilter
|
||||
context_object_name = 'orders'
|
||||
|
||||
def get_queryset(self):
|
||||
queryset = super().get_queryset()
|
||||
return queryset.filter(customer__isnull=False) # Exclude orders without a customer
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['customers'] = Customer.objects.all()
|
||||
return context
|
||||
Loading…
Reference in New Issue
Block a user