Browse code

Update

Benjamin Roth authored on08/08/2023 12:37:24
Showing6 changed files
... ...
@@ -8,6 +8,7 @@
8 8
  * @license commercial
9 9
  */
10 10
 
11
+use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungRebsorteModel;
11 12
 use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungSlotsModel;
12 13
 use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungStandortModel;
13 14
 
... ...
@@ -19,3 +20,4 @@ $GLOBALS['BE_MOD']['content']['weinanlieferung'] = array
19 20
 
20 21
 $GLOBALS['TL_MODELS']['tl_vr_wa_slot'] = WeinanlieferungSlotsModel::class;
21 22
 $GLOBALS['TL_MODELS']['tl_vr_wa_standort'] = WeinanlieferungStandortModel::class;
23
+$GLOBALS['TL_MODELS']['tl_vr_wa_rebsorte'] = WeinanlieferungRebsorteModel::class;
... ...
@@ -118,6 +118,8 @@ $GLOBALS['TL_DCA']['tl_vr_wa_slot'] = array
118 118
         'date'        => array
119 119
         (
120 120
             'exclude'   => true,
121
+            'filter'    => true,
122
+            'flag'      => DataContainer::SORT_MONTH_ASC,
121 123
             'inputType' => 'text',
122 124
             'eval'      => array('rgxp' => 'date', 'mandatory' => true, 'datepicker' => true, 'tl_class' => 'w50 wizard'),
123 125
             'sql'       => "int(10) unsigned NULL"
... ...
@@ -126,9 +128,8 @@ $GLOBALS['TL_DCA']['tl_vr_wa_slot'] = array
126 128
         (
127 129
             'exclude'   => true,
128 130
             'default'   => time(),
129
-            'filter'    => true,
130 131
             'sorting'   => true,
131
-            'flag'      => DataContainer::SORT_MONTH_DESC,
132
+            'flag'      => DataContainer::SORT_MONTH_ASC,
132 133
             'inputType' => 'text',
133 134
             'eval'      => array('rgxp' => 'time', 'mandatory' => true, 'tl_class' => 'w50'),
134 135
             'sql'       => "int(10) NULL"
... ...
@@ -163,7 +164,8 @@ $GLOBALS['TL_DCA']['tl_vr_wa_slot'] = array
163 164
             'inputType' => 'select',
164 165
             'foreignKey'   => 'tl_vr_wa_rebsorte.title',
165 166
             'eval'      => array('rgxp' => 'natural', 'mandatory' => false, 'multiple'=>true,'chosen'=>true,'includeBlankOption' => true, 'tl_class' => 'w50','csv'=>','),
166
-            'sql'       => "blob NULL"
167
+            'sql'       => "blob NULL",
168
+            'relation'   => array('type' => 'hasMany', 'load' => 'lazy')
167 169
         ),
168 170
         'anmerkungen' => array
169 171
         (
... ...
@@ -8,7 +8,7 @@
8 8
             <dd>{{ slot.behaelter }}</dd>
9 9
 
10 10
             <dt>Verarbeitete Sorten</dt>
11
-            <dd>{{ slot.sorte }}</dd>
11
+            <dd>{{ slot.sorte|join(', ') }}</dd>
12 12
         </dl>
13 13
 
14 14
     </div>
15 15
new file mode 100644
... ...
@@ -0,0 +1,29 @@
1
+<div class="modal-content">
2
+    <div id="wa-unauthorized">
3
+        <h1>Unauthorized</h1>
4
+    </div>
5
+</div>
6
+<script>
7
+
8
+    (function ($) {
9
+
10
+        window.modals = window.modals || []
11
+
12
+        if (window.modals.wa_unauthorized === undefined)
13
+        {
14
+            window.modals.wa_unauthorized = new jBox('Modal', {
15
+            closeButton: 'box',
16
+            content: $('#wa-unauthorized'),
17
+            maxWidth: 650,
18
+            minWidth: 100,
19
+            minHeight: 100,
20
+            width: 650,
21
+            addClass: ''
22
+        }).open();
23
+        } else {
24
+            window.modals.wa_unauthorized.content.empty();
25
+            window.modals.wa_unauthorized.setContent($('#wa-unauthorized')).open();
26
+        }
27
+
28
+    })(jQuery);
29
+</script>
... ...
@@ -42,6 +42,11 @@ class SlotAjaxController extends AbstractController
42 42
     {
43 43
         System::loadLanguageFile('default');
44 44
 
45
+        if (!$this->tokenChecker->hasFrontendUser())
46
+        {
47
+            return $this->renderUnauthorized();
48
+        }
49
+
45 50
         if (empty($_REQUEST['do']))
46 51
         {
47 52
             return new Response('Required parameter missing',412);
... ...
@@ -70,13 +75,26 @@ class SlotAjaxController extends AbstractController
70 75
             return new Response('Could not load slot data',500);
71 76
         }
72 77
 
78
+        $arrSorten = [];
79
+        if (($Sorten = $Slot->getRelated('sorte')) !== null)
80
+        {
81
+            $arrSorten = $Sorten->fetchEach('title');
82
+        }
83
+
73 84
         $arrData = [
74 85
             'id'       => $Slot->id,
75
-            'slot'     => $Slot->row(),
86
+            'slot'     => array_merge($Slot->row(),[
87
+                'sorte' => $arrSorten
88
+            ]),
76 89
             'standort' => $Slot->getRelated('pid')
77 90
         ];
78 91
 
79 92
         return $this->render('@Contao/modal_slot_details.html.twig',$arrData);
80 93
     }
81 94
 
95
+    protected function renderUnauthorized()
96
+    {
97
+        return $this->render('@Contao/modal_unauthorized.html.twig');
98
+    }
99
+
82 100
 }
83 101
new file mode 100644
... ...
@@ -0,0 +1,24 @@
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\Model;
14
+
15
+use Contao\Model;
16
+
17
+class WeinanlieferungRebsorteModel extends Model
18
+{
19
+    /**
20
+     * Table name
21
+     * @var string
22
+     */
23
+    protected static $strTable = 'tl_vr_wa_rebsorte';
24
+}