mirror of
https://github.com/welton89/RRBEC.git
synced 2026-04-05 13:35:42 +00:00
chore: Delete numerous application modules, templates, static assets, documentation, and build files.
This commit is contained in:
0
home/__init__.py
Normal file
0
home/__init__.py
Normal file
3
home/admin.py
Normal file
3
home/admin.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
6
home/apps.py
Normal file
6
home/apps.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class HomeConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'home'
|
||||
0
home/migrations/__init__.py
Normal file
0
home/migrations/__init__.py
Normal file
3
home/models.py
Normal file
3
home/models.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
74
home/templates/home.html
Normal file
74
home/templates/home.html
Normal file
@@ -0,0 +1,74 @@
|
||||
{% extends "base.html" %}
|
||||
{% load static %}
|
||||
|
||||
{% block 'head' %}
|
||||
<link rel="stylesheet" href="{% static 'home/css/home.css' %}">
|
||||
{% endblock %}
|
||||
|
||||
{% block 'title' %}
|
||||
RRB&C - DashBoard
|
||||
{% endblock %}
|
||||
|
||||
{% block 'body' %}
|
||||
<body>
|
||||
<div class="grid-container">
|
||||
<h1>DashBoard</h1>
|
||||
<div class="grid-container" style="grid-template-columns: repeat(2, 2fr); align-items: center; margin: 0px;">
|
||||
<input id="data-start" name="data-start" oninput="mediaCuisine()" type="date">
|
||||
<input id="data-end" name="data-end" oninput="mediaCuisine()" type="date">
|
||||
</div>
|
||||
<h4 id="30-days">Últimos 30 dias</h4>
|
||||
</div>
|
||||
|
||||
<div class="grid-container">
|
||||
<div class="card-resumo">
|
||||
<div>
|
||||
<p> Faturamento </p>
|
||||
<h2 id="total-pagamentos">Carregando... </h2>
|
||||
</div>
|
||||
<img src="{% static 'midia/icons/money-bag.svg' %}" >
|
||||
</div>
|
||||
<div class="card-resumo">
|
||||
<div>
|
||||
<p>Total de Vendas</p>
|
||||
<h2 id="qtd-pagamentos">Carregando... </h2>
|
||||
</div>
|
||||
<img src="{% static 'midia/icons/cart.svg' %}" >
|
||||
</div>
|
||||
|
||||
<div class="card-resumo">
|
||||
<div>
|
||||
<p>Ticket médio</p>
|
||||
<h2 id="ticket-medio">Carregando... </h2>
|
||||
</div>
|
||||
<img src="{% static 'midia/icons/ticket.svg' %}" >
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<h4> Mais vendidos </h4>
|
||||
<canvas id="vendas" style="width:100%;height: 85%;max-width:100%;"></canvas>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<h4>Tempo médio na cozinha</h4>
|
||||
<div style="width:95%;max-width:100%;padding: 10px 30px 10px 30px;">
|
||||
<canvas id="cuisine" style="width:80%;height: 65%;max-width:100%;"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h4>Ranking atendente</h4>
|
||||
<hr>
|
||||
<p>1º - Atendente 1</p><p>2º - Atendente 2</p>
|
||||
<p>3º - Atendente 3</p><p>4º - Atendente 4</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<h4 style="justify-self: center;">Faturamento mês a mês</h4>
|
||||
<!-- <div class="card-faturamento-anual"> -->
|
||||
<canvas class="card-faturamento-anual" id="mensal" ></canvas>
|
||||
<!-- </div> -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.6.0/chart.min.js"></script>
|
||||
<script src="{% static 'home/js/home.js' %}"></script>
|
||||
</body>
|
||||
{% endblock %}
|
||||
3
home/tests.py
Normal file
3
home/tests.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
8
home/urls.py
Normal file
8
home/urls.py
Normal file
@@ -0,0 +1,8 @@
|
||||
from django.urls import path
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
path('', views.home, name='home'),
|
||||
path('chartCuisine/<str:dateStart>/<str:dateEnd>', views.chartCuisine, name='chartCuisine'),
|
||||
|
||||
]
|
||||
96
home/views.py
Normal file
96
home/views.py
Normal file
@@ -0,0 +1,96 @@
|
||||
from django.shortcuts import render
|
||||
from django.db.models import Sum
|
||||
from django.db.models import Count, F
|
||||
from django.http import JsonResponse
|
||||
from django.contrib.admin.views.decorators import staff_member_required
|
||||
from django.contrib.auth.models import User
|
||||
from django.utils.dateparse import parse_datetime
|
||||
|
||||
import datetime
|
||||
|
||||
|
||||
|
||||
from comandas.models import ProductComanda
|
||||
from orders.models import Order
|
||||
from payments.models import Payments
|
||||
from gestaoRaul.decorators import group_required
|
||||
|
||||
@group_required(groupName='Gerente')
|
||||
def home(request):
|
||||
|
||||
return render(request, 'home.html')
|
||||
|
||||
|
||||
@group_required(groupName='Gerente')
|
||||
def chartCuisine(request,dateStart,dateEnd):
|
||||
try:
|
||||
dateStart = parse_datetime(dateStart+' 07:00:00')
|
||||
dateEnd = parse_datetime(dateEnd+' 07:00:00')+ datetime.timedelta(days=1)
|
||||
except:
|
||||
dateStart = parse_datetime('2025-01-01 07:00:00')
|
||||
dateEnd = datetime.datetime.now()
|
||||
|
||||
tFila = []
|
||||
tPreparando = []
|
||||
tFinalizado = []
|
||||
|
||||
total_pagamentos = Payments.objects.filter(datetime__range=(dateStart, dateEnd)).aggregate(total=Sum('value'))['total']
|
||||
total_pagamentos = 0 if total_pagamentos is None else total_pagamentos
|
||||
qdt_pagamentos = Payments.objects.filter(datetime__range=(dateStart, dateEnd)).aggregate(total=Count('value'))['total']
|
||||
qdt_pagamentos = 0 if qdt_pagamentos is None else qdt_pagamentos
|
||||
try:
|
||||
ticket_medio = total_pagamentos / qdt_pagamentos
|
||||
except:
|
||||
ticket_medio = 0
|
||||
|
||||
try:
|
||||
produtos_mais_vendidos = ProductComanda.objects.filter(
|
||||
data_time__range=(dateStart, dateEnd)
|
||||
).values('product').annotate(
|
||||
quantidade=Count('product'),
|
||||
nome=F('product__name')
|
||||
).order_by('-quantidade')[:5]
|
||||
maisVendidos = {}
|
||||
for produto in produtos_mais_vendidos:
|
||||
maisVendidos[produto['nome']] = produto['quantidade']
|
||||
produtos_mais_vendidos = maisVendidos
|
||||
|
||||
except:
|
||||
produtos_mais_vendidos = {
|
||||
'petra': 25,
|
||||
'petra2': 26,
|
||||
'petra3': 27,
|
||||
'petra4': 28,
|
||||
'petra5': 29,
|
||||
}
|
||||
|
||||
orders = Order.objects.filter(delivered__isnull=False, queue__gt=dateStart, queue__lt=dateEnd)
|
||||
try:
|
||||
for order in orders:
|
||||
tFila.append((order.preparing - order.queue).total_seconds())
|
||||
tPreparando.append((order.finished - order.preparing).total_seconds())
|
||||
tFinalizado.append((order.delivered - order.finished).total_seconds())
|
||||
|
||||
mediaFila = int((sum(tFila) / len(tFila))/60)
|
||||
mediaPreparando = int((sum(tPreparando) / len(tPreparando))/60)
|
||||
mediaFinalizado = int((sum(tFinalizado) / len(tFinalizado))/60)
|
||||
|
||||
return JsonResponse({
|
||||
'mediaFila': mediaFila,
|
||||
'mediaPreparando': mediaPreparando,
|
||||
'mediaFinalizado': mediaFinalizado,
|
||||
'total_pagamentos': round(total_pagamentos, 2),
|
||||
'qtd_pagamentos': qdt_pagamentos,
|
||||
'ticket_medio': round(ticket_medio, 2),
|
||||
'produtos_mais_vendidos': produtos_mais_vendidos,
|
||||
})
|
||||
except:
|
||||
return JsonResponse({
|
||||
'mediaFila': 0,
|
||||
'mediaPreparando': 0,
|
||||
'mediaFinalizado': 0,
|
||||
'total_pagamentos': round(total_pagamentos, 2),
|
||||
'qtd_pagamentos': qdt_pagamentos,
|
||||
'ticket_medio': round(ticket_medio, 2),
|
||||
'produtos_mais_vendidos': produtos_mais_vendidos,
|
||||
})
|
||||
Reference in New Issue
Block a user