From 09caff2b2a06d1f8ac8203567035a21c612165f9 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Thu, 11 Jan 2024 13:15:02 +0100 Subject: send resources --- src/Model/Event/SendUnits.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/Model/Event/SendUnits.php') diff --git a/src/Model/Event/SendUnits.php b/src/Model/Event/SendUnits.php index ed4d5b6..c9afd6e 100644 --- a/src/Model/Event/SendUnits.php +++ b/src/Model/Event/SendUnits.php @@ -102,6 +102,27 @@ class SendUnits extends BaseEvent ); } + public function cancel(): void + { + $this->event = $this->getEvent(); + + $cancelTimeDiff = $this->event->createdAt->diff(new \DateTime()); + $cancelTime = (new \DateTime())->add($cancelTimeDiff); + + $this->isCanceled = true; + $this->home = $this->destination; + $this->residence = $this->source; + + DB::query( + 'update events set time=:time where id=:id', + ['time' => $cancelTime->format('c'), 'id' => $this->event->id] + ); + DB::query( + 'update events_send_units set is_canceled=:is_canceled, home=:home, residence=:residence where id=:id', + ['is_canceled' => $this->isCanceled, 'home' => $this->home, 'residence' => $this->residence, 'id' => $this->id] + ); + } + public function dbInsert(): void { DB::query( -- cgit v1.2.3