Browse code

Add list page picker to booking list module

Benjamin Roth authored on08/09/2023 13:01:36
Showing1 changed files
... ...
@@ -20,6 +20,7 @@ use Contao\CoreBundle\ServiceAnnotation\FrontendModule;
20 20
 use Contao\Date;
21 21
 use Contao\FrontendUser;
22 22
 use Contao\ModuleModel;
23
+use Contao\PageModel;
23 24
 use Contao\StringUtil;
24 25
 use Contao\System;
25 26
 use Contao\Template;
... ...
@@ -49,6 +50,10 @@ class WeinanlieferungBookedListModuleController extends AbstractFrontendModuleCo
49 50
     {
50 51
         $GLOBALS['TL_CSS']['vr_wa'] = 'bundles/vonrotenbergweinanlieferung/css/frontend.scss|static';
51 52
         $arrData = $template->getData();
53
+        if (($ListPage = PageModel::findById($model->vr_wa_listPage)) !== null)
54
+        {
55
+            $arrData['listPageUrl'] = $ListPage->getFrontendUrl();
56
+        }
52 57
 
53 58
         // Get bookings
54 59
         if (($bookings = WeinanlieferungReservationModel::findBy("uid",FrontendUser::getInstance()->id,['order' => "(SELECT tl_vr_wa_slot.time FROM tl_vr_wa_slot WHERE tl_vr_wa_slot.id=tl_vr_wa_reservation.pid) ASC"])) !== null)
Browse code

Lot's of changes and improvements

Benjamin Roth authored on31/08/2023 13:52:40
Showing1 changed files
... ...
@@ -47,6 +47,7 @@ class WeinanlieferungBookedListModuleController extends AbstractFrontendModuleCo
47 47
 
48 48
     protected function getResponse(Template $template, ModuleModel $model, Request $request): ?Response
49 49
     {
50
+        $GLOBALS['TL_CSS']['vr_wa'] = 'bundles/vonrotenbergweinanlieferung/css/frontend.scss|static';
50 51
         $arrData = $template->getData();
51 52
 
52 53
         // Get bookings
Browse code

Update

Benjamin Roth authored on30/08/2023 22:08:09
Showing1 changed files
... ...
@@ -76,12 +76,28 @@ class WeinanlieferungBookedListModuleController extends AbstractFrontendModuleCo
76 76
                         $strStandort = $Standort->title;
77 77
                     }
78 78
 
79
+                    if ($booking->ernteart !== null)
80
+                    {
81
+                        foreach (explode(',', $booking->ernteart) as $ernteart)
82
+                        {
83
+                            $arrErnteart[] = $GLOBALS['TL_LANG']['REF']['wa_ernteart'][$ernteart] ?? $ernteart;
84
+                        }
85
+                    }
86
+
87
+                    $arrLage = [];
88
+                    if (($Lage = $booking->getRelated('lage')) !== null)
89
+                    {
90
+                        $arrLage = $Lage->fetchEach('title');
91
+                    }
92
+
79 93
                     $arrData['days'][$day->dayBegin][] = array_merge($booking->row(), [
80 94
                         'sorte'              => $arrSorten,
81 95
                         'slot'  => array_merge($Slot->row(),[
82 96
                             'anmerkungen' => $Slot->anmerkungen ? StringUtil::substr(strip_tags($Slot->anmerkungen),110) : '',
83 97
                         ]),
84 98
                         'standort' => $strStandort,
99
+                        'ernteart' => $arrErnteart,
100
+                        'lage' => $arrLage,
85 101
                     ]);
86 102
                 }
87 103
             }
Browse code

Lot's of changes and improvements

Benjamin Roth authored on30/08/2023 17:18:43
Showing1 changed files
... ...
@@ -59,6 +59,7 @@ class WeinanlieferungBookedListModuleController extends AbstractFrontendModuleCo
59 59
                 {
60 60
                     $day = new Date($Slot->date);
61 61
                     $arrSorten = [];
62
+                    $arrErnteart = [];
62 63
 
63 64
                     $SortenLeseart = explode(';',$booking->sorten);
64 65
                     foreach($SortenLeseart as $sorteLeseart)
Browse code

Lot's of changes and improvements

Benjamin Roth authored on29/08/2023 15:05:02
Showing1 changed files
... ...
@@ -69,9 +69,18 @@ class WeinanlieferungBookedListModuleController extends AbstractFrontendModuleCo
69 69
                         $arrSorten[$objSorte->id.','.$objLeseart->id] = ($objSorte !== null  ? $objSorte->title : '') . ' ' . ($objLeseart !== null  ? $objLeseart->title : '');
70 70
                     }
71 71
 
72
+                    $strStandort = '';
73
+                    if (($Standort = $Slot->getRelated('pid')) !== null)
74
+                    {
75
+                        $strStandort = $Standort->title;
76
+                    }
77
+
72 78
                     $arrData['days'][$day->dayBegin][] = array_merge($booking->row(), [
73 79
                         'sorte'              => $arrSorten,
74
-                        'slot'  => $Slot->row()
80
+                        'slot'  => array_merge($Slot->row(),[
81
+                            'anmerkungen' => $Slot->anmerkungen ? StringUtil::substr(strip_tags($Slot->anmerkungen),110) : '',
82
+                        ]),
83
+                        'standort' => $strStandort,
75 84
                     ]);
76 85
                 }
77 86
             }
Browse code

Update

Benjamin Roth authored on15/08/2023 00:19:43
Showing1 changed files
... ...
@@ -21,9 +21,11 @@ use Contao\Date;
21 21
 use Contao\FrontendUser;
22 22
 use Contao\ModuleModel;
23 23
 use Contao\StringUtil;
24
+use Contao\System;
24 25
 use Contao\Template;
25 26
 use Symfony\Component\HttpFoundation\Request;
26 27
 use Symfony\Component\HttpFoundation\Response;
28
+use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungLeseartModel;
27 29
 use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungRebsorteModel;
28 30
 use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungReservationModel;
29 31
 use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungSlotsModel;
... ...
@@ -58,9 +60,13 @@ class WeinanlieferungBookedListModuleController extends AbstractFrontendModuleCo
58 60
                     $day = new Date($Slot->date);
59 61
                     $arrSorten = [];
60 62
 
61
-                    if (($Sorten = $booking->getRelated('sorten')) !== null)
63
+                    $SortenLeseart = explode(';',$booking->sorten);
64
+                    foreach($SortenLeseart as $sorteLeseart)
62 65
                     {
63
-                        $arrSorten = $Sorten->fetchEach('title');
66
+                        list($sorte,$leseart) = explode(',',$sorteLeseart);
67
+                        $objSorte = WeinanlieferungRebsorteModel::findByPk($sorte);
68
+                        $objLeseart = WeinanlieferungLeseartModel::findByPk($leseart);
69
+                        $arrSorten[$objSorte->id.','.$objLeseart->id] = ($objSorte !== null  ? $objSorte->title : '') . ' ' . ($objLeseart !== null  ? $objLeseart->title : '');
64 70
                     }
65 71
 
66 72
                     $arrData['days'][$day->dayBegin][] = array_merge($booking->row(), [
Browse code

Update

Benjamin Roth authored on09/08/2023 16:04:53
Showing1 changed files
... ...
@@ -48,14 +48,14 @@ class WeinanlieferungBookedListModuleController extends AbstractFrontendModuleCo
48 48
         $arrData = $template->getData();
49 49
 
50 50
         // Get bookings
51
-        if (($bookings = WeinanlieferungReservationModel::findBy("uid",FrontendUser::getInstance()->id)) !== null)
51
+        if (($bookings = WeinanlieferungReservationModel::findBy("uid",FrontendUser::getInstance()->id,['order' => "(SELECT tl_vr_wa_slot.time FROM tl_vr_wa_slot WHERE tl_vr_wa_slot.id=tl_vr_wa_reservation.pid) ASC"])) !== null)
52 52
         {
53 53
             /** @var WeinanlieferungReservationModel $booking */
54 54
             foreach ($bookings as $booking)
55 55
             {
56 56
                 if (($Slot = $booking->getRelated('pid')) !== null)
57 57
                 {
58
-                    $day = new Date($booking->date);
58
+                    $day = new Date($Slot->date);
59 59
                     $arrSorten = [];
60 60
 
61 61
                     if (($Sorten = $booking->getRelated('sorten')) !== null)
Browse code

Update

Benjamin Roth authored on09/08/2023 09:01:03
Showing1 changed files
1 1
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
+}