| ... | ... |
@@ -151,7 +151,7 @@ $GLOBALS['TL_DCA']['tl_vr_wa_reservation'] = array |
| 151 | 151 |
( |
| 152 | 152 |
'exclude' => true, |
| 153 | 153 |
'inputType' => 'text', |
| 154 |
- 'eval' => array('rgxp'=>'natural','tl_class'=>'w50'),
|
|
| 154 |
+ 'eval' => array('rgxp'=>'natural','tl_class'=>'w50', 'readonly' => true, 'disabled'=>true),
|
|
| 155 | 155 |
'sql' => "int(4) unsigned NOT NULL default 0", |
| 156 | 156 |
), |
| 157 | 157 |
'unit_id' => array |
| ... | ... |
@@ -15,6 +15,7 @@ namespace vonRotenberg\WeinanlieferungBundle\EventListener\DataContainer; |
| 15 | 15 |
use Contao\CoreBundle\ServiceAnnotation\Callback; |
| 16 | 16 |
use Contao\DataContainer; |
| 17 | 17 |
use Contao\Date; |
| 18 |
+use Contao\Input; |
|
| 18 | 19 |
use Contao\StringUtil; |
| 19 | 20 |
use Doctrine\DBAL\Connection; |
| 20 | 21 |
use Symfony\Component\EventDispatcher\EventDispatcherInterface; |
| ... | ... |
@@ -23,6 +24,7 @@ use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungLeseartModel; |
| 23 | 24 |
use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungRebsorteModel; |
| 24 | 25 |
use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungReservationModel; |
| 25 | 26 |
use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungSlotsModel; |
| 27 |
+use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungUnitModel; |
|
| 26 | 28 |
|
| 27 | 29 |
class WeinanlieferungReservationContainerListener |
| 28 | 30 |
{
|
| ... | ... |
@@ -365,15 +367,39 @@ class WeinanlieferungReservationContainerListener |
| 365 | 367 |
*/ |
| 366 | 368 |
public function onSubmitCallback(DataContainer $dc) |
| 367 | 369 |
{
|
| 368 |
- if (($reservation = WeinanlieferungReservationModel::findByPk($dc->id)) !== null && $reservation->checked_in) |
|
| 370 |
+ if (($reservation = WeinanlieferungReservationModel::findByPk($dc->id)) !== null) |
|
| 369 | 371 |
{
|
| 370 |
- $time = time(); |
|
| 371 |
- $reservation->checked_in = '1'; |
|
| 372 |
- $reservation->checked_in_on = $time; |
|
| 373 |
- $reservation->save(); |
|
| 372 |
+ // Handle checck-in |
|
| 373 |
+ if ($reservation->checked_in) |
|
| 374 |
+ {
|
|
| 375 |
+ $time = time(); |
|
| 376 |
+ $reservation->checked_in = '1'; |
|
| 377 |
+ $reservation->checked_in_on = $time; |
|
| 378 |
+ $reservation->save(); |
|
| 379 |
+ |
|
| 380 |
+ $event = new CheckInCompletedEvent($reservation->row(), $reservation); |
|
| 381 |
+ $this->eventDispatcher->dispatch($event, CheckInCompletedEvent::NAME); |
|
| 382 |
+ } |
|
| 374 | 383 |
|
| 375 |
- $event = new CheckInCompletedEvent($reservation->row(), $reservation); |
|
| 376 |
- $this->eventDispatcher->dispatch($event, CheckInCompletedEvent::NAME); |
|
| 384 |
+ // Handle units |
|
| 385 |
+ if ($reservation->unit_amount) |
|
| 386 |
+ {
|
|
| 387 |
+ // recompute the base units |
|
| 388 |
+ $unitId = (int)$reservation->unit_id; |
|
| 389 |
+ $unitAmount = (int)$reservation->unit_amount; |
|
| 390 |
+ $multiplier = 1; |
|
| 391 |
+ if ($unitId > 0) |
|
| 392 |
+ {
|
|
| 393 |
+ if (($u = WeinanlieferungUnitModel::findByPk($unitId)) !== null) |
|
| 394 |
+ {
|
|
| 395 |
+ $multiplier = max(1, (int)$u->multiplier); |
|
| 396 |
+ } |
|
| 397 |
+ } |
|
| 398 |
+ |
|
| 399 |
+ $intBehaelter = $unitAmount * $multiplier; |
|
| 400 |
+ $reservation->behaelter = $intBehaelter; |
|
| 401 |
+ $reservation->save(); |
|
| 402 |
+ } |
|
| 377 | 403 |
} |
| 378 | 404 |
} |
| 379 | 405 |
|