| ... | ... |
@@ -8,9 +8,11 @@ |
| 8 | 8 |
* @license commercial |
| 9 | 9 |
*/ |
| 10 | 10 |
|
| 11 |
+use vonRotenberg\WeinanlieferungBundle\Controller\Frontend\Module\WeinanlieferungBookedListModuleController; |
|
| 11 | 12 |
use vonRotenberg\WeinanlieferungBundle\Controller\Frontend\Module\WeinanlieferungSlotsListModuleController; |
| 12 | 13 |
|
| 13 | 14 |
$GLOBALS['TL_DCA']['tl_module']['palettes'][WeinanlieferungSlotsListModuleController::TYPE] = '{title_legend},name,headline,type;{wa_config_legend},vr_wa_standortId;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},cssID';
|
| 15 |
+$GLOBALS['TL_DCA']['tl_module']['palettes'][WeinanlieferungBookedListModuleController::TYPE] = '{title_legend},name,headline,type;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},cssID';
|
|
| 14 | 16 |
|
| 15 | 17 |
|
| 16 | 18 |
$GLOBALS['TL_DCA']['tl_module']['fields']['vr_wa_standortId'] = array( |
| ... | ... |
@@ -8,6 +8,7 @@ |
| 8 | 8 |
* @license commercial |
| 9 | 9 |
*/ |
| 10 | 10 |
|
| 11 |
+use vonRotenberg\WeinanlieferungBundle\Controller\Frontend\Module\WeinanlieferungBookedListModuleController; |
|
| 11 | 12 |
use vonRotenberg\WeinanlieferungBundle\Controller\Frontend\Module\WeinanlieferungSlotsListModuleController; |
| 12 | 13 |
|
| 13 | 14 |
$GLOBALS['TL_LANG']['MOD']['weinanlieferung'][0] = 'Weinanlieferung'; |
| ... | ... |
@@ -17,3 +18,5 @@ $GLOBALS['TL_LANG']['MOD']['tl_vr_wa_slot'] = 'Zeitslots'; |
| 17 | 18 |
|
| 18 | 19 |
$GLOBALS['TL_LANG']['FMD'][WeinanlieferungSlotsListModuleController::TYPE][0] = 'Weinanlieferung-Zeitslotliste'; |
| 19 | 20 |
$GLOBALS['TL_LANG']['FMD'][WeinanlieferungSlotsListModuleController::TYPE][1] = 'Gibt eine Liste mit buchbaren Zeitslots aus.'; |
| 21 |
+$GLOBALS['TL_LANG']['FMD'][WeinanlieferungBookedListModuleController::TYPE][0] = 'Weinanlieferung-Buchungsübersicht'; |
|
| 22 |
+$GLOBALS['TL_LANG']['FMD'][WeinanlieferungBookedListModuleController::TYPE][1] = 'Gibt eine Liste mit gebuchten Zeitslots aus.'; |
| 20 | 23 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,38 @@ |
| 1 |
+<div hx-get="{{ insert_tag('env::request') }}" hx-headers='{"VR-Ajax": "WabookingsModule"}' hx-trigger="updateWaList from:body" class="{{ class }} content-wrapper block"{{ cssID }}{% if style is defined and style is not empty %} style="{{ style }}"{% endif %}>
|
|
| 2 |
+ |
|
| 3 |
+ {% block content %}
|
|
| 4 |
+ {% if days is defined and days|length %}
|
|
| 5 |
+ <div class="list"> |
|
| 6 |
+ {% for day,bookings in days %}
|
|
| 7 |
+ <h3 class="toggler-dis">{{ day|date('d.m.Y') }}</h3>
|
|
| 8 |
+ <div class="accordion-dis"> |
|
| 9 |
+ <div class="bookings"> |
|
| 10 |
+ {% for booking in bookings %}
|
|
| 11 |
+ <div class="row"> |
|
| 12 |
+ <div class="flex align-items-center"> |
|
| 13 |
+ <div class="full half-500 third-900 time"> |
|
| 14 |
+ <span class="title">Uhrzeit</span> |
|
| 15 |
+ {{ booking.slot.time|date('H:i') }}
|
|
| 16 |
+ </div> |
|
| 17 |
+ <div class="full half-500 fourth-900 behaelter"> |
|
| 18 |
+ <span class="title">Gebuchte Behälterkapazität</span> |
|
| 19 |
+ {{ booking.behaelter }}
|
|
| 20 |
+ </div> |
|
| 21 |
+ <div class="full two-third-500 fourth-900 rebsorten"> |
|
| 22 |
+ <span class="title">Anliefernde Sorten</span> |
|
| 23 |
+ {{ booking.sorte|join(', ') }}
|
|
| 24 |
+ </div> |
|
| 25 |
+ <div class="full third-500 sixth-900 align-right action"> |
|
| 26 |
+ <a hx-get="/_ajax/vr_wa/v1/slot?do=delete&id={{ booking.id }}" hx-target="body" hx-swap="beforeend" href="javascript:;" class="button error">Löschen</a>
|
|
| 27 |
+ </div> |
|
| 28 |
+ </div> |
|
| 29 |
+ </div> |
|
| 30 |
+ {% endfor %}
|
|
| 31 |
+ </div> |
|
| 32 |
+ </div> |
|
| 33 |
+ {% endfor %}
|
|
| 34 |
+ </div> |
|
| 35 |
+ {% endif %}
|
|
| 36 |
+ {% endblock %}
|
|
| 37 |
+ |
|
| 38 |
+</div> |
| ... | ... |
@@ -32,7 +32,7 @@ |
| 32 | 32 |
<div class="accordion-dis"> |
| 33 | 33 |
<div class="slots"> |
| 34 | 34 |
{% for slot in slots %}
|
| 35 |
- <div class="row{{ not slot.buchbar ? ' error' : '' }}">
|
|
| 35 |
+ <div class="row{{ not slot.buchbar ? ' error' : '' }}{{ slot.gebucht ? ' booked' : '' }}">
|
|
| 36 | 36 |
<div class="flex align-items-center"> |
| 37 | 37 |
<div class="full half-500 third-900 time"> |
| 38 | 38 |
<span class="title">Uhrzeit</span> |
| ... | ... |
@@ -12,12 +12,14 @@ declare(strict_types=1); |
| 12 | 12 |
|
| 13 | 13 |
namespace vonRotenberg\WeinanlieferungBundle\Controller\Frontend\Ajax; |
| 14 | 14 |
|
| 15 |
+use Contao\Controller; |
|
| 15 | 16 |
use Contao\CoreBundle\Controller\AbstractController; |
| 16 | 17 |
use Contao\CoreBundle\Framework\ContaoFramework; |
| 17 | 18 |
use Contao\CoreBundle\Security\Authentication\Token\TokenChecker; |
| 18 | 19 |
use Contao\FrontendUser; |
| 19 | 20 |
use Contao\Input; |
| 20 | 21 |
use Contao\System; |
| 22 |
+use Doctrine\DBAL\Connection; |
|
| 21 | 23 |
use Symfony\Component\HttpFoundation\Request; |
| 22 | 24 |
use Symfony\Component\HttpFoundation\Response; |
| 23 | 25 |
use Symfony\Component\Routing\Annotation\Route; |
| ... | ... |
@@ -63,6 +65,9 @@ class SlotAjaxController extends AbstractController |
| 63 | 65 |
|
| 64 | 66 |
case 'reservate': |
| 65 | 67 |
return $this->reservate(); |
| 68 |
+ |
|
| 69 |
+ case 'delete': |
|
| 70 |
+ return $this->deleteBooking(); |
|
| 66 | 71 |
} |
| 67 | 72 |
|
| 68 | 73 |
return new Response('',500);
|
| ... | ... |
@@ -137,6 +142,29 @@ class SlotAjaxController extends AbstractController |
| 137 | 142 |
return new Response('<p>Reservierung erfolgreich</p>');
|
| 138 | 143 |
} |
| 139 | 144 |
|
| 145 |
+ protected function deleteBooking() |
|
| 146 |
+ {
|
|
| 147 |
+ if (empty($_REQUEST['id'])) |
|
| 148 |
+ {
|
|
| 149 |
+ return new Response('Missing parameter',500);
|
|
| 150 |
+ } |
|
| 151 |
+ |
|
| 152 |
+ /** @var Connection $db */ |
|
| 153 |
+ $db = Controller::getContainer()->get('database_connection');
|
|
| 154 |
+ |
|
| 155 |
+ $arrCriteria = [ |
|
| 156 |
+ 'uid' => FrontendUser::getInstance()->id, |
|
| 157 |
+ 'id' => $_REQUEST['id'] |
|
| 158 |
+ ]; |
|
| 159 |
+ |
|
| 160 |
+ if ($db->delete('tl_vr_wa_reservation',$arrCriteria))
|
|
| 161 |
+ {
|
|
| 162 |
+ return new Response(null,203); |
|
| 163 |
+ } |
|
| 164 |
+ |
|
| 165 |
+ return new Response('Could not delete',500);
|
|
| 166 |
+ } |
|
| 167 |
+ |
|
| 140 | 168 |
protected function renderUnauthorized() |
| 141 | 169 |
{
|
| 142 | 170 |
return $this->render('@Contao/modal_unauthorized.html.twig');
|
| 143 | 171 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,85 @@ |
| 1 |
+<?php |
|
| 2 |
+ |
|
| 3 |
+declare(strict_types=1); |
|
| 4 |
+ |
|
| 5 |
+/* |
|
| 6 |
+ * This file is part of contao-weinanlieferung-bundle. |
|
| 7 |
+ * |
|
| 8 |
+ * (c) vonRotenberg |
|
| 9 |
+ * |
|
| 10 |
+ * @license commercial |
|
| 11 |
+ */ |
|
| 12 |
+ |
|
| 13 |
+namespace vonRotenberg\WeinanlieferungBundle\Controller\Frontend\Module; |
|
| 14 |
+ |
|
| 15 |
+use Contao\Controller; |
|
| 16 |
+use Contao\CoreBundle\Controller\FrontendModule\AbstractFrontendModuleController; |
|
| 17 |
+use Contao\CoreBundle\Exception\ResponseException; |
|
| 18 |
+use Contao\CoreBundle\InsertTag\InsertTagParser; |
|
| 19 |
+use Contao\CoreBundle\ServiceAnnotation\FrontendModule; |
|
| 20 |
+use Contao\Date; |
|
| 21 |
+use Contao\FrontendUser; |
|
| 22 |
+use Contao\ModuleModel; |
|
| 23 |
+use Contao\StringUtil; |
|
| 24 |
+use Contao\Template; |
|
| 25 |
+use Symfony\Component\HttpFoundation\Request; |
|
| 26 |
+use Symfony\Component\HttpFoundation\Response; |
|
| 27 |
+use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungRebsorteModel; |
|
| 28 |
+use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungReservationModel; |
|
| 29 |
+use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungSlotsModel; |
|
| 30 |
+ |
|
| 31 |
+/** |
|
| 32 |
+ * @FrontendModule(WeinanlieferungBookedListModuleController::TYPE, category="miscellaneous") |
|
| 33 |
+ */ |
|
| 34 |
+class WeinanlieferungBookedListModuleController extends AbstractFrontendModuleController |
|
| 35 |
+{
|
|
| 36 |
+ public const TYPE = 'wa_booked_list'; |
|
| 37 |
+ |
|
| 38 |
+ private $insertTagParser; |
|
| 39 |
+ |
|
| 40 |
+ public function __construct(InsertTagParser $insertTagParser) |
|
| 41 |
+ {
|
|
| 42 |
+ $this->insertTagParser = $insertTagParser; |
|
| 43 |
+ } |
|
| 44 |
+ |
|
| 45 |
+ |
|
| 46 |
+ protected function getResponse(Template $template, ModuleModel $model, Request $request): ?Response |
|
| 47 |
+ {
|
|
| 48 |
+ $arrData = $template->getData(); |
|
| 49 |
+ |
|
| 50 |
+ // Get bookings |
|
| 51 |
+ if (($bookings = WeinanlieferungReservationModel::findBy("uid",FrontendUser::getInstance()->id)) !== null)
|
|
| 52 |
+ {
|
|
| 53 |
+ /** @var WeinanlieferungReservationModel $booking */ |
|
| 54 |
+ foreach ($bookings as $booking) |
|
| 55 |
+ {
|
|
| 56 |
+ if (($Slot = $booking->getRelated('pid')) !== null)
|
|
| 57 |
+ {
|
|
| 58 |
+ $day = new Date($booking->date); |
|
| 59 |
+ $arrSorten = []; |
|
| 60 |
+ |
|
| 61 |
+ if (($Sorten = $booking->getRelated('sorten')) !== null)
|
|
| 62 |
+ {
|
|
| 63 |
+ $arrSorten = $Sorten->fetchEach('title');
|
|
| 64 |
+ } |
|
| 65 |
+ |
|
| 66 |
+ $arrData['days'][$day->dayBegin][] = array_merge($booking->row(), [ |
|
| 67 |
+ 'sorte' => $arrSorten, |
|
| 68 |
+ 'slot' => $Slot->row() |
|
| 69 |
+ ]); |
|
| 70 |
+ } |
|
| 71 |
+ } |
|
| 72 |
+ } |
|
| 73 |
+ |
|
| 74 |
+ $template->setData($arrData); |
|
| 75 |
+ |
|
| 76 |
+ // Handle ajax |
|
| 77 |
+ if ($request->headers->get('VR-Ajax') == 'WaBookedModule')
|
|
| 78 |
+ {
|
|
| 79 |
+ throw new ResponseException(new Response($this->insertTagParser->replace($template->parse()))); |
|
| 80 |
+ } |
|
| 81 |
+ |
|
| 82 |
+ return $template->getResponse(); |
|
| 83 |
+ } |
|
| 84 |
+ |
|
| 85 |
+} |
| ... | ... |
@@ -18,12 +18,14 @@ use Contao\CoreBundle\Exception\ResponseException; |
| 18 | 18 |
use Contao\CoreBundle\InsertTag\InsertTagParser; |
| 19 | 19 |
use Contao\CoreBundle\ServiceAnnotation\FrontendModule; |
| 20 | 20 |
use Contao\Date; |
| 21 |
+use Contao\FrontendUser; |
|
| 21 | 22 |
use Contao\ModuleModel; |
| 22 | 23 |
use Contao\StringUtil; |
| 23 | 24 |
use Contao\Template; |
| 24 | 25 |
use Symfony\Component\HttpFoundation\Request; |
| 25 | 26 |
use Symfony\Component\HttpFoundation\Response; |
| 26 | 27 |
use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungRebsorteModel; |
| 28 |
+use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungReservationModel; |
|
| 27 | 29 |
use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungSlotsModel; |
| 28 | 30 |
|
| 29 | 31 |
/** |
| ... | ... |
@@ -85,7 +87,8 @@ class WeinanlieferungSlotsListModuleController extends AbstractFrontendModuleCon |
| 85 | 87 |
$arrData['days'][$day->dayBegin][] = array_merge($slot->row(),[ |
| 86 | 88 |
'sorte' => $arrSorten, |
| 87 | 89 |
'behaelterAvailable' => $intAvailableBehaelter, |
| 88 |
- 'buchbar' => (boolean) $intAvailableBehaelter |
|
| 90 |
+ 'buchbar' => (boolean) $intAvailableBehaelter, |
|
| 91 |
+ 'gebucht' => (boolean) WeinanlieferungReservationModel::countBy(["uid = ?","pid = ?"],[FrontendUser::getInstance()->id,$slot->id]) |
|
| 89 | 92 |
]); |
| 90 | 93 |
} |
| 91 | 94 |
} |