From b21316248572cb27ed1f504529ad6680a473022e Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Tue, 2 Jan 2024 20:42:01 +0100 Subject: gemini --- src/Controller/Event.php | 85 ------------------------------------------------ 1 file changed, 85 deletions(-) delete mode 100644 src/Controller/Event.php (limited to 'src/Controller/Event.php') diff --git a/src/Controller/Event.php b/src/Controller/Event.php deleted file mode 100644 index 1fd304d..0000000 --- a/src/Controller/Event.php +++ /dev/null @@ -1,85 +0,0 @@ - $request->get('x'), 'y' => $request->get('y')] - ) - ); - } - - #[Route(path: '/event/{id}/cancel', methods: ['POST'])] - public function cancel(Request $request): Response - { - $event = DB::fetch(Model::class, 'select * from events where id=:id', ['id' => $request->get('id')])[0] ?? null; - $village = Village::get($event->villageId); - - /**@var SendUnits $sendUnitsEvent*/ - $sendUnitsEvent = DB::fetch(SendUnits::class, 'select * from events_send_units where event_id=:id', ['id' => $event->id])[0] ?? null; - if (! empty($sendUnitsEvent)) { - if ($sendUnitsEvent->type === 'SendBack') { - $cancelTimeDiff = $event->createdAt->diff(new \DateTime()); - $cancelTime = (new \DateTime())->add($cancelTimeDiff); - - $sendUnitsEvent->isCanceled = true; - $sendUnitsEvent->home = $sendUnitsEvent->destination; - $sendUnitsEvent->residence = $sendUnitsEvent->source; - - DB::query( - 'update events set time=:time where id=:id', - ['time' => $cancelTime->format('c'), 'id' => $request->get('id')] - ); - DB::query( - 'update events_send_units set is_canceled=:is_canceled, home=:home, residence=:residence where id=:id', - ['is_canceled' => $sendUnitsEvent->isCanceled, 'home' => $sendUnitsEvent->home, 'residence' => $sendUnitsEvent->residence, 'id' => $sendUnitsEvent->id] - ); - } - - else if ($sendUnitsEvent->type === 'Recall') { - $cancelTimeDiff = $event->createdAt->diff(new \DateTime()); - $cancelTime = (new \DateTime())->add($cancelTimeDiff); - - $sendUnitsEvent->isCanceled = true; - $sendUnitsEvent->home = $sendUnitsEvent->destination; - $sendUnitsEvent->residence = $sendUnitsEvent->source; - - DB::query( - 'update events set time=:time where id=:id', - ['time' => $cancelTime->format('c'), 'id' => $request->get('id')] - ); - DB::query( - 'update events_send_units set is_canceled=:is_canceled, home=:home, residence=:residence where id=:id', - ['is_canceled' => $sendUnitsEvent->isCanceled, 'home' => $sendUnitsEvent->home, 'residence' => $sendUnitsEvent->residence, 'id' => $sendUnitsEvent->id] - ); - } - } - - else { - DB::query('delete from event where id=:id', ['id' => $request->get('id')]); - } - - return new RedirectResponse( - Router::generate( - 'village.show', - ['x' => $village->x, 'y' => $village->y] - ) - ); - } -} -- cgit v1.2.3