Benjamin Roth authored on18/07/2024 13:49:56
Showing11 changed files
... ...
@@ -50,7 +50,7 @@ $GLOBALS['TL_DCA']['tl_vr_wa_slotassistant'] =
50 50
                                     'label' => $GLOBALS['TL_LANG']['tl_vr_wa_slotassistant']['date_start'],
51 51
                                     'inputType' => 'text',
52 52
                                     'eval' => [
53
-                                        'style' => 'width:350px',
53
+                                        'style' => 'width:150px',
54 54
                                         'mandatory' => true,
55 55
                                         'rgxp' =>'datim',
56 56
                                         'datepicker' => true
... ...
@@ -61,7 +61,7 @@ $GLOBALS['TL_DCA']['tl_vr_wa_slotassistant'] =
61 61
                                     'label' => $GLOBALS['TL_LANG']['tl_vr_wa_slotassistant']['date_end'],
62 62
                                     'inputType' => 'text',
63 63
                                     'eval' => [
64
-                                        'style' => 'width:350px',
64
+                                        'style' => 'width:150px',
65 65
                                         'mandatory' => true,
66 66
                                         'rgxp' =>'datim',
67 67
                                         'datepicker' => true
... ...
@@ -86,7 +86,7 @@ $GLOBALS['TL_DCA']['tl_vr_wa_slottypes'] = array
86 86
     // Palettes
87 87
     'palettes' => array
88 88
     (
89
-        'default' => '{title_legend},title;{config_legend},containers,units'
89
+        'default' => '{title_legend},title;{config_legend},duration,containers,units'
90 90
     ),
91 91
 
92 92
     // Subpalettes
... ...
@@ -124,6 +124,21 @@ $GLOBALS['TL_DCA']['tl_vr_wa_slottypes'] = array
124 124
             ),
125 125
             'sql'                     => "varchar(64) NOT NULL default ''"
126 126
         ),
127
+        'duration' => array
128
+        (
129
+            'exclude'                 => true,
130
+            'inputType'               => 'text',
131
+            'eval'                    => array
132
+            (
133
+                'mandatory' => true,
134
+                'maxlength' => 4,
135
+                'maxval'    => 1440,
136
+                'minval'    => 1,
137
+                'rgxp'      => 'natural',
138
+                'tl_class' => 'w50'
139
+            ),
140
+            'sql'                     => "int(4) NOT NULL default 0"
141
+        ),
127 142
         'containers' => array
128 143
         (
129 144
             'exclude'                 => true,
... ...
@@ -44,7 +44,7 @@ $GLOBALS['TL_DCA']['tl_vr_wa_standort'] = array
44 44
         ),
45 45
         'global_operations' => array
46 46
         (
47
-            'rebsorte' => array
47
+            /*'rebsorte' => array
48 48
             (
49 49
                 'href'                => 'table=tl_vr_wa_rebsorte',
50 50
                 'class'               => 'header_rebsorte',
... ...
@@ -58,7 +58,7 @@ $GLOBALS['TL_DCA']['tl_vr_wa_standort'] = array
58 58
             (
59 59
                 'href'                => 'table=tl_vr_wa_lage',
60 60
                 'class'               => 'header_lage',
61
-            ),
61
+            ),*/
62 62
             'all' => array
63 63
             (
64 64
                 'href'                => 'act=select',
... ...
@@ -76,7 +76,7 @@ $GLOBALS['TL_DCA']['tl_vr_wa_standort'] = array
76 76
             'slottypes' => array
77 77
             (
78 78
                 'href'                => 'table=tl_vr_wa_slottypes',
79
-                'icon'                => 'edit.gif',
79
+                'icon'                => '/bundles/vonrotenbergweinanlieferung/images/icons/stack.svg',
80 80
             ),
81 81
             'editheader' => array
82 82
             (
... ...
@@ -10,6 +10,12 @@
10 10
 
11 11
 $GLOBALS['TL_LANG']['MSC']['wa_sorte'] = 'Rebsorte';
12 12
 $GLOBALS['TL_LANG']['MSC']['wa_leseart'] = 'Leseart';
13
+$GLOBALS['TL_LANG']['MSC']['wa_container'] = 'Behälter';
14
+$GLOBALS['TL_LANG']['MSC']['wa_duration'] = 'Dauer';
15
+$GLOBALS['TL_LANG']['MSC']['wa_duration_minute'] = 'Minute';
16
+$GLOBALS['TL_LANG']['MSC']['wa_duration_minutes'] = 'Minuten';
17
+$GLOBALS['TL_LANG']['MSC']['wa_duration_hour'] = 'Stunde';
18
+$GLOBALS['TL_LANG']['MSC']['wa_duration_hours'] = 'Stunden';
13 19
 
14 20
 $GLOBALS['TL_LANG']['REF']['wa_ernteart'] = [
15 21
     'handlese' => 'Handlese',
16 22
new file mode 100644
... ...
@@ -0,0 +1,47 @@
1
+<?xml version="1.0" ?>
2
+<xliff version="1.1">
3
+    <file datatype="php" original="contao/languages/en/tl_vr_wa_slottypes.xlf" source-language="en" target-language="de">
4
+        <body>
5
+            <trans-unit id="tl_vr_wa_slottypes.title.0">
6
+                <source>Title</source>
7
+                <target>Titel</target>
8
+            </trans-unit>
9
+            <trans-unit id="tl_vr_wa_slottypes.title.1">
10
+                <source>The designation of the slot type.</source>
11
+                <target>Die Bezeichnung des Slottyps.</target>
12
+            </trans-unit>
13
+            <trans-unit id="tl_vr_wa_slottypes.duration.0">
14
+                <source>Duration in min.</source>
15
+                <target>Dauer in min.</target>
16
+            </trans-unit>
17
+            <trans-unit id="tl_vr_wa_slottypes.duration.1">
18
+                <source>The duration of the slot.</source>
19
+                <target>Die Dauer des Slots.</target>
20
+            </trans-unit>
21
+            <trans-unit id="tl_vr_wa_slottypes.containers.0">
22
+                <source>Processable containers</source>
23
+                <target>Verarbeitbare Containermenge</target>
24
+            </trans-unit>
25
+            <trans-unit id="tl_vr_wa_slottypes.containers.1">
26
+                <source>The amount of processable containers within the slot duration.</source>
27
+                <target>Die Anzahl der verarbeitbaren Container innerhalb der Slotdauer.</target>
28
+            </trans-unit>
29
+            <trans-unit id="tl_vr_wa_slottypes.units.0">
30
+                <source>Additional container units</source>
31
+                <target>Zusätzliche Container-Einheiten</target>
32
+            </trans-unit>
33
+            <trans-unit id="tl_vr_wa_slottypes.units.1">
34
+                <source>Additional selectable container units for slot booking.</source>
35
+                <target>Zusätzlich wählbare Behältereinheiten für die Slotbuchung.</target>
36
+            </trans-unit>
37
+            <trans-unit id="tl_vr_wa_slottypes.title_legend">
38
+                <source>Title settings</source>
39
+                <target>Titel-Einstellungen</target>
40
+            </trans-unit>
41
+            <trans-unit id="tl_vr_wa_slottypes.config_legend">
42
+                <source>Slot configuration</source>
43
+                <target>Slot-Konfiguration</target>
44
+            </trans-unit>
45
+        </body>
46
+    </file>
47
+</xliff>
... ...
@@ -15,5 +15,5 @@ $GLOBALS['TL_LANG']['tl_vr_wa_units']['description'][1] = 'DIe Bezeichnung wird
15 15
 $GLOBALS['TL_LANG']['tl_vr_wa_units']['containers'][0] = 'Behälter';
16 16
 $GLOBALS['TL_LANG']['tl_vr_wa_units']['containers'][1] = 'Die Anzahl an Behälter, die dieser Einheit entsprechen.';
17 17
 
18
-$GLOBALS['TL_LANG']['tl_vr_wa_standort']['title_legend'] = 'Bezeichnung';
19
-$GLOBALS['TL_LANG']['tl_vr_wa_standort']['unit_legend'] = 'Einheit-Konfiguration';
18
+$GLOBALS['TL_LANG']['tl_vr_wa_units']['title_legend'] = 'Bezeichnung';
19
+$GLOBALS['TL_LANG']['tl_vr_wa_units']['unit_legend'] = 'Einheit-Konfiguration';
20 20
new file mode 100644
... ...
@@ -0,0 +1 @@
1
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-layers"><polygon points="12 2 2 7 12 12 22 7 12 2"></polygon><polyline points="2 17 12 22 22 17"></polyline><polyline points="2 12 12 17 22 12"></polyline></svg>
0 2
\ No newline at end of file
1 3
new file mode 100644
... ...
@@ -0,0 +1 @@
1
+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#259232" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-layers"><polygon points="12 2 2 7 12 12 22 7 12 2"></polygon><polyline points="2 17 12 22 22 17"></polyline><polyline points="2 12 12 17 22 12"></polyline></svg>
0 2
\ No newline at end of file
... ...
@@ -128,11 +128,8 @@ class WeinanlieferungSlotAssistantController extends AbstractController
128 128
                     'widget' => new SelectMenu([
129 129
                         'name'      => 'slotType',
130 130
                         'mandatory' => true,
131
-                        'options'   => [
132
-                            ['value' => 'eins', 'label' => 'eins'],
133
-                            ['value' => 'zwei', 'label' => 'zwei']
134
-                        ],
135
-                        'label'     => 'Zeitslot-Typ'
131
+                        'options'   => $this->getSlottypeOptions(),
132
+                        'label'     => 'Zeitslot-Typ',
136 133
                     ])
137 134
                 ],
138 135
                 [
... ...
@@ -171,9 +168,10 @@ class WeinanlieferungSlotAssistantController extends AbstractController
171 168
                 ],*/
172 169
                 [
173 170
                     'class'  => 'clr',
174
-                    'help' => 'blah',
171
+                    'help' => 'Die Zeiträume, für die neue Slots angelegt werden sollen.',
175 172
                     'widget' => new MultiColumnWizard([
176 173
                         'name'       => 'timeframe',
174
+                        'label'      => 'Zeiträume',
177 175
                         'minCount' => 1,
178 176
                         'columnFields' =>
179 177
                             [
... ...
@@ -182,7 +180,7 @@ class WeinanlieferungSlotAssistantController extends AbstractController
182 180
                                         'label' => $GLOBALS['TL_LANG']['tl_vr_wa_slotassistant']['date_start'],
183 181
                                         'inputType' => 'text',
184 182
                                         'eval' => [
185
-                                            'style' => 'width:350px',
183
+                                            'style' => 'width:150px',
186 184
                                             'mandatory' => true,
187 185
                                             'rgxp' =>'datim',
188 186
                                             'datepicker' => true
... ...
@@ -193,7 +191,7 @@ class WeinanlieferungSlotAssistantController extends AbstractController
193 191
                                         'label' => $GLOBALS['TL_LANG']['tl_vr_wa_slotassistant']['date_end'],
194 192
                                         'inputType' => 'text',
195 193
                                         'eval' => [
196
-                                            'style' => 'width:350px',
194
+                                            'style' => 'width:150px',
197 195
                                             'mandatory' => true,
198 196
                                             'rgxp' =>'datim',
199 197
                                             'datepicker' => true
... ...
@@ -354,4 +352,23 @@ class WeinanlieferungSlotAssistantController extends AbstractController
354 352
         $this->fields = $arrWidgets;
355 353
         return $this->fields;
356 354
     }
355
+
356
+    protected function getSlottypeOptions()
357
+    {
358
+        $arrOptions = [['value'=>'','label'=>'-']];
359
+        $Slottypes = $this->db->prepare("SELECT t.id, t.title, s.title as 'standort' FROM tl_vr_wa_slottypes t INNER JOIN tl_vr_wa_standort s ON s.id = t.pid ORDER BY title")->executeQuery();
360
+
361
+        if ($Slottypes->rowCount() > 0)
362
+        {
363
+            foreach ($Slottypes->fetchAllAssociative() as $option)
364
+            {
365
+                $arrOptions[] = [
366
+                    'value' => $option['id'],
367
+                    'label' => $option['title'].' ['.$option['standort'].']'
368
+                ];
369
+            }
370
+        }
371
+
372
+        return $arrOptions;
373
+    }
357 374
 }
... ...
@@ -15,10 +15,12 @@ namespace vonRotenberg\WeinanlieferungBundle\EventListener\Backend;
15 15
 
16 16
 
17 17
 use Contao\CoreBundle\Event\MenuEvent;
18
+use Knp\Menu\Util\MenuManipulator;
18 19
 use Symfony\Component\HttpFoundation\RequestStack;
19 20
 use Symfony\Component\Routing\RouterInterface;
20 21
 use Terminal42\ServiceAnnotationBundle\Annotation\ServiceTag;
21 22
 use vonRotenberg\WeinanlieferungBundle\Controller\Backend\WeinanlieferungBookingsController;
23
+use vonRotenberg\WeinanlieferungBundle\Controller\Backend\WeinanlieferungSlotAssistantController;
22 24
 
23 25
 /**
24 26
  * @ServiceTag("kernel.event_listener", event="contao.backend_menu_build", priority=-255)
... ...
@@ -59,5 +61,19 @@ use vonRotenberg\WeinanlieferungBundle\Controller\Backend\WeinanlieferungBooking
59 61
          ;
60 62
 
61 63
          $contentNode->addChild($node);
64
+
65
+         $node = $factory
66
+             ->createItem('slot-assistant')
67
+             ->setUri($this->router->generate(WeinanlieferungSlotAssistantController::class,['ref'=>$ref]))
68
+             ->setLabel('Slot-Assistent')
69
+             ->setLinkAttribute('title', 'Assistent zur Massenalage von Zeitslots für Standorte')
70
+             ->setLinkAttribute('class', 'navigation wa-slot-assistant')
71
+             ->setCurrent($this->requestStack->getCurrentRequest()->get('_controller') === WeinanlieferungSlotAssistantController::class)
72
+         ;
73
+
74
+         $contentNode->addChild($node);
75
+
76
+         $manipulator = new MenuManipulator();
77
+         $manipulator->moveToPosition($contentNode['slot-assistant'],1);
62 78
      }
63 79
 }
64 80
new file mode 100644
... ...
@@ -0,0 +1,66 @@
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\EventListener\DataContainer;
14
+
15
+use Contao\CoreBundle\ServiceAnnotation\Callback;
16
+use Contao\DataContainer;
17
+use Doctrine\DBAL\Connection;
18
+use Symfony\Contracts\Translation\TranslatorInterface;
19
+
20
+class WeinanlieferungSlottypesContainerListener
21
+{
22
+    /** @var Connection */
23
+    protected $db;
24
+
25
+    private TranslatorInterface $translator;
26
+
27
+    public function __construct(Connection $db, TranslatorInterface $translator)
28
+    {
29
+        $this->db = $db;
30
+        $this->translator = $translator;
31
+    }
32
+
33
+    /**
34
+     * @Callback(table="tl_vr_wa_slottypes", target="list.sorting.child_record")
35
+     */
36
+    public function onChildRecordCallback(array $row): string
37
+    {
38
+        $strRow = '<div class="tl_content_left">%s</div>';
39
+        $label = $row['title'];
40
+        $label .= ' <span style="color:#999;padding-left:3px">['.$this->translator->trans('MSC.wa_container', [], 'contao_tl_vr_wa_units').': '.$row['containers'].']</span>';
41
+        $label .= ' <span style="color:#999;padding-left:3px">['.$this->translator->trans('MSC.wa_duration', [], 'contao_tl_vr_wa_units').': '.$row['duration'].' '.($row['duration'] == 1 ? $this->translator->trans('MSC.wa_duration_minute', [], 'contao_tl_vr_wa_units') : $this->translator->trans('MSC.wa_duration_minutes', [], 'contao_tl_vr_wa_units')).']</span>';
42
+
43
+        return sprintf($strRow,$label);
44
+    }
45
+
46
+    /**
47
+     * @Callback(table="tl_vr_wa_slottypes", target="fields.units.options")
48
+     */
49
+    public function onUnitsOptionsCallback(?DataContainer $dc): array
50
+    {
51
+        $arrOptions = [];
52
+
53
+        $Units = $this->db->prepare("SELECT id, title, description, containers FROM tl_vr_wa_units ORDER BY title")
54
+                          ->executeQuery();
55
+
56
+        if ($Units->rowCount() > 0)
57
+        {
58
+            foreach ($Units->fetchAllAssociative() as $option)
59
+            {
60
+                $arrOptions[$option['id']] = $option['description'] ?: $option['title'].' ['.$option['containers'].' '.$this->translator->trans('MSC.wa_container', [], 'contao_tl_vr_wa_units').']';
61
+            }
62
+        }
63
+
64
+        return $arrOptions;
65
+    }
66
+}