... | ... |
@@ -17,6 +17,8 @@ use Contao\DataContainer; |
17 | 17 |
use Contao\Date; |
18 | 18 |
use Contao\StringUtil; |
19 | 19 |
use Doctrine\DBAL\Connection; |
20 |
+use Symfony\Component\EventDispatcher\EventDispatcherInterface; |
|
21 |
+use vonRotenberg\WeinanlieferungBundle\Event\CheckInCompletedEvent; |
|
20 | 22 |
use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungLeseartModel; |
21 | 23 |
use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungRebsorteModel; |
22 | 24 |
use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungReservationModel; |
... | ... |
@@ -27,9 +29,13 @@ class WeinanlieferungReservationContainerListener |
27 | 29 |
/** @var Connection */ |
28 | 30 |
protected $db; |
29 | 31 |
|
30 |
- public function __construct(Connection $db) |
|
32 |
+ private $eventDispatcher; |
|
33 |
+ |
|
34 |
+ |
|
35 |
+ public function __construct(Connection $db, EventDispatcherInterface $eventDispatcher) |
|
31 | 36 |
{ |
32 | 37 |
$this->db = $db; |
38 |
+ $this->eventDispatcher = $eventDispatcher; |
|
33 | 39 |
} |
34 | 40 |
|
35 | 41 |
|
... | ... |
@@ -334,4 +340,21 @@ class WeinanlieferungReservationContainerListener |
334 | 340 |
} |
335 | 341 |
return $varValue; |
336 | 342 |
} |
343 |
+ |
|
344 |
+ /** |
|
345 |
+ * @Callback(table="tl_vr_wa_reservation", target="config.onsubmit") |
|
346 |
+ */ |
|
347 |
+ public function onSubmitCallback(DataContainer $dc) |
|
348 |
+ { |
|
349 |
+ if (($reservation = WeinanlieferungReservationModel::findByPk($dc->id)) !== null && $reservation->checked_in) |
|
350 |
+ { |
|
351 |
+ $time = time(); |
|
352 |
+ $reservation->checked_in = '1'; |
|
353 |
+ $reservation->checked_in_on = $time; |
|
354 |
+ $reservation->save(); |
|
355 |
+ |
|
356 |
+ $event = new CheckInCompletedEvent($reservation->row(), $reservation); |
|
357 |
+ $this->eventDispatcher->dispatch($event, CheckInCompletedEvent::NAME); |
|
358 |
+ } |
|
359 |
+ } |
|
337 | 360 |
} |