diff --git a/app/controllers/consultation/admin.php b/app/controllers/consultation/admin.php index a1f16c549bf49d4206d7452d7eb3aef5d310e34d..1a831247639ef1fca8ae29b7ed8d59ec0f8847e5 100644 --- a/app/controllers/consultation/admin.php +++ b/app/controllers/consultation/admin.php @@ -394,24 +394,27 @@ class Consultation_AdminController extends ConsultationController 'sem_perm' => $permissions, ]); } + } - if (Request::isPost()) { - CSRFProtection::verifyUnsafeRequest(); + public function store_booking_action($block_id, $slot_id, $page = 0): void + { + CSRFProtection::verifyUnsafeRequest(); - if ($this->slot->isOccupied()) { - PageLayout::postError(_('Dieser Termin ist bereits belegt.')); - } else { - $booking = new ConsultationBooking(); - $booking->slot_id = $this->slot->id; - $booking->user_id = Request::option('user_id'); - $booking->reason = trim(Request::get('reason')); - $booking->store(); + $slot = $this->loadSlot($block_id, $slot_id); - PageLayout::postSuccess(_('Der Termin wurde reserviert.')); - } + if ($slot->isOccupied()) { + PageLayout::postError(_('Dieser Termin ist bereits belegt.')); + } else { + $booking = new ConsultationBooking(); + $booking->slot_id = $slot->id; + $booking->user_id = Request::option('user_id'); + $booking->reason = trim(Request::get('reason')); + $booking->store(); - $this->redirect("consultation/admin/index/{$page}#slot-{$this->slot->id}"); + PageLayout::postSuccess(_('Der Termin wurde reserviert.')); } + + $this->redirect("consultation/admin/index/{$page}#slot-{$slot->id}"); } public function edit_action($block_id, $page = 0) diff --git a/app/views/consultation/admin/book.php b/app/views/consultation/admin/book.php index a5a4371bd31ad71808054d9e017b7b9919ed0bfb..9e2fa9172dcab4bc741139bef312fb9fc39b9ae7 100644 --- a/app/views/consultation/admin/book.php +++ b/app/views/consultation/admin/book.php @@ -5,7 +5,7 @@ * @var int $page */ ?> -<form action="<?= $controller->book($slot->block, $slot, $page) ?>" method="post" class="default"> +<form action="<?= $controller->store_booking($slot->block, $slot, $page) ?>" method="post" class="default"> <?= CSRFProtection::tokenTag() ?> <fieldset>