Amdinoberfläche Statistikansicht Agentureinzelansicht angefangen, Übersichtsseite Agenturen fertig
This commit is contained in:
parent
9ff6268b8a
commit
98092af442
|
|
@ -0,0 +1,65 @@
|
|||
{% extends "adm/adm_base.html" %}
|
||||
{% block content %}
|
||||
{% load adm_tags %}
|
||||
{% getAgencyData agency as agdata %}
|
||||
<div class="content-section col-12">
|
||||
<h4>Einzelagenturansicht</h4>
|
||||
<hr>
|
||||
<h5>Daten der Agentur</h5>
|
||||
<table>
|
||||
<tr>
|
||||
<td style="min-width: 180px">Name</td>
|
||||
<td>{{agency.name}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Registriert am</td>
|
||||
<td>{{agency.registerdate|date:"d.m.Y"}}
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Nutzer</td>
|
||||
<td>{{agdata.0}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Standards</td>
|
||||
<td>{{agdata.1}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Bezahlstatus</td>
|
||||
<td>{% if agency.paymentstatus == 0 %} Normal {% else %}Kostenlos{% endif %}</td>
|
||||
</tr>
|
||||
</table>
|
||||
<hr>
|
||||
<h5>Rechnungen (letzten drei)</h5>
|
||||
{% if bills|length == 0 %}
|
||||
Es liegen keine Rechnungen vor.
|
||||
{% else %}
|
||||
<table style="width: 70%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>Rechnungs-Nr.</td>
|
||||
<td>Datum</td>
|
||||
<td>Status</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for bill in bills %}
|
||||
<tr>
|
||||
<td><a href="{% url 'ag-getbillpdf' bill.pk %}" target="_blank">{{bill.billnumber}}</a></td>
|
||||
<td>{{bill.billdate|date:"d.m.Y"}}</td>
|
||||
<td>
|
||||
{% if bill.billstatus == "open" %} <i class="far fa-times-circle" style="color: red"></i> {% elif bill.billstatus == "paid" %} <i class="far fa-check-circle" style="color: green"></i> {% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endif %}
|
||||
<hr>
|
||||
<h5>Nutzerübersicht</h5>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
{% endblock content %}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
{% extends "adm/adm_base.html" %}
|
||||
{% block content %}
|
||||
{% load adm_tags %}
|
||||
<div class="content-section col-12">
|
||||
<h4>Agenturübersicht</h4>
|
||||
<hr>
|
||||
|
|
@ -13,12 +14,11 @@
|
|||
</thead>
|
||||
<tbody >
|
||||
{% for ele in agencys %}
|
||||
{% getAgencyData ele as agdata %}
|
||||
<tr>
|
||||
<td>{{ele.name}}</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
|
||||
|
||||
<td><a href="{% url 'adm-agency-single' ele.pk %}">{{ele.name}}</a></td>
|
||||
<td>{{agdata.0}}</td>
|
||||
<td>{{agdata.1}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
|
|
|||
|
|
@ -96,6 +96,14 @@
|
|||
<span>Agenturen</span></a>
|
||||
</li>
|
||||
|
||||
<hr class="sidebar-divider my-0">
|
||||
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{% url 'users-dashboard' %}">
|
||||
<i class="fas fa-laptop"></i>
|
||||
<span>Zur Digitalen Agentur</span></a>
|
||||
</li>
|
||||
|
||||
<!-- Sidebar Toggler (Sidebar) -->
|
||||
<!--
|
||||
<div class="text-center d-none d-md-inline">
|
||||
|
|
|
|||
|
|
@ -1,52 +1,75 @@
|
|||
{% extends "adm/adm_base.html" %}
|
||||
{% block content %}
|
||||
<div class="content-section col-12">
|
||||
<h4>Statistikdaten über alle</h4>
|
||||
<h4>Statistikdaten</h4>
|
||||
<hr>
|
||||
<table class="table table-hover" id="statistics" >
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Datum</th>
|
||||
<th scope="col">Agenturen</th>
|
||||
<th scope="col">Benutzer</th>
|
||||
<th scope="col">Standards</th>
|
||||
<th scope="col">Chatnachrichten</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody >
|
||||
{% for ele in statistik %}
|
||||
<tr>
|
||||
<td>{{ele.staticdate|date:"d.m.Y"}}</td>
|
||||
<td>{{ele.agencys}}</td>
|
||||
<td>{{ele.users}}</td>
|
||||
<td>{{ele.standards}}</td>
|
||||
<td>{{ele.chatmessages}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
<p>
|
||||
Anzahl Datensätze: {{statistik|length}}<br />
|
||||
</p>
|
||||
<div class="chart-container" style="">
|
||||
<canvas id="all_stats"></canvas>
|
||||
</div>
|
||||
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
|
||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.1.6/Chart.bundle.min.js"></script>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
$('#statistics').DataTable({
|
||||
"language": {
|
||||
"search" : "Suche",
|
||||
"info": "Zeige _START_ bis _END_ von _TOTAL_ Einträgen",
|
||||
"lengthMenu": "Zeige _MENU_ Einträge",
|
||||
"zeroRecords": "Nichts gefunden",
|
||||
"infoEmpty": "Keine Einträge",
|
||||
"paginate": {
|
||||
"first": "Erste",
|
||||
"last": "Letzte",
|
||||
"next": "Nächste",
|
||||
"previous": "Zurück"
|
||||
},
|
||||
},
|
||||
"pageLength": 50,
|
||||
"buttons" : {
|
||||
"className" : "btn-danger"
|
||||
}
|
||||
});
|
||||
})
|
||||
<script>
|
||||
new Chart(document.getElementById("all_stats"),{
|
||||
"type":"line",
|
||||
"data":
|
||||
{
|
||||
"labels":
|
||||
[
|
||||
{% for ele in statistik %}
|
||||
"{{ele.staticdate|date:'d.m.Y'}}",
|
||||
{% endfor %}
|
||||
],
|
||||
"datasets":[
|
||||
{"label":"Agenturen",
|
||||
"data":[
|
||||
{% for ele in statistik %}
|
||||
{{ele.agencys}},
|
||||
{% endfor %}
|
||||
],
|
||||
"fill":false,
|
||||
"borderColor":"#664AD9",
|
||||
"lineTension":0.1
|
||||
},
|
||||
{"label":"Nutzer",
|
||||
"data":[
|
||||
{% for ele in statistik %}
|
||||
{{ele.users}},
|
||||
{% endfor %}
|
||||
],
|
||||
"fill":false,
|
||||
"borderColor":"#5DF0CB",
|
||||
"lineTension":0.1
|
||||
},
|
||||
{"label":"Standards",
|
||||
"data":[
|
||||
{% for ele in statistik %}
|
||||
{{ele.standards}},
|
||||
{% endfor %}
|
||||
],
|
||||
"fill":false,
|
||||
"borderColor":"#FA746A",
|
||||
"lineTension":0.1
|
||||
},
|
||||
{"label":"Chatnachrichten",
|
||||
"data":[
|
||||
{% for ele in statistik %}
|
||||
{{ele.chatmessages}},
|
||||
{% endfor %}
|
||||
],
|
||||
"fill":false,
|
||||
"borderColor":"#D3D94A",
|
||||
"lineTension":0.1
|
||||
},
|
||||
|
||||
]
|
||||
},
|
||||
"options":{}});
|
||||
</script>
|
||||
{% endblock content %}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
{% extends "adm/adm_base.html" %}
|
||||
{% block content %}
|
||||
<div class="content-section col-12">
|
||||
<h4>Statistikdaten</h4>
|
||||
<hr>
|
||||
<table class="table table-hover" id="statistics" >
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Datum</th>
|
||||
<th scope="col">Agenturen</th>
|
||||
<th scope="col">Benutzer</th>
|
||||
<th scope="col">Standards</th>
|
||||
<th scope="col">Chatnachrichten</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody >
|
||||
{% for ele in statistik %}
|
||||
<tr>
|
||||
<td>{{ele.staticdate|date:"d.m.Y"}}</td>
|
||||
<td>{{ele.agencys}}</td>
|
||||
<td>{{ele.users}}</td>
|
||||
<td>{{ele.standards}}</td>
|
||||
<td>{{ele.chatmessages}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
$('#statistics').DataTable({
|
||||
"language": {
|
||||
"search" : "Suche",
|
||||
"info": "Zeige _START_ bis _END_ von _TOTAL_ Einträgen",
|
||||
"lengthMenu": "Zeige _MENU_ Einträge",
|
||||
"zeroRecords": "Nichts gefunden",
|
||||
"infoEmpty": "Keine Einträge",
|
||||
"paginate": {
|
||||
"first": "Erste",
|
||||
"last": "Letzte",
|
||||
"next": "Nächste",
|
||||
"previous": "Zurück"
|
||||
},
|
||||
},
|
||||
"pageLength": 50,
|
||||
"buttons" : {
|
||||
"className" : "btn-danger"
|
||||
}
|
||||
});
|
||||
})
|
||||
</script>
|
||||
{% endblock content %}
|
||||
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,29 @@
|
|||
from django import template
|
||||
from django.contrib.auth.models import Group, User
|
||||
from users.models import AgencyGroup, Agency, AgencyNetwork, AgencyNetworkPreperation, UserTime, UserYearAbsenceInfo
|
||||
from standards.models import Standards, StandardCommentRate, StandardComments
|
||||
from timemanagement.models import Workday, FreeDays, Absence
|
||||
from message.models import Message
|
||||
import os
|
||||
from django.conf import settings
|
||||
from django.utils import timezone
|
||||
from datetime import date
|
||||
import datetime
|
||||
register = template.Library()
|
||||
|
||||
|
||||
'''
|
||||
|
||||
Agenturdaten zurückgeben
|
||||
|
||||
TASK: Hier noch mehr Datenfelder über die Agentur hinzunehmen, bei Bedarf
|
||||
|
||||
'''
|
||||
@register.simple_tag
|
||||
def getAgencyData(ele):
|
||||
data = [0,1]
|
||||
|
||||
data[0] = len(User.objects.filter(profile__agency=ele))
|
||||
data[1] = len(Standards.objects.filter(agency=ele))
|
||||
|
||||
return data
|
||||
|
|
@ -10,5 +10,6 @@ Permissions definiert in models.py bei USERS und dann hier vor die View geschrie
|
|||
urlpatterns = [
|
||||
path('', AdmMain.as_view(), name='adm-main'),
|
||||
path('ag/', AdmAgencys.as_view(), name="adm-agencys"),
|
||||
path('agsingle/<int:agpk>', AdmAgencySingle.as_view(), name="adm-agency-single"),
|
||||
path('cron/<slug:code>', statisticCronJob, name="adm-cron")
|
||||
]
|
||||
|
|
|
|||
49
adm/views.py
49
adm/views.py
|
|
@ -6,9 +6,12 @@ from django.http import HttpResponseRedirect,HttpResponse, JsonResponse
|
|||
from .models import MainStatistic
|
||||
from django.contrib.auth.models import User
|
||||
from chat.models import ChatMessage
|
||||
from users.models import Agency
|
||||
from users.models import Agency, AgencyBills
|
||||
from standards.models import Standards
|
||||
|
||||
'''
|
||||
Prüfung, ob angemeldeter User Mitarbeiterstatus hat. IMMER PER DISPATCH EINBAUEN!
|
||||
'''
|
||||
def checkForStuffUser(request):
|
||||
if request.user.is_staff:
|
||||
return True
|
||||
|
|
@ -16,6 +19,9 @@ def checkForStuffUser(request):
|
|||
return False
|
||||
|
||||
|
||||
'''
|
||||
Hauptansicht Statisik
|
||||
'''
|
||||
class AdmMain(TemplateView):
|
||||
template_name = "adm/adm_main.html"
|
||||
|
||||
|
|
@ -31,10 +37,13 @@ class AdmMain(TemplateView):
|
|||
|
||||
context.update({'active_link' : "adm-statistic"})
|
||||
|
||||
context.update({'statistik' : MainStatistic.objects.all().order_by('-staticdate')})
|
||||
context.update({'statistik' : MainStatistic.objects.all().order_by('staticdate')[:180] })
|
||||
|
||||
return context
|
||||
|
||||
'''
|
||||
Gesamtansicht der Agenturen
|
||||
'''
|
||||
class AdmAgencys(TemplateView):
|
||||
template_name = "adm/adm_agencys.html"
|
||||
|
||||
|
|
@ -54,6 +63,28 @@ class AdmAgencys(TemplateView):
|
|||
|
||||
return context
|
||||
|
||||
'''
|
||||
Einzelansicht der Agenturen
|
||||
'''
|
||||
class AdmAgencySingle(TemplateView):
|
||||
template_name = "adm/adm_agency_single.html"
|
||||
|
||||
def dispatch(self, *args, **kwargs):
|
||||
if(checkForStuffUser(self.request)):
|
||||
return super().dispatch(*args, **kwargs)
|
||||
else:
|
||||
messages.warning(self.request, f'Sie benötigen einen Mitarbeiter-Account, um diese Seiten aufzurufen!')
|
||||
return redirect("login")
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context.update({'active_link' : "adm-agencys"})
|
||||
context.update({'agency' : Agency.objects.get(pk=kwargs['agpk'])})
|
||||
context.update({'bills' : AgencyBills.objects.filter(agency=Agency.objects.get(pk=kwargs['agpk'])).order_by('-billdate')[:3]})
|
||||
|
||||
return context
|
||||
|
||||
|
||||
# CRONJOB, um die Statistik zu füllen!
|
||||
def statisticCronJob(request, code):
|
||||
data = {}
|
||||
|
|
@ -68,3 +99,17 @@ def statisticCronJob(request, code):
|
|||
return JsonResponse(data)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -300,7 +300,7 @@ from django.http import HttpResponse
|
|||
def GetBillPDF(request, pk):
|
||||
bill = AgencyBills.objects.get(pk=pk)
|
||||
# Sicherheitscheck, ob der angefragte User zur Agentur gehört und das Recht hat, Agenturinfos zu bearbeiten
|
||||
if bill.agency == request.user.profile.agency and request.user.has_perm("users.agencyinfo"):
|
||||
if (bill.agency == request.user.profile.agency and request.user.has_perm("users.agencyinfo")) or request.user.is_staff:
|
||||
headers = {
|
||||
'Authorization': 'Bearer ' + settings.LEX_API,
|
||||
'Content-Type': 'application/json',
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -237,5 +237,6 @@ BOOTSTRAP4 = {
|
|||
OPTIONS={
|
||||
'libraries': {
|
||||
'counter_tag': 'standards.tags',
|
||||
'adm_tag' : 'adm.tags'
|
||||
},
|
||||
}
|
||||
|
|
@ -10,7 +10,7 @@ from timemanagement.models import Workday, Breaks, AbsenceReason, FreeDays, Abse
|
|||
from chat.models import ChatRoom
|
||||
from recoverdir.models import PersLetter, Documents, Handlungsleitfaden, RDContact, RecoverDirSetting
|
||||
from simple_history.admin import SimpleHistoryAdmin
|
||||
|
||||
from adm.models import MainStatistic
|
||||
|
||||
|
||||
admin.site.register(StandardComments)
|
||||
|
|
@ -41,3 +41,4 @@ admin.site.register(Documents, SimpleHistoryAdmin)
|
|||
admin.site.register(Handlungsleitfaden)
|
||||
admin.site.register(RDContact)
|
||||
admin.site.register(RecoverDirSetting)
|
||||
admin.site.register(MainStatistic)
|
||||
Loading…
Reference in New Issue