feat: dashboard for role 'manager'

This commit is contained in:
Björn Fromme
2024-03-01 13:50:54 +01:00
parent a4a3f43df9
commit 7e5b0e66c4
4 changed files with 175 additions and 3 deletions
+31 -3
View File
@@ -2,17 +2,45 @@
namespace App\Controller\Manager;
use App\Entity\Assignment;
use App\Model\AssignmentFilterDto;
use App\Repository\AssignmentRepository;
use Knp\Component\Pager\PaginatorInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
class IndexController extends AbstractController
{
#[Route('/management', name: 'app_manager_index')]
public function index(): Response
public function __construct(private readonly AssignmentRepository $assignmentRepository, private readonly PaginatorInterface $paginator)
{
return $this->render('manager/index.html.twig', [
}
#[Route('/management', name: 'app_manager_index')]
public function index(Request $request): Response
{
$filterDto = new AssignmentFilterDto();
$filterDto->setStatus(Assignment::STATUS_UNSTAFFED);
$query = $this
->assignmentRepository
->getListQuery($filterDto)
;
$pagination = $this->paginator->paginate(
$query,
$request->query->getInt('page', 1),
10,
[
'wrap-queries' => true, // Required for query with 'having' clause
'defaultSortFieldName' => 'destination.dateFrom',
'defaultSortDirection' => 'desc',
]
);
return $this->render('manager/index.html.twig', [
'pagination' => $pagination,
]);
}
}
+1
View File
@@ -28,6 +28,7 @@ class Assignment implements BlameableEntityInterface, TimestampableEntityInterfa
public const STATUS_STAFFED = 'staffed';
public const STATUS_PARTLY_STAFFED = 'partly_staffed';
public const STATUS_STAFFING = 'staffing';
public const STATUS_UNSTAFFED = 'unstaffed';
#[ORM\Id]
#[ORM\GeneratedValue]
+3
View File
@@ -97,6 +97,9 @@ class AssignmentRepository extends ServiceEntityRepository
->andHaving('COUNT(application.id) > 0')
;
break;
case Assignment::STATUS_UNSTAFFED:
$qb->having('assignment.availableDispositions > COUNT(disposition.id)');
break;
}
}
+140
View File
@@ -1,4 +1,144 @@
{% extends 'manager/layout.html.twig' %}
{% block title %}Offene Einsätze{% endblock %}
{% block content %}
<div class="flex items-start justify-between pb-4">
<h1 class="text-2xl font-bold">
Offene Einsätze
</h1>
</div>
<div class="data-table-wrapper">
<div class="data-table-wrapper__inner">
<table class="data-table">
<thead>
<tr>
<th>
Status
</th>
<th>
{{ knp_pagination_sortable(pagination, 'Einsatz&shy;zeitraum', 'destination.dateFrom') }}
</th>
<th>
{{ knp_pagination_sortable(pagination, 'Destination', 'destination.product') }}
</th>
<th>
{{ knp_pagination_sortable(pagination, 'Jobprofil', 'job_profile.name') }}
</th>
<th>
{{ knp_pagination_sortable(pagination, 'Bus', 'assignment.pickup') }}
</th>
<th>
Einteilungen
</th>
<th></th>
</tr>
</thead>
<tbody>
{% for assignment in pagination %}
<tr>
<td>
<div class="flex flex-col items-center space-y-2">
{% if assignment.status == 'draft' %}
<svg viewBox="0 0 5 5" class="h-4 w-4 fill-current text-gray-100">
<circle cx="3" cy="3" r="2" />
</svg>
{{ icon('edit', 'w-4 h-4') }}
{% else %}
{% if assignment.staffed %}
<svg viewBox="0 0 5 5" class="h-4 w-4 fill-current text-green-500">
<circle cx="3" cy="3" r="2" />
</svg>
{% elseif assignment.partlyStaffed %}
<svg viewBox="0 0 5 5" class="h-4 w-4 fill-current text-yellow-500">
<circle cx="3" cy="3" r="2" />
</svg>
{% elseif assignment.staffing %}
<svg viewBox="0 0 5 5" class="h-4 w-4 fill-current text-blue-500">
<circle cx="3" cy="3" r="2" />
</svg>
{% else %}
<svg viewBox="0 0 5 5" class="h-4 w-4 fill-current text-gray-100">
<circle cx="3" cy="3" r="2" />
</svg>
{% endif %}
{% if assignment.status == 'closed' %}
{{ icon('locked', 'w-4 h-4 text-red-500') }}
{% else %}
{{ icon('unlocked', 'w-4 h-4') }}
{% endif %}
{% endif %}
</div>
</td>
<td>
<a href="{{ path('app_administrative_assignment_detail', { 'uuid': assignment.uuid, 'r': return_url() }) }}">
{{ assignment.effectivePeriod.start|date('d.m.Y') }} -
<br>
{{ assignment.effectivePeriod.end|date('d.m.Y') }}
</a>
</td>
<td>
<a href="{{ path('app_administrative_assignment_detail', { 'uuid': assignment.uuid, 'r': return_url() }) }}"
class="flex items-start space-x-2">
{{ icon('flag-' ~ assignment.destination.country, 'w-5 h-5 shrink-0') }}
<div class="flex-1">
{{ assignment.destination.hotel }}
</div>
</a>
</td>
<td>
<a href="{{ path('app_administrative_assignment_detail', { 'uuid': assignment.uuid, 'r': return_url() }) }}">
{{ assignment.jobProfile.name }}
</a>
</td>
<td>
{% if assignment.pickup %}
{% set pickup = assignment.destination.pickup(assignment.pickup) %}
{% if pickup %}
<a href="{{ path('app_administrative_assignment_detail', { 'uuid': assignment.uuid, 'r': return_url() }) }}">
<span class="whitespace-nowrap">ab {{ pickup.city }}</span>
<br>
{{ pickup.time }}
</a>
{% else %}
<span class="text-red-500">ungültiger Zustieg</span>
{% endif %}
{% else %}
-
{% endif %}
</td>
<td>
<span>{{ assignment.dispositions|length }}/{{ assignment.availableDispositions }}</span>
<ul>
{% for disposition in assignment.dispositions %}
<li>
<div role="button"
title="Teamer:innen-Info anzeigen"
aria-label="Teamer:innen-Info anzeigen"
hx-get="{{ path('app_administrative_teamer_info', { 'uuid': disposition.teamer.uuid }) }}"
hx-target="body"
hx-swap="beforeend">
<span class="whitespace-nowrap">{{ disposition.teamer }}</span>
<twig:RatingStars averageRating="{{ disposition.teamer.averageRating }}" />
</div>
</li>
{% endfor %}
</ul>
</td>
<td>
</td>
</tr>
{% else %}
<tr>
<td colspan="8">
Keine Daten...
</td>
</tr>
{% endfor %}
</tbody>
</table>
{{ knp_pagination_render(pagination) }}
</div>
</div>
{% endblock %}