83 lines
3.3 KiB
Python
83 lines
3.3 KiB
Python
from django.shortcuts import render
|
|
from django.views.generic import TemplateView
|
|
from django.contrib.auth.mixins import LoginRequiredMixin #, PermissionRequiredMixin
|
|
from django.utils import timezone
|
|
from django.contrib.auth import views as auth_views
|
|
from Base.Metrics.Dashboard import (
|
|
get_sum_of_professional,
|
|
get_sum_of_service,
|
|
get_sum_of_professional_detail,
|
|
get_sum_payment_method_service,
|
|
get_sum_of_product,
|
|
)
|
|
from Base.Metrics.DashboardAdmin import (
|
|
get_total_bank,
|
|
get_total_prof,
|
|
get_sum_of_stone,
|
|
get_total_firm,
|
|
get_total_expense,
|
|
get_total_expense_prof,
|
|
get_total_credit_prof,
|
|
)
|
|
from Base.Metrics.DashboardProf import (
|
|
get_total_serv,
|
|
get_sum_expense,
|
|
get_sum_credit,
|
|
get_total_money,
|
|
)
|
|
from Base.models import Professional
|
|
from Movement.models import Calendar
|
|
|
|
def Home(request):
|
|
context = { 'ok':' Tudo ok', }
|
|
return render(request,'Home.html',context )
|
|
|
|
class Login(auth_views.LoginView):
|
|
template_name = 'Login/Login.html'
|
|
|
|
class Dashboard(LoginRequiredMixin, TemplateView):
|
|
template_name = 'Dashboards/Dashboard/index.html'
|
|
def get_context_data(self, **kwargs):
|
|
context = super().get_context_data(**kwargs)
|
|
Day = timezone.localtime(timezone.now())
|
|
context['Professional'] = get_sum_of_professional.metric(Day)
|
|
context['Service'] = get_sum_of_service.metric(Day)
|
|
context['Sum_of_professional_detail'] = get_sum_of_professional_detail.metric(Day)
|
|
context['Sum_payment_method_service'] = get_sum_payment_method_service.metric(Day)
|
|
context['Sum_of_product'] = get_sum_of_product.metric(Day)
|
|
return context
|
|
|
|
class DashboardAdmin(LoginRequiredMixin, TemplateView):
|
|
template_name = 'Dashboards/DashboardAdmin/index.html'
|
|
def get_context_data(self, **kwargs):
|
|
context = super().get_context_data(**kwargs)
|
|
context['total_bank'] = get_total_bank.metric()
|
|
context['total_firm'] = get_total_firm.metric()
|
|
# context['total_prof'] = get_total_prof.metric()
|
|
context['total_expense'] = get_total_expense.metric()
|
|
context['Stone'] = get_sum_of_stone.metric()
|
|
# context['total_expense_prof'] = get_total_expense_prof.metric()
|
|
# context['total_credit_prof'] = get_total_credit_prof.metric()
|
|
return context
|
|
|
|
class DashboardProf(LoginRequiredMixin, TemplateView):
|
|
template_name = 'Dashboards/DashboardProf/index.html'
|
|
def get_context_data(self, **kwargs):
|
|
context = super().get_context_data(**kwargs)
|
|
if self.request.GET.get('Prof'):
|
|
total_serv = get_total_serv.metric(self.request.GET.get('Prof'))
|
|
sum_expense = get_sum_expense.metric(self.request.GET.get('Prof'))
|
|
sum_credit = get_sum_credit.metric(self.request.GET.get('Prof'))
|
|
sum_money = get_total_money.metric(self.request.GET.get('Prof'))
|
|
else:
|
|
total_serv = Calendar.objects.none()
|
|
sum_expense = Calendar.objects.none()
|
|
sum_credit = Calendar.objects.none()
|
|
sum_money = Calendar.objects.none()
|
|
|
|
context['Total_serv'] = total_serv
|
|
context['Expense'] = sum_expense
|
|
context['Credit'] = sum_credit
|
|
context['Money'] = sum_money
|
|
context['Professionals'] = Professional.objects.all()
|
|
return context |