Compare commits

..
43 Commits
Author SHA1 Message Date
fromme 3c34cfa76a feat: offer the questionnaire for placements ended within a rolling window 2026-11-10 09:23:23 +01:00
fromme 9d0cdd7f52 chore: update inline documentation of feedback config files 2026-11-08 14:41:38 +01:00
fromme 9583612fdc refactor: use english naming for the n8n assignments api 2026-11-07 09:33:54 +01:00
fromme 0bc77b7463 feat: expose winter placements to n8n over an api endpoint 2026-11-06 10:09:56 +01:00
fromme 4ff963d1e2 feat: let managers edit the staffing matrix 2026-11-05 17:18:26 +01:00
fromme f9d2ff084d feat: decide the staffing split per ski level 2026-11-05 17:04:24 +01:00
fromme 7aefe88610 chore: replace contract template pdf 2026-11-05 10:57:18 +01:00
fromme 09eea86183 chore: update project dependencies 2026-11-04 16:29:04 +01:00
fromme ddfaa4b440 chore: streamlined naming of feedback menu items 2026-10-28 11:23:21 +01:00
fromme d3b9b0611b chore: update project dependencies 2026-10-28 09:19:05 +01:00
fromme fe0c854f1d refactor: offer the questionnaire test from the assignment overview 2026-10-27 17:37:47 +01:00
fromme 0b736b51fb feat: calmer questionnaire form with selects and clickable answer rows 2026-10-27 17:32:41 +01:00
fromme af97468b2d feat: put the placement in one line above the questionnaire 2026-10-27 17:27:40 +01:00
fromme a0170f5952 refactor: split the questionnaire into teamer and bus feedback 2026-10-27 17:22:22 +01:00
fromme 2f4f9800dd fix: offer the questionnaire after every placement, the bus part to escorts 2026-10-27 17:12:24 +01:00
fromme 9fedc5b5d3 feat: let the office test the questionnaire on any assignment 2026-10-27 17:07:17 +01:00
fromme a35f91ac63 feat: list and show submitted questionnaires to the office 2026-10-27 17:02:51 +01:00
fromme 890e04f8a6 feat: remind teamers of open questionnaires on the dashboard 2026-10-27 16:59:44 +01:00
fromme 5e4e574076 feat: let teamers fill in and read their questionnaire 2026-10-27 16:56:49 +01:00
fromme 2a041d25a0 feat: let the teamer fill in the questionnaire after a bus escort 2026-10-27 16:53:23 +01:00
fromme df6734c939 feat: store questionnaire responses per disposition 2026-10-27 16:51:56 +01:00
fromme 8070fda64d feat: build the questionnaire form from its definition 2026-10-27 16:47:38 +01:00
fromme d06b647dac feat: decide when a conditional questionnaire question is shown 2026-10-27 16:43:14 +01:00
fromme a84275b40e feat: add questionnaire definitions and their catalog 2026-10-27 16:41:46 +01:00
fromme 2ec2a4c93f chore: fix typo in menu item 2026-10-20 17:14:41 +02:00
fromme de4aedd26e refactor: name the per-teamer disposition lists correctly 2026-10-20 17:14:13 +02:00
frommeandClaude Opus 5.5 5090f72fab fix: log a called-off disposition under its own id key
The disposition call-off logged the disposition's id as "assignment_id" and
set the status from the Assignment constant; both now use the disposition's
own name.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-20 17:13:53 +02:00
fromme c00dd86eb4 feat: list upcoming season assignments among a teamer's dispositions 2026-10-20 17:13:45 +02:00
fromme 300bb2058f feat: apply season task deadlines to all open checklist entries 2026-10-20 16:52:45 +02:00
fromme 3fe510e64e fix: render form help texts smaller and muted 2026-10-20 16:52:32 +02:00
fromme 48691227cb chore: move menu entry to better suiting submenu 2026-10-20 16:34:12 +02:00
fromme 34ff630b75 chore: update project dependencies 2026-10-20 14:21:22 +02:00
fromme 3f806669c6 fix: show scrollbars only when an inner area overflows 2026-10-20 14:17:58 +02:00
fromme e31f607f66 chore: declare browser targets in .browserslistrc 2026-10-20 14:05:05 +02:00
fromme 8c53676133 feat: let the remaining textareas grow with their content 2026-10-20 14:04:55 +02:00
fromme 2de985b009 chore: upgrade webpack encore from 4.7 to 7.2 2026-10-20 14:04:43 +02:00
fromme 1cda9d378a chore: upgrade tailwind css from 3.4 to 4.3 2026-10-20 14:04:24 +02:00
fromme 9fcba26942 chore: bump node to 24 in ddev 2026-10-16 10:46:40 +02:00
fromme 13e5b6c3af feat: boost pagination and sorting links with htmx 2026-10-16 10:39:47 +02:00
fromme 493a43d952 fix: give the empty-field test case its own data provider 2026-10-16 10:12:30 +02:00
fromme 7493afde45 chore: update project dependencies 2026-10-16 10:06:22 +02:00
fromme d159cb212c feat: paginate the staffing matrix preview 2026-10-16 10:05:42 +02:00
fromme c7e0ad67e6 fix: put the guiding fee on one guide place only 2026-10-16 09:56:04 +02:00
179 changed files with 9445 additions and 6542 deletions

No files matched your search

+4
View File
@@ -0,0 +1,4 @@
# Tailwind 4's floor: browsers without cascade layers, or Chrome before 111, can't render the
# app's CSS, so the JS isn't transpiled for them either.
defaults and fully supports css-cascade-layers
not chrome < 111
+1 -1
View File
@@ -17,7 +17,7 @@ use_dns_when_possible: true
timezone: Europe/Berlin timezone: Europe/Berlin
composer_version: "2" composer_version: "2"
web_environment: [] web_environment: []
nodejs_version: "18" nodejs_version: "24"
corepack_enable: false corepack_enable: false
disable_upload_dirs_warning: true disable_upload_dirs_warning: true
+2
View File
@@ -94,6 +94,8 @@ MYEP_OAUTH2_URL_RESOURCE_OWNER_DETAILS=https://my.ep-reisen.de/api/userinfo
MYEP_OAUTH2_SCOPES=email,id,roles,profile MYEP_OAUTH2_SCOPES=email,id,roles,profile
# Shared key the sibling websites send in the X-Api-Key header. Empty here: set it per stage. # Shared key the sibling websites send in the X-Api-Key header. Empty here: set it per stage.
APPLICATION_FORM_API_KEY= APPLICATION_FORM_API_KEY=
# Shared key n8n reads the assignments feed with, in the X-Api-Key header. Empty here: set it per stage.
N8N_API_KEY=
# Booking link for the Team-Infocall, substituted for {bookingUrl} in the application form # Booking link for the Team-Infocall, substituted for {bookingUrl} in the application form
# receipt mail. Empty here: set it per stage. While it is empty that mail is not sent at all - # receipt mail. Empty here: set it per stage. While it is empty that mail is not sent at all -
# an invitation with a dead booking link is worse than none. # an invitation with a dead booking link is worse than none.
+2
View File
@@ -10,5 +10,7 @@ APP_TRUSTED_HOSTS='^localhost$'
# loaded in the test environment - so the throwaway key the tests send belongs here. # loaded in the test environment - so the throwaway key the tests send belongs here.
# Keep it in sync with ApplicationFormControllerTest::KEY. # Keep it in sync with ApplicationFormControllerTest::KEY.
APPLICATION_FORM_API_KEY=test-application-form-api-key APPLICATION_FORM_API_KEY=test-application-form-api-key
# Keep in sync with Api\Assignment\ListControllerTest::KEY.
N8N_API_KEY=test-n8n-api-key
# The receipt mail refuses to render without it, and several tests send that mail. # The receipt mail refuses to render without it, and several tests send that mail.
APPLICATION_FORM_BOOKING_URL=https://bookings.example.com/team-infocall APPLICATION_FORM_BOOKING_URL=https://bookings.example.com/team-infocall
+1 -1
View File
@@ -1 +1 @@
18 24
+9
View File
@@ -3,6 +3,15 @@ htmx.config.includeIndicatorStyles = false
htmx.config.historyCacheSize = 0 htmx.config.historyCacheSize = 0
htmx.config.allowScriptTags = false htmx.config.allowScriptTags = false
// A boosted link is a page navigation: show the error page like the browser would, instead of
// swallowing the 4xx/5xx and leaving the click without effect.
document.addEventListener('htmx:beforeSwap', (event) => {
if (true === event.detail.boosted && event.detail.xhr.status >= 400) {
event.detail.shouldSwap = true
event.detail.isError = false
}
})
import './bootstrap.js'; import './bootstrap.js';
/* /*
* Welcome to your app's main JavaScript file! * Welcome to your app's main JavaScript file!
@@ -0,0 +1,74 @@
import { Controller } from '@hotwired/stimulus'
/*
* Shows a questionnaire question only while its show_if holds, mirroring
* App\Model\Questionnaire\Definition::isVisible(): the condition must be met and the question it
* depends on must itself be shown.
*
* Every question row carries data-question-key; a conditional one also data-show-if, the JSON
* {question, operator, value} that App\Form\QuestionnaireType writes. A hidden row stays in the
* form and is submitted: a draft keeps its answer, and the server drops it on submit.
*/
export default class extends Controller {
connect() {
this.update()
}
update() {
const visible = {}
// Rows come in definition order, and a condition may only name an earlier question, so
// the question a row depends on has always been decided by the time the row is reached.
for (const row of this.element.querySelectorAll('[data-question-key]')) {
const key = row.dataset.questionKey
const condition = row.dataset.showIf ? JSON.parse(row.dataset.showIf) : null
visible[key] = null === condition
|| (true === visible[condition.question] && this.isMet(condition))
row.hidden = false === visible[key]
}
}
isMet({ question, operator, value }) {
const answer = this.answer(question)
if (null === answer) {
return false
}
switch (operator) {
case 'equals':
return answer === value
case 'in':
return value.includes(answer)
case 'lte':
return Number(answer) <= value
default:
return false
}
}
answer(key) {
const row = this.element.querySelector(`[data-question-key="${key}"]`)
if (null === row) {
return null
}
const checked = row.querySelector('input[type="radio"]:checked')
if (null !== checked) {
return checked.value
}
const select = row.querySelector('select')
if (null !== select) {
return '' === select.value ? null : select.value
}
return null
}
}
Binary file not shown.
+9 -9
View File
@@ -1,9 +1,9 @@
@import "components/badge.css"; @import "./components/badge.css";
@import "components/autocomplete.css"; @import "./components/autocomplete.css";
@import "components/button.css"; @import "./components/button.css";
@import "components/datatable.css"; @import "./components/datatable.css";
@import "components/datepicker.css"; @import "./components/datepicker.css";
@import "components/toast.css"; @import "./components/toast.css";
@import "components/tooltip.css"; @import "./components/tooltip.css";
@import "components/timeline.css"; @import "./components/timeline.css";
@import "components/mail-body.css"; @import "./components/mail-body.css";
+44 -5
View File
@@ -1,7 +1,46 @@
@import "tailwindcss/base"; @import "tailwindcss";
@import "_base.css"; @import "./_base.css" layer(base);
@import "./_components.css" layer(components);
@import "tailwindcss/components"; @plugin "@tailwindcss/forms";
@import "_components.css";
@import "tailwindcss/utilities"; @source inline("rotate-90");
@theme {
--font-sans: Lato, sans-serif;
--font-weight-semibold: 700;
--font-weight-bold: 900;
--color-primary: #3d8ccb;
--color-secondary: #f9c700;
}
/*
* Tailwind 3 defaults that Tailwind 4 changed: borders were gray-200 instead of currentColor,
* and buttons had a pointer cursor.
*/
@layer base {
*,
::after,
::before,
::backdrop,
::file-selector-button {
border-color: var(--color-gray-200, currentcolor);
}
button:not(:disabled),
[role="button"]:not(:disabled) {
cursor: pointer;
}
}
/*
* Thin scrollbars without a track for inner scrolling areas. The page scrollbar takes its
* style from <html>, which body * leaves out. Firefox and Chrome/Edge 121+ honour these;
* Safari keeps its own overlay scrollbars.
*/
@layer base {
body * {
scrollbar-width: thin;
scrollbar-color: var(--color-gray-300) transparent;
}
}
+3 -3
View File
@@ -3,11 +3,11 @@
.flatpickr-day.selected, .flatpickr-day.selected,
.flatpickr-day.selected:hover, .flatpickr-day.selected:hover,
.flatpickr-day.selected:focus { .flatpickr-day.selected:focus {
background-color: theme('colors.secondary'); background-color: var(--color-secondary);
border-color: theme('colors.secondary'); border-color: var(--color-secondary);
} }
.flatpickr-monthDropdown-months, .flatpickr-monthDropdown-months,
.flatpickr-current-month .flatpickr-monthDropdown-months { .flatpickr-current-month .flatpickr-monthDropdown-months {
@apply form-select pt-0 pb-0 focus:outline-none focus:shadow-none; @apply form-select pt-0 pb-0 focus:outline-hidden focus:shadow-none;
} }
+1 -1
View File
@@ -1,4 +1,4 @@
.scroll-container { .scroll-container {
@apply overflow-scroll; @apply overflow-auto;
max-height: calc(100vh - 320px); max-height: calc(100vh - 320px);
} }
+4 -4
View File
@@ -1,20 +1,20 @@
@import "toastify-js/src/toastify.css"; @import "toastify-js/src/toastify.css";
.toastify { .toastify {
@apply shadow-lg rounded; @apply shadow-lg rounded-sm;
} }
.toastify--success { .toastify--success {
@apply text-gray-100; @apply text-gray-100;
background: theme('colors.emerald.600'); background: var(--color-emerald-600);
} }
.toastify--warning { .toastify--warning {
@apply text-gray-100; @apply text-gray-100;
background: theme('colors.red.600'); background: var(--color-red-600);
} }
.toastify--info { .toastify--info {
@apply text-gray-100; @apply text-gray-100;
background: theme('colors.blue.600'); background: var(--color-blue-600);
} }
+5 -5
View File
@@ -1,18 +1,18 @@
@import "tippy.js/dist/tippy.css"; @import "tippy.js/dist/tippy.css";
.tippy-box { .tippy-box {
background-color: theme('colors.primary'); background-color: var(--color-primary);
} }
.tippy-box[data-placement^='top'] > .tippy-arrow::before { .tippy-box[data-placement^='top'] > .tippy-arrow::before {
border-top-color: theme('colors.primary'); border-top-color: var(--color-primary);
} }
.tippy-box[data-placement^='bottom'] > .tippy-arrow::before { .tippy-box[data-placement^='bottom'] > .tippy-arrow::before {
border-bottom-color: theme('colors.primary'); border-bottom-color: var(--color-primary);
} }
.tippy-box[data-placement^='left'] > .tippy-arrow::before { .tippy-box[data-placement^='left'] > .tippy-arrow::before {
border-left-color: theme('colors.primary'); border-left-color: var(--color-primary);
} }
.tippy-box[data-placement^='right'] > .tippy-arrow::before { .tippy-box[data-placement^='right'] > .tippy-arrow::before {
border-right-color: theme('colors.primary'); border-right-color: var(--color-primary);
} }
Generated
+602 -514
View File
File diff suppressed because it is too large. Load diff
+1
View File
@@ -13,6 +13,7 @@ security:
memory: memory:
users: users:
api: { roles: [ ROLE_API ] } api: { roles: [ ROLE_API ] }
n8n: { roles: [ ROLE_API_ASSIGNMENTS ] }
role_hierarchy: role_hierarchy:
ROLE_TEAM_ADMIN: [ ROLE_ADMINISTRATIVE ] ROLE_TEAM_ADMIN: [ ROLE_ADMINISTRATIVE ]
+271
View File
@@ -0,0 +1,271 @@
# Questionnaire a teamer fills in after a placement with bus escort, in addition to
# teamer_feedback.yaml and on the same page (App\Service\Questionnaire\DispositionContext).
#
# Replaces the Google form "Bus-Feedback 25-26"; the question-by-question spec, with every decision
# taken, is kept locally outside the repository. Questions whose answer the
# disposition already knows (travel date, destination, Reiseleitung, first pickup) are not asked:
# they are snapshotted into the response's context instead.
#
# Labels, help texts, section titles and option labels may be edited in place. Renaming or
# removing a question or option key, or changing a type, needs a new version: copy this file to
# bus_feedback.v1.yaml first, then bump `version` here. Submitted answers are keyed by it.
#
# Parsed and validated by App\Config\QuestionnaireCatalog; QuestionnaireCatalogTest builds it.
#
# Question fields: key, label, type (text | textarea | choice | multi | date | rating),
# required (default false), help, widget (choice only: radio | dropdown, default radio),
# options (choice and multi only), show_if ({question, equals | in | lte}, earlier questions only).
key: bus_feedback
version: 1
title: "Bus-Feedback"
sections:
- key: bus_trip
title: "Busfahrt"
questions:
- key: direction
label: "Hin- oder Rückfahrt"
type: choice
required: true
options:
- { key: outbound, label: "Hinfahrt" }
- { key: return, label: "Rückfahrt" }
- key: bus_company
label: "Bus-Unternehmen:"
type: choice
widget: dropdown
required: true
options:
- { key: boonk, label: "Boonk Reisen" }
- { key: piccolonia, label: "Piccolonia" }
- { key: heess, label: "Heeß" }
- { key: finkbeiner, label: "Finkbeiner" }
- { key: other, label: "Anderes Unternehmen" }
- key: bus_company_other
label: "Name des Busunternehmens:"
type: text
required: true
show_if: { question: bus_company, equals: other }
- key: bus_team
title: "Busteam"
questions:
- key: driver_names
label: "Busfahrer-Namen:"
type: text
required: true
- key: bus_first_pickup
title: "1. Abfahrtsort"
questions:
- key: on_time_at_first_pickup
label: "Bus pünktlich am 1. Abfahrtsort?"
type: choice
required: true
options:
- { key: "yes", label: "Ja" }
- { key: "no", label: "Nein" }
- key: delay_at_first_pickup
label: "Wieviel Verspätung hatte der Bus am 1. Abfahrtsort?"
type: text
required: true
show_if: { question: on_time_at_first_pickup, equals: "no" }
- key: bus_rating
title: "Bewertung Bus & Fahrer"
questions:
- key: overall_impression
label: "Gesamteindruck des Busses"
type: choice
widget: dropdown
required: true
options:
- { key: very_good, label: "Sehr gut" }
- { key: good, label: "Gut" }
- { key: ok, label: "OK" }
- { key: not_so_good, label: "nicht so gut" }
- { key: bad, label: "schlecht" }
- key: vehicle_age
label: "Alter des Fahrzeugs"
type: choice
widget: dropdown
required: true
options:
- { key: very_new, label: "Sehr neu" }
- { key: new, label: "neu" }
- { key: ok, label: "OK" }
- { key: somewhat_old, label: "etwas älter" }
- { key: very_old, label: "sehr alt" }
- key: seating_comfort
label: "Sitzkomfort im Bus"
type: choice
widget: dropdown
required: true
options:
- { key: very_good, label: "Sehr gut" }
- { key: good, label: "Gut" }
- { key: ok, label: "OK" }
- { key: not_so_good, label: "nicht so gut" }
- { key: bad, label: "schlecht" }
- key: driver_friendliness
label: "Freundlichkeit der Fahrer"
type: choice
widget: dropdown
required: true
options:
- { key: very_friendly, label: "Sehr freundlich" }
- { key: friendly, label: "freundlich" }
- { key: ok, label: "OK" }
- { key: not_so_friendly, label: "nicht so freundlich" }
- { key: unfriendly, label: "unfreundlich" }
- key: breaks
label: "Pausenzeiten"
type: choice
widget: dropdown
required: true
options:
- { key: very_good, label: "Sehr gut" }
- { key: good, label: "Gut" }
- { key: ok, label: "OK" }
- { key: not_so_good, label: "nicht so gut" }
- { key: unacceptable, label: "geht gar nicht" }
- key: temperature
label: "Temperatur im Bus"
type: choice
widget: dropdown
required: true
options:
- { key: very_good, label: "Sehr gut" }
- { key: good, label: "Gut" }
- { key: ok, label: "OK" }
- { key: not_so_good, label: "nicht so gut" }
- { key: unacceptable, label: "geht gar nicht" }
- key: guest_behaviour
label: "Verhalten der Gäste im Bus"
type: choice
widget: dropdown
required: true
options:
- { key: very_good, label: "Sehr gut" }
- { key: good, label: "Gut" }
- { key: ok, label: "OK" }
- { key: not_so_good, label: "nicht so gut" }
- { key: unacceptable, label: "geht gar nicht" }
- key: bus_pickups
title: "Ladestellen"
questions:
- key: drivers_knew_pickups
label: "Waren den Fahrern alle Abfahrtsorte bekannt?"
type: choice
required: true
options:
- { key: "yes", label: "Ja" }
- { key: "no", label: "Nein" }
- key: unknown_pickups
label: "Welche Abfahrtsorte waren nicht bekannt? Gab es dadurch Probleme?"
type: textarea
required: true
show_if: { question: drivers_knew_pickups, equals: "no" }
- key: bus_destination
title: "Zielkenntnis"
questions:
- key: drivers_knew_destination
label: "War den Busfahrern der Zielort und die Ausladestelle bekannt?"
type: choice
required: true
options:
- { key: "yes", label: "Ja" }
- { key: "no", label: "Nein" }
- key: bus_equipment
title: "Bus, Technik & Allgemeines"
questions:
- key: video
label: "Video/DVD-Gerät"
type: choice
widget: dropdown
required: true
options:
- { key: working, label: "funktionstüchtig" }
- { key: broken, label: "defekt" }
- { key: missing, label: "nicht vorhanden" }
- key: wc
label: "WC"
type: choice
widget: dropdown
required: true
options:
- { key: working, label: "funktionstüchtig" }
- { key: broken, label: "defekt" }
- { key: closed, label: "nicht geöffnet" }
- key: luggage
label: "Gepäck"
type: choice
widget: dropdown
required: true
options:
- { key: trailer, label: "Anhänger" }
- { key: ski_box, label: "Skikoffer" }
- { key: trailer_and_ski_box, label: "Anhänger und Skikoffer" }
- { key: none, label: "Kein Anhänger oder Skikoffer" }
- key: smoking
label: "Rauchen im Bus"
type: choice
widget: dropdown
required: true
options:
- { key: driver, label: "Busfahrer hat im Bus geraucht" }
- { key: driver_and_guests, label: "Busfahrer und Gäste haben im Bus geraucht" }
- { key: nobody, label: "Es wurde nicht geraucht" }
- key: snow_chains
label: "Schneeketten"
type: choice
widget: dropdown
required: true
options:
- { key: fitted, label: "Fahrer hat Ketten aufgezogen" }
- { key: not_needed, label: "Ketten wurden nicht gebraucht" }
- { key: not_fitted, label: "Ketten nicht aufgezogen (trotz starkem Schneefall)" }
- key: bus_damage
title: "Schäden"
questions:
- key: bus_damage
label: "Entstanden während der Fahrt Schäden am Bus?"
type: choice
widget: dropdown
required: true
options:
- { key: none, label: "Keine Schäden" }
- { key: settled_with_driver, label: "Bereits mit Fahrer abgeklärt" }
- { key: claim_expected, label: "Da wird vom Busunternehmen noch was kommen" }
- key: damage_description
label: "Was ist passiert?"
type: textarea
required: true
show_if: { question: bus_damage, equals: claim_expected }
- key: bus_remarks
title: "Anmerkungen zur Busfahrt"
questions:
- key: bus_remarks
label: "Das ging gar nicht / ist besonders hervorzuheben:"
type: textarea
+137
View File
@@ -0,0 +1,137 @@
# Questionnaire every teamer fills in after a placement (Disposition, not SeasonAssignment).
#
# Replaces the Google form "RL-Feedback 25-26"; the question-by-question spec, with every decision
# taken, is kept locally outside the repository. A teamer who escorted the bus
# also gets bus_feedback.yaml, on the same page. Questions whose answer the disposition already
# knows (name, job profile, house, arrival day) are not asked: they are snapshotted into the
# response's context instead.
#
# Labels, help texts, section titles and option labels may be edited in place. Renaming or
# removing a question or option key, or changing a type, needs a new version: copy this file to
# teamer_feedback.v1.yaml first, then bump `version` here. Submitted answers are keyed by it.
#
# Parsed and validated by App\Config\QuestionnaireCatalog; QuestionnaireCatalogTest builds it.
#
# Question fields: key, label, type (text | textarea | choice | multi | date | rating),
# required (default false), help, widget (choice only: radio | dropdown, default radio),
# options (choice and multi only), show_if ({question, equals | in | lte}, earlier questions only).
key: teamer_feedback
version: 1
title: "Wochenteamer:innen-Feedback"
description: |-
Nur durch euer Feedback können wir besser werden! 🙂
Bei Bewertunsskalen: 1= schlecht, 5 = sehr gut
sections:
- key: organisation
title: "Organisation & Ablauf"
questions:
- key: office_briefing_rating
label: "Wie gut hast du dich vorab vom Büro gebrieft gefühlt?"
type: rating
required: true
- key: office_briefing_low_reason
label: "Wenn 1 - 3 Sterne Bewertung, warum?"
type: textarea
required: true
show_if: { question: office_briefing_rating, lte: 3 }
- key: team_week_seminar
label: "War das Wochenteam-Seminar hilfreich für dich? Warst du bzw. wurdest du gut vorbereitet?"
type: choice
widget: dropdown
required: true
options:
- { key: very_helpful, label: "Ja, die Schulung war sehr hilfreich und ich fühlte mich bestens vorbereitet." }
- { key: mostly_helpful, label: "Ja, größtenteils – einige Themen hätte man noch vertiefen können." }
- { key: partly_helpful, label: "Es ging – die Schulung war teilweise hilfreich, aber nicht ausreichend für alle Aufgaben." }
- { key: rather_not_helpful, label: "Eher nein – ich fühlte mich in vielen Bereichen unvorbereitet." }
- { key: not_helpful, label: "Nein, die Schulung war kaum hilfreich und hat mich nicht auf den Arbeitsalltag vorbereitet." }
- { key: not_attended, label: "Ich habe nicht teilgenommen." }
- key: onsite_organisation_rating
label: "Wie gut lief die Reiseorganisation vor Ort?"
type: rating
required: true
- key: had_organisational_problems
label: "Gab es organisatorische Probleme?"
type: choice
required: true
options:
- { key: "yes", label: "Ja" }
- { key: "no", label: "Nein" }
- key: organisational_problems
label: "Wenn ja, welche?"
type: text
show_if: { question: had_organisational_problems, equals: "yes" }
- key: communication
title: "Kommunikation & Zusammenarbeit"
questions:
- key: teamer_collaboration_rating
label: "Wie lief die Kommunikation & Zusammenarbeit mit den E&P Teamer:innen vor Ort während der Reise?"
type: rating
required: true
- key: support_wished
label: "Welche Unterstützung hättest du dir zusätzlich gewünscht?"
type: textarea
- key: house_manager_problem_handling
label: "Wie ist deine Hausleitung mit Problemen vor Ort umgegangen?"
type: choice
widget: dropdown
required: true
options:
- { key: very_good, label: "Sehr gut – Probleme wurden schnell, fair und lösungsorientiert behandelt." }
- { key: good, label: "Gut – die meisten Anliegen wurden ernst genommen und bearbeitet." }
- { key: mixed, label: "Teils gut/teils schlecht – manche Probleme wurden gelöst, andere nicht." }
- { key: rather_poor, label: "Eher schlecht – es wurde wenig unternommen oder nicht auf Augenhöhe kommuniziert." }
- { key: very_poor, label: "Sehr schlecht – Probleme wurden ignoriert oder verschlimmert." }
- key: felt_overwhelmed
label: "Gab es Momente, in denen du dich überfordert gefühlt hast?"
type: choice
required: true
options:
- { key: "yes", label: "Ja" }
- { key: "no", label: "Nein" }
- key: overwhelmed_reason
label: "Wenn ja, wodurch?"
type: textarea
show_if: { question: felt_overwhelmed, equals: "yes" }
- key: improvement
title: "Verbesserung"
questions:
- key: wished_differently
label: "Was hättest du dir anders oder besser gewünscht?"
type: textarea
- key: would_work_again
label: "Würdest du wieder als Reiseleitung für E&P arbeiten?"
type: choice
required: true
options:
- { key: "yes", label: "Ja" }
- { key: "no", label: "Nein" }
- key: would_not_work_again_reason
label: "Wenn nein, warum nicht?"
type: textarea
show_if: { question: would_work_again, equals: "no" }
- key: other
title: "Sonstiges"
questions:
- key: anything_else
label: |-
Du hast nun schon vieles beantwortet,
aber nirgendwo konntest du folgende Aspekte loswerden:
type: textarea
+52 -1
View File
@@ -40,6 +40,37 @@ parameters:
# rejects every request instead of letting them through. # rejects every request instead of letting them through.
application_form_api_key: '%env(string:APPLICATION_FORM_API_KEY)%' application_form_api_key: '%env(string:APPLICATION_FORM_API_KEY)%'
# Shared key n8n reads the assignments feed with (GET /api/assignments). Same rules as above.
n8n_api_key: '%env(string:N8N_API_KEY)%'
# What the n8n assignments feed covers: assignments in these houses (matched against the first
# three characters of destination.hotelCode) for these job profiles - guide, course and
# service-team work. Job profile ids are database ids, so check them against production.
assignment_export.house_codes: [ DPW, DGS, DWW, DKI, DKS ]
assignment_export.job_profile_ids:
- 5 # Reiseleitung
- 9 # Reiseleitung Ski
- 10 # Reiseleitung Snowboard
- 3 # Kursleitung Ski Anfänger:innen
- 14 # Kursleitung Ski Fortgeschrittene
- 18 # Kursleitung Ski Anfänger:innen + Fortgeschrittene
- 36 # Kursleitung Ski Kinder Anfänger:innen & Kinderbetreuung
- 37 # Kursleitung Ski Kinder Fortgeschrittene
- 38 # Kursleitung Ski Kinder
- 4 # Kursleitung Snowboard Anfänger:innen
- 15 # Kursleitung Snowboard Fortgeschrittene
- 19 # Kursleitung Snowboard Anfänger:innen + Fortgeschrittene
- 47 # Kursleitung Snowboard Kinder/Jugendliche Anfänger:innen
- 20 # Reise- und Kursleitung Ski Anfänger:innen
- 21 # Reise- und Kursleitung Ski Fortgeschrittene
- 22 # Reise- und Kursleitung Ski Anfänger:innen + Fortgeschrittene
- 23 # Reise- und Kursleitung Snowboard Anfänger:innen
- 24 # Reise- und Kursleitung Snowboard Fortgeschrittene
- 25 # Reise- und Kursleitung Snowboard Anfänger:innen + Fortgeschrittene
- 6 # Serviceteam 40h (ST40)
- 13 # Serviceteam 25h (ST25)
- 16 # Serviceteam 10h (ST10)
# Booking link the application form receipt mail invites the applicant to. A deployment # Booking link the application form receipt mail invites the applicant to. A deployment
# value rather than part of the wording, so a new booking system does not need an edit in # value rather than part of the wording, so a new booking system does not need an edit in
# every stage's mail text. # every stage's mail text.
@@ -90,6 +121,11 @@ parameters:
season_start: '11-01' season_start: '11-01'
season_end: '04-01' season_end: '04-01'
# The teamer questionnaires after a placement (config/questionnaires/teamer_feedback.yaml, plus
# bus_feedback.yaml for a bus escort) are offered for placements that ended within this many
# days. Without a window every past placement would show up as pending on the teamers' dashboards.
questionnaire_window_days: 30
# How far ahead of the destination's first travel day a season assignment's checklist # How far ahead of the destination's first travel day a season assignment's checklist
# entries fall due. A relative date expression, applied to destination.dateFrom, and the # entries fall due. A relative date expression, applied to destination.dateFrom, and the
# single definition of both deadlines: the first is this offset, the second defaults to # single definition of both deadlines: the first is this offset, the second defaults to
@@ -151,6 +187,9 @@ services:
# Only the path enters the container - the file itself is parsed on demand by # Only the path enters the container - the file itself is parsed on demand by
# App\Config\EmailTextCatalog, since its contents matter on few requests. # App\Config\EmailTextCatalog, since its contents matter on few requests.
$emailTextsFile: '%kernel.project_dir%/config/email_texts.yaml' $emailTextsFile: '%kernel.project_dir%/config/email_texts.yaml'
# Likewise parsed on demand, by App\Config\QuestionnaireCatalog.
$questionnaireDir: '%kernel.project_dir%/config/questionnaires'
$questionnaireWindowDays: '%questionnaire_window_days%'
$mailingBusTransport: '%mailing_bus_transport%' $mailingBusTransport: '%mailing_bus_transport%'
$seasonStart: '%season_start%' $seasonStart: '%season_start%'
$seasonEnd: '%season_end%' $seasonEnd: '%season_end%'
@@ -428,7 +467,10 @@ services:
App\Security\AccessToken\ApiKeyTokenHandler: App\Security\AccessToken\ApiKeyTokenHandler:
arguments: arguments:
$apiKey: '%application_form_api_key%' # user identifier in security.yaml's api_user_provider => key
$apiKeys:
api: '%application_form_api_key%'
n8n: '%n8n_api_key%'
$logger: '@monolog.logger.api' $logger: '@monolog.logger.api'
App\Controller\Api\ApplicationFormController: App\Controller\Api\ApplicationFormController:
@@ -436,6 +478,13 @@ services:
$logger: '@monolog.logger.api' $logger: '@monolog.logger.api'
tags: [ 'controller.service_arguments' ] tags: [ 'controller.service_arguments' ]
App\Controller\Api\Assignment\ListController:
arguments:
$houseCodes: '%assignment_export.house_codes%'
$jobProfileIds: '%assignment_export.job_profile_ids%'
$logger: '@monolog.logger.api'
tags: [ 'controller.service_arguments' ]
App\EventListener\EmailRecipientWhitelistSubscriber: App\EventListener\EmailRecipientWhitelistSubscriber:
arguments: arguments:
$allowedRecipients: '%mail_recipient_whitelist%' $allowedRecipients: '%mail_recipient_whitelist%'
@@ -463,4 +512,6 @@ when@dev:
when@test: when@test:
parameters: parameters:
# a job profile id ListControllerTest inserts itself - db_test has no job profiles
assignment_export.job_profile_ids: [ 900001 ]
mailing_bus_transport: 'sync' mailing_bus_transport: 'sync'
+2 -1
View File
@@ -38,6 +38,7 @@ $rsyncOptions = [
'.env.test.local', '.env.test.local',
'.gitignore', '.gitignore',
'.nvmrc', '.nvmrc',
'.browserslistrc',
'.php-cs-fixer.cache', '.php-cs-fixer.cache',
'.php-cs-fixer.dist.php', '.php-cs-fixer.dist.php',
'.phpunit.result.cache', '.phpunit.result.cache',
@@ -51,7 +52,7 @@ $rsyncOptions = [
'phpunit.xml.dist', 'phpunit.xml.dist',
'public/.htaccess', 'public/.htaccess',
'tailwind.config.js', 'tailwind.config.js',
'webpack.config.js', 'webpack.config.mjs',
'rapidapi.paw', 'rapidapi.paw',
'bin/.phpunit', 'bin/.phpunit',
'temp/*', 'temp/*',
+35
View File
@@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Adds questionnaire_response: a respondent's answers to one questionnaire from
* config/questionnaires/, for now the teamer questionnaire after a placement.
*
* Written by hand rather than taken from doctrine:migrations:diff, which also carries the
* pre-existing drift of the dev database.
*/
final class Version20261027140000 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add questionnaire_response';
}
public function up(Schema $schema): void
{
$this->addSql('CREATE TABLE questionnaire_response (id INT AUTO_INCREMENT NOT NULL, uuid VARCHAR(36) NOT NULL, questionnaire VARCHAR(64) NOT NULL, version INT NOT NULL, status VARCHAR(16) NOT NULL, submitted_at DATETIME DEFAULT NULL, answers JSON NOT NULL, context JSON NOT NULL, created_by VARCHAR(255) DEFAULT NULL, updated_by VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME DEFAULT NULL, disposition_id INT DEFAULT NULL, UNIQUE INDEX UNIQ_A0400276D17F50A6 (uuid), UNIQUE INDEX questionnaire_disposition (questionnaire, disposition_id), INDEX IDX_A0400276287B65ED (disposition_id), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci`');
$this->addSql('ALTER TABLE questionnaire_response ADD CONSTRAINT FK_A0400276287B65ED FOREIGN KEY (disposition_id) REFERENCES disposition (id) ON DELETE CASCADE');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE questionnaire_response DROP FOREIGN KEY FK_A0400276287B65ED');
$this->addSql('DROP TABLE questionnaire_response');
}
}
+39
View File
@@ -0,0 +1,39 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Replaces the staffing matrix's split flag with one flag per ski level.
*
* A split row takes over every level it has, so it keeps planning the same assignments. The way
* back folds the two flags into one, which loses a row that takes over one level of two.
*
* Written by hand rather than taken from doctrine:migrations:diff, which also carries the
* pre-existing drift of the dev database.
*/
final class Version20261105100000 extends AbstractMigration
{
public function getDescription(): string
{
return 'Replace staffing_rule.split with split_beginner / split_advanced';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE staffing_rule ADD split_beginner TINYINT NOT NULL, ADD split_advanced TINYINT NOT NULL');
$this->addSql('UPDATE staffing_rule SET split_beginner = split AND ski_beginner, split_advanced = split AND ski_advanced');
$this->addSql('ALTER TABLE staffing_rule DROP split');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE staffing_rule ADD split TINYINT NOT NULL');
$this->addSql('UPDATE staffing_rule SET split = split_beginner OR split_advanced');
$this->addSql('ALTER TABLE staffing_rule DROP split_beginner, DROP split_advanced');
}
}
+45
View File
@@ -0,0 +1,45 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Numbers the places of an assignment, for the n8n placements feed ("platz_id").
*
* Existing active placements are numbered 1..n per assignment in creation order; called-off ones
* stay without a number, they hold no place. n8n has not seen a place number yet, so the initial
* order is free to choose.
*
* Written by hand rather than taken from doctrine:migrations:diff, which also carries the
* pre-existing drift of the dev database.
*/
final class Version20261106100000 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add disposition.slot and number the active placements per assignment';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE disposition ADD slot SMALLINT DEFAULT NULL');
$this->addSql(<<<'SQL'
UPDATE disposition
INNER JOIN (
SELECT id, ROW_NUMBER() OVER (PARTITION BY assignment_id ORDER BY id) AS slot
FROM disposition
WHERE status <> 'called_off' AND assignment_id IS NOT NULL
) AS numbered ON numbered.id = disposition.id
SET disposition.slot = numbered.slot
SQL);
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE disposition DROP slot');
}
}
+1676 -5443
View File
File diff suppressed because it is too large. Load diff
+12 -14
View File
@@ -1,39 +1,37 @@
{ {
"name": "myep-team", "name": "myep-team",
"dependencies": { "dependencies": {
"@babel/core": "^7.17.0", "@babel/core": "^8.0.0",
"@babel/preset-env": "^7.16.0", "@babel/preset-env": "^8.0.0",
"@hotwired/stimulus": "^3.0.0", "@hotwired/stimulus": "^3.0.0",
"@symfony/stimulus-bridge": "^3.2.0", "@symfony/stimulus-bridge": "^3.2.0",
"@symfony/webpack-encore": "^4.0.0", "@symfony/webpack-encore": "^7.2.0",
"@tailwindcss/forms": "^0.5.6", "@tailwindcss/forms": "^0.5.6",
"@tailwindcss/typography": "^0.5.10", "@tailwindcss/postcss": "^4.3.3",
"@trevoreyre/autocomplete-js": "^2.4.1", "@trevoreyre/autocomplete-js": "^2.4.1",
"autoprefixer": "^10.4.15", "babel-plugin-polyfill-corejs3": "^1.0.0",
"chart.js": "^4.5.1", "chart.js": "^4.5.1",
"core-js": "^3.23.0", "core-js": "^3.50.0",
"dropzone": "^6.0.0-beta.2", "dropzone": "^6.0.0-beta.2",
"file-loader": "^6.2.0",
"flatpickr": "^4.6.13", "flatpickr": "^4.6.13",
"htmx.org": "^1.9.10", "htmx.org": "^2.0.11",
"lightningcss": "^1.32.0",
"mjml": "^4.15.3", "mjml": "^4.15.3",
"postcss": "^8.4.29", "postcss": "^8.4.29",
"postcss-import": "^15.1.0", "postcss-loader": "^8.1.1",
"postcss-loader": "^7.3.3",
"pretty-bytes": "^6.1.1", "pretty-bytes": "^6.1.1",
"regenerator-runtime": "^0.13.9", "regenerator-runtime": "^0.13.9",
"sortablejs": "^1.15.0", "sortablejs": "^1.15.0",
"stimulus-use": "^0.52.2", "stimulus-use": "^0.52.2",
"tailwindcss": "^3.3.3", "tailwindcss": "^4.3.3",
"tippy.js": "^6.3.7", "tippy.js": "^6.3.7",
"toastify-js": "^1.12.0", "toastify-js": "^1.12.0",
"webpack": "^5.74.0", "webpack": "^5.101.0",
"webpack-cli": "^4.10.0" "webpack-cli": "^7.0.0"
}, },
"license": "UNLICENSED", "license": "UNLICENSED",
"private": true, "private": true,
"scripts": { "scripts": {
"dev-server": "encore dev-server",
"dev": "encore dev", "dev": "encore dev",
"watch": "encore dev --watch", "watch": "encore dev --watch",
"build": "encore production --progress", "build": "encore production --progress",
+2 -4
View File
@@ -1,7 +1,5 @@
module.exports = { module.exports = {
plugins: { plugins: {
'postcss-import': {}, '@tailwindcss/postcss': {},
tailwindcss: {},
autoprefixer: {},
} }
} }
+389
View File
@@ -0,0 +1,389 @@
<?php
namespace App\Config;
use App\Enum\ChoiceWidget;
use App\Enum\ConditionOperator;
use App\Enum\QuestionType;
use App\Model\Questionnaire\Condition;
use App\Model\Questionnaire\Definition;
use App\Model\Questionnaire\Option;
use App\Model\Questionnaire\Question;
use App\Model\Questionnaire\Section;
use Symfony\Component\Yaml\Yaml;
/**
* Reads questionnaire definitions from config/questionnaires/.
*
* `<key>.yaml` is the current version of a questionnaire; `<key>.v<n>.yaml` keeps an older one that
* responses were submitted under, so they can still be rendered with the labels they were given.
*
* Files are parsed lazily and memoised, like EmailTextCatalog. A definition is checked strictly
* while it is built - unknown fields, unknown types, duplicate keys and show_if conditions that
* point at a later question or a non-existent option all throw - because a typo in the YAML should
* fail in QuestionnaireCatalogTest, not in front of a teamer.
*/
class QuestionnaireCatalog
{
/**
* The questionnaire every teamer fills in after a placement; see DispositionVoter::QUESTIONNAIRE.
*/
public const string TEAMER_FEEDBACK = 'teamer_feedback';
/**
* The one a teamer who escorted the bus fills in as well, on the same page.
*/
public const string BUS_FEEDBACK = 'bus_feedback';
private const array ROOT_FIELDS = ['key', 'version', 'title', 'description', 'sections'];
private const array SECTION_FIELDS = ['key', 'title', 'questions'];
private const array QUESTION_FIELDS = ['key', 'label', 'type', 'required', 'help', 'widget', 'options', 'show_if'];
private const array OPTION_FIELDS = ['key', 'label'];
// A question key becomes a form field name and a JSON key in stored answers.
private const string KEY_PATTERN = '/^[a-z][a-z0-9_]*$/';
private const int RATING_MIN = 1;
private const int RATING_MAX = 5;
/**
* @var array<string, Definition> keyed by file path
*/
private array $definitions = [];
public function __construct(
private readonly string $questionnaireDir,
) {
}
/**
* The first end date the teamer questionnaire is still offered for: the services.yaml
* parameter questionnaire_window_days, in days before today. Placements that ended earlier are neither
* pending nor open, so a deploy does not offer it for every past placement at once.
*/
public static function windowStart(int $windowDays): \DateTimeImmutable
{
if ($windowDays < 0) {
throw new \InvalidArgumentException(sprintf('questionnaire_window_days must not be negative, got %d', $windowDays));
}
return new \DateTimeImmutable(sprintf('today -%d days', $windowDays));
}
/**
* @param int|null $version null for the current version
*/
public function get(string $key, ?int $version = null): Definition
{
$current = $this->load($this->questionnaireDir.'/'.$key.'.yaml');
if (null === $version || $version === $current->version) {
return $current;
}
return $this->load(sprintf('%s/%s.v%d.yaml', $this->questionnaireDir, $key, $version));
}
/**
* The keys of the questionnaires there are, i.e. of their current files.
*
* @return list<string>
*/
public function keys(): array
{
$keys = [];
foreach (glob($this->questionnaireDir.'/*.yaml') ?: [] as $file) {
if (1 === preg_match('/^([a-z0-9_]+)\.yaml$/', basename($file), $match)) {
$keys[] = $match[1];
}
}
sort($keys);
return $keys;
}
/**
* Every definition in the directory, archived versions included.
*
* @return list<Definition>
*/
public function all(): array
{
$files = glob($this->questionnaireDir.'/*.yaml') ?: [];
sort($files);
return array_map($this->load(...), $files);
}
private function load(string $file): Definition
{
if (!is_file($file)) {
throw new \InvalidArgumentException(sprintf('Questionnaire definition "%s" does not exist', $file));
}
return $this->definitions[$file] ??= $this->build(Yaml::parseFile($file), basename($file));
}
private function build(mixed $data, string $file): Definition
{
$this->assertFields($data, self::ROOT_FIELDS, ['key', 'version', 'title', 'sections'], $file);
if (1 !== preg_match('/^(?<key>[a-z0-9_]+)(\.v(?<version>\d+))?\.yaml$/', $file, $name)) {
throw $this->error($file, 'file name must be <key>.yaml or <key>.v<version>.yaml');
}
if ($data['key'] !== $name['key']) {
throw $this->error($file, sprintf('key "%s" does not match the file name', $data['key']));
}
if (!is_int($data['version']) || $data['version'] < 1) {
throw $this->error($file, 'version must be a positive integer');
}
if (isset($name['version']) && (int) $name['version'] !== $data['version']) {
throw $this->error($file, sprintf('version %d does not match the file name', $data['version']));
}
if (!is_array($data['sections']) || [] === $data['sections'] || !array_is_list($data['sections'])) {
throw $this->error($file, 'sections must be a non-empty list');
}
$sections = [];
$sectionKeys = [];
/** @var array<string, Question> $questions every question parsed so far, for show_if */
$questions = [];
foreach ($data['sections'] as $index => $sectionData) {
$context = sprintf('%s: section #%d', $file, $index + 1);
$this->assertFields($sectionData, self::SECTION_FIELDS, ['key', 'questions'], $context);
$key = $this->key($sectionData['key'], $context);
if (in_array($key, $sectionKeys, true)) {
throw $this->error($context, sprintf('duplicate section key "%s"', $key));
}
$sectionKeys[] = $key;
$context = sprintf('%s: section "%s"', $file, $key);
if (!is_array($sectionData['questions']) || [] === $sectionData['questions'] || !array_is_list($sectionData['questions'])) {
throw $this->error($context, 'questions must be a non-empty list');
}
$sectionQuestions = [];
foreach ($sectionData['questions'] as $questionData) {
$question = $this->buildQuestion($questionData, $questions, $context);
$questions[$question->key] = $question;
$sectionQuestions[] = $question;
}
$sections[] = new Section($key, $this->optionalString($sectionData['title'] ?? null, 'title', $context), $sectionQuestions);
}
return new Definition(
$data['key'],
$data['version'],
$this->string($data['title'], 'title', $file),
$this->optionalString($data['description'] ?? null, 'description', $file),
$sections,
);
}
/**
* @param array<string, Question> $earlier
*/
private function buildQuestion(mixed $data, array $earlier, string $context): Question
{
$this->assertFields($data, self::QUESTION_FIELDS, ['key', 'label', 'type'], $context.': question');
$key = $this->key($data['key'], $context.': question');
$context = sprintf('%s: question "%s"', $context, $key);
if (isset($earlier[$key])) {
throw $this->error($context, 'duplicate question key');
}
$type = QuestionType::tryFrom((string) $data['type'])
?? throw $this->error($context, sprintf('unknown type "%s"', $data['type']));
$required = $data['required'] ?? false;
if (!is_bool($required)) {
throw $this->error($context, 'required must be true or false');
}
$widget = null;
if (array_key_exists('widget', $data)) {
if (QuestionType::CHOICE !== $type) {
throw $this->error($context, 'widget is only allowed on a choice question');
}
$widget = ChoiceWidget::tryFrom((string) $data['widget'])
?? throw $this->error($context, sprintf('unknown widget "%s"', $data['widget']));
} elseif (QuestionType::CHOICE === $type) {
$widget = ChoiceWidget::RADIO;
}
$options = [];
if ($type->hasOptions()) {
$options = $this->buildOptions($data['options'] ?? null, $context);
} elseif (array_key_exists('options', $data)) {
throw $this->error($context, sprintf('options are not allowed on a %s question', $type->value));
}
$showIf = array_key_exists('show_if', $data)
? $this->buildCondition($data['show_if'], $earlier, $context)
: null;
return new Question(
$key,
$this->string($data['label'], 'label', $context),
$type,
$required,
$this->optionalString($data['help'] ?? null, 'help', $context),
$widget,
$options,
$showIf,
);
}
/**
* @return list<Option>
*/
private function buildOptions(mixed $data, string $context): array
{
if (!is_array($data) || [] === $data || !array_is_list($data)) {
throw $this->error($context, 'options must be a non-empty list');
}
$options = [];
$keys = [];
foreach ($data as $optionData) {
$this->assertFields($optionData, self::OPTION_FIELDS, self::OPTION_FIELDS, $context.': option');
// An option key is stored as the answer; YAML would turn an unquoted 1 into an int.
$key = $this->key((string) $optionData['key'], $context.': option');
if (in_array($key, $keys, true)) {
throw $this->error($context, sprintf('duplicate option key "%s"', $key));
}
$keys[] = $key;
$options[] = new Option($key, $this->string($optionData['label'], 'option label', $context));
}
return $options;
}
/**
* @param array<string, Question> $earlier
*/
private function buildCondition(mixed $data, array $earlier, string $context): Condition
{
$context .= ': show_if';
$operators = array_map(static fn (ConditionOperator $operator): string => $operator->value, ConditionOperator::cases());
$this->assertFields($data, ['question', ...$operators], ['question'], $context);
$given = array_values(array_intersect($operators, array_keys($data)));
if (1 !== count($given)) {
throw $this->error($context, sprintf('needs exactly one of %s', implode(', ', $operators)));
}
$operator = ConditionOperator::from($given[0]);
$value = $data[$given[0]];
// Only an earlier question can be answered by the time this one is reached, and it rules
// out cycles without having to look for them.
$controlling = $earlier[$data['question']]
?? throw $this->error($context, sprintf('question "%s" is not an earlier question', $data['question']));
match ($operator) {
ConditionOperator::EQUALS, ConditionOperator::IN => $this->assertOptionValue($controlling, $operator, $value, $context),
ConditionOperator::LTE => $this->assertRatingValue($controlling, $value, $context),
};
return new Condition($controlling->key, $operator, $value);
}
private function assertOptionValue(Question $controlling, ConditionOperator $operator, mixed $value, string $context): void
{
if (QuestionType::CHOICE !== $controlling->type) {
throw $this->error($context, sprintf('%s needs a choice question, "%s" is %s', $operator->value, $controlling->key, $controlling->type->value));
}
$values = ConditionOperator::IN === $operator ? $value : [$value];
if (!is_array($values) || [] === $values || !array_is_list($values)) {
throw $this->error($context, 'in needs a non-empty list of option keys');
}
foreach ($values as $optionKey) {
if (!is_string($optionKey) || null === $controlling->getOption($optionKey)) {
throw $this->error($context, sprintf('"%s" is not an option of "%s"', is_string($optionKey) ? $optionKey : json_encode($optionKey), $controlling->key));
}
}
}
private function assertRatingValue(Question $controlling, mixed $value, string $context): void
{
if (QuestionType::RATING !== $controlling->type) {
throw $this->error($context, sprintf('lte needs a rating question, "%s" is %s', $controlling->key, $controlling->type->value));
}
if (!is_int($value) || $value < self::RATING_MIN || $value > self::RATING_MAX) {
throw $this->error($context, sprintf('lte needs a rating from %d to %d', self::RATING_MIN, self::RATING_MAX));
}
}
/**
* @param list<string> $allowed
* @param list<string> $required
*/
private function assertFields(mixed $data, array $allowed, array $required, string $context): void
{
if (!is_array($data) || array_is_list($data)) {
throw $this->error($context, 'must be a mapping');
}
if ([] !== $unknown = array_diff(array_keys($data), $allowed)) {
throw $this->error($context, sprintf('unknown field(s) %s', implode(', ', $unknown)));
}
if ([] !== $missing = array_diff($required, array_keys($data))) {
throw $this->error($context, sprintf('missing field(s) %s', implode(', ', $missing)));
}
}
private function key(mixed $value, string $context): string
{
if (!is_string($value) || 1 !== preg_match(self::KEY_PATTERN, $value)) {
throw $this->error($context, sprintf('key %s must be lower snake_case', json_encode($value)));
}
return $value;
}
private function string(mixed $value, string $field, string $context): string
{
if (!is_string($value) || '' === trim($value)) {
throw $this->error($context, sprintf('%s must be a non-empty string', $field));
}
return $value;
}
private function optionalString(mixed $value, string $field, string $context): ?string
{
return null === $value ? null : $this->string($value, $field, $context);
}
private function error(string $context, string $message): \UnexpectedValueException
{
return new \UnexpectedValueException(sprintf('%s: %s', $context, $message));
}
}
@@ -1,34 +0,0 @@
<?php
namespace App\Controller\Admin\System\StaffingRule;
use App\Service\Assignment\StaffingConfigurationException;
use App\Service\Export\StaffingPreviewExporter;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
class PreviewController extends AbstractController
{
public function __construct(private readonly StaffingPreviewExporter $previewExporter)
{
}
#[Route('/admin/system/staffing-rule/preview', name: 'app_admin_system_staffing_rule_preview')]
#[IsGranted('ROLE_TEAM_ADMIN')]
public function index(): Response
{
try {
$rows = $this->previewExporter->rows();
} catch (StaffingConfigurationException $e) {
$this->addFlash('error', 'Ein Jobprofil oder Honorar der Besetzungsmatrix ist nicht (mehr) vorhanden: '.$e->getMessage());
return $this->redirectToRoute('app_admin_system_staffing_rule_index');
}
return $this->render('admin/system/staffing_rule/preview.html.twig', [
'rows' => $rows,
]);
}
}
@@ -5,8 +5,8 @@ namespace App\Controller\Admin\Teamer;
use App\Entity\Teamer; use App\Entity\Teamer;
use App\Htmx\HxRedirectResponse; use App\Htmx\HxRedirectResponse;
use App\Repository\ApplicationRepository; use App\Repository\ApplicationRepository;
use App\Repository\DispositionRepository;
use App\Service\Teamer\AccountDeletionHandler; use App\Service\Teamer\AccountDeletionHandler;
use App\Service\Teamer\UpcomingPlacementCollector;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
@@ -18,7 +18,7 @@ class DeleteAccountController extends AbstractController
public function __construct( public function __construct(
private readonly AccountDeletionHandler $accountDeletionHandler, private readonly AccountDeletionHandler $accountDeletionHandler,
private readonly ApplicationRepository $applicationRepository, private readonly ApplicationRepository $applicationRepository,
private readonly DispositionRepository $dispositionRepository, private readonly UpcomingPlacementCollector $upcomingPlacementCollector,
) { ) {
} }
@@ -39,7 +39,8 @@ class DeleteAccountController extends AbstractController
return $this->render('admin/teamer/modal_delete_account.html.twig', [ return $this->render('admin/teamer/modal_delete_account.html.twig', [
'teamer' => $teamer, 'teamer' => $teamer,
'pendingApplicationCount' => count($this->applicationRepository->getPendingForTeamer($teamer, 100)), 'pendingApplicationCount' => count($this->applicationRepository->getPendingForTeamer($teamer, 100)),
'upcomingDispositionCount' => count($this->dispositionRepository->getUpcomingDispositionsByTeamer($teamer, 100)), // season assignments included: an active season placement is an open commitment as well
'upcomingPlacementCount' => count($this->upcomingPlacementCollector->collect($teamer)),
]); ]);
} }
@@ -2,7 +2,6 @@
namespace App\Controller\Administrative\Disposition; namespace App\Controller\Administrative\Disposition;
use App\Entity\Assignment;
use App\Entity\Disposition; use App\Entity\Disposition;
use App\Event\DispositionCalledOffEvent; use App\Event\DispositionCalledOffEvent;
use App\Form\DispositionCallOffType; use App\Form\DispositionCallOffType;
@@ -33,7 +32,7 @@ class CallOffController extends AbstractController
$form->handleRequest($request); $form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) { if ($form->isSubmitted() && $form->isValid()) {
$disposition->setStatus(Assignment::STATUS_CALLED_OFF); $disposition->setStatus(Disposition::STATUS_CALLED_OFF);
$sendNotification = $form->get('sendNotification')->getData(); $sendNotification = $form->get('sendNotification')->getData();
$this->entityManager->flush(); $this->entityManager->flush();
@@ -46,7 +45,7 @@ class CallOffController extends AbstractController
$assignment = $disposition->getAssignment(); $assignment = $disposition->getAssignment();
$this->logger->info('Call off disposition', [ $this->logger->info('Call off disposition', [
'assignment_id' => $disposition->getId(), 'disposition_id' => $disposition->getId(),
'destination' => (string) $assignment->getDestination(), 'destination' => (string) $assignment->getDestination(),
'job_profile' => $assignment->getJobProfile()->getName(), 'job_profile' => $assignment->getJobProfile()->getName(),
]); ]);
@@ -0,0 +1,61 @@
<?php
namespace App\Controller\Administrative\Questionnaire;
use App\Config\QuestionnaireCatalog;
use App\Controller\Traits\ReturnUrlTrait;
use App\Entity\QuestionnaireResponse;
use App\Repository\QuestionnaireResponseRepository;
use Symfony\Bridge\Doctrine\Attribute\MapEntity;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Routing\Requirement\Requirement;
use Symfony\Component\Security\Http\Attribute\IsGranted;
/**
* One submitted questionnaire: what the disposition knew when it was submitted, then the answers,
* rendered with the definition version they were given under.
*/
class DetailController extends AbstractController
{
use ReturnUrlTrait;
public function __construct(
private readonly QuestionnaireCatalog $catalog,
private readonly QuestionnaireResponseRepository $responseRepository,
) {
}
// the requirement keeps /administrative/questionnaire/list from being read as a uuid
#[Route('/administrative/questionnaire/{uuid}', name: 'app_administrative_questionnaire_detail', requirements: ['uuid' => Requirement::UUID])]
#[IsGranted('ROLE_ADMINISTRATIVE')]
public function index(
#[MapEntity(mapping: ['uuid' => 'uuid'])]
QuestionnaireResponse $response,
Request $request,
): Response {
// a draft is still the teamer's
if (false === $response->isSubmitted()) {
throw new NotFoundHttpException();
}
// the other questionnaire of the same placement, e.g. the bus feedback beside the teamer feedback
$siblings = array_filter(
$this->responseRepository->findByDisposition($response->getDisposition()),
static fn (QuestionnaireResponse $sibling): bool => $sibling !== $response && $sibling->isSubmitted(),
);
return $this->render('administrative/questionnaire/detail.html.twig', [
'definition' => $this->catalog->get($response->getQuestionnaire(), $response->getVersion()),
'response' => $response,
'siblings' => array_map(fn (QuestionnaireResponse $sibling): array => [
'response' => $sibling,
'title' => $this->catalog->get($sibling->getQuestionnaire(), $sibling->getVersion())->title,
], array_values($siblings)),
'returnUrl' => $this->getReturnUrl($request, 'app_administrative_questionnaire_index'),
]);
}
}
@@ -0,0 +1,65 @@
<?php
namespace App\Controller\Administrative\Questionnaire;
use App\Config\QuestionnaireCatalog;
use App\Repository\QuestionnaireResponseRepository;
use App\Service\Common\QuestionnaireResponseFilterHandler;
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;
use Symfony\Component\Security\Http\Attribute\IsGranted;
/**
* The submitted responses to one questionnaire, teamer or bus feedback. Only administrative users
* read them: they rate the house manager among others, so house managers are deliberately not
* let in.
*/
class IndexController extends AbstractController
{
public function __construct(
private readonly QuestionnaireResponseFilterHandler $filterHandler,
private readonly QuestionnaireResponseRepository $responseRepository,
private readonly QuestionnaireCatalog $catalog,
private readonly PaginatorInterface $paginator,
) {
}
#[Route(
'/administrative/questionnaire/list/{questionnaire}',
name: 'app_administrative_questionnaire_index',
requirements: ['questionnaire' => '[a-z0-9_]+'],
defaults: ['questionnaire' => QuestionnaireCatalog::TEAMER_FEEDBACK],
)]
#[IsGranted('ROLE_ADMINISTRATIVE')]
public function index(string $questionnaire, Request $request): Response
{
$keys = $this->catalog->keys();
if (!in_array($questionnaire, $keys, true)) {
throw $this->createNotFoundException(sprintf('No questionnaire "%s"', $questionnaire));
}
$filterDto = $this->filterHandler->getFilterSettings();
$pagination = $this->paginator->paginate(
$this->responseRepository->getListQuery($questionnaire, $filterDto),
$request->query->getInt('page', 1),
$request->query->getInt('limit', 50),
[
'defaultSortFieldName' => 'response.submittedAt',
'defaultSortDirection' => 'desc',
]
);
return $this->render('administrative/questionnaire/index.html.twig', [
'definition' => $this->catalog->get($questionnaire),
// for switching between the questionnaires
'definitions' => array_map($this->catalog->get(...), $keys),
'pagination' => $pagination,
'filterDto' => $filterDto,
]);
}
}
@@ -0,0 +1,75 @@
<?php
namespace App\Controller\Administrative\Questionnaire;
use App\Config\QuestionnaireCatalog;
use App\Controller\Traits\ReturnUrlTrait;
use App\Entity\Assignment;
use App\Form\QuestionnaireType;
use App\Model\Questionnaire\Definition;
use Symfony\Bridge\Doctrine\Attribute\MapEntity;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
/**
* The questionnaires as a teamer gets them, for trying out on any assignment - before or after the
* trip, placed or not. It shows what a placement on this assignment gets - the teamer feedback,
* and the bus feedback too for a bus escort; ?bus_escort=1 or 0 tries the other case. Nothing is
* saved: "Absenden" shows the answers as they would be stored, "Entwurf speichern" just keeps them
* in the form.
*/
class TestController extends AbstractController
{
use ReturnUrlTrait;
public function __construct(
private readonly QuestionnaireCatalog $catalog,
) {
}
#[Route('/administrative/questionnaire/test/{uuid}', name: 'app_administrative_questionnaire_test')]
#[IsGranted('ROLE_ADMINISTRATIVE')]
public function index(
#[MapEntity(mapping: ['uuid' => 'uuid'])]
Assignment $assignment,
Request $request,
): Response {
$busEscort = $request->query->has('bus_escort')
? $request->query->getBoolean('bus_escort')
: $assignment->hasBusEscort();
$definitions = [$this->catalog->get(QuestionnaireCatalog::TEAMER_FEEDBACK)];
if ($busEscort) {
$definitions[] = $this->catalog->get(QuestionnaireCatalog::BUS_FEEDBACK);
}
$form = $this->createForm(QuestionnaireType::class, [], ['definitions' => $definitions]);
$form->handleRequest($request);
$submitted = null;
$draft = false;
if ($form->isSubmitted() && $form->isValid()) {
if (QuestionnaireType::isFinal($form)) {
$submitted = array_map(static fn (Definition $definition): array => [
'definition' => $definition,
'answers' => $definition->withoutHiddenAnswers($form->getData()[$definition->key] ?? []),
], $definitions);
} else {
$draft = true;
}
}
return $this->render('administrative/questionnaire/test.html.twig', [
'assignment' => $assignment,
'form' => $form,
'submitted' => $submitted,
'draft' => $draft,
'busEscort' => $busEscort,
'returnUrl' => $this->getReturnUrl($request, 'app_administrative_assignment_index'),
]);
}
}
@@ -46,6 +46,9 @@ class TaskDeadlineController extends AbstractController
$form->handleRequest($request); $form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) { if ($form->isSubmitted() && $form->isValid()) {
$applyToAll = true === $form->get('applyToAll')->getData();
$appliedCount = $applyToAll ? ($seasonAssignment?->applyDeadlinesToOpenTasks($task) ?? 0) : 0;
$this->entityManager->flush(); $this->entityManager->flush();
$this->logger->info('Change season assignment task deadlines', [ $this->logger->info('Change season assignment task deadlines', [
@@ -54,9 +57,13 @@ class TaskDeadlineController extends AbstractController
'task' => $task->getTaskKey(), 'task' => $task->getTaskKey(),
'deadline_override_1' => $task->getDeadlineOverride1()?->format('Y-m-d'), 'deadline_override_1' => $task->getDeadlineOverride1()?->format('Y-m-d'),
'deadline_override_2' => $task->getDeadlineOverride2()?->format('Y-m-d'), 'deadline_override_2' => $task->getDeadlineOverride2()?->format('Y-m-d'),
'apply_to_all' => $applyToAll,
'applied_count' => $appliedCount,
]); ]);
$this->addFlash('success', 'Die Fristen wurden gespeichert'); $this->addFlash('success', $applyToAll
? 'Die Fristen wurden für alle offenen Einträge gespeichert'
: 'Die Fristen wurden gespeichert');
return new HxRedirectResponse($returnUrl); return new HxRedirectResponse($returnUrl);
} }
@@ -1,6 +1,6 @@
<?php <?php
namespace App\Controller\Admin\System\StaffingRule; namespace App\Controller\Administrative\System\StaffingRule;
use App\Entity\StaffingRule; use App\Entity\StaffingRule;
use App\Form\StaffingRuleType; use App\Form\StaffingRuleType;
@@ -21,8 +21,8 @@ class CreateController extends AbstractController
) { ) {
} }
#[Route('/admin/system/staffing-rule/create', name: 'app_admin_system_staffing_rule_create')] #[Route('/administrative/system/staffing-rule/create', name: 'app_administrative_system_staffing_rule_create')]
#[IsGranted('ROLE_TEAM_ADMIN')] #[IsGranted('ROLE_ADMINISTRATIVE')]
public function index(Request $request): Response public function index(Request $request): Response
{ {
$rule = new StaffingRule(); $rule = new StaffingRule();
@@ -39,10 +39,10 @@ class CreateController extends AbstractController
'product_code' => $rule->getProductCode(), 'product_code' => $rule->getProductCode(),
]); ]);
return new HxRedirectResponse($this->generateUrl('app_admin_system_staffing_rule_index')); return new HxRedirectResponse($this->generateUrl('app_administrative_system_staffing_rule_index'));
} }
return $this->render('admin/system/staffing_rule/modal_create.html.twig', [ return $this->render('administrative/system/staffing_rule/modal_create.html.twig', [
'form' => $form->createView(), 'form' => $form->createView(),
]); ]);
} }
@@ -1,6 +1,6 @@
<?php <?php
namespace App\Controller\Admin\System\StaffingRule; namespace App\Controller\Administrative\System\StaffingRule;
use App\Entity\StaffingRule; use App\Entity\StaffingRule;
use App\Htmx\HxRedirectResponse; use App\Htmx\HxRedirectResponse;
@@ -20,8 +20,8 @@ class DeleteController extends AbstractController
) { ) {
} }
#[Route('/admin/system/staffing-rule/delete/{uuid}', name: 'app_admin_system_staffing_rule_delete')] #[Route('/administrative/system/staffing-rule/delete/{uuid}', name: 'app_administrative_system_staffing_rule_delete')]
#[IsGranted('ROLE_TEAM_ADMIN')] #[IsGranted('ROLE_ADMINISTRATIVE')]
public function index(StaffingRule $rule, Request $request): Response public function index(StaffingRule $rule, Request $request): Response
{ {
if (true === $request->isMethod('POST')) { if (true === $request->isMethod('POST')) {
@@ -34,10 +34,10 @@ class DeleteController extends AbstractController
'product_code' => $rule->getProductCode(), 'product_code' => $rule->getProductCode(),
]); ]);
return new HxRedirectResponse($this->generateUrl('app_admin_system_staffing_rule_index')); return new HxRedirectResponse($this->generateUrl('app_administrative_system_staffing_rule_index'));
} }
return $this->render('admin/system/staffing_rule/modal_delete.html.twig', [ return $this->render('administrative/system/staffing_rule/modal_delete.html.twig', [
'rule' => $rule, 'rule' => $rule,
]); ]);
} }
@@ -1,6 +1,6 @@
<?php <?php
namespace App\Controller\Admin\System\StaffingRule; namespace App\Controller\Administrative\System\StaffingRule;
use App\Entity\StaffingRule; use App\Entity\StaffingRule;
use App\Form\StaffingRuleType; use App\Form\StaffingRuleType;
@@ -21,8 +21,8 @@ class EditController extends AbstractController
) { ) {
} }
#[Route('/admin/system/staffing-rule/edit/{uuid}', name: 'app_admin_system_staffing_rule_edit')] #[Route('/administrative/system/staffing-rule/edit/{uuid}', name: 'app_administrative_system_staffing_rule_edit')]
#[IsGranted('ROLE_TEAM_ADMIN')] #[IsGranted('ROLE_ADMINISTRATIVE')]
public function index(StaffingRule $rule, Request $request): Response public function index(StaffingRule $rule, Request $request): Response
{ {
$form = $this->createForm(StaffingRuleType::class, $rule); $form = $this->createForm(StaffingRuleType::class, $rule);
@@ -37,10 +37,10 @@ class EditController extends AbstractController
'product_code' => $rule->getProductCode(), 'product_code' => $rule->getProductCode(),
]); ]);
return new HxRedirectResponse($this->generateUrl('app_admin_system_staffing_rule_index')); return new HxRedirectResponse($this->generateUrl('app_administrative_system_staffing_rule_index'));
} }
return $this->render('admin/system/staffing_rule/modal_edit.html.twig', [ return $this->render('administrative/system/staffing_rule/modal_edit.html.twig', [
'form' => $form->createView(), 'form' => $form->createView(),
]); ]);
} }
@@ -1,6 +1,6 @@
<?php <?php
namespace App\Controller\Admin\System\StaffingRule; namespace App\Controller\Administrative\System\StaffingRule;
use App\Service\Assignment\StaffingConfigurationException; use App\Service\Assignment\StaffingConfigurationException;
use App\Service\Export\StaffingPreviewExporter; use App\Service\Export\StaffingPreviewExporter;
@@ -21,8 +21,8 @@ class ExportController extends AbstractController
) { ) {
} }
#[Route('/admin/system/staffing-rule/export', name: 'app_admin_system_staffing_rule_export')] #[Route('/administrative/system/staffing-rule/export', name: 'app_administrative_system_staffing_rule_export')]
#[IsGranted('ROLE_TEAM_ADMIN')] #[IsGranted('ROLE_ADMINISTRATIVE')]
public function index(): Response public function index(): Response
{ {
try { try {
@@ -30,13 +30,13 @@ class ExportController extends AbstractController
} catch (StaffingConfigurationException $e) { } catch (StaffingConfigurationException $e) {
$this->addFlash('error', 'Ein Jobprofil oder Honorar der Besetzungsmatrix ist nicht (mehr) vorhanden: '.$e->getMessage()); $this->addFlash('error', 'Ein Jobprofil oder Honorar der Besetzungsmatrix ist nicht (mehr) vorhanden: '.$e->getMessage());
return $this->redirectToRoute('app_admin_system_staffing_rule_index'); return $this->redirectToRoute('app_administrative_system_staffing_rule_index');
} }
if ([] === $rows) { if ([] === $rows) {
$this->addFlash('error', 'Keine Daten für den Export vorhanden'); $this->addFlash('error', 'Keine Daten für den Export vorhanden');
return $this->redirectToRoute('app_admin_system_staffing_rule_preview'); return $this->redirectToRoute('app_administrative_system_staffing_rule_preview');
} }
$spreadsheet = $this->previewExporter->export($rows); $spreadsheet = $this->previewExporter->export($rows);
@@ -1,6 +1,6 @@
<?php <?php
namespace App\Controller\Admin\System\StaffingRule; namespace App\Controller\Administrative\System\StaffingRule;
use App\Repository\StaffingRuleRepository; use App\Repository\StaffingRuleRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@@ -14,11 +14,11 @@ class IndexController extends AbstractController
{ {
} }
#[Route('/admin/system/staffing-rule', name: 'app_admin_system_staffing_rule_index')] #[Route('/administrative/system/staffing-rule', name: 'app_administrative_system_staffing_rule_index')]
#[IsGranted('ROLE_TEAM_ADMIN')] #[IsGranted('ROLE_ADMINISTRATIVE')]
public function index(): Response public function index(): Response
{ {
return $this->render('admin/system/staffing_rule/index.html.twig', [ return $this->render('administrative/system/staffing_rule/index.html.twig', [
'rules' => $this->staffingRuleRepository->getList(), 'rules' => $this->staffingRuleRepository->getList(),
]); ]);
} }
@@ -0,0 +1,46 @@
<?php
namespace App\Controller\Administrative\System\StaffingRule;
use App\Service\Assignment\StaffingConfigurationException;
use App\Service\Export\StaffingPreviewExporter;
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;
use Symfony\Component\Security\Http\Attribute\IsGranted;
class PreviewController extends AbstractController
{
public function __construct(
private readonly StaffingPreviewExporter $previewExporter,
private readonly PaginatorInterface $paginator,
) {
}
#[Route('/administrative/system/staffing-rule/preview', name: 'app_administrative_system_staffing_rule_preview')]
#[IsGranted('ROLE_ADMINISTRATIVE')]
public function index(Request $request): Response
{
try {
$rows = $this->previewExporter->rows();
} catch (StaffingConfigurationException $e) {
$this->addFlash('error', 'Ein Jobprofil oder Honorar der Besetzungsmatrix ist nicht (mehr) vorhanden: '.$e->getMessage());
return $this->redirectToRoute('app_administrative_system_staffing_rule_index');
}
// The candidates are a computed list, not a query: page the finished rows. The Excel
// export stays the full list.
$pagination = $this->paginator->paginate(
$rows,
$request->query->getInt('page', 1),
$request->query->getInt('limit', 50),
);
return $this->render('administrative/system/staffing_rule/preview.html.twig', [
'pagination' => $pagination,
]);
}
}
@@ -11,7 +11,7 @@ use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted; use Symfony\Component\Security\Http\Attribute\IsGranted;
class RecentAssignmentsController extends AbstractController class RecentDispositionsController extends AbstractController
{ {
public function __construct( public function __construct(
private readonly DispositionRepository $dispositionRepository, private readonly DispositionRepository $dispositionRepository,
@@ -19,7 +19,7 @@ class RecentAssignmentsController extends AbstractController
) { ) {
} }
#[Route('/administrative/teamer/recent-assignments/{uuid}', name: 'app_administrative_teamer_recent_assignments')] #[Route('/administrative/teamer/recent-dispositions/{uuid}', name: 'app_administrative_teamer_recent_dispositions')]
#[IsGranted('ROLE_ADMINISTRATIVE')] #[IsGranted('ROLE_ADMINISTRATIVE')]
public function index(Teamer $teamer, Request $request): Response public function index(Teamer $teamer, Request $request): Response
{ {
@@ -38,7 +38,7 @@ class RecentAssignmentsController extends AbstractController
] ]
); );
return $this->render('administrative/teamer/recent_assignments.html.twig', [ return $this->render('administrative/teamer/recent_dispositions.html.twig', [
'teamer' => $teamer, 'teamer' => $teamer,
'pagination' => $pagination, 'pagination' => $pagination,
]); ]);
@@ -3,7 +3,7 @@
namespace App\Controller\Administrative\Teamer; namespace App\Controller\Administrative\Teamer;
use App\Entity\Teamer; use App\Entity\Teamer;
use App\Repository\DispositionRepository; use App\Service\Teamer\UpcomingPlacementCollector;
use Knp\Component\Pager\PaginatorInterface; use Knp\Component\Pager\PaginatorInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
@@ -11,34 +11,26 @@ use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted; use Symfony\Component\Security\Http\Attribute\IsGranted;
class UpcomingAssignmentsController extends AbstractController class UpcomingDispositionsController extends AbstractController
{ {
public function __construct( public function __construct(
private readonly DispositionRepository $dispositionRepository, private readonly UpcomingPlacementCollector $upcomingPlacementCollector,
private readonly PaginatorInterface $paginator, private readonly PaginatorInterface $paginator,
) { ) {
} }
#[Route('/administrative/teamer/upcoming-assignments/{uuid}', name: 'app_administrative_teamer_upcoming_assignments')] #[Route('/administrative/teamer/upcoming-dispositions/{uuid}', name: 'app_administrative_teamer_upcoming_dispositions')]
#[IsGranted('ROLE_ADMINISTRATIVE')] #[IsGranted('ROLE_ADMINISTRATIVE')]
public function index(Teamer $teamer, Request $request): Response public function index(Teamer $teamer, Request $request): Response
{ {
$query = $this // an array rather than a query: dispositions and season assignments are merged in PHP
->dispositionRepository
->getUpcomingDispositionsByTeamerQuery($teamer)
;
$pagination = $this->paginator->paginate( $pagination = $this->paginator->paginate(
$query, $this->upcomingPlacementCollector->collect($teamer),
$request->query->getInt('page', 1), $request->query->getInt('page', 1),
10, 10
[
'defaultSortFieldName' => 'destination.dateFrom',
'defaultSortDirection' => 'asc',
]
); );
return $this->render('administrative/teamer/upcoming_assignments.html.twig', [ return $this->render('administrative/teamer/upcoming_dispositions.html.twig', [
'teamer' => $teamer, 'teamer' => $teamer,
'pagination' => $pagination, 'pagination' => $pagination,
]); ]);
@@ -0,0 +1,130 @@
<?php
namespace App\Controller\Api\Assignment;
use App\Entity\Assignment;
use App\Entity\Disposition;
use App\Entity\Upload;
use App\Enum\PlaceStatus;
use App\Model\AssignmentExportQueryDto;
use App\Repository\AssignmentRepository;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Attribute\MapQueryString;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
/**
* The assignments feed n8n reads: one row per place of the houses' guide, course and service-team
* assignments overlapping a date range. A row is a place, not a person - re-staffing a place
* changes the person on the same platz_id, and an open place has person_id null. A called-off
* assignment is left out entirely, as is a place the office struck.
*
* The field names are the consumer's (German), the n8n workflow is built on them; the path and the
* query parameters follow the app's English URL vocabulary, and errors are English, like every
* response of the api firewall.
*/
class ListController extends AbstractController
{
/**
* @param list<string> $houseCodes
* @param list<int> $jobProfileIds
*/
public function __construct(
private readonly AssignmentRepository $assignmentRepository,
private readonly array $houseCodes,
private readonly array $jobProfileIds,
private readonly LoggerInterface $logger,
) {
}
#[Route('/api/assignments', name: 'app_api_assignment_list', methods: ['GET'])]
#[IsGranted('ROLE_API_ASSIGNMENTS')]
public function index(
#[MapQueryString(validationFailedStatusCode: Response::HTTP_BAD_REQUEST)]
// Deliberately without a default: the resolver would hand that over unvalidated for a
// request without any query string, instead of the 400 naming from and to.
AssignmentExportQueryDto $query,
): JsonResponse {
$rows = [];
$assignments = $this->assignmentRepository->findForExport(
$query->getFromDate(),
$query->getToDate(),
$this->houseCodes,
$this->jobProfileIds,
);
foreach ($assignments as $assignment) {
foreach ($assignment->getPlaces() as $slot => $disposition) {
$rows[] = $this->row($assignment, $slot, $disposition);
}
}
// the range and the count, never the rows - they name people
$this->logger->info('Assignments exported', [
'from' => $query->from,
'to' => $query->to,
'assignments' => count($assignments),
'places' => count($rows),
]);
return new JsonResponse($rows);
}
/**
* @return array<string, mixed>
*/
private function row(Assignment $assignment, int $slot, ?Disposition $disposition): array
{
$destination = $assignment->getDestination();
$jobProfile = $assignment->getJobProfile();
$teamer = $disposition?->getTeamer();
$code = (string) $destination->getCode();
return [
'platz_id' => sprintf('%d-%d', $assignment->getId(), $slot),
'einsatz_id' => $assignment->getId(),
'person_id' => $teamer?->getId(),
'vorname' => $teamer?->getFirstName(),
'nachname' => $teamer?->getLastName(),
'haus' => substr((string) $destination->getHotelCode(), 0, 3),
'von' => $destination->getDateFrom()->format('Y-m-d'),
'bis' => $destination->getDateTo()->format('Y-m-d'),
'jobprofil_id' => $jobProfile->getId(),
'jobprofil' => $jobProfile->getName(),
'status' => PlaceStatus::fromDisposition($disposition)->value,
'unter_26' => $this->isUnder26($disposition, $assignment),
'vertrag_liegt_vor' => $this->hasCheckedContract($disposition),
// Older codes carry a slash ("DPWBSP/030229"), current ones do not.
'reise_code' => '' === $code ? null : str_replace('/', '', $code),
];
}
/**
* Under 26 on the first day of the assignment.
*/
private function isUnder26(?Disposition $disposition, Assignment $assignment): ?bool
{
if (null === $dateOfBirth = $disposition?->getTeamer()?->getDateOfBirth()) {
return null;
}
return $dateOfBirth->modify('+26 years') > $assignment->getDestination()->getDateFrom();
}
/**
* Only once the office has checked it - an uploaded contract alone does not count. Null where
* there is no contract to have: an open place, or an assignment that skips the formalities.
*/
private function hasCheckedContract(?Disposition $disposition): ?bool
{
if (null === $disposition || true === $disposition->isSkipFormalities()) {
return null;
}
return true === $disposition->getDocumentByType(Upload::TYPE_CONTRACT)?->isConfirmed();
}
}
@@ -0,0 +1,54 @@
<?php
namespace App\Controller\Common;
use App\Controller\Traits\ReturnUrlTrait;
use App\Form\QuestionnaireResponseFilterType;
use App\Htmx\HxRedirectResponse;
use App\Service\Common\QuestionnaireResponseFilterHandler;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
/**
* One filter for both questionnaire lists; it returns to the list it was opened from.
*/
class QuestionnaireResponseFilterController extends AbstractController
{
use ReturnUrlTrait;
public function __construct(private readonly QuestionnaireResponseFilterHandler $filterHandler)
{
}
#[Route('/common/questionnaire-response/filter', name: 'app_common_questionnaire_response_filter')]
#[IsGranted('ROLE_ADMINISTRATIVE')]
public function index(Request $request): Response
{
$formData = $this->filterHandler->getFilterSettings();
$form = $this->createForm(QuestionnaireResponseFilterType::class, $formData);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$this->filterHandler->handleRequest($form);
return new HxRedirectResponse($this->getReturnUrl($request, 'app_administrative_questionnaire_index'));
}
return $this->render('common/modal_questionnaire_response_filter.html.twig', [
'filterForm' => $form->createView(),
'filterDto' => $form->getData(),
]);
}
#[Route('/common/questionnaire-response/filter/reset', name: 'app_common_questionnaire_response_filter_reset')]
#[IsGranted('ROLE_ADMINISTRATIVE')]
public function reset(Request $request): Response
{
$this->filterHandler->resetFilterSettings();
return $this->redirect($this->getReturnUrl($request, 'app_administrative_questionnaire_index'));
}
}
@@ -3,7 +3,8 @@
namespace App\Controller\Teamer\Disposition; namespace App\Controller\Teamer\Disposition;
use App\Entity\User; use App\Entity\User;
use App\Repository\DispositionRepository; use App\Service\Season\SeasonAssignmentResolver;
use App\Service\Teamer\UpcomingPlacementCollector;
use Knp\Component\Pager\PaginatorInterface; use Knp\Component\Pager\PaginatorInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
@@ -14,7 +15,8 @@ use Symfony\Component\Security\Http\Attribute\IsGranted;
class UpcomingController extends AbstractController class UpcomingController extends AbstractController
{ {
public function __construct( public function __construct(
private readonly DispositionRepository $dispositionRepository, private readonly UpcomingPlacementCollector $upcomingPlacementCollector,
private readonly SeasonAssignmentResolver $seasonAssignmentResolver,
private readonly PaginatorInterface $paginator, private readonly PaginatorInterface $paginator,
) { ) {
} }
@@ -27,24 +29,18 @@ class UpcomingController extends AbstractController
$user = $this->getUser(); $user = $this->getUser();
$teamer = $user->getTeamer(); $teamer = $user->getTeamer();
$query = $this // an array rather than a query: dispositions and season assignments are merged in PHP
->dispositionRepository
->getUpcomingDispositionsByTeamerQuery($teamer)
;
$pagination = $this->paginator->paginate( $pagination = $this->paginator->paginate(
$query, $this->upcomingPlacementCollector->collect($teamer),
$request->query->getInt('page', 1), $request->query->getInt('page', 1),
9, 9
[
'defaultSortFieldName' => 'destination.dateFrom',
'defaultSortDirection' => 'asc',
]
); );
return $this->render('teamer/disposition/upcoming.html.twig', [ return $this->render('teamer/disposition/upcoming.html.twig', [
'teamer' => $teamer, 'teamer' => $teamer,
'pagination' => $pagination, 'pagination' => $pagination,
// the season page shows only this one, so only this one is linked
'linkedSeasonAssignment' => $this->seasonAssignmentResolver->resolveFor($teamer),
]); ]);
} }
} }
+24 -3
View File
@@ -2,12 +2,15 @@
namespace App\Controller\Teamer; namespace App\Controller\Teamer;
use App\Config\QuestionnaireCatalog;
use App\Entity\Application; use App\Entity\Application;
use App\Entity\Assignment; use App\Entity\Assignment;
use App\Entity\Disposition; use App\Entity\Disposition;
use App\Entity\Feedback; use App\Entity\Feedback;
use App\Entity\News; use App\Entity\News;
use App\Entity\User; use App\Entity\User;
use App\Service\Season\SeasonAssignmentResolver;
use App\Service\Teamer\UpcomingPlacementCollector;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
@@ -16,8 +19,11 @@ use Symfony\Component\Security\Http\Attribute\IsGranted;
class IndexController extends AbstractController class IndexController extends AbstractController
{ {
public function __construct(private readonly EntityManagerInterface $entityManager) public function __construct(
{ private readonly EntityManagerInterface $entityManager,
private readonly UpcomingPlacementCollector $upcomingPlacementCollector,
private readonly SeasonAssignmentResolver $seasonAssignmentResolver,
) {
} }
#[Route('/teamer', name: 'app_teamer_index')] #[Route('/teamer', name: 'app_teamer_index')]
@@ -66,6 +72,18 @@ class IndexController extends AbstractController
$dispositionDocuments = $this->processDocuments($upcomingDispositions); $dispositionDocuments = $this->processDocuments($upcomingDispositions);
$pendingQuestionnaires = $this
->entityManager
->getRepository(Disposition::class)
->findPendingQuestionnaireByTeamer(
$teamer,
QuestionnaireCatalog::windowStart((int) $this->getParameter('questionnaire_window_days')),
)
;
// the list merges in season assignments; the document notices above stay on dispositions
$upcomingPlacements = array_slice($this->upcomingPlacementCollector->collect($teamer), 0, 5);
return $this->render('teamer/index.html.twig', [ return $this->render('teamer/index.html.twig', [
'news' => $news, 'news' => $news,
'teamer' => $teamer, 'teamer' => $teamer,
@@ -73,8 +91,11 @@ class IndexController extends AbstractController
'recentFeedback' => $recentFeedback, 'recentFeedback' => $recentFeedback,
'pendingApplications' => $pendingApplications, 'pendingApplications' => $pendingApplications,
'currentDispositions' => $currentDispositions, 'currentDispositions' => $currentDispositions,
'upcomingDispositions' => $upcomingDispositions, 'upcomingPlacements' => $upcomingPlacements,
// the season page shows only this one, so only this one is linked
'linkedSeasonAssignment' => $this->seasonAssignmentResolver->resolveFor($teamer),
'dispositionDocuments' => $dispositionDocuments, 'dispositionDocuments' => $dispositionDocuments,
'pendingQuestionnaires' => $pendingQuestionnaires,
]); ]);
} }
@@ -0,0 +1,64 @@
<?php
namespace App\Controller\Teamer\Questionnaire;
use App\Config\QuestionnaireCatalog;
use App\Entity\Disposition;
use App\Repository\QuestionnaireResponseRepository;
use App\Service\Questionnaire\DispositionContext;
use Symfony\Bridge\Doctrine\Attribute\MapEntity;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
/**
* The teamer's own submitted questionnaires for a placement, read-only, each rendered with the
* definition version it was submitted under.
*/
class DetailController extends AbstractController
{
public function __construct(
private readonly QuestionnaireCatalog $catalog,
private readonly QuestionnaireResponseRepository $responseRepository,
) {
}
#[Route('/teamer/questionnaire/{uuid}/detail', name: 'app_teamer_questionnaire_detail')]
#[IsGranted('ROLE_TEAMER')]
#[IsGranted('QUESTIONNAIRE', subject: 'disposition')]
public function index(
#[MapEntity(mapping: ['uuid' => 'uuid'])]
Disposition $disposition,
): Response {
$submitted = [];
$open = false;
$responses = $this->responseRepository->findByDisposition($disposition);
// what applies now, plus anything submitted under an earlier state of the assignment
$keys = array_unique([...DispositionContext::questionnaires($disposition->getAssignment()), ...array_keys($responses)]);
foreach ($keys as $key) {
$response = $responses[$key] ?? null;
if (true === $response?->isSubmitted()) {
$submitted[] = [
'definition' => $this->catalog->get($key, $response->getVersion()),
'response' => $response,
];
} else {
$open = true;
}
}
if ([] === $submitted) {
return $this->redirectToRoute('app_teamer_questionnaire_edit', ['uuid' => $disposition->getUuid()]);
}
return $this->render('teamer/questionnaire/detail.html.twig', [
'disposition' => $disposition,
'submitted' => $submitted,
'open' => $open,
]);
}
}
@@ -0,0 +1,124 @@
<?php
namespace App\Controller\Teamer\Questionnaire;
use App\Config\QuestionnaireCatalog;
use App\Entity\Disposition;
use App\Entity\QuestionnaireResponse;
use App\Form\QuestionnaireType;
use App\Repository\QuestionnaireResponseRepository;
use App\Service\Questionnaire\DispositionContext;
use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Bridge\Doctrine\Attribute\MapEntity;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
/**
* The teamer's questionnaires after a placement on one page: the teamer feedback, and after a bus
* escort the bus feedback too. Saved as drafts until submitted; one submit submits all of them,
* each as a response of its own. Submitted ones are final and only shown read-only
* (DetailController).
*
* Only the questionnaires not yet submitted are offered, so one that applies later - an escort
* added after the teamer submitted - can still be filled in.
*/
class EditController extends AbstractController
{
public function __construct(
private readonly QuestionnaireCatalog $catalog,
private readonly QuestionnaireResponseRepository $responseRepository,
private readonly EntityManagerInterface $entityManager,
private readonly LoggerInterface $logger,
) {
}
#[Route('/teamer/questionnaire/{uuid}', name: 'app_teamer_questionnaire_edit')]
#[IsGranted('ROLE_TEAMER')]
#[IsGranted('QUESTIONNAIRE', subject: 'disposition')]
public function index(
#[MapEntity(mapping: ['uuid' => 'uuid'])]
Disposition $disposition,
Request $request,
): Response {
$responses = $this->responseRepository->findByDisposition($disposition);
$definitions = [];
foreach (DispositionContext::questionnaires($disposition->getAssignment()) as $key) {
if (true !== ($responses[$key] ?? null)?->isSubmitted()) {
$definitions[] = $this->catalog->get($key);
}
}
if ([] === $definitions) {
return $this->redirectToRoute('app_teamer_questionnaire_detail', ['uuid' => $disposition->getUuid()]);
}
$data = [];
foreach ($definitions as $definition) {
$data[$definition->key] = ($responses[$definition->key] ?? null)?->getAnswers() ?? [];
}
$form = $this->createForm(QuestionnaireType::class, $data, ['definitions' => $definitions]);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$context = DispositionContext::build($disposition);
$final = QuestionnaireType::isFinal($form);
foreach ($definitions as $definition) {
$response = $responses[$definition->key] ?? null;
if (null === $response) {
$response = QuestionnaireResponse::forDisposition($definition, $disposition);
$this->entityManager->persist($response);
$responses[$definition->key] = $response;
}
$answers = $form->getData()[$definition->key] ?? [];
if (true === $final) {
$response->submit($definition, $answers, $context, new \DateTimeImmutable());
} else {
$response->saveDraft($answers, $context);
}
}
$this->entityManager->flush();
foreach ($definitions as $definition) {
$this->logger->info($final ? 'Submit questionnaire' : 'Save questionnaire draft', [
'questionnaire' => $definition->key,
'questionnaire_response_id' => $responses[$definition->key]->getId(),
'disposition_id' => $disposition->getId(),
'teamer_id' => $disposition->getTeamer()->getId(),
]);
}
if (true === $final) {
$this->addFlash('success', 'Danke! Dein Fragebogen wurde abgeschickt.');
return $this->redirectToRoute('app_teamer_questionnaire_detail', ['uuid' => $disposition->getUuid()]);
}
$this->addFlash('success', 'Dein Entwurf wurde gespeichert.');
return $this->redirectToRoute('app_teamer_questionnaire_edit', ['uuid' => $disposition->getUuid()]);
}
$drafts = array_filter($responses, static fn (QuestionnaireResponse $response): bool => !$response->isSubmitted());
return $this->render('teamer/questionnaire/edit.html.twig', [
'disposition' => $disposition,
'form' => $form,
'lastSaved' => [] === $drafts ? null : max(array_map(
static fn (QuestionnaireResponse $response): \DateTimeInterface => $response->getUpdatedAt() ?? $response->getCreatedAt(),
$drafts,
)),
]);
}
}
+82 -1
View File
@@ -256,13 +256,22 @@ class Assignment implements BlameableEntityInterface, TimestampableEntityInterfa
return $this; return $this;
} }
/**
* Whether the teamer escorts the bus: the "Busbegleitung ab" pickup is set. 0 is stored for
* "Keine Busbegleitung" as well as null, so this is not a plain null check.
*/
public function hasBusEscort(): bool
{
return 0 !== (int) $this->pickup;
}
public function getEffectivePickupDate(): ?\DateTimeImmutable public function getEffectivePickupDate(): ?\DateTimeImmutable
{ {
if (null !== $this->pickupDate) { if (null !== $this->pickupDate) {
return $this->pickupDate; return $this->pickupDate;
} }
if (0 !== (int) $this->pickup && null !== $destination = $this->getDestination()) { if ($this->hasBusEscort() && null !== $destination = $this->getDestination()) {
return $destination return $destination
->getDateFrom() ->getDateFrom()
->modify('-1 day') ->modify('-1 day')
@@ -472,6 +481,78 @@ class Assignment implements BlameableEntityInterface, TimestampableEntityInterfa
}); });
} }
/**
* The lowest place number no active placement holds - the one a new placement takes.
*/
public function getNextFreeSlot(): int
{
return $this->nextFreeSlotIn(array_flip($this->getHeldSlots()));
}
/**
* The places the n8n feed reports, as place number => the active placement filling it, or
* null for an open place. A place is a row there, not a person, so a called-off teamer's place
* is open again under the same number rather than gone.
*
* Every held place is listed, topped up with the lowest free numbers to availableDispositions.
* Lowering the count while a high number is still held therefore drops an open low number, not
* the held one; a held place beyond the count is still listed, it has a person on it.
*
* @return array<int, Disposition|null>
*/
public function getPlaces(): array
{
$places = [];
$unnumbered = [];
foreach ($this->getActiveDispositions() as $disposition) {
if (null === $slot = $disposition->getSlot()) {
$unnumbered[] = $disposition;
} else {
$places[$slot] = $disposition;
}
}
// Without a number only when created outside DisposeController; such a placement takes
// the next free number after the numbered ones, so that nobody drops out of the feed.
foreach ($unnumbered as $disposition) {
$places[$this->nextFreeSlotIn($places)] = $disposition;
}
while (count($places) < (int) $this->availableDispositions) {
$places[$this->nextFreeSlotIn($places)] = null;
}
ksort($places);
return $places;
}
/**
* @return list<int>
*/
private function getHeldSlots(): array
{
return array_values(array_filter(
$this->getActiveDispositions()->map(fn (Disposition $disposition) => $disposition->getSlot())->toArray(),
fn (?int $slot) => null !== $slot,
));
}
/**
* @param array<int, mixed> $places
*/
private function nextFreeSlotIn(array $places): int
{
$slot = 1;
while (array_key_exists($slot, $places)) {
++$slot;
}
return $slot;
}
public function getConfirmedDispositions(): Collection public function getConfirmedDispositions(): Collection
{ {
return $this->dispositions->filter(function (Disposition $disposition) { return $this->dispositions->filter(function (Disposition $disposition) {
+23
View File
@@ -80,6 +80,16 @@ class Disposition implements BlameableEntityInterface, TimestampableEntityInterf
#[ORM\Column(type: Types::BOOLEAN, options: ['default' => false])] #[ORM\Column(type: Types::BOOLEAN, options: ['default' => false])]
private bool $feedbackWaived = false; private bool $feedbackWaived = false;
/**
* The numbered place on the assignment this placement fills - the n8n feed's "platz_id" is
* "<assignment id>-<slot>", and n8n hangs the Wechselpass off it. Taken once, here at creation,
* and never renumbered: a replacement takes the number the called-off teamer freed, whoever
* stays keeps theirs. A called-off placement keeps its number for the record but no longer
* holds it (Assignment::getPlaces()).
*/
#[ORM\Column(type: Types::SMALLINT, nullable: true)]
private ?int $slot = null;
public function __construct(Application $application) public function __construct(Application $application)
{ {
$this->uuid = Uuid::v4(); $this->uuid = Uuid::v4();
@@ -89,6 +99,7 @@ class Disposition implements BlameableEntityInterface, TimestampableEntityInterf
? static::STATUS_CONFIRMED ? static::STATUS_CONFIRMED
: static::STATUS_NEW; : static::STATUS_NEW;
$this->assignment = $application->getAssignment(); $this->assignment = $application->getAssignment();
$this->slot = $this->assignment?->getNextFreeSlot();
$this->teamer = $application->getTeamer(); $this->teamer = $application->getTeamer();
$this->pickup = $application->getPickup(); $this->pickup = $application->getPickup();
$this->specialAgreements = $application->getRequests(); $this->specialAgreements = $application->getRequests();
@@ -373,4 +384,16 @@ class Disposition implements BlameableEntityInterface, TimestampableEntityInterf
return $this; return $this;
} }
public function getSlot(): ?int
{
return $this->slot;
}
public function setSlot(?int $slot): static
{
$this->slot = $slot;
return $this;
}
} }
+189
View File
@@ -0,0 +1,189 @@
<?php
namespace App\Entity;
use App\Entity\Traits\BlameableEntity;
use App\Entity\Traits\TimestampableEntity;
use App\Enum\QuestionnaireResponseStatus;
use App\Model\Questionnaire\Definition;
use App\Repository\QuestionnaireResponseRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Uid\Uuid;
/**
* One respondent's answers to one questionnaire (config/questionnaires/), a draft until submitted.
*
* Answers are keyed by question key and only mean something together with the definition of
* $questionnaire in $version. $context holds what the subject already knew - for a disposition,
* who, where, when and the escort pickup - so those questions are not asked and the response stays
* readable when the assignment is edited later.
*
* Its subject is a Disposition today. A questionnaire about something else gets a nullable foreign
* key of its own beside $disposition, not a generic subject column.
*
* Not soft-deletable: nothing in the UI deletes a response, and it goes with its disposition.
*/
#[ORM\Entity(repositoryClass: QuestionnaireResponseRepository::class)]
#[ORM\HasLifecycleCallbacks]
#[ORM\UniqueConstraint(name: 'questionnaire_disposition', columns: ['questionnaire', 'disposition_id'])]
class QuestionnaireResponse implements BlameableEntityInterface, TimestampableEntityInterface
{
use BlameableEntity;
use TimestampableEntity;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(type: 'string', length: 36, unique: true)]
private string $uuid;
#[ORM\Column(length: 64)]
private string $questionnaire;
#[ORM\Column]
private int $version;
#[ORM\Column(length: 16, enumType: QuestionnaireResponseStatus::class)]
private QuestionnaireResponseStatus $status = QuestionnaireResponseStatus::DRAFT;
#[ORM\Column(nullable: true)]
private ?\DateTimeImmutable $submittedAt = null;
/**
* @var array<string, mixed>
*/
#[ORM\Column(type: Types::JSON)]
private array $answers = [];
/**
* @var array<string, mixed>
*/
#[ORM\Column(type: Types::JSON)]
private array $context = [];
#[ORM\ManyToOne]
#[ORM\JoinColumn(onDelete: 'CASCADE')]
private ?Disposition $disposition = null;
private function __construct(Definition $definition)
{
$this->uuid = Uuid::v4();
$this->questionnaire = $definition->key;
$this->version = $definition->version;
}
public static function forDisposition(Definition $definition, Disposition $disposition): static
{
$instance = new static($definition);
$instance->disposition = $disposition;
return $instance;
}
/**
* Keeps every answer, including those to questions that are hidden right now: switching an
* answer back restores the follow-up already written.
*
* @param array<string, mixed> $answers
* @param array<string, mixed> $context
*/
public function saveDraft(array $answers, array $context): static
{
$this->assertDraft();
$this->answers = $answers;
$this->context = $context;
return $this;
}
/**
* Final. Keeps only the answers to questions that are shown, and records the definition version
* they were given under - the draft may have been started under an older one.
*
* @param array<string, mixed> $answers
* @param array<string, mixed> $context
*/
public function submit(Definition $definition, array $answers, array $context, \DateTimeImmutable $now): static
{
$this->assertDraft();
if ($definition->key !== $this->questionnaire) {
throw new \LogicException(sprintf('Response to "%s" cannot be submitted with "%s"', $this->questionnaire, $definition->key));
}
$this->answers = $definition->withoutHiddenAnswers($answers);
$this->context = $context;
$this->version = $definition->version;
$this->status = QuestionnaireResponseStatus::SUBMITTED;
$this->submittedAt = $now;
return $this;
}
public function isSubmitted(): bool
{
return QuestionnaireResponseStatus::SUBMITTED === $this->status;
}
public function getId(): ?int
{
return $this->id;
}
public function getUuid(): string
{
return $this->uuid;
}
public function getQuestionnaire(): string
{
return $this->questionnaire;
}
public function getVersion(): int
{
return $this->version;
}
public function getStatus(): QuestionnaireResponseStatus
{
return $this->status;
}
public function getSubmittedAt(): ?\DateTimeImmutable
{
return $this->submittedAt;
}
/**
* @return array<string, mixed>
*/
public function getAnswers(): array
{
return $this->answers;
}
/**
* @return array<string, mixed>
*/
public function getContext(): array
{
return $this->context;
}
public function getDisposition(): ?Disposition
{
return $this->disposition;
}
private function assertDraft(): void
{
if ($this->isSubmitted()) {
throw new \LogicException(sprintf('Questionnaire response %s is already submitted', $this->uuid));
}
}
}
+24
View File
@@ -208,6 +208,30 @@ class SeasonAssignment implements BlameableEntityInterface, TimestampableEntityI
return $this; return $this;
} }
/**
* Copies both deadline overrides of $source onto every other entry that is not ticked off,
* empty ones included - an empty override resets the entry to its computed deadline. Entries
* already done keep theirs: their deadline is history by then.
*
* @return int the number of entries changed, $source not counted
*/
public function applyDeadlinesToOpenTasks(SeasonAssignmentTask $source): int
{
$count = 0;
foreach ($this->tasks as $task) {
if ($task === $source || $task->isDone()) {
continue;
}
$task->setDeadlineOverride1($source->getDeadlineOverride1());
$task->setDeadlineOverride2($source->getDeadlineOverride2());
++$count;
}
return $count;
}
/** /**
* @return Collection<int, Upload> * @return Collection<int, Upload>
*/ */
+38 -16
View File
@@ -55,9 +55,13 @@ class StaffingRule implements BlameableEntityInterface, TimestampableEntityInter
#[ORM\Column] #[ORM\Column]
private bool $skiAdvanced = false; private bool $skiAdvanced = false;
/** The Reiseleitungen take over the ski levels, one level per place. */ /** A Reiseleitung takes over the beginners' course (Reise- und Kursleitung), one place. */
#[ORM\Column] #[ORM\Column]
private bool $split = false; private bool $splitBeginner = false;
/** A Reiseleitung takes over the advanced course (Reise- und Kursleitung), one place. */
#[ORM\Column]
private bool $splitAdvanced = false;
#[ORM\Column] #[ORM\Column]
private bool $guiding = false; private bool $guiding = false;
@@ -74,20 +78,26 @@ class StaffingRule implements BlameableEntityInterface, TimestampableEntityInter
#[Assert\Callback] #[Assert\Callback]
public function validateCombination(ExecutionContextInterface $context): void public function validateCombination(ExecutionContextInterface $context): void
{ {
$levels = $this->getSkiLevelCount(); if (true === $this->splitBeginner && false === $this->skiBeginner) {
if (true === $this->split && 0 === $levels) {
$context $context
->buildViolation('Ein Split braucht mindestens einen Skikurs') ->buildViolation('Die Reiseleitung kann nur einen Kurs übernehmen, der angeboten wird')
->atPath('split') ->atPath('splitBeginner')
->addViolation() ->addViolation()
; ;
} }
if (true === $this->split && $levels > (int) $this->guides) { if (true === $this->splitAdvanced && false === $this->skiAdvanced) {
$context $context
->buildViolation('Bei einem Split braucht jedes Kursniveau eine eigene Reiseleitung') ->buildViolation('Die Reiseleitung kann nur einen Kurs übernehmen, der angeboten wird')
->atPath('split') ->atPath('splitAdvanced')
->addViolation()
;
}
if ($this->getSplitLevelCount() > (int) $this->guides) {
$context
->buildViolation('Jeder übernommene Kurs braucht eine eigene Reiseleitung')
->atPath('guides')
->addViolation() ->addViolation()
; ;
} }
@@ -101,9 +111,9 @@ class StaffingRule implements BlameableEntityInterface, TimestampableEntityInter
} }
} }
public function getSkiLevelCount(): int public function getSplitLevelCount(): int
{ {
return (int) $this->skiBeginner + (int) $this->skiAdvanced; return (int) $this->splitBeginner + (int) $this->splitAdvanced;
} }
public function getId(): ?int public function getId(): ?int
@@ -165,14 +175,26 @@ class StaffingRule implements BlameableEntityInterface, TimestampableEntityInter
return $this; return $this;
} }
public function isSplit(): bool public function isSplitBeginner(): bool
{ {
return $this->split; return $this->splitBeginner;
} }
public function setSplit(bool $split): static public function setSplitBeginner(bool $splitBeginner): static
{ {
$this->split = $split; $this->splitBeginner = $splitBeginner;
return $this;
}
public function isSplitAdvanced(): bool
{
return $this->splitAdvanced;
}
public function setSplitAdvanced(bool $splitAdvanced): static
{
$this->splitAdvanced = $splitAdvanced;
return $this; return $this;
} }
+12
View File
@@ -0,0 +1,12 @@
<?php
namespace App\Enum;
/**
* How a single-choice question is rendered: a radio list or a select.
*/
enum ChoiceWidget: string
{
case RADIO = 'radio';
case DROPDOWN = 'dropdown';
}
+13
View File
@@ -0,0 +1,13 @@
<?php
namespace App\Enum;
/**
* How a show_if condition compares the controlling question's answer with its value.
*/
enum ConditionOperator: string
{
case EQUALS = 'equals';
case IN = 'in';
case LTE = 'lte';
}
+29
View File
@@ -0,0 +1,29 @@
<?php
namespace App\Enum;
use App\Entity\Disposition;
/**
* The status of a place in the n8n assignments feed. The values are the feed's contract.
*/
enum PlaceStatus: string
{
case OPEN = 'offen';
case REQUESTED = 'angefragt';
case CONTRACT = 'vertrag';
case FIXED = 'fix';
/**
* A called-off placement holds no place, so it never reaches this - its place is open.
*/
public static function fromDisposition(?Disposition $disposition): self
{
return match ($disposition?->getStatus()) {
null, Disposition::STATUS_CALLED_OFF => self::OPEN,
Disposition::STATUS_NEW => self::REQUESTED,
Disposition::STATUS_CHECKING_CONTRACT => self::CONTRACT,
default => self::FIXED,
};
}
}
+22
View File
@@ -0,0 +1,22 @@
<?php
namespace App\Enum;
/**
* The kinds of question a questionnaire definition may use. Each maps to exactly one form field
* in QuestionnaireType; adding one means a case here and a line there, nothing more.
*/
enum QuestionType: string
{
case TEXT = 'text';
case TEXTAREA = 'textarea';
case CHOICE = 'choice';
case MULTI = 'multi';
case DATE = 'date';
case RATING = 'rating';
public function hasOptions(): bool
{
return self::CHOICE === $this || self::MULTI === $this;
}
}
+17
View File
@@ -0,0 +1,17 @@
<?php
namespace App\Enum;
enum QuestionnaireResponseStatus: string
{
case DRAFT = 'draft';
case SUBMITTED = 'submitted';
public function label(): string
{
return match ($this) {
self::DRAFT => 'Entwurf',
self::SUBMITTED => 'Abgeschickt',
};
}
}
+4 -9
View File
@@ -5,7 +5,6 @@ namespace App\Form;
use App\Entity\Feedback; use App\Entity\Feedback;
use App\Entity\FeedbackSet; use App\Entity\FeedbackSet;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -24,20 +23,16 @@ abstract class AbstractFeedbackType extends AbstractType
'label' => false, 'label' => false,
'feedback_set' => $feedbackSet, 'feedback_set' => $feedbackSet,
]) ])
->add('comment', TextareaType::class, [ ->add('comment', AutosizeTextareaType::class, [
'label' => 'Kommentar (öffentlich)', 'label' => 'Kommentar (öffentlich)',
'required' => false, 'required' => false,
'attr' => [ 'min_rows' => 5,
'rows' => 5,
],
'help' => 'Bitte formuliere deinen Kommentar so, dass er an das Team weitergegeben werden kann', 'help' => 'Bitte formuliere deinen Kommentar so, dass er an das Team weitergegeben werden kann',
]) ])
->add('commentInternal', TextareaType::class, [ ->add('commentInternal', AutosizeTextareaType::class, [
'label' => 'Kommentar (intern)', 'label' => 'Kommentar (intern)',
'required' => false, 'required' => false,
'attr' => [ 'min_rows' => 5,
'rows' => 5,
],
]) ])
; ;
} }
+2 -5
View File
@@ -7,7 +7,6 @@ use App\Model\ApplicationStatusDto;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType; use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -24,12 +23,10 @@ class ApplicationStatusType extends AbstractType
'neu' => Application::STATUS_NEW, 'neu' => Application::STATUS_NEW,
], ],
]) ])
->add('comment', TextareaType::class, [ ->add('comment', AutosizeTextareaType::class, [
'label' => 'Kommentar/Begründung', 'label' => 'Kommentar/Begründung',
'required' => false, 'required' => false,
'attr' => [ 'min_rows' => 3,
'rows' => 3,
],
]) ])
->add('commentVisible', CheckboxType::class, [ ->add('commentVisible', CheckboxType::class, [
'label' => 'Kommentar/Begründung sichtbar für Teamer:in', 'label' => 'Kommentar/Begründung sichtbar für Teamer:in',
+4 -9
View File
@@ -15,7 +15,6 @@ use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType; use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType; use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent; use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents; use Symfony\Component\Form\FormEvents;
@@ -73,23 +72,19 @@ class AssignmentType extends AbstractType
->where('job_profile.deletedAt IS NULL'); ->where('job_profile.deletedAt IS NULL');
}, },
]) ])
->add('jobProfileInfo', TextareaType::class, [ ->add('jobProfileInfo', AutosizeTextareaType::class, [
'label' => 'Zusatzinfos', 'label' => 'Zusatzinfos',
'required' => false, 'required' => false,
'attr' => [ 'min_rows' => 3,
'rows' => 3,
],
]) ])
// ->add('pickupDate', DatepickerType::class, [ // ->add('pickupDate', DatepickerType::class, [
// 'label' => 'abweichender Zustieg bei Busbegleitung', // 'label' => 'abweichender Zustieg bei Busbegleitung',
// 'required' => false, // 'required' => false,
// ]) // ])
->add('benefits', TextareaType::class, [ ->add('benefits', AutosizeTextareaType::class, [
'label' => 'Benefits', 'label' => 'Benefits',
'required' => false, 'required' => false,
'attr' => [ 'min_rows' => 5,
'rows' => 5,
],
]) ])
->add('fees', EntityType::class, [ ->add('fees', EntityType::class, [
'label' => 'Honorar(e)', 'label' => 'Honorar(e)',
+3 -6
View File
@@ -6,7 +6,6 @@ use App\Entity\Upload;
use App\Model\DocumentCheckDto; use App\Model\DocumentCheckDto;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent; use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents; use Symfony\Component\Form\FormEvents;
@@ -21,12 +20,10 @@ class DocumentCheckType extends AbstractType
'label' => 'neuer Status', 'label' => 'neuer Status',
'choices' => $options['status_choices'][$options['document_type']], 'choices' => $options['status_choices'][$options['document_type']],
]) ])
->add('comment', TextareaType::class, [ ->add('comment', AutosizeTextareaType::class, [
'label' => 'Kommentar/Begründung', 'label' => 'Kommentar/Begründung',
'required' => false, 'required' => false,
'attr' => [ 'min_rows' => 3,
'rows' => 3,
],
]) ])
->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) { ->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
/** @var DocumentCheckDto $data */ /** @var DocumentCheckDto $data */
@@ -34,7 +31,7 @@ class DocumentCheckType extends AbstractType
$upload = $data->getUpload(); $upload = $data->getUpload();
if (Upload::TYPE_INVOICE === $upload->getType()) { if (Upload::TYPE_INVOICE === $upload->getType()) {
$event->getForm()->add('specialAgreements', TextareaType::class, [ $event->getForm()->add('specialAgreements', AutosizeTextareaType::class, [
'label' => 'zusätzliche Absprache', 'label' => 'zusätzliche Absprache',
'required' => false, 'required' => false,
]); ]);
+2 -5
View File
@@ -6,7 +6,6 @@ use App\Entity\Upload;
use App\Model\DriverLicenseCheckDto; use App\Model\DriverLicenseCheckDto;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -23,12 +22,10 @@ class DriverLicenseCheckType extends AbstractType
'abgelehnt' => Upload::STATUS_REJECTED, 'abgelehnt' => Upload::STATUS_REJECTED,
], ],
]) ])
->add('comment', TextareaType::class, [ ->add('comment', AutosizeTextareaType::class, [
'label' => 'Kommentar/Begründung', 'label' => 'Kommentar/Begründung',
'required' => false, 'required' => false,
'attr' => [ 'min_rows' => 3,
'rows' => 3,
],
]) ])
; ;
} }
+2 -2
View File
@@ -4,7 +4,6 @@ namespace App\Form;
use App\Entity\Faq; use App\Entity\Faq;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -17,8 +16,9 @@ class FaqType extends AbstractType
->add('question', TextType::class, [ ->add('question', TextType::class, [
'label' => 'Frage', 'label' => 'Frage',
]) ])
->add('answer', TextareaType::class, [ ->add('answer', AutosizeTextareaType::class, [
'label' => 'Antwort', 'label' => 'Antwort',
'min_rows' => 5,
]) ])
; ;
} }
+4 -9
View File
@@ -4,7 +4,6 @@ namespace App\Form;
use App\Entity\Feedback; use App\Entity\Feedback;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -13,19 +12,15 @@ class FeedbackApproveType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options): void public function buildForm(FormBuilderInterface $builder, array $options): void
{ {
$builder $builder
->add('comment', TextareaType::class, [ ->add('comment', AutosizeTextareaType::class, [
'label' => 'Kommentar (öffentlich)', 'label' => 'Kommentar (öffentlich)',
'required' => false, 'required' => false,
'attr' => [ 'min_rows' => 5,
'rows' => 5,
],
]) ])
->add('commentInternal', TextareaType::class, [ ->add('commentInternal', AutosizeTextareaType::class, [
'label' => 'Kommentar (intern)', 'label' => 'Kommentar (intern)',
'required' => false, 'required' => false,
'attr' => [ 'min_rows' => 5,
'rows' => 5,
],
]) ])
; ;
} }
+2 -5
View File
@@ -5,7 +5,6 @@ namespace App\Form;
use App\Entity\News; use App\Entity\News;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -22,11 +21,9 @@ class NewsType extends AbstractType
'label.news.status.2' => News::STATUS_IMPORTANT, 'label.news.status.2' => News::STATUS_IMPORTANT,
], ],
]) ])
->add('message', TextareaType::class, [ ->add('message', AutosizeTextareaType::class, [
'label' => 'Nachricht', 'label' => 'Nachricht',
'attr' => [ 'min_rows' => 5,
'rows' => 5,
],
]) ])
; ;
} }
@@ -0,0 +1,53 @@
<?php
namespace App\Form;
use App\Entity\Teamer;
use App\Model\QuestionnaireResponseFilterDto;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class QuestionnaireResponseFilterType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('teamer', AutocompleteEntityType::class, [
'label' => 'Teamer',
'required' => false,
'class' => Teamer::class,
'label_property' => 'name',
'label_function' => fn (Teamer $teamer) => (string) $teamer,
'endpoint_route' => 'app_admin_autocomplete_teamer',
])
->add('hotel', TextType::class, [
'label' => 'Haus',
'required' => false,
])
->add('dateFrom', DatepickerType::class, [
'label' => 'Einsatzende von',
'required' => false,
])
->add('dateTo', DatepickerType::class, [
'label' => 'Einsatzende bis',
'required' => false,
])
->add('apply', SubmitType::class, [
'label' => 'filtern',
])
->add('reset', SubmitType::class, [
'label' => 'reset',
])
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => QuestionnaireResponseFilterDto::class,
]);
}
}
+200
View File
@@ -0,0 +1,200 @@
<?php
namespace App\Form;
use App\Enum\ChoiceWidget;
use App\Enum\QuestionType;
use App\Model\Questionnaire\Definition;
use App\Model\Questionnaire\Option;
use App\Model\Questionnaire\Question;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\ClickableInterface;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\FormType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormError;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* Builds one form from one or more questionnaire definitions - a teamer after a bus escort answers
* teamer_feedback and bus_feedback on one page. The data is keyed by questionnaire key, each
* holding that questionnaire's flat answers keyed by question key: every questionnaire is a child
* of its own, and each of its sections a child with inherit_data, which groups the fields on screen
* without nesting the answers.
*
* Two buttons: "draft" saves whatever is filled in, "submit" also demands every required question
* that is shown. No field is HTML-required, or the browser would refuse to send a half-filled
* draft. Whether a question is shown is Definition::isVisible(), the same rule the
* questionnaire Stimulus controller applies on screen via the row's data-show-if.
*/
class QuestionnaireType extends AbstractType
{
public const string DRAFT = 'draft';
public const string SUBMIT = 'submit';
private const int RATING_MAX = 5;
public function buildForm(FormBuilderInterface $builder, array $options): void
{
/** @var list<Definition> $definitions */
$definitions = $options['definitions'];
foreach ($definitions as $definition) {
$questionnaireBuilder = $builder->create($definition->key, FormType::class, [
'label' => $definition->title,
'help' => $definition->description,
'empty_data' => [],
'block_prefix' => 'questionnaire_part',
]);
foreach ($definition->sections as $section) {
$sectionBuilder = $builder->create($section->key, FormType::class, [
'inherit_data' => true,
'label' => $section->title ?? false,
'block_prefix' => 'questionnaire_section',
]);
foreach ($section->questions as $question) {
$sectionBuilder->add($question->key, ...$this->field($definition, $question));
}
$questionnaireBuilder->add($sectionBuilder);
}
$builder->add($questionnaireBuilder);
}
$builder
->add(self::DRAFT, SubmitType::class, [
'label' => 'Entwurf speichern',
])
->add(self::SUBMIT, SubmitType::class, [
'label' => 'Absenden',
])
->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) use ($definitions): void {
$form = $event->getForm();
if (!$this->isFinal($form)) {
return;
}
foreach ($definitions as $definition) {
$answers = $form->getData()[$definition->key] ?? [];
foreach ($definition->sections as $section) {
foreach ($section->questions as $question) {
if ($question->required
&& $definition->isVisible($question, $answers)
&& $this->isEmpty($answers[$question->key] ?? null)
) {
$form->get($definition->key)->get($section->key)->get($question->key)->addError(
new FormError('Bitte beantworte diese Frage.')
);
}
}
}
}
})
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver
->setRequired('definitions')
->setAllowedTypes('definitions', Definition::class.'[]')
->setAllowedValues('definitions', static fn (array $definitions): bool => [] !== $definitions
&& count($definitions) === count(array_unique(array_map(static fn (Definition $definition): string => $definition->key, $definitions))))
->setDefaults([
'data_class' => null,
'empty_data' => [],
])
;
}
/**
* Whether the form was sent with the submit button rather than as a draft. A form sent without
* any button (Enter in a text field) counts as a draft: losing nothing beats submitting early.
*/
public static function isFinal(FormInterface $form): bool
{
$button = $form->get(self::SUBMIT);
return $button instanceof ClickableInterface && $button->isClicked();
}
/**
* @return array{0: class-string, 1: array<string, mixed>}
*/
private function field(Definition $definition, Question $question): array
{
$common = [
'label' => $question->label,
'help' => $question->help,
'required' => false,
// read by assets/controllers/questionnaire_controller.js; prefixed with the questionnaire,
// since question keys are only unique within one
'row_attr' => ['data-question-key' => $definition->key.'.'.$question->key] + (null === $question->showIf ? [] : [
'data-show-if' => json_encode([
'question' => $definition->key.'.'.$question->showIf->question,
'operator' => $question->showIf->operator->value,
'value' => $question->showIf->value,
], JSON_THROW_ON_ERROR),
]),
];
return match ($question->type) {
QuestionType::TEXT => [TextType::class, $common],
QuestionType::TEXTAREA => [AutosizeTextareaType::class, $common + ['min_rows' => 3]],
QuestionType::CHOICE => [ChoiceType::class, $common + $this->choices($question) + (ChoiceWidget::RADIO === $question->widget ? [
'expanded' => true,
// a radio list needs no "none" entry
'placeholder' => false,
'block_prefix' => 'questionnaire_choice',
] : [
'expanded' => false,
// a select needs an empty first line, or the first option would be preselected
'placeholder' => 'Bitte wählen',
])],
QuestionType::MULTI => [ChoiceType::class, $common + $this->choices($question) + [
'expanded' => true,
'multiple' => true,
'block_prefix' => 'questionnaire_choice',
]],
QuestionType::DATE => [DatepickerType::class, $common + [
'input' => 'string',
'input_format' => 'Y-m-d',
]],
QuestionType::RATING => [ChoiceType::class, $common + [
'choices' => array_combine(range(1, self::RATING_MAX), range(1, self::RATING_MAX)),
'expanded' => true,
'placeholder' => false,
'block_prefix' => 'questionnaire_rating',
]],
};
}
/**
* The option keys as choices, labelled through a callback: keyed by label, two options that
* share one would silently collapse into a single choice.
*
* @return array{choices: list<string>, choice_label: \Closure(string): string}
*/
private function choices(Question $question): array
{
return [
'choices' => array_map(static fn (Option $option): string => $option->key, $question->options),
'choice_label' => static fn (string $key): string => $question->getOption($key)->label,
];
}
private function isEmpty(mixed $answer): bool
{
return null === $answer || '' === $answer || [] === $answer;
}
}
+8
View File
@@ -4,6 +4,7 @@ namespace App\Form;
use App\Entity\SeasonAssignmentTask; use App\Entity\SeasonAssignmentTask;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -27,6 +28,13 @@ class SeasonTaskDeadlineType extends AbstractType
'required' => false, 'required' => false,
'help' => 'Ohne Angabe gilt Frist 1.', 'help' => 'Ohne Angabe gilt Frist 1.',
]) ])
// unmapped: the controller copies the entered deadlines onto the other entries
->add('applyToAll', CheckboxType::class, [
'label' => 'auf alle Fristen anwenden',
'required' => false,
'mapped' => false,
'help' => 'Gilt für alle noch nicht erledigten Einträge. Leere Felder setzen deren Fristen auf den berechneten Wert zurück.',
])
; ;
} }
+8 -3
View File
@@ -31,9 +31,14 @@ class StaffingRuleType extends AbstractType
'label' => 'Ski Fortgeschrittene', 'label' => 'Ski Fortgeschrittene',
'required' => false, 'required' => false,
]) ])
->add('split', CheckboxType::class, [ ->add('splitBeginner', CheckboxType::class, [
'label' => 'Split', 'label' => 'Reiseleitung übernimmt Ski Anfänger:innen',
'help' => 'Die Reiseleitungen übernehmen die Kurse (Reise- und Kursleitung)', 'help' => 'Reise- und Kursleitung statt einer eigenen Kursleitung',
'required' => false,
])
->add('splitAdvanced', CheckboxType::class, [
'label' => 'Reiseleitung übernimmt Ski Fortgeschrittene',
'help' => 'Reise- und Kursleitung statt einer eigenen Kursleitung',
'required' => false, 'required' => false,
]) ])
->add('guiding', CheckboxType::class, [ ->add('guiding', CheckboxType::class, [
+2 -5
View File
@@ -7,7 +7,6 @@ use App\Service\Common\PickupOptions;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType; use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent; use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents; use Symfony\Component\Form\FormEvents;
@@ -19,12 +18,10 @@ class TeamerApplicationType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options): void public function buildForm(FormBuilderInterface $builder, array $options): void
{ {
$builder $builder
->add('requests', TextareaType::class, [ ->add('requests', AutosizeTextareaType::class, [
'label' => 'Wünsche', 'label' => 'Wünsche',
'required' => false, 'required' => false,
'attr' => [ 'min_rows' => 3,
'rows' => 3,
],
]) ])
->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) { ->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
/** @var Application $application */ /** @var Application $application */
+2 -5
View File
@@ -7,7 +7,6 @@ use App\Entity\Teamer;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Translation\TranslatableMessage; use Symfony\Component\Translation\TranslatableMessage;
@@ -59,12 +58,10 @@ class TeamerJobProfileType extends AbstractType
'expanded' => true, 'expanded' => true,
'multiple' => true, 'multiple' => true,
]) ])
->add('remarks', TextareaType::class, [ ->add('remarks', AutosizeTextareaType::class, [
'label' => 'Wünsche/Anmerkungen', 'label' => 'Wünsche/Anmerkungen',
'required' => false, 'required' => false,
'attr' => [ 'min_rows' => 3,
'rows' => 3,
],
]) ])
; ;
} }
+2 -5
View File
@@ -6,7 +6,6 @@ use App\Enum\WorkMonthStatus;
use App\Model\WorkMonthReviewDto; use App\Model\WorkMonthReviewDto;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -27,12 +26,10 @@ class WorkMonthReviewType extends AbstractType
], ],
'choice_value' => static fn (?WorkMonthStatus $status) => $status?->value, 'choice_value' => static fn (?WorkMonthStatus $status) => $status?->value,
]) ])
->add('comment', TextareaType::class, [ ->add('comment', AutosizeTextareaType::class, [
'label' => 'Kommentar/Begründung', 'label' => 'Kommentar/Begründung',
'required' => false, 'required' => false,
'attr' => [ 'min_rows' => 3,
'rows' => 3,
],
]) ])
; ;
} }
+18 -6
View File
@@ -97,10 +97,10 @@ class AdminMenuBuilder extends AbstractMenuBuilder
], ],
]); ]);
$menu->addChild('Feedbackübersicht', [ $menu->addChild('Teamer:innen-Feedback', [
'route' => 'app_administrative_feedback_index', 'route' => 'app_administrative_feedback_index',
'linkAttributes' => [ 'linkAttributes' => [
'title' => 'Feedbackübersicht', 'title' => 'Teamer:innen-Feedback',
], ],
'extras' => [ 'extras' => [
'icon' => 'feedback', 'icon' => 'feedback',
@@ -109,6 +109,18 @@ class AdminMenuBuilder extends AbstractMenuBuilder
], ],
], ],
]); ]);
$menu->addChild('Reisefeedback', [
'route' => 'app_administrative_questionnaire_index',
'linkAttributes' => [
'title' => 'Reisefeedback nach Einsätzen',
],
'extras' => [
'icon' => 'document',
'routes' => [
['pattern' => '/^app_administrative_questionnaire_/'],
],
],
]);
$menu->addChild('Teamübersicht', [ $menu->addChild('Teamübersicht', [
'route' => 'app_administrative_teamer_index', 'route' => 'app_administrative_teamer_index',
@@ -267,13 +279,13 @@ class AdminMenuBuilder extends AbstractMenuBuilder
], ],
]); ]);
$settingsMenu->addChild('Besetzungsmatrix', [ $settingsMenu->addChild('Besetzungsmatrix', [
'route' => 'app_admin_system_staffing_rule_index', 'route' => 'app_administrative_system_staffing_rule_index',
'linkAttributes' => [ 'linkAttributes' => [
'title' => 'Besetzungsmatrix', 'title' => 'Besetzungsmatrix',
], ],
'extras' => [ 'extras' => [
'routes' => [ 'routes' => [
['pattern' => '/^app_admin_system_staffing_rule_/'], ['pattern' => '/^app_administrative_system_staffing_rule_/'],
], ],
], ],
]); ]);
@@ -417,14 +429,14 @@ class AdminMenuBuilder extends AbstractMenuBuilder
], ],
]); ]);
$menu->addChild('Vergangene Einsätze', [ $menu->addChild('Vergangene Einsätze', [
'route' => 'app_administrative_teamer_recent_assignments', 'route' => 'app_administrative_teamer_recent_dispositions',
'routeParameters' => $this->getDefaultRouteParameters('uuid'), 'routeParameters' => $this->getDefaultRouteParameters('uuid'),
'linkAttributes' => [ 'linkAttributes' => [
'title' => 'Vergangene Einsätze', 'title' => 'Vergangene Einsätze',
], ],
]); ]);
$menu->addChild('Bevorstehende Einsätze', [ $menu->addChild('Bevorstehende Einsätze', [
'route' => 'app_administrative_teamer_upcoming_assignments', 'route' => 'app_administrative_teamer_upcoming_dispositions',
'routeParameters' => $this->getDefaultRouteParameters('uuid'), 'routeParameters' => $this->getDefaultRouteParameters('uuid'),
'linkAttributes' => [ 'linkAttributes' => [
'title' => 'Bevorstehende Einsätze', 'title' => 'Bevorstehende Einsätze',
+27 -4
View File
@@ -106,10 +106,10 @@ class ManagerMenuBuilder extends AbstractMenuBuilder
], ],
], ],
]); ]);
$menu->addChild('Feedbackübersicht', [ $menu->addChild('Teamer:innen-Feedback', [
'route' => 'app_administrative_feedback_index', 'route' => 'app_administrative_feedback_index',
'linkAttributes' => [ 'linkAttributes' => [
'title' => 'Feedbackübersicht', 'title' => 'Teamer:innen-Feedback',
], ],
'extras' => [ 'extras' => [
'icon' => 'feedback', 'icon' => 'feedback',
@@ -118,6 +118,18 @@ class ManagerMenuBuilder extends AbstractMenuBuilder
], ],
], ],
]); ]);
$menu->addChild('Reisefeedback', [
'route' => 'app_administrative_questionnaire_index',
'linkAttributes' => [
'title' => 'Reisefeedback',
],
'extras' => [
'icon' => 'document',
'routes' => [
['pattern' => '/^app_administrative_questionnaire_/'],
],
],
]);
$statisticsMenu = $menu->addChild('Statistiken', [ $statisticsMenu = $menu->addChild('Statistiken', [
'extras' => [ 'extras' => [
'icon' => 'chart', 'icon' => 'chart',
@@ -155,6 +167,17 @@ class ManagerMenuBuilder extends AbstractMenuBuilder
'icon' => 'settings', 'icon' => 'settings',
], ],
]); ]);
$settingsMenu->addChild('Besetzungsmatrix', [
'route' => 'app_administrative_system_staffing_rule_index',
'linkAttributes' => [
'title' => 'Besetzungsmatrix',
],
'extras' => [
'routes' => [
['pattern' => '/^app_administrative_system_staffing_rule_/'],
],
],
]);
$settingsMenu->addChild('Reisen', [ $settingsMenu->addChild('Reisen', [
'route' => 'app_administrative_system_destination_index', 'route' => 'app_administrative_system_destination_index',
'linkAttributes' => [ 'linkAttributes' => [
@@ -231,14 +254,14 @@ class ManagerMenuBuilder extends AbstractMenuBuilder
], ],
]); ]);
$menu->addChild('Vergangene Einsätze', [ $menu->addChild('Vergangene Einsätze', [
'route' => 'app_administrative_teamer_recent_assignments', 'route' => 'app_administrative_teamer_recent_dispositions',
'routeParameters' => $this->getDefaultRouteParameters('uuid'), 'routeParameters' => $this->getDefaultRouteParameters('uuid'),
'linkAttributes' => [ 'linkAttributes' => [
'title' => 'Vergangene Einsätze', 'title' => 'Vergangene Einsätze',
], ],
]); ]);
$menu->addChild('Bevorstehende Einsätze', [ $menu->addChild('Bevorstehende Einsätze', [
'route' => 'app_administrative_teamer_upcoming_assignments', 'route' => 'app_administrative_teamer_upcoming_dispositions',
'routeParameters' => $this->getDefaultRouteParameters('uuid'), 'routeParameters' => $this->getDefaultRouteParameters('uuid'),
'linkAttributes' => [ 'linkAttributes' => [
'title' => 'Bevorstehende Einsätze', 'title' => 'Bevorstehende Einsätze',
+25 -18
View File
@@ -54,22 +54,6 @@ class TeamerMenuBuilder extends AbstractMenuBuilder
], ],
]); ]);
// Only for an all-season teamer who actually has an assignment this season: the page
// would have nothing to show otherwise, and it throws a 404 in exactly that case.
if (null !== $this->resolveSeasonAssignment()) {
$profileMenu->addChild('Saison-Teamer:in', [
'route' => 'app_teamer_season_index',
'linkAttributes' => [
'title' => 'Saison-Teamer:in',
],
'extras' => [
'routes' => [
['pattern' => '/^app_teamer_season_/'],
],
],
]);
}
// Season teamers only, and on the flag rather than on a current assignment: a month // Season teamers only, and on the flag rather than on a current assignment: a month
// still has to be reachable after the season it belongs to has ended. // still has to be reachable after the season it belongs to has ended.
if (true === $this->isSeasonTeamer()) { if (true === $this->isSeasonTeamer()) {
@@ -110,6 +94,23 @@ class TeamerMenuBuilder extends AbstractMenuBuilder
'icon' => 'bus', 'icon' => 'bus',
], ],
]); ]);
// Only for an all-season teamer who actually has an assignment this season: the page
// would have nothing to show otherwise, and it throws a 404 in exactly that case.
if (null !== $this->resolveSeasonAssignment()) {
$dispositionMenu->addChild('Saison-Einsatz', [
'route' => 'app_teamer_season_index',
'linkAttributes' => [
'title' => 'Saison-Einsatz',
],
'extras' => [
'routes' => [
['pattern' => '/^app_teamer_season_/'],
],
],
]);
}
$dispositionMenu->addChild('Merkliste', [ $dispositionMenu->addChild('Merkliste', [
'route' => 'app_teamer_bookmark_index', 'route' => 'app_teamer_bookmark_index',
'linkAttributes' => [ 'linkAttributes' => [
@@ -128,10 +129,16 @@ class TeamerMenuBuilder extends AbstractMenuBuilder
'title' => 'Nächste Einsätze', 'title' => 'Nächste Einsätze',
], ],
]); ]);
$dispositionMenu->addChild('Letze Einsätze', [ $dispositionMenu->addChild('Letzte Einsätze', [
'route' => 'app_teamer_disposition_recent', 'route' => 'app_teamer_disposition_recent',
'linkAttributes' => [ 'linkAttributes' => [
'title' => 'Letze Einsätze', 'title' => 'Letzte Einsätze',
],
// the questionnaire after a past bus escort
'extras' => [
'routes' => [
['pattern' => '/^app_teamer_questionnaire_/'],
],
], ],
]); ]);
+35
View File
@@ -0,0 +1,35 @@
<?php
namespace App\Model;
use Symfony\Component\Validator\Constraints as Assert;
/**
* The date range of GET /api/assignments, mapped from the query string. The parameter names follow
* the app's English URL vocabulary, like the path.
*/
class AssignmentExportQueryDto
{
public function __construct(
#[Assert\NotBlank(message: 'from must not be empty.')]
#[Assert\Date(message: 'from must be a date as YYYY-MM-DD.')]
public readonly ?string $from = null,
#[Assert\NotBlank(message: 'to must not be empty.')]
#[Assert\Date(message: 'to must be a date as YYYY-MM-DD.')]
#[Assert\GreaterThanOrEqual(propertyPath: 'from', message: 'to must not be before from.')]
public readonly ?string $to = null,
) {
}
// Not getFrom()/getTo(): the property accessor prefers a getter over the public property, so
// the GreaterThanOrEqual above would compare the string "to" with a DateTimeImmutable.
public function getFromDate(): \DateTimeImmutable
{
return new \DateTimeImmutable($this->from);
}
public function getToDate(): \DateTimeImmutable
{
return new \DateTimeImmutable($this->to);
}
}
+44
View File
@@ -0,0 +1,44 @@
<?php
namespace App\Model\Questionnaire;
use App\Enum\ConditionOperator;
/**
* A question's show_if: it is shown, and can be required, only while this holds.
*/
readonly class Condition
{
/**
* @param string|list<string>|int $value an option key for EQUALS, a list of them for IN,
* a rating for LTE
*/
public function __construct(
public string $question,
public ConditionOperator $operator,
public string|array|int $value,
) {
}
/**
* Whether the controlling question's answer satisfies this condition. An unanswered question
* satisfies none: a follow-up stays hidden until there is something to follow up on.
*
* This says nothing about whether the controlling question is itself shown; that is
* Definition::isVisible().
*
* @param array<string, mixed> $answers keyed by question key
*/
public function isMet(array $answers): bool
{
$answer = $answers[$this->question] ?? null;
return match ($this->operator) {
ConditionOperator::EQUALS => $answer === $this->value,
ConditionOperator::IN => in_array($answer, $this->value, true),
// A rating arrives as an int from the form and from stored JSON alike; anything else
// is not a rating.
ConditionOperator::LTE => is_int($answer) && $answer <= $this->value,
};
}
}
+90
View File
@@ -0,0 +1,90 @@
<?php
namespace App\Model\Questionnaire;
/**
* One version of a questionnaire as read from config/questionnaires/. Responses store its key and
* version, and their answers are keyed by Question::$key.
*/
readonly class Definition
{
/**
* @param list<Section> $sections
*/
public function __construct(
public string $key,
public int $version,
public string $title,
public ?string $description,
public array $sections,
) {
}
/**
* @return array<string, Question> in the order they are asked, keyed by question key
*/
public function getQuestions(): array
{
$questions = [];
foreach ($this->sections as $section) {
foreach ($section->questions as $question) {
$questions[$question->key] = $question;
}
}
return $questions;
}
public function getQuestion(string $key): ?Question
{
return $this->getQuestions()[$key] ?? null;
}
/**
* The answers worth keeping once the questionnaire is submitted: those to questions that are
* shown, and not empty. A draft keeps everything, so switching an answer back restores the
* follow-up the respondent had already written.
*
* @param array<string, mixed> $answers keyed by question key
*
* @return array<string, mixed>
*/
public function withoutHiddenAnswers(array $answers): array
{
$kept = [];
foreach ($this->getQuestions() as $key => $question) {
$answer = $answers[$key] ?? null;
if (null !== $answer && '' !== $answer && [] !== $answer && $this->isVisible($question, $answers)) {
$kept[$key] = $answer;
}
}
return $kept;
}
/**
* Whether a question is shown for these answers: it has no show_if, or its condition is met
* and the question it depends on is shown in turn. A hidden question's answer counts for
* nothing, even if one was given before it was hidden - otherwise a follow-up could stay open
* on an answer the respondent can no longer see.
*
* Terminates because a show_if may only name an earlier question (QuestionnaireCatalog).
*
* @param array<string, mixed> $answers keyed by question key
*/
public function isVisible(Question $question, array $answers): bool
{
if (null === $question->showIf) {
return true;
}
$controlling = $this->getQuestion($question->showIf->question);
return null !== $controlling
&& $this->isVisible($controlling, $answers)
&& $question->showIf->isMet($answers);
}
}
+12
View File
@@ -0,0 +1,12 @@
<?php
namespace App\Model\Questionnaire;
readonly class Option
{
public function __construct(
public string $key,
public string $label,
) {
}
}
+36
View File
@@ -0,0 +1,36 @@
<?php
namespace App\Model\Questionnaire;
use App\Enum\ChoiceWidget;
use App\Enum\QuestionType;
readonly class Question
{
/**
* @param list<Option> $options only for CHOICE and MULTI
* @param ChoiceWidget|null $widget only for CHOICE
*/
public function __construct(
public string $key,
public string $label,
public QuestionType $type,
public bool $required = false,
public ?string $help = null,
public ?ChoiceWidget $widget = null,
public array $options = [],
public ?Condition $showIf = null,
) {
}
public function getOption(string $key): ?Option
{
foreach ($this->options as $option) {
if ($key === $option->key) {
return $option;
}
}
return null;
}
}
+16
View File
@@ -0,0 +1,16 @@
<?php
namespace App\Model\Questionnaire;
readonly class Section
{
/**
* @param list<Question> $questions
*/
public function __construct(
public string $key,
public ?string $title,
public array $questions,
) {
}
}
@@ -0,0 +1,61 @@
<?php
namespace App\Model;
use App\Entity\Teamer;
class QuestionnaireResponseFilterDto extends AbstractFilterDto
{
protected ?Teamer $teamer = null;
protected ?string $hotel = null;
protected ?\DateTimeImmutable $dateFrom = null;
protected ?\DateTimeImmutable $dateTo = null;
public function getTeamer(): ?Teamer
{
return $this->teamer;
}
public function setTeamer(?Teamer $teamer): static
{
$this->teamer = $teamer;
return $this;
}
public function getHotel(): ?string
{
return $this->hotel;
}
public function setHotel(?string $hotel): static
{
$this->hotel = $hotel;
return $this;
}
public function getDateFrom(): ?\DateTimeImmutable
{
return $this->dateFrom;
}
public function setDateFrom(?\DateTimeImmutable $dateFrom): static
{
$this->dateFrom = $dateFrom;
return $this;
}
public function getDateTo(): ?\DateTimeImmutable
{
return $this->dateTo;
}
public function setDateTo(?\DateTimeImmutable $dateTo): static
{
$this->dateTo = $dateTo;
return $this;
}
}
+49
View File
@@ -431,4 +431,53 @@ class AssignmentRepository extends ServiceEntityRepository
->getSingleColumnResult() ->getSingleColumnResult()
); );
} }
/**
* The assignments the n8n assignments feed reports: published, in one of the houses, for one of
* the job profiles, and overlapping the range. Placements, their teamers and documents come
* fetch-joined - every place row needs them. All placements are loaded, called-off ones included:
* a fetch join on a filtered collection would leave the assignment with a partial one, and
* Assignment::getPlaces() leaves them out anyway.
*
* @param list<string> $houseCodes matched against the first three characters of the hotel code
* @param list<int> $jobProfileIds
*
* @return list<Assignment>
*/
public function findForExport(\DateTimeImmutable $from, \DateTimeImmutable $to, array $houseCodes, array $jobProfileIds): array
{
if ([] === $houseCodes || [] === $jobProfileIds) {
return [];
}
$qb = $this->createQueryBuilder('assignment');
return $qb
->addSelect('destination', 'jobProfile', 'disposition', 'teamer', 'document')
->innerJoin('assignment.destination', 'destination')
->innerJoin('assignment.jobProfile', 'jobProfile')
->leftJoin('assignment.dispositions', 'disposition')
->leftJoin('disposition.teamer', 'teamer')
->leftJoin('disposition.documents', 'document')
->where($qb->expr()->andX(
$qb->expr()->lte('destination.dateFrom', ':to'),
$qb->expr()->gte('destination.dateTo', ':from'),
$qb->expr()->in('SUBSTRING(destination.hotelCode, 1, 3)', ':houseCodes'),
$qb->expr()->in('jobProfile.id', ':jobProfileIds'),
$qb->expr()->notIn('assignment.status', ':excludedStatuses'),
$qb->expr()->isNull('assignment.deletedAt'),
$qb->expr()->isNull('destination.deletedAt'),
))
->orderBy('destination.dateFrom')
->addOrderBy('destination.hotelCode')
->addOrderBy('assignment.id')
->setParameter('from', $from->format('Y-m-d'))
->setParameter('to', $to->format('Y-m-d'))
->setParameter('houseCodes', $houseCodes)
->setParameter('jobProfileIds', $jobProfileIds)
->setParameter('excludedStatuses', [Assignment::STATUS_DRAFT, Assignment::STATUS_CALLED_OFF, Assignment::STATUS_DELETED])
->getQuery()
->getResult()
;
}
} }
+99
View File
@@ -2,12 +2,16 @@
namespace App\Repository; namespace App\Repository;
use App\Config\QuestionnaireCatalog;
use App\Entity\Assignment; use App\Entity\Assignment;
use App\Entity\Disposition; use App\Entity\Disposition;
use App\Entity\QuestionnaireResponse;
use App\Entity\Teamer; use App\Entity\Teamer;
use App\Entity\Upload; use App\Entity\Upload;
use App\Enum\QuestionnaireResponseStatus;
use App\Repository\Filter\SeasonPeriodFilter; use App\Repository\Filter\SeasonPeriodFilter;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Query; use Doctrine\ORM\Query;
use Doctrine\ORM\Query\Expr\Comparison; use Doctrine\ORM\Query\Expr\Comparison;
use Doctrine\ORM\Query\Expr\Join; use Doctrine\ORM\Query\Expr\Join;
@@ -52,6 +56,17 @@ class DispositionRepository extends ServiceEntityRepository
; ;
} }
/**
* All of them, unlike getUpcomingDispositionsByTeamer(): merged with the season assignments
* by App\Service\Teamer\UpcomingPlacementCollector, which sorts and pages the result.
*
* @return Disposition[]
*/
public function findAllUpcomingByTeamer(Teamer $teamer): array
{
return $this->getUpcomingDispositionsByTeamerQuery($teamer)->getResult();
}
public function getUpcomingDispositionsByTeamer(Teamer $teamer, int $limit = 5): array public function getUpcomingDispositionsByTeamer(Teamer $teamer, int $limit = 5): array
{ {
return $this return $this
@@ -61,6 +76,90 @@ class DispositionRepository extends ServiceEntityRepository
; ;
} }
/**
* The teamer's placements with a questionnaire still to be submitted - not started, or saved as
* a draft: the teamer feedback, and after a bus escort the bus feedback too
* (DispositionContext::questionnaires(), spelled out here in DQL). The rules are those of
* DispositionVoter::QUESTIONNAIRE - over (today included), on or after $windowStart, neither
* called off nor skip-formalities - so every row shown on the dashboard can be opened.
*
* The responses are joined as arbitrary entities because the association is one-way; the
* questionnaire key has to be part of each JOIN condition, or one questionnaire's response
* would stand in for the other's.
*
* Rows are [0 => Disposition, 'teamerStatus' => ?QuestionnaireResponseStatus,
* 'busStatus' => ?QuestionnaireResponseStatus].
*/
public function getPendingQuestionnaireQuery(Teamer $teamer, \DateTimeImmutable $windowStart): Query
{
$qb = $this->createQueryBuilder('disposition');
return $qb
->select('disposition', 'assignment', 'destination', 'teamer_response.status AS teamerStatus', 'bus_response.status AS busStatus')
->innerJoin('disposition.assignment', 'assignment')
->innerJoin('assignment.destination', 'destination')
->leftJoin(
QuestionnaireResponse::class,
'teamer_response',
Join::ON,
'teamer_response.disposition = disposition AND teamer_response.questionnaire = :teamerQuestionnaire'
)
->leftJoin(
QuestionnaireResponse::class,
'bus_response',
Join::ON,
'bus_response.disposition = disposition AND bus_response.questionnaire = :busQuestionnaire'
)
->where($qb->expr()->andX(
$qb->expr()->eq('disposition.teamer', ':teamer'),
$qb->expr()->neq('disposition.status', ':dispositionCalledOff'),
$qb->expr()->notIn('assignment.status', ':assignmentStatuses'),
$qb->expr()->eq('assignment.skipFormalities', ':skipFormalities'),
$qb->expr()->gte('destination.dateTo', ':windowStart'),
$qb->expr()->lte('destination.dateTo', ':today'),
$qb->expr()->orX(
$qb->expr()->isNull('teamer_response.id'),
$qb->expr()->eq('teamer_response.status', ':draft'),
// a bus escort, i.e. Assignment::hasBusEscort(), owing the bus feedback
$qb->expr()->andX(
$qb->expr()->isNotNull('assignment.pickup'),
$qb->expr()->neq('assignment.pickup', 0),
$qb->expr()->orX(
$qb->expr()->isNull('bus_response.id'),
$qb->expr()->eq('bus_response.status', ':draft')
)
)
)
))
->orderBy('destination.dateTo', \SortDirection::Descending)
->setParameter('teamer', $teamer)
->setParameter('teamerQuestionnaire', QuestionnaireCatalog::TEAMER_FEEDBACK)
->setParameter('busQuestionnaire', QuestionnaireCatalog::BUS_FEEDBACK)
->setParameter('dispositionCalledOff', Disposition::STATUS_CALLED_OFF)
->setParameter('assignmentStatuses', [Assignment::STATUS_CALLED_OFF, Assignment::STATUS_DELETED])
->setParameter('skipFormalities', false)
->setParameter('windowStart', $windowStart, Types::DATE_IMMUTABLE)
->setParameter('today', new \DateTimeImmutable('today'), Types::DATE_IMMUTABLE)
->setParameter('draft', QuestionnaireResponseStatus::DRAFT)
->getQuery()
;
}
/**
* @return list<array{disposition: Disposition, draft: bool}>
*/
public function findPendingQuestionnaireByTeamer(Teamer $teamer, \DateTimeImmutable $windowStart): array
{
return array_map(
static fn (array $row): array => [
'disposition' => $row[0],
'draft' => QuestionnaireResponseStatus::DRAFT === $row['teamerStatus']
|| QuestionnaireResponseStatus::DRAFT === $row['busStatus'],
],
$this->getPendingQuestionnaireQuery($teamer, $windowStart)->getResult(),
);
}
public function getRecentDispositionsByTeamerQuery(Teamer $teamer): Query public function getRecentDispositionsByTeamerQuery(Teamer $teamer): Query
{ {
$qb = $this->createQueryBuilder('disposition'); $qb = $this->createQueryBuilder('disposition');
@@ -0,0 +1,96 @@
<?php
namespace App\Repository;
use App\Entity\Disposition;
use App\Entity\QuestionnaireResponse;
use App\Enum\QuestionnaireResponseStatus;
use App\Model\QuestionnaireResponseFilterDto;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Query;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<QuestionnaireResponse>
*
* @method QuestionnaireResponse|null find($id, $lockMode = null, $lockVersion = null)
* @method QuestionnaireResponse|null findOneBy(array $criteria, array $orderBy = null)
* @method QuestionnaireResponse[] findAll()
* @method QuestionnaireResponse[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class QuestionnaireResponseRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, QuestionnaireResponse::class);
}
/**
* Submitted responses to one questionnaire for the office's list. Drafts stay out: until the
* teamer submits, a response is theirs. Filtered and sorted on the live disposition rather
* than the snapshot in `context`, which JSON would make neither sortable nor indexable.
*/
public function getListQuery(string $questionnaire, QuestionnaireResponseFilterDto $filterDto): Query
{
$qb = $this->createQueryBuilder('response');
$qb
->select('response', 'disposition', 'teamer', 'assignment', 'destination')
->innerJoin('response.disposition', 'disposition')
->innerJoin('disposition.teamer', 'teamer')
->innerJoin('disposition.assignment', 'assignment')
->innerJoin('assignment.destination', 'destination')
->where($qb->expr()->andX(
$qb->expr()->eq('response.questionnaire', ':questionnaire'),
$qb->expr()->eq('response.status', ':submitted')
))
->setParameter('questionnaire', $questionnaire)
->setParameter('submitted', QuestionnaireResponseStatus::SUBMITTED)
;
if (null !== $teamer = $filterDto->getTeamer()) {
$qb
->andWhere($qb->expr()->eq('disposition.teamer', ':teamer'))
->setParameter('teamer', $teamer)
;
}
if (null !== $hotel = $filterDto->getHotel()) {
$qb
->andWhere($qb->expr()->like('destination.hotel', ':hotel'))
->setParameter('hotel', '%'.addcslashes($hotel, '%_').'%')
;
}
if (null !== $dateFrom = $filterDto->getDateFrom()) {
$qb
->andWhere($qb->expr()->gte('destination.dateTo', ':dateFrom'))
->setParameter('dateFrom', $dateFrom, Types::DATE_IMMUTABLE)
;
}
if (null !== $dateTo = $filterDto->getDateTo()) {
$qb
->andWhere($qb->expr()->lte('destination.dateTo', ':dateTo'))
->setParameter('dateTo', $dateTo, Types::DATE_IMMUTABLE)
;
}
return $qb->getQuery();
}
/**
* @return array<string, QuestionnaireResponse> keyed by questionnaire key
*/
public function findByDisposition(Disposition $disposition): array
{
$responses = [];
foreach ($this->findBy(['disposition' => $disposition]) as $response) {
$responses[$response->getQuestionnaire()] = $response;
}
return $responses;
}
}
@@ -7,6 +7,7 @@ use App\Entity\Teamer;
use App\Model\SeasonAssignmentFilterDto; use App\Model\SeasonAssignmentFilterDto;
use App\Repository\Traits\QueryHelperTrait; use App\Repository\Traits\QueryHelperTrait;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Query; use Doctrine\ORM\Query;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use Doctrine\Persistence\ManagerRegistry; use Doctrine\Persistence\ManagerRegistry;
@@ -91,6 +92,42 @@ class SeasonAssignmentRepository extends ServiceEntityRepository
; ;
} }
/**
* A teamer's season assignments that have not ended yet, earliest first - listed alongside
* the upcoming dispositions. A running season counts, just as a running disposition does.
*
* @return SeasonAssignment[]
*/
public function findUpcomingByTeamer(Teamer $teamer): array
{
return $this
->createUpcomingByTeamerQueryBuilder($teamer)
->getQuery()
->getResult()
;
}
/**
* Extracted so the conditions can be pinned by a test compiling the DQL.
*/
public function createUpcomingByTeamerQueryBuilder(Teamer $teamer): QueryBuilder
{
$qb = $this->createQueryBuilder('season_assignment');
return $qb
->select('season_assignment', 'job_profile')
->innerJoin('season_assignment.jobProfile', 'job_profile')
->where($qb->expr()->andX(
$qb->expr()->eq('season_assignment.teamer', ':teamer'),
$qb->expr()->isNull('season_assignment.deletedAt'),
$qb->expr()->gte('season_assignment.dateTo', ':today')
))
->setParameter('teamer', $teamer)
->setParameter('today', new \DateTimeImmutable('today'), Types::DATE_IMMUTABLE)
->addOrderBy('season_assignment.dateFrom', \SortDirection::Ascending)
;
}
/** /**
* Extracted so the conditions can be pinned by a test compiling the DQL - the suite has no * Extracted so the conditions can be pinned by a test compiling the DQL - the suite has no
* fixtures, so what is asserted is what the query says, not what it returns. * fixtures, so what is asserted is what the query says, not what it returns.
+24 -16
View File
@@ -8,38 +8,46 @@ use Symfony\Component\Security\Http\AccessToken\AccessTokenHandlerInterface;
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge; use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
/** /**
* Validates the shared key a sibling website posts with. There is no person to log in and no * Validates the shared key a machine caller sends. There is no person to log in and no account to
* account to look up: the key is the identity, and the user it resolves to is the in-memory * look up: the key is the identity, and the user it resolves to is one of the in-memory users of
* "api" user of the api_user_provider - nothing about it may reach the user table, where a row * the api_user_provider - nothing about it may reach the user table, where a row would be a login
* would be a login to this application's UI. * to this application's UI.
*
* One key per caller, each resolving to its own user and roles: the websites posting application
* forms must not read assignments, and n8n reading assignments must not post forms.
*/ */
class ApiKeyTokenHandler implements AccessTokenHandlerInterface class ApiKeyTokenHandler implements AccessTokenHandlerInterface
{ {
public const USER_IDENTIFIER = 'api'; /**
* @param array<string, string> $apiKeys user identifier => key
*/
public function __construct( public function __construct(
private readonly string $apiKey, private readonly array $apiKeys,
private readonly LoggerInterface $logger, private readonly LoggerInterface $logger,
) { ) {
} }
public function getUserBadgeFrom(string $accessToken): UserBadge public function getUserBadgeFrom(string $accessToken): UserBadge
{ {
// An unconfigured key locks the endpoint instead of opening it: hash_equals('', '') // An unconfigured key locks its caller out instead of opening the door: hash_equals('', '')
// is true, so without this check a deployment that forgot the secret would accept // is true, so without this filter a deployment that forgot a secret would accept an empty
// an empty key from anyone. // key from anyone.
if ('' === $this->apiKey) { $configuredKeys = array_filter($this->apiKeys, fn (string $key) => '' !== $key);
if ([] === $configuredKeys) {
$this->logger->error('API key authentication attempted while no key is configured'); $this->logger->error('API key authentication attempted while no key is configured');
throw new BadCredentialsException('No API key configured.'); throw new BadCredentialsException('No API key configured.');
} }
if (false === hash_equals($this->apiKey, $accessToken)) { foreach ($configuredKeys as $identifier => $key) {
$this->logger->warning('API key authentication failed'); if (true === hash_equals($key, $accessToken)) {
return new UserBadge((string) $identifier);
throw new BadCredentialsException('Invalid API key.'); }
} }
return new UserBadge(self::USER_IDENTIFIER); $this->logger->warning('API key authentication failed');
throw new BadCredentialsException('Invalid API key.');
} }
} }
+6 -2
View File
@@ -51,11 +51,15 @@ class BpnAuthenticator extends AbstractLoginFormAuthenticator implements Authent
* The firewall saves the requested url as the target path right before it calls this. An * The firewall saves the requested url as the target path right before it calls this. An
* htmx request is a fragment - a modal, a table body - that cannot stand as a page, so * htmx request is a fragment - a modal, a table body - that cannot stand as a page, so
* after the login it must not be where the user lands. htmx does not send the * after the login it must not be where the user lands. htmx does not send the
* X-Requested-With header that would make Symfony skip it on its own. * X-Requested-With header that would make Symfony skip it on its own. A boosted request
* (a paginator or sort link) is the exception: it fetches a whole page and stays the deeplink.
*/ */
public function start(Request $request, ?AuthenticationException $authException = null): Response public function start(Request $request, ?AuthenticationException $authException = null): Response
{ {
if (true === $request->headers->has('HX-Request') && true === $request->hasSession()) { if (true === $request->headers->has('HX-Request')
&& false === $request->headers->has('HX-Boosted')
&& true === $request->hasSession()
) {
$this->removeTargetPath($request->getSession(), self::FIREWALL_NAME); $this->removeTargetPath($request->getSession(), self::FIREWALL_NAME);
} }
+3 -1
View File
@@ -48,8 +48,10 @@ class ApplicationVoter extends Voter
return match ($attribute) { return match ($attribute) {
static::STATUS, static::DELETE => true, static::STATUS, static::DELETE => true,
static::VIEW => Application::STATUS_REJECTED !== $status, static::VIEW => Application::STATUS_REJECTED !== $status,
// A called-off placement frees its place, so it does not count here: re-staffing
// must not take raising availableDispositions, which would add a place.
static::DISPOSE => Application::STATUS_REJECTED !== $status static::DISPOSE => Application::STATUS_REJECTED !== $status
&& $assignment->getAvailableDispositions() > $assignment->getDispositions()->count(), && $assignment->getAvailableDispositions() > $assignment->getActiveDispositions()->count(),
default => false, default => false,
}; };
} }
+45 -2
View File
@@ -2,6 +2,7 @@
namespace App\Security\Voter; namespace App\Security\Voter;
use App\Config\QuestionnaireCatalog;
use App\Entity\Disposition; use App\Entity\Disposition;
use App\Entity\Upload; use App\Entity\Upload;
use App\Entity\User; use App\Entity\User;
@@ -22,9 +23,15 @@ class DispositionVoter extends Voter
public const FEEDBACK = 'FEEDBACK'; public const FEEDBACK = 'FEEDBACK';
public const CALL_OFF = 'CALL_OFF'; public const CALL_OFF = 'CALL_OFF';
public const MANAGE_RECEIPTS = 'MANAGE_RECEIPTS'; public const MANAGE_RECEIPTS = 'MANAGE_RECEIPTS';
public const QUESTIONNAIRE = 'QUESTIONNAIRE';
public function __construct(private readonly Security $security) /**
{ * @param int $questionnaireWindowDays the services.yaml parameter questionnaire_window_days
*/
public function __construct(
private readonly Security $security,
private readonly int $questionnaireWindowDays,
) {
} }
protected function supports(string $attribute, mixed $subject): bool protected function supports(string $attribute, mixed $subject): bool
@@ -44,6 +51,7 @@ class DispositionVoter extends Voter
static::FEEDBACK, static::FEEDBACK,
static::CALL_OFF, static::CALL_OFF,
static::MANAGE_RECEIPTS, static::MANAGE_RECEIPTS,
static::QUESTIONNAIRE,
]); ]);
} }
@@ -69,6 +77,7 @@ class DispositionVoter extends Voter
static::CALL_OFF => $this->security->isGranted('ROLE_ADMINISTRATIVE') static::CALL_OFF => $this->security->isGranted('ROLE_ADMINISTRATIVE')
&& Disposition::STATUS_CALLED_OFF !== $disposition->getStatus(), && Disposition::STATUS_CALLED_OFF !== $disposition->getStatus(),
static::MANAGE_RECEIPTS => $this->assertManageReceiptsAllowed($token, $disposition), static::MANAGE_RECEIPTS => $this->assertManageReceiptsAllowed($token, $disposition),
static::QUESTIONNAIRE => $this->assertQuestionnaireAllowed($token, $disposition),
default => false, default => false,
}; };
} }
@@ -104,6 +113,40 @@ class DispositionVoter extends Voter
], true); ], true);
} }
/**
* Whether the teamer may fill in, and later read, the questionnaires after this placement:
* every placement gets the teamer feedback, a bus escort the bus feedback as well
* (DispositionContext::questionnaires() - which ones is not this voter's business). Only the
* teamer themself: the office reads the submitted responses through ROLE_ADMINISTRATIVE, not
* through this attribute.
*
* "Over" is the destination's end date, not Disposition::STATUS_ENDED: the cron sets that a
* run late, and it moves on to checking_invoice and completed while the date stays true. An
* assignment ending today counts as over, as in DispositionRepository's feedback queries.
*
* Skip-formalities placements are left out, as they are from contract, invoice and feedback.
*
* DispositionRepository::getPendingQuestionnaireQuery() applies the same rules in DQL for the
* dashboard; change both together.
*/
private function assertQuestionnaireAllowed(TokenInterface $token, Disposition $disposition): bool
{
if (false === $this->assertTeamerAccess($token, $disposition)) {
return false;
}
if (true === $disposition->isSkipFormalities()
|| Disposition::STATUS_CALLED_OFF === $disposition->getStatus()) {
return false;
}
$dateTo = $disposition->getAssignment()?->getDestination()?->getDateTo();
return null !== $dateTo
&& $dateTo >= QuestionnaireCatalog::windowStart($this->questionnaireWindowDays)
&& $dateTo <= new \DateTimeImmutable('today');
}
private function assertHouseManagerAccess(TokenInterface $token, Disposition $disposition): bool private function assertHouseManagerAccess(TokenInterface $token, Disposition $disposition): bool
{ {
if (false === $this->security->isGranted('ROLE_HOUSE_MANAGER')) { if (false === $this->security->isGranted('ROLE_HOUSE_MANAGER')) {
+46 -45
View File
@@ -14,14 +14,17 @@ use App\Service\Common\PickupOptions;
* *
* The rules, agreed with the stakeholders on 2026-10-15: * The rules, agreed with the stakeholders on 2026-10-15:
* - one assignment per role, the role's head count as its places; * - one assignment per role, the role's head count as its places;
* - without split, each ski level is a Kursleitung of its own, one place; * - each ski level is a Kursleitung of its own, one place, unless the matrix has a Reiseleitung
* - with split, a Reiseleitung takes over each level through the combined profile, one place * take it over: then it is the combined profile, one place, and the plain Reiseleitung keeps
* per level, and the plain Reiseleitung keeps the remaining places; * the remaining places. Decided per level (2026-11-05), so one Reiseleitung can take over one
* - Guiding is the guiding fee on every guide-type assignment, not an assignment of its own; * level while the other stays a Kursleitung;
* - a date with bus travel (boarding points) gets its first boarding point pre-selected as * - a date with bus travel (boarding points) gets its first boarding point pre-selected as
* Busbegleitung on exactly one assignment, the first guide-type one - the plain Reiseleitung * Busbegleitung on exactly one assignment, the first guide-type one - the plain Reiseleitung
* where there is one. Taken from the date, not the matrix: bus travel varies between the * where there is one. Taken from the date, not the matrix: bus travel varies between the
* dates of one product. * dates of one product;
* - Guiding is the guiding fee on exactly one guide place, not an assignment of its own: the
* bus escort's. Where that assignment has more places, one place is split off to carry
* fee and pickup, so the others are neither guiding nor escorting the bus.
*/ */
final class AssignmentPlanner final class AssignmentPlanner
{ {
@@ -30,40 +33,35 @@ final class AssignmentPlanner
*/ */
public function plan(StaffingRule $rule, Destination $destination): array public function plan(StaffingRule $rule, Destination $destination): array
{ {
$roles = []; $combined = [];
$guides = (int) $rule->getGuides(); $courses = [];
if (true === $rule->isSplit()) { if (true === $rule->isSkiBeginner()) {
$combined = []; if (true === $rule->isSplitBeginner()) {
$combined[] = [StaffingRole::GUIDE_SKI_BEGINNER, 1];
if (true === $rule->isSkiBeginner()) { } else {
$combined[] = StaffingRole::GUIDE_SKI_BEGINNER; $courses[] = [StaffingRole::SKI_BEGINNER, 1];
}
if (true === $rule->isSkiAdvanced()) {
$combined[] = StaffingRole::GUIDE_SKI_ADVANCED;
}
// The matrix validation refuses more levels than guides; max() keeps a row that
// slipped past it from planning a negative head count.
$roles[] = [StaffingRole::GUIDE, max(0, $guides - count($combined))];
foreach ($combined as $role) {
$roles[] = [$role, 1];
}
} else {
$roles[] = [StaffingRole::GUIDE, $guides];
if (true === $rule->isSkiBeginner()) {
$roles[] = [StaffingRole::SKI_BEGINNER, 1];
}
if (true === $rule->isSkiAdvanced()) {
$roles[] = [StaffingRole::SKI_ADVANCED, 1];
} }
} }
if (true === $rule->isSkiAdvanced()) {
if (true === $rule->isSplitAdvanced()) {
$combined[] = [StaffingRole::GUIDE_SKI_ADVANCED, 1];
} else {
$courses[] = [StaffingRole::SKI_ADVANCED, 1];
}
}
// The matrix validation refuses more taken-over levels than guides; max() keeps a row
// that slipped past it from planning a negative head count.
$roles = [
[StaffingRole::GUIDE, max(0, (int) $rule->getGuides() - count($combined))],
...$combined,
...$courses,
];
$pickup = $this->firstPickup($destination); $pickup = $this->firstPickup($destination);
$guiding = $rule->isGuiding();
$planned = []; $planned = [];
foreach ($roles as [$role, $places]) { foreach ($roles as [$role, $places]) {
@@ -71,26 +69,29 @@ final class AssignmentPlanner
continue; continue;
} }
$fees = []; $fees = true === $role->isCourse() ? [StaffingFee::COURSE] : [];
if (true === $role->isGuide() && true === $rule->isGuiding()) { if (false === $role->isGuide()) {
$fees[] = StaffingFee::GUIDING; $planned[] = new PlannedAssignment($role, $places, null, $fees);
continue;
} }
if (true === $role->isCourse()) { $first = true === $guiding ? 1 : $places;
$fees[] = StaffingFee::COURSE;
}
$planned[] = new PlannedAssignment( $planned[] = new PlannedAssignment(
$role, $role,
$places, $first,
true === $role->isGuide() ? $pickup : null, $pickup,
$fees, true === $guiding ? [StaffingFee::GUIDING, ...$fees] : $fees,
); );
if (true === $role->isGuide()) { if ($first < $places) {
$pickup = null; $planned[] = new PlannedAssignment($role, $places - $first, null, $fees);
} }
$guiding = false;
$pickup = null;
} }
return $planned; return $planned;
@@ -0,0 +1,48 @@
<?php
namespace App\Service\Common;
use App\Entity\Teamer;
use App\Model\AbstractFilterDto;
use App\Model\QuestionnaireResponseFilterDto;
class QuestionnaireResponseFilterHandler extends AbstractFilterHandler
{
protected string $namespace = 'filter:questionnaire_response';
protected string $modelClass = QuestionnaireResponseFilterDto::class;
public function getFilterSettings(): QuestionnaireResponseFilterDto
{
$filterDto = new $this->modelClass();
if (null === $data = $this->getSession()->get($this->namespace)) {
return $filterDto;
}
if (isset($data['teamer_id'])) {
$filterDto->setTeamer($this->entityManager->getRepository(Teamer::class)->find($data['teamer_id']));
}
if (isset($data['hotel'])) {
$filterDto->setHotel($data['hotel']);
}
if (isset($data['date_from'])) {
$filterDto->setDateFrom($data['date_from']);
}
if (isset($data['date_to'])) {
$filterDto->setDateTo($data['date_to']);
}
return $filterDto;
}
protected function saveFilterSettings(AbstractFilterDto $filterDto): void
{
/* @var QuestionnaireResponseFilterDto $filterDto */
$this->getSession()->set($this->namespace, [
'teamer_id' => $filterDto->getTeamer()?->getId(),
'hotel' => $filterDto->getHotel(),
'date_from' => $filterDto->getDateFrom(),
'date_to' => $filterDto->getDateTo(),
]);
}
}
@@ -0,0 +1,74 @@
<?php
namespace App\Service\Questionnaire;
use App\Config\QuestionnaireCatalog;
use App\Entity\Assignment;
use App\Entity\Disposition;
/**
* What a disposition already knows, snapshotted into a QuestionnaireResponse so the questionnaire
* need not ask it: who, in which role, where, when, and where the bus escort started.
*
* Kept as plain scalars (dates as Y-m-d), because it is stored as JSON and must stay readable
* after the assignment, its destination or the teamer change.
*/
final class DispositionContext
{
/**
* The questionnaires a placement on this assignment gets, in the order they are shown: every
* teamer the teamer feedback, a bus escort the bus feedback as well. Takes the assignment so
* the office's test mode can ask before anyone is placed.
*
* DispositionRepository::getPendingQuestionnaireQuery() spells the same rule in DQL.
*
* @return list<string> questionnaire keys
*/
public static function questionnaires(Assignment $assignment): array
{
return $assignment->hasBusEscort()
? [QuestionnaireCatalog::TEAMER_FEEDBACK, QuestionnaireCatalog::BUS_FEEDBACK]
: [QuestionnaireCatalog::TEAMER_FEEDBACK];
}
/**
* @return array{
* teamerName: ?string,
* jobProfileName: ?string,
* jobProfileCategory: ?string,
* destinationProduct: ?string,
* hotel: ?string,
* hotelCode: ?string,
* dateFrom: ?string,
* dateTo: ?string,
* escortPickup: array{busProId: ?int, city: ?string, street: ?string, time: ?string}|null,
* escortPickupDate: ?string,
* }
*/
public static function build(Disposition $disposition): array
{
$assignment = $disposition->getAssignment();
$destination = $assignment?->getDestination();
$jobProfile = $assignment?->getJobProfile();
$pickup = $assignment?->hasBusEscort() ? $destination?->getPickup($assignment->getPickup()) : null;
return [
'teamerName' => $disposition->getTeamer()?->getFullName(),
'jobProfileName' => $jobProfile?->getName(),
'jobProfileCategory' => $jobProfile?->getCategory(),
'destinationProduct' => $destination?->getProduct(),
'hotel' => $destination?->getHotel(),
'hotelCode' => $destination?->getHotelCode(),
'dateFrom' => $destination?->getDateFrom()?->format('Y-m-d'),
'dateTo' => $destination?->getDateTo()?->format('Y-m-d'),
'escortPickup' => null === $pickup ? null : [
// Pickup::fromArray() fills id, not busProId; the assignment holds the same value
'busProId' => $assignment->getPickup(),
'city' => $pickup->getCity(),
'street' => $pickup->getStreet(),
'time' => $pickup->getTime(),
],
'escortPickupDate' => $assignment?->getEffectivePickupDate()?->format('Y-m-d'),
];
}
}
@@ -0,0 +1,62 @@
<?php
namespace App\Service\Teamer;
use App\Entity\Disposition;
use App\Entity\SeasonAssignment;
use App\Entity\Teamer;
use App\Repository\DispositionRepository;
use App\Repository\SeasonAssignmentRepository;
/**
* A teamer's upcoming placements as one list, earliest first.
*
* "Placement" covers both ways a teamer is placed: a Disposition on an Assignment, or a
* SeasonAssignment. It is not an entity, only the name for the two together.
*
* The two live in separate tables, so no single query can sort or page across both. A teamer
* has a few dozen upcoming dispositions at most, so both are loaded in full and merged here;
* callers page or slice the result. Each row carries exactly one of the two records.
*/
class UpcomingPlacementCollector
{
public function __construct(
private readonly DispositionRepository $dispositionRepository,
private readonly SeasonAssignmentRepository $seasonAssignmentRepository,
) {
}
/**
* @return list<array{dateFrom: ?\DateTimeImmutable, dateTo: ?\DateTimeImmutable, disposition: ?Disposition, seasonAssignment: ?SeasonAssignment}>
*/
public function collect(Teamer $teamer): array
{
$rows = [];
// season assignments first: the sort is stable, so on the same start day the season,
// which frames the dispositions inside it, comes before them
foreach ($this->seasonAssignmentRepository->findUpcomingByTeamer($teamer) as $seasonAssignment) {
$rows[] = [
'dateFrom' => $seasonAssignment->getDateFrom(),
'dateTo' => $seasonAssignment->getDateTo(),
'disposition' => null,
'seasonAssignment' => $seasonAssignment,
];
}
foreach ($this->dispositionRepository->findAllUpcomingByTeamer($teamer) as $disposition) {
$destination = $disposition->getAssignment()?->getDestination();
$rows[] = [
'dateFrom' => $destination?->getDateFrom(),
'dateTo' => $destination?->getDateTo(),
'disposition' => $disposition,
'seasonAssignment' => null,
];
}
usort($rows, static fn (array $a, array $b): int => $a['dateFrom'] <=> $b['dateFrom']);
return $rows;
}
}
-32
View File
@@ -1,32 +0,0 @@
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
'./templates/**/*.twig',
'./src/Twig/*.php',
],
safelist: ['rotate-90'],
theme: {
container: {
center: true,
padding: '2rem',
},
extend: {
fontFamily: {
sans: ['Lato', 'sans-serif'],
},
fontWeight: {
semibold: '700',
bold: '900',
},
colors: {
primary: '#3d8ccb',
secondary: '#f9c700',
}
},
},
plugins: [
require('@tailwindcss/forms'),
require('@tailwindcss/typography'),
],
}
+1 -1
View File
@@ -1,7 +1,7 @@
{% set type = type|default('info') %} {% set type = type|default('info') %}
<div class="{{ html_classes('p-4 mb-4 flex items-start space-x-2 text-gray-100 rounded-md', { 'bg-blue-600': type == 'info', 'bg-red-600': type == 'warning', 'bg-green-600': type == 'success' }) }}"> <div class="{{ html_classes('p-4 mb-4 flex items-start space-x-2 text-gray-100 rounded-md', { 'bg-blue-600': type == 'info', 'bg-red-600': type == 'warning', 'bg-green-600': type == 'success' }) }}">
{{ icon(type == 'success' ? 'check' : 'alert', 'w-5 h-5 flex-shrink-0') }} {{ icon(type == 'success' ? 'check' : 'alert', 'w-5 h-5 shrink-0') }}
<div class="leading-relaxed text-base"> <div class="leading-relaxed text-base">
{% block message %} {% block message %}
{{ message | nl2br }} {{ message | nl2br }}
@@ -4,7 +4,7 @@
<dt class="text-sm font-bold leading-6 text-gray-900"> <dt class="text-sm font-bold leading-6 text-gray-900">
Jobprofil Jobprofil
</dt> </dt>
<dd class="mt-1 text-sm leading-6 text-gray-700 sm:col-span-3 sm:mt-0 max-h-96 overflow-y-scroll"> <dd class="mt-1 text-sm leading-6 text-gray-700 sm:col-span-3 sm:mt-0 max-h-96 overflow-y-auto pr-3">
<strong>{{ assignment.jobProfile.name }}</strong> <strong>{{ assignment.jobProfile.name }}</strong>
{% if assignment.jobProfileInfo %} {% if assignment.jobProfileInfo %}
<div class="pt-2"> <div class="pt-2">
@@ -1,6 +1,6 @@
{% if is_maintenance_mode() %} {% if is_maintenance_mode() %}
<div class="sticky top-0 z-50 bg-red-600 text-gray-100 px-4 lg:px-8 py-2 flex items-center justify-center space-x-2"> <div class="sticky top-0 z-50 bg-red-600 text-gray-100 px-4 lg:px-8 py-2 flex items-center justify-center space-x-2">
{{ icon('alert', 'w-5 h-5 flex-shrink-0') }} {{ icon('alert', 'w-5 h-5 shrink-0') }}
<span class="leading-relaxed">Wartungsmodus — das Portal ist für andere Benutzer gesperrt.</span> <span class="leading-relaxed">Wartungsmodus — das Portal ist für andere Benutzer gesperrt.</span>
</div> </div>
{% endif %} {% endif %}
+1 -1
View File
@@ -11,7 +11,7 @@
'- Punkt': 'Aufzählung', '- Punkt': 'Aufzählung',
'1. Punkt': 'Nummerierung', '1. Punkt': 'Nummerierung',
} %} } %}
<span class="inline-flex items-center space-x-1 py-1 px-2 bg-gray-50 border border-gray-200 rounded"> <span class="inline-flex items-center space-x-1 py-1 px-2 bg-gray-50 border border-gray-200 rounded-sm">
<code>{{ example }}</code> <code>{{ example }}</code>
<span>{{ label }}</span> <span>{{ label }}</span>
</span> </span>
Loaded 100 of 179 files, more files were not shown because too many files have changed in this diff. Show more