diff --git a/booking/urls.py b/booking/urls.py index d411529..c91d3ee 100644 --- a/booking/urls.py +++ b/booking/urls.py @@ -1,7 +1,8 @@ from django.urls import path -from booking.views import CreateBookingView +from booking.views import CreateBookingView, BookingListView urlpatterns = [ path('client/', CreateBookingView.as_view(), name='client_booking'), + path('employee_bookings', BookingListView.as_view(), name='employee_bookings'), ] \ No newline at end of file diff --git a/booking/views.py b/booking/views.py index 03a2fa5..fb9bb64 100644 --- a/booking/views.py +++ b/booking/views.py @@ -1,10 +1,10 @@ from django.shortcuts import render from django.urls import reverse_lazy -from django.views.generic import CreateView +from django.views.generic import CreateView, ListView from booking.forms import BookingCreateForm from booking.models import Booking -from common.utils import filter_queryset_by_user +from common.utils.utils import filter_queryset_by_user # Create your views here. @@ -42,4 +42,11 @@ class CreateBookingView(CreateView): form.instance.vehicles_left = form.cleaned_data.get('vehicles') if self.request.user.line: form.instance.line = self.request.user.line - return super().form_valid(form) \ No newline at end of file + return super().form_valid(form) + + +class BookingListView(ListView): + template_name = 'employee/booking-list.html' + model = Booking + context_object_name = 'bookings' + paginate_by = 30 # Number of containers per page diff --git a/containers/services.py b/containers/services.py new file mode 100644 index 0000000..f340f22 --- /dev/null +++ b/containers/services.py @@ -0,0 +1,14 @@ +from containers.models import Container + +def get_container_for_booking(booking): + filters = { + 'expedited': False, + } + + if booking.container_number: + filters['container_number'] = booking.container_number + else: + filters['container_type'] = booking.container_type + filters['line'] = booking.line + + return Container.objects.filter(**filters).order_by('created_at').first() \ No newline at end of file diff --git a/containers/urls.py b/containers/urls.py index 6542082..d110fc1 100644 --- a/containers/urls.py +++ b/containers/urls.py @@ -1,9 +1,10 @@ from django.urls import include, path -from containers.views import ContainerReceive, ContainerExpedition, ContainerSearchView +from containers.views import ContainerReceive, ContainerExpedition, ContainerSearchView, ContainersListView urlpatterns = [ path('search', ContainerSearchView.as_view(), name='container_search'), + path('employee_containers', ContainersListView.as_view(), name='employee_containers'), path('/', include([ path('receive', ContainerReceive.as_view(), name='container_receive'), path('expedition', ContainerExpedition.as_view(), name='container_expedition'), diff --git a/containers/views.py b/containers/views.py index d24867b..1718ee6 100644 --- a/containers/views.py +++ b/containers/views.py @@ -1,9 +1,9 @@ from django.shortcuts import render, redirect from django.urls import reverse_lazy from django.views import View -from django.views.generic import CreateView, UpdateView, FormView +from django.views.generic import CreateView, UpdateView, FormView, ListView -from common.utils import get_container_by_number +from common.utils.utils import get_container_by_number from containers.forms import ContainerReceiveForm, ContainerExpeditionForm from containers.models import Container from preinfo.models import Preinfo @@ -94,5 +94,12 @@ class ContainerExpedition(UpdateView): - +class ContainersListView(ListView): + template_name = 'employee/containers-list.html' + model = Container + context_object_name = 'containers' + paginate_by = 30 # Number of containers per page + # def get(self, request): + # containers = Container.objects.order_by('-received_on').all()[:10] # Fetch the last 10 containers + # return render(request, self.template_name, {'containers': containers}) diff --git a/preinfo/urls.py b/preinfo/urls.py index 361a691..2be1034 100644 --- a/preinfo/urls.py +++ b/preinfo/urls.py @@ -1,8 +1,9 @@ from django.urls import path -from preinfo.views import ClientPreinfoView, check_preinfo, PreinfoSearchView +from preinfo.views import ClientPreinfoView, check_preinfo, PreinfoSearchView, PreinfoListView urlpatterns = [ path('client/', ClientPreinfoView.as_view(), name='client_preinfo'), path('check-preinfo/', check_preinfo, name='check_preinfo'), path('preinfo-search/', PreinfoSearchView.as_view(), name='preinfo_search'), + path('employee_preinfo/', PreinfoListView.as_view(), name='employee_preinfo'), ] \ No newline at end of file diff --git a/preinfo/views.py b/preinfo/views.py index c810e95..0c1fe1c 100644 --- a/preinfo/views.py +++ b/preinfo/views.py @@ -6,9 +6,9 @@ from django.http import JsonResponse from django.shortcuts import render, redirect from django.urls import reverse_lazy from django.views import View -from django.views.generic import TemplateView, FormView, CreateView +from django.views.generic import TemplateView, FormView, CreateView, ListView -from common.utils import filter_queryset_by_user, get_preinfo_by_number +from common.utils.utils import filter_queryset_by_user, get_preinfo_by_number from preinfo.forms import PreinfoBaseForm, PreinfoCreateForm from preinfo.models import Preinfo @@ -79,4 +79,11 @@ class PreinfoSearchView(View): next_url = request.POST.get('param') return redirect(next_url, pk=preinfo.pk) - return render(request, self.template_name, {'error': 'Not found'}) \ No newline at end of file + return render(request, self.template_name, {'error': 'Not found'}) + + +class PreinfoListView(ListView): + model = Preinfo + template_name = 'employee/preinfo-list.html' + context_object_name = 'preinfos' + paginate_by = 30 # Number of items per page diff --git a/templates/employee-sidebar.html b/templates/employee-sidebar.html index 1e4e996..8f159a2 100644 --- a/templates/employee-sidebar.html +++ b/templates/employee-sidebar.html @@ -13,23 +13,23 @@ Dashboard - + - Container Preinfo + Available Containers - + Bookings - + - Reports + Preinfos {% if request.user.UserType.ADMIN %} @@ -40,8 +40,27 @@ - Settings + Accounts + +{#
Account
#} + + + + + + Companies + + + + + + + + Lines + + + {% endif %} diff --git a/templates/employee/booking-list.html b/templates/employee/booking-list.html new file mode 100644 index 0000000..2a0a636 --- /dev/null +++ b/templates/employee/booking-list.html @@ -0,0 +1,40 @@ +{% extends 'employee-base.html' %} +{% load static %} + +{% block content %} + + + + + + + + + + + + + + + {% for booking in bookings %} + + + + + + + + + + + + + + + {% endfor %} + +
StatusBooking №VehiclesContainer numberContainer typeContainer countLineCarrierContainers expeditedVehicles left
{{ booking.status }}{{ booking.number }}{{ booking.vehicles }}{{ booking.container_number }}{{ booking.container_type }}{{ booking.container_count }}{{ booking.line.short_name }}{{ booking.carrier }}{{ booking.container_expedited_count }}{{ booking.vehicles_left }} +{# Edit |#} +{# Delete#} +
+{% endblock content %} \ No newline at end of file diff --git a/templates/employee/containers-list.html b/templates/employee/containers-list.html new file mode 100644 index 0000000..8fdb785 --- /dev/null +++ b/templates/employee/containers-list.html @@ -0,0 +1,36 @@ +{% extends 'employee-base.html' %} +{% load static %} + +{% block content %} + + + + + + + + + + + + + {% for container in containers %} + + + + + + + + + + + + + {% endfor %} + +
Container №Container typeLineReceived onPositionSweptWashedBooking
{{ container.number }}{{ container.container_type }}{{ container.line.short_name }}{{ container.received_on }}{{ container.position }}{{ container.swept }}{{ container.washed }}{{ container.booking.id }} +{# Edit |#} +{# Delete#} +
+{% endblock content %} \ No newline at end of file diff --git a/templates/employee/preinfo-list.html b/templates/employee/preinfo-list.html new file mode 100644 index 0000000..1f3d55f --- /dev/null +++ b/templates/employee/preinfo-list.html @@ -0,0 +1,32 @@ +{% extends 'employee-base.html' %} +{% load static %} + +{% block content %} + + + + + + + + + + + {% for preinfo in preinfos %} + + + + + + + + + + + {% endfor %} + +
Preinfo IDContainer №Container typeLineCreated onCreated by
{{ preinfo.id }}{{ preinfo.container_number }}{{ preinfo.container_type }}{{ preinfo.line.short_name }}{{ preinfo.created_on }}{{ preinfo.created_by.username }} +{# Edit |#} +{# Delete#} +
+{% endblock content %} \ No newline at end of file diff --git a/templates/registration/register.html b/templates/registration/register.html index 7830ed4..ded6612 100644 --- a/templates/registration/register.html +++ b/templates/registration/register.html @@ -1,4 +1,4 @@ -{% extends 'client-base.html' %} +{% extends 'employee-base.html' %} {% block content %}