ADD: Отчёты

This commit is contained in:
e-serg 2024-04-15 02:52:11 +03:00
parent e419e46700
commit 149093c715
6 changed files with 203 additions and 5 deletions

View File

@ -85,3 +85,11 @@ body {
/* фон заголовка и подвала модального окна */
background: whitesmoke;
}

View File

@ -31,6 +31,7 @@ urlpatterns = [
re_path(r'^add-clone$', views.add_clone),
re_path(r'^save-clone$', views.save_clone),
re_path(r'^report1$', views.report1),
re_path(r'^report2$', views.report2),
]

View File

@ -1,9 +1,11 @@
# -*- coding: utf-8 -*-
from django.shortcuts import render, HttpResponseRedirect
from django.template.loader import render_to_string
from django.http import HttpRequest, HttpResponse
from django.contrib.auth import authenticate, login, logout
from django.template.exceptions import TemplateDoesNotExist, TemplateSyntaxError
from rosmorport_tsts.models import TbPetsClones
from time import process_time
@ -109,8 +111,23 @@ def report1(request: HttpRequest) -> HttpResponse:
:param
:return response: исходящий http-ответ
"""
cpu_start = process_time()
to_template = {"PETS": TbPetsClones.objects.all()}
to_template.update({"Q_CPU": process_time() - cpu_start})
return render(request, template_name="page/report1.jinja", context=to_template)
def report2(request: HttpRequest) -> HttpResponse:
""" Отчет по клонированным питомцам
:param
:return response: исходящий http-ответ
"""
cpu_start = process_time()
to_template = {
"META_REFRESH": "3600; url=/logout", # автоматический logout через 10 минут бездействия
"PETS": TbPetsClones.objects.all()
"PETS": TbPetsClones.objects.all(),
"PET_TYPES": TbPetsClones.PetType.choices,
"PET_SEXES": TbPetsClones.PetSex.choices
}
return render(request, template_name="report1.jinja", context=to_template)
to_template.update({"Q_CPU": process_time() - cpu_start})
return render(request, template_name="page/report2.jinja", context=to_template)

View File

@ -49,7 +49,9 @@
</div>
<div class="col-4">
<div class="input-group input-group-lg mb-3">
<span class="input-group-text ps-3 pe-2 py-3 bg-dark text-light" id="basic-addon1"><i class="fa-solid fa-ruble-sign"></i></span>
<span class="input-group-text ps-3 pe-2 py-3 bg-dark text-light" id="basic-addon1">
<i class="fa-solid fa-ruble-sign"></i>
</span>
<input type="text" class="form-control" placeholder="Заплачено наличными" aria-label="Заплачено"
name="pay" required>
<span class="input-group-text">.00</span>

View File

@ -0,0 +1,66 @@
{% extends 'base.jinja' %}
{% block CONTENT %}<div class="row px-3">
<div class="col-12 my-2">
<h1>Отчёт 1</h1>
</div>
</div>
<div class="row px-3">
<div class="col-12"><table class="table table-sm table-secondary table-striped table-hover">
<thead >
<tr style="position: sticky;">
<th scope="col" title="Серийный номер" class="bg-dark text-light"><i class="fa-solid fa-paw"></i> #</th>
<th scope="col" class="bg-dark text-light"><i class="fa-solid fa-paw"></i> Имя</th>
<th scope="col" class="bg-dark text-light"><i class="fa-solid fa-paw"></i> Тип</th>
<th scope="col" class="bg-dark text-light"><i class="fa-solid fa-paw"></i> Пол</th>
<th scope="col" title="Регистрация" class="bg-dark text-light"><i class="fa-solid fa-id-card"></i></th>
<th scope="col" title="Состояние здоровья" class="bg-dark text-light"><i class="fa-solid fa-heart"></i></th>
<th scope="col" title="Заказчик" class="bg-dark text-light"><i class="fa-solid fa-person"></i></th>
<th scope="col" title="Комментарии" class="bg-dark text-light"><i class="fa-solid fa-comment"></i></th>
<th scope="col" title="Цена заказа" class="bg-dark text-light text-end"><i class="fa-solid fa-ruble-sign"></i></th>
</tr>
</thead>
<tbody style="font-family: monospace;">
{% for PET in PETS %}<tr>
<td>{{ PET.szPetSerNum }}</td>
<td>{% if PET.szPetName %}{{ PET.szPetName }}{% else %}&mdash;{% endif %}</td>
<td>{{ PET.iPetType }}</td>
<td>{{ PET.iPetSex }}</td>
<td>{% if PET.bPetIsReg %}<i class="fa-solid fa-circle-check"></i>{% endif %}</td>
<td>{% if not PET.bPetIsAlive %}<i class="fa-solid fa-skull-crossbones"></i>{% endif %}</td>
<td>{% if PET.szPetOwner %}{{ PET.szPetOwner }}{% else %}&mdash;{% endif %}</td>
<td>{% if PET.szPetComment %}<i class="fa-solid fa-comment" title="{{ PET.szPetComment }}"></i>{% endif %}</td>
<td class="text-end">{{ PET.szPetPrice }}</td>
</tr>{% endfor %}
</tbody>
</table></div>
</div>
<div class="row px-3">
<div class="col-12">
<nav aria-label="Page navigation example">
<ul class="pagination">
<li class="page-item">
<a class="page-link" href="#" aria-label="Previous">
<span aria-hidden="true">&laquo;</span>
</a>
</li>
<li class="page-item"><a class="page-link" href="#">1</a></li>
<li class="page-item"><a class="page-link" href="#">2</a></li>
<li class="page-item"><a class="page-link" href="#">3</a></li>
<li class="page-item">
<a class="page-link" href="#" aria-label="Next">
<span aria-hidden="true">&raquo;</span>
</a>
</li>
</ul>
</nav>
</div>
</div>
<div class="row px-3">
<div class="col-12">
<p class="text-sm-end px-4 bg-info-subtle text-info"><small><small><i class="fa-solid fa-microchip"></i>
{{ Q_CPU|stringformat:".6f" }}</small></small></p>
</div>
</div>{% endblock CONTENT %}

View File

@ -0,0 +1,104 @@
{% extends 'base.jinja' %}
{% block CONTENT %}<div class="row px-3">
<div class="col-6 my-2">
<h1>Отчёт 2</h1>
</div>
<div class="col-6">
<div class="input-group my-3">
<span class="input-group-text" id="pet-type">
<i class="fa-solid fa-filter"></i><i class="fa-solid fa-paw"></i>
</span>
<select class="form-select" aria-label="Тип питомца" id="type">
<option selected value="tA">Все</option>{% for TYPE in PET_TYPES %}
<option value="t{{ TYPE.0 }}">{{ TYPE.1 }}</option>{% endfor %}
</select>
<select class="form-select" aria-label="Пол" id="sex">
<option selected value="tA">Все</option>{% for SEX in PET_SEXES %}
<option value="s{{ SEX.0 }}">{{ SEX.1 }}</option>{% endfor %}
</select>
</div>
</div>
</div>
<div class="row px-3">
<div class="col-12"><table class="table table-sm table-secondary table-striped table-hover">
<thead >
<tr style="position: sticky;">
<th scope="col" title="Серийный номер" class="bg-dark text-light"><i class="fa-solid fa-paw"></i> #</th>
<th scope="col" class="bg-dark text-light"><i class="fa-solid fa-paw"></i> Имя</th>
<th scope="col" class="bg-dark text-light"><i class="fa-solid fa-paw"></i> Тип</th>
<th scope="col" class="bg-dark text-light"><i class="fa-solid fa-paw"></i> Пол</th>
<th scope="col" title="Регистрация" class="bg-dark text-light"><i class="fa-solid fa-id-card"></i></th>
<th scope="col" title="Состояние здоровья" class="bg-dark text-light"><i class="fa-solid fa-heart"></i></th>
<th scope="col" title="Заказчик" class="bg-dark text-light"><i class="fa-solid fa-person"></i></th>
<th scope="col" title="Комментарии" class="bg-dark text-light"><i class="fa-solid fa-comment"></i></th>
<th scope="col" title="Цена заказа" class="bg-dark text-light text-end"><i class="fa-solid fa-ruble-sign"></i></th>
</tr>
</thead>
<tbody style="font-family: monospace;">
{% for PET in PETS %}<tr class="t{{ PET.iPetType }} s{{ PET.iPetSex }}">
<td>{{ PET.szPetSerNum }}</td>
<td>{% if PET.szPetName %}{{ PET.szPetName }}{% else %}&mdash;{% endif %}</td>
<td>{{ PET.iPetType }}</td>
<td>{{ PET.iPetSex }}</td>
<td>{% if PET.bPetIsReg %}<i class="fa-solid fa-circle-check"></i>{% endif %}</td>
<td>{% if not PET.bPetIsAlive %}<i class="fa-solid fa-skull-crossbones"></i>{% endif %}</td>
<td>{% if PET.szPetOwner %}{{ PET.szPetOwner }}{% else %}&mdash;{% endif %}</td>
<td>{% if PET.szPetComment %}<i class="fa-solid fa-comment" title="{{ PET.szPetComment }}"></i>{% endif %}</td>
<td class="text-end">{{ PET.szPetPrice }}</td>
</tr>{% endfor %}
</tbody>
</table></div>
</div>
<div class="row px-3">
<div class="col-12">
<nav aria-label="Page navigation example">
<ul class="pagination">
<li class="page-item">
<a class="page-link" href="#" aria-label="Previous">
<span aria-hidden="true">&laquo;</span>
</a>
</li>
<li class="page-item"><a class="page-link" href="#">1</a></li>
<li class="page-item"><a class="page-link" href="#">2</a></li>
<li class="page-item"><a class="page-link" href="#">3</a></li>
<li class="page-item">
<a class="page-link" href="#" aria-label="Next">
<span aria-hidden="true">&raquo;</span>
</a>
</li>
</ul>
</nav>
</div>
</div>
<div class="row px-3">
<div class="col-12">
<p class="text-sm-end px-4 bg-info-subtle text-info"><small><small><i class="fa-solid fa-microchip"></i>
{{ Q_CPU|stringformat:".6f" }}</small></small></p>
</div>
</div>{% endblock CONTENT %}
{% block JS_1 %}<script type="text/javascript">
$(document).ready(function() {
$('#type').change(function(){
let point = $(this).find("option:selected").attr('value');
if (point === 'tA')
$('tbody > tr').show();
else {
$('tbody > tr').hide();
$('tbody > tr.' + point).show();
}
});
$('#sex').change(function(){
let point = $(this).find("option:selected").attr('value');
if (point === 'sA')
$('tbody > tr').show();
else {
$('tbody > tr').hide();
$('tbody > tr.' + point).show();
}
});
});
</script>{% endblock %}