commit unversioned files ;)

master
kikimor 8 months ago
parent 844a26a287
commit 3ed72beb6c

@ -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'),
]

@ -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)
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

@ -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()

@ -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('<int:pk>/', include([
path('receive', ContainerReceive.as_view(), name='container_receive'),
path('expedition', ContainerExpedition.as_view(), name='container_expedition'),

@ -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})

@ -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'),
]

@ -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'})
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

@ -13,23 +13,23 @@
</svg>
Dashboard
</a>
<a href="{% url 'client_preinfo' %}" id="preinfoNav" class="nav-item flex items-center px-6 py-3 text-white">
<a href="{% url 'employee_containers' %}" id="preinfoNav" class="nav-item flex items-center px-6 py-3 text-white">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-3" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2" />
</svg>
Container Preinfo
Available Containers
</a>
<a href="{% url 'client_booking' %}" id="ordersNav" class="nav-item flex items-center px-6 py-3 text-white">
<a href="{% url 'employee_bookings' %}" id="ordersNav" class="nav-item flex items-center px-6 py-3 text-white">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-3" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4" />
</svg>
Bookings
</a>
<a href="#" class="nav-item flex items-center px-6 py-3 text-white">
<a href="{% url 'employee_preinfo' %}" class="nav-item flex items-center px-6 py-3 text-white">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-3" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 17v-2m3 2v-4m3 4v-6m2 10H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
</svg>
Reports
Preinfos
</a>
{% if request.user.UserType.ADMIN %}
@ -40,8 +40,27 @@
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z" />
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
</svg>
Settings
Accounts
</a>
{# <div class="px-4 py-2 mt-6 text-xs text-blue-300 uppercase tracking-wider">Account</div>#}
<a href="{% url 'register' %}" class="nav-item flex items-center px-6 py-3 text-white">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-3" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z" />
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
</svg>
Companies
</a>
<a href="{% url 'register' %}" class="nav-item flex items-center px-6 py-3 text-white">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-3" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z" />
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
</svg>
Lines
</a>
{% endif %}
</nav>

@ -0,0 +1,40 @@
{% extends 'employee-base.html' %}
{% load static %}
{% block content %}
<table>
<tr>
<th>Status</th>
<th>Booking №</th>
<th>Vehicles</th>
<th>Container number</th>
<th>Container type</th>
<th>Container count</th>
<th>Line</th>
<th>Carrier</th>
<th>Containers expedited</th>
<th>Vehicles left</th>
</tr>
{% for booking in bookings %}
<tr>
<td>{{ booking.status }}</td>
<td>{{ booking.number }}</td>
<td>{{ booking.vehicles }}</td>
<td>{{ booking.container_number }}</td>
<td>{{ booking.container_type }}</td>
<td>{{ booking.container_count }}</td>
<td>{{ booking.line.short_name }}</td>
<td>{{ booking.carrier }}</td>
<td>{{ booking.container_expedited_count }}</td>
<td>{{ booking.vehicles_left }}</td>
<td>
{# <a href="{% url 'employee:preinfo_edit' preinfo.id %}">Edit</a> |#}
{# <a href="{% url 'employee:preinfo_delete' preinfo.id %}">Delete</a>#}
</td>
</tr>
{% endfor %}
</table>
{% endblock content %}

@ -0,0 +1,36 @@
{% extends 'employee-base.html' %}
{% load static %}
{% block content %}
<table>
<tr>
<th>Container №</th>
<th>Container type</th>
<th>Line</th>
<th>Received on</th>
<th>Position</th>
<th>Swept</th>
<th>Washed</th>
<th>Booking</th>
</tr>
{% for container in containers %}
<tr>
<td>{{ container.number }}</td>
<td>{{ container.container_type }}</td>
<td>{{ container.line.short_name }}</td>
<td>{{ container.received_on }}</td>
<td>{{ container.position }}</td>
<td>{{ container.swept }}</td>
<td>{{ container.washed }}</td>
<td>{{ container.booking.id }}</td>
<td>
{# <a href="{% url 'employee:preinfo_edit' preinfo.id %}">Edit</a> |#}
{# <a href="{% url 'employee:preinfo_delete' preinfo.id %}">Delete</a>#}
</td>
</tr>
{% endfor %}
</table>
{% endblock content %}

@ -0,0 +1,32 @@
{% extends 'employee-base.html' %}
{% load static %}
{% block content %}
<table>
<tr>
<th>Preinfo ID</th>
<th>Container №</th>
<th>Container type</th>
<th>Line</th>
<th>Created on</th>
<th>Created by</th>
</tr>
{% for preinfo in preinfos %}
<tr>
<td>{{ preinfo.id }}</td>
<td>{{ preinfo.container_number }}</td>
<td>{{ preinfo.container_type }}</td>
<td>{{ preinfo.line.short_name }}</td>
<td>{{ preinfo.created_on }}</td>
<td>{{ preinfo.created_by.username }}</td>
<td>
{# <a href="{% url 'preinfo_edit' preinfo.id %}">Edit</a> |#}
{# <a href="{% url 'preinfo_delete' preinfo.id %}">Delete</a>#}
</td>
</tr>
{% endfor %}
</table>
{% endblock content %}

@ -1,4 +1,4 @@
{% extends 'client-base.html' %}
{% extends 'employee-base.html' %}
{% block content %}
<form method="post">

Loading…
Cancel
Save