mirror of
https://github.com/Sosokker/Inventory-Management-System.git
synced 2025-12-19 15:34:04 +01:00
Add transfer view and filter
This commit is contained in:
parent
8fef2aa3e8
commit
93e97cc434
@ -52,7 +52,7 @@ Manage
|
|||||||
|
|
||||||
<!-- Nav Item - Transfer -->
|
<!-- Nav Item - Transfer -->
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="tables.html">
|
<a class="nav-link" href={% url "transfer-list" %}>
|
||||||
<i class="fas fa-fw fa-table"></i>
|
<i class="fas fa-fw fa-table"></i>
|
||||||
<span>Transfer</span></a>
|
<span>Transfer</span></a>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
128
templates/transaction/transfer.html
Normal file
128
templates/transaction/transfer.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>Transfer From</th>
|
||||||
|
<th>Transfer To</th>
|
||||||
|
<th>Item Name</th>
|
||||||
|
<th>Quantity</th>
|
||||||
|
<th>Updated Time</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<th>Transfer From</th>
|
||||||
|
<th>Transfer To</th>
|
||||||
|
<th>Item Name</th>
|
||||||
|
<th>Quantity</th>
|
||||||
|
<th>Updated Time</th>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
<tbody>
|
||||||
|
{% if filter.is_bound %}
|
||||||
|
{% for transfer in filter.qs %}
|
||||||
|
<tr>
|
||||||
|
{% comment %} <td><a href={% url "inventory" wid=warehouse_id iid=inventory.id %}>{{ inventory.stock_identifier }}<a/></td> {% endcomment %}
|
||||||
|
<td>{{ transfer.from_warehouse }}</td>
|
||||||
|
<td>{{ transfer.to_warehouse }}</td>
|
||||||
|
<td>{{ transfer.item }}</td>
|
||||||
|
<td>{{ transfer.quantity }}</td>
|
||||||
|
<td>{{ transfer.update_time }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
|
{% for transfer in transfer_list %}
|
||||||
|
<tr>
|
||||||
|
{% comment %} <td><a href={% url "inventory" wid=warehouse_id iid=inventory.id %}>{{ inventory.stock_identifier }}<a/></td> {% endcomment %}
|
||||||
|
<td>{{ transfer.from_warehouse }}</td>
|
||||||
|
<td>{{ transfer.to_warehouse }}</td>
|
||||||
|
<td>{{ transfer.item }}</td>
|
||||||
|
<td>{{ transfer.quantity }}</td>
|
||||||
|
<td>{{ transfer.update_time }}</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 %}
|
||||||
@ -1,6 +1,6 @@
|
|||||||
from django import forms
|
from django import forms
|
||||||
import django_filters
|
import django_filters
|
||||||
from transaction.models import Order
|
from transaction.models import Order, Transfer
|
||||||
|
|
||||||
class OrderFilter(django_filters.FilterSet):
|
class OrderFilter(django_filters.FilterSet):
|
||||||
customer_name = django_filters.CharFilter(field_name='customer__name', lookup_expr='icontains', label='Customer Name')
|
customer_name = django_filters.CharFilter(field_name='customer__name', lookup_expr='icontains', label='Customer Name')
|
||||||
@ -10,3 +10,13 @@ class OrderFilter(django_filters.FilterSet):
|
|||||||
class Meta:
|
class Meta:
|
||||||
model = Order
|
model = Order
|
||||||
fields = ['customer_name', 'item_name', 'order_date']
|
fields = ['customer_name', 'item_name', 'order_date']
|
||||||
|
|
||||||
|
|
||||||
|
class TransferFilter(django_filters.FilterSet):
|
||||||
|
from_warehouse = django_filters.CharFilter(field_name='from_warehouse__name', lookup_expr='icontains', label='From Warehouse')
|
||||||
|
to_warehouse = django_filters.CharFilter(field_name='to_warehouse__name', lookup_expr='icontains', label='To Warehouse')
|
||||||
|
item_name = django_filters.CharFilter(field_name='item__name', lookup_expr='icontains', label='Item Name')
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = Transfer
|
||||||
|
fields = ['from_warehouse', 'to_warehouse', 'item_name']
|
||||||
@ -1,7 +1,8 @@
|
|||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
|
||||||
from transaction.views import CustomerOrderView
|
from transaction.views import CustomerOrderView, TransferListView
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('order/', CustomerOrderView.as_view(), name='customer-order'),
|
path('order/', CustomerOrderView.as_view(), name='customer-order'),
|
||||||
|
path('transfers/', TransferListView.as_view(), name='transfer-list'),
|
||||||
]
|
]
|
||||||
|
|||||||
@ -1,19 +1,31 @@
|
|||||||
from django_filters.views import FilterView
|
from django_filters.views import FilterView
|
||||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
from transaction.models import Order, Customer
|
from transaction.models import Order, Transfer
|
||||||
from transaction.filters import OrderFilter
|
from transaction.filters import OrderFilter, TransferFilter
|
||||||
|
|
||||||
class CustomerOrderView(FilterView, LoginRequiredMixin):
|
class CustomerOrderView(FilterView, LoginRequiredMixin):
|
||||||
template_name = 'transaction/order_filter.html'
|
template_name = 'transaction/order.html'
|
||||||
model = Order
|
model = Order
|
||||||
filterset_class = OrderFilter
|
filterset_class = OrderFilter
|
||||||
context_object_name = 'orders'
|
context_object_name = 'orders'
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
queryset = super().get_queryset()
|
queryset = super().get_queryset()
|
||||||
return queryset.filter(customer__isnull=False) # Exclude orders without a customer
|
return queryset.filter(customer__isnull=False)
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context['customers'] = Customer.objects.all()
|
context['order_list'] = Order.objects.all()
|
||||||
|
return context
|
||||||
|
|
||||||
|
|
||||||
|
class TransferListView(FilterView):
|
||||||
|
template_name = 'transaction/transfer.html'
|
||||||
|
model = Transfer
|
||||||
|
filterset_class = TransferFilter
|
||||||
|
context_object_name = 'transfers_list'
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super().get_context_data(**kwargs)
|
||||||
|
context['transfer_list'] = Transfer.objects.all()
|
||||||
return context
|
return context
|
||||||
Loading…
Reference in New Issue
Block a user