Browse code

Update

Benjamin Roth authored on06/08/2023 22:56:38
Showing12 changed files
... ...
@@ -16,6 +16,7 @@
16 16
     "require": {
17 17
         "php": "^7.4 || ^8.0",
18 18
         "contao/core-bundle": "^4.13",
19
+        "contao/calendar-bundle": "^4.13",
19 20
         "symfony/config": "^5.4",
20 21
         "symfony/dependency-injection": "^5.4",
21 22
         "symfony/http-kernel": "^5.4",
... ...
@@ -10,5 +10,5 @@
10 10
 
11 11
 $GLOBALS['BE_MOD']['content']['weinanlieferung'] = array
12 12
 (
13
-    'tables'      => array('tl_vr_wa_standort', 'tl_vr_wa_slot'),
13
+    'tables'      => array('tl_vr_wa_standort', 'tl_vr_wa_slot','tl_vr_wa_rebsorte'),
14 14
 );
15 15
new file mode 100644
... ...
@@ -0,0 +1,124 @@
1
+<?php
2
+
3
+/**
4
+ * This file is part of contao-weinanlieferung-bundle.
5
+ *
6
+ * (c) vonRotenberg
7
+ *
8
+ * @license commercial
9
+ */
10
+
11
+use Contao\DC_Table;
12
+use Contao\DataContainer;
13
+
14
+$GLOBALS['TL_DCA']['tl_vr_wa_rebsorte'] = array
15
+(
16
+    // Config
17
+    'config' => array
18
+    (
19
+        'dataContainer'    => DC_Table::class,
20
+        'enableVersioning' => true,
21
+        'sql'              => array
22
+        (
23
+            'keys' => array
24
+            (
25
+                'id'  => 'primary'
26
+            )
27
+        )
28
+    ),
29
+
30
+    // List
31
+    'list' => array
32
+    (
33
+        'sorting' => array
34
+        (
35
+            'mode'                    => DataContainer::MODE_SORTED,
36
+            'fields'                  => array('title'),
37
+            'flag'                    => DataContainer::SORT_INITIAL_LETTER_ASC,
38
+            'panelLayout'             => 'limit'
39
+        ),
40
+        'label' => array(
41
+            'fields'                  => array('title'),
42
+            'format'                  => '%s'
43
+        ),
44
+        'global_operations' => array
45
+        (
46
+            'back' => array
47
+            (
48
+                'href'                => 'table=tl_vr_wa_standort',
49
+                'class'               => 'header_back',
50
+            ),
51
+            'all' => array
52
+            (
53
+                'href'                => 'act=select',
54
+                'class'               => 'header_edit_all',
55
+                'attributes'          => 'onclick="Backend.getScrollOffset()" accesskey="e"'
56
+            )
57
+        ),
58
+        'operations' => array
59
+        (
60
+            'edit' => array
61
+            (
62
+                'href'                => 'act=edit',
63
+                'icon'                => 'edit.gif',
64
+            ),
65
+            'copy' => array
66
+            (
67
+                'href'                => 'act=paste&amp;mode=copy',
68
+                'icon'                => 'copy.svg'
69
+            ),
70
+            'cut' => array
71
+            (
72
+                'href'                => 'act=paste&amp;mode=cut',
73
+                'icon'                => 'cut.svg',
74
+                'attributes'          => 'onclick="Backend.getScrollOffset()"'
75
+            ),
76
+            'delete' => array
77
+            (
78
+                'href'                => 'act=delete',
79
+                'icon'                => 'delete.gif',
80
+            ),
81
+            'show' => array
82
+            (
83
+                'icon'                => 'show.gif',
84
+            ),
85
+        )
86
+    ),
87
+
88
+    // Palettes
89
+    'palettes' => array
90
+    (
91
+        'default' => '{title_legend},title'
92
+    ),
93
+
94
+    // Subpalettes
95
+    'subpalettes' => array
96
+    (
97
+    ),
98
+
99
+    // Fields
100
+    'fields' => array
101
+    (
102
+        'id' => array
103
+        (
104
+            'sql'                     => "int(10) unsigned NOT NULL auto_increment"
105
+        ),
106
+        'tstamp' => array
107
+        (
108
+            'sql'                     => "int(10) unsigned NOT NULL default 0"
109
+        ),
110
+        'title' => array
111
+        (
112
+            'exclude'                 => true,
113
+            'sorting'                 => true,
114
+            'flag'                    => DataContainer::SORT_INITIAL_LETTER_ASC,
115
+            'inputType'               => 'text',
116
+            'eval'                    => array
117
+            (
118
+                'mandatory' => true,
119
+                'maxlength' => 255
120
+            ),
121
+            'sql'                     => "varchar(255) NOT NULL default ''"
122
+        )
123
+    )
124
+);
... ...
@@ -37,7 +37,7 @@ $GLOBALS['TL_DCA']['tl_vr_wa_slot'] = array
37 37
             'mode' => DataContainer::MODE_PARENT,
38 38
             'fields' => array('time'),
39 39
             'headerFields' => array('title'),
40
-            'disableGrouping' => true,
40
+//            'disableGrouping' => true,
41 41
             'panelLayout' => 'filter;sort,limit',
42 42
         ),
43 43
         'global_operations' => array
... ...
@@ -72,6 +72,12 @@ $GLOBALS['TL_DCA']['tl_vr_wa_slot'] = array
72 72
                 'href'                => 'act=delete',
73 73
                 'icon'                => 'delete.gif',
74 74
             ),
75
+            'toggle' => array
76
+            (
77
+                'href'                => 'act=toggle&amp;field=buchbar',
78
+                'icon'                => 'visible.svg',
79
+                'showInHeader'        => true
80
+            ),
75 81
             'show' => array
76 82
             (
77 83
                 'icon'                => 'show.gif',
... ...
@@ -82,45 +88,121 @@ $GLOBALS['TL_DCA']['tl_vr_wa_slot'] = array
82 88
     // Palettes
83 89
     'palettes' => array
84 90
     (
85
-        'default' => '{time_legend},date,time'
91
+        '__selector__' => array('addEnclosure'),
92
+        'default' => '{time_legend},date,time;{type_legend},behaelter,leseart,sorte;{info_legend},anmerkungen,addEnclosure;{booking_legend},buchbar,buchbar_bis'
86 93
     ),
87 94
 
88 95
     // Subpalettes
89 96
     'subpalettes' => array
90
-    (),
97
+    (
98
+        'addEnclosure' => 'enclosure'
99
+    ),
91 100
 
92 101
     // Fields
93 102
     'fields' => array
94 103
     (
95
-        'id' => array
104
+        'id'          => array
96 105
         (
97 106
             'sql' => "int(10) unsigned NOT NULL auto_increment"
98 107
         ),
99
-        'pid' => array
108
+        'pid'         => array
100 109
         (
101 110
             'foreignKey' => 'tl_vr_wa_standort.title',
102
-            'sql' => "int(10) unsigned NOT NULL default '0'",
103
-            'relation' => array('type' => 'belongsTo', 'load' => 'lazy')
111
+            'sql'        => "int(10) unsigned NOT NULL default '0'",
112
+            'relation'   => array('type' => 'belongsTo', 'load' => 'lazy')
104 113
         ),
105
-        'tstamp' => array
114
+        'tstamp'      => array
106 115
         (
107 116
             'sql' => "int(10) unsigned NOT NULL default '0'"
108 117
         ),
109
-        'date' => array
118
+        'date'        => array
119
+        (
120
+            'exclude'   => true,
121
+            'inputType' => 'text',
122
+            'eval'      => array('rgxp' => 'date', 'mandatory' => true, 'datepicker' => true, 'tl_class' => 'w50 wizard'),
123
+            'sql'       => "int(10) unsigned NULL"
124
+        ),
125
+        'time'        => array
110 126
         (
111
-            'inputType'               => 'text',
112
-            'eval'                    => array('rgxp'=>'date', 'mandatory'=>true, 'doNotCopy'=>true, 'datepicker'=>true, 'tl_class'=>'w50 wizard'),
113
-            'sql'                     => "int(10) unsigned NULL"
127
+            'exclude'   => true,
128
+            'default'   => time(),
129
+            'filter'    => true,
130
+            'sorting'   => true,
131
+            'flag'      => DataContainer::SORT_MONTH_DESC,
132
+            'inputType' => 'text',
133
+            'eval'      => array('rgxp' => 'time', 'mandatory' => true, 'tl_class' => 'w50'),
134
+            'sql'       => "int(10) NULL"
114 135
         ),
115
-        'time' => array
116
-        (
117
-            'default'                 => time(),
118
-            'filter'                  => true,
119
-            'sorting'                 => true,
120
-            'flag'                    => DataContainer::SORT_MONTH_DESC,
121
-            'inputType'               => 'text',
122
-            'eval'                    => array('rgxp'=>'time', 'mandatory'=>true, 'doNotCopy'=>true, 'tl_class'=>'w50'),
123
-            'sql'                     => "int(10) NULL"
136
+        'behaelter'   => array
137
+        (
138
+            'exclude'   => true,
139
+            'inputType' => 'select',
140
+            'options_callback'   => function () {
141
+                $range = [];
142
+                for ($i = 1; $i <= 30; $i++)
143
+                {
144
+                    $range[] = $i;
145
+                }
146
+                return $range;
147
+            },
148
+            'eval'      => array('rgxp' => 'natural', 'mandatory' => true, 'includeBlankOption' => true, 'tl_class' => 'w50'),
149
+            'sql'       => "smallint(3) unsigned NOT NULL default 0"
150
+        ),
151
+        'leseart'     => array
152
+        (
153
+            'exclude'   => true,
154
+            'inputType' => 'select',
155
+            'options'   => [],
156
+            'reference' => &$GLOBALS['TL_LANG']['MSC']['leseart'],
157
+            'eval'      => array('rgxp' => 'natural', 'mandatory' => false, 'includeBlankOption' => true, 'tl_class' => 'clr w50'),
158
+            'sql'       => "varchar(32) NOT NULL default ''"
159
+        ),
160
+        'sorte'       => array
161
+        (
162
+            'exclude'   => true,
163
+            'inputType' => 'select',
164
+            'foreignKey'   => 'tl_vr_wa_rebsorte.title',
165
+            'eval'      => array('rgxp' => 'natural', 'mandatory' => false, 'multiple'=>true,'chosen'=>true,'includeBlankOption' => true, 'tl_class' => 'w50','csv'=>','),
166
+            'sql'       => "blob NULL"
167
+        ),
168
+        'anmerkungen' => array
169
+        (
170
+            'exclude'                 => true,
171
+            'search'                  => true,
172
+            'inputType'               => 'textarea',
173
+            'eval'                    => array('rte'=>'tinyMCE', 'tl_class'=>'clr'),
174
+            'sql'                     => "text NULL"
175
+        ),
176
+        'addEnclosure' => array
177
+        (
178
+            'exclude'                 => true,
179
+            'inputType'               => 'checkbox',
180
+            'eval'                    => array('submitOnChange'=>true),
181
+            'sql'                     => "char(1) NOT NULL default ''"
182
+        ),
183
+        'enclosure' => array
184
+        (
185
+            'exclude'                 => true,
186
+            'inputType'               => 'fileTree',
187
+            'eval'                    => array('multiple'=>true, 'fieldType'=>'checkbox', 'filesOnly'=>true, 'isDownloads'=>true, 'extensions'=>Config::get('allowedDownload'), 'mandatory'=>true, 'isSortable'=>true),
188
+            'sql'                     => "blob NULL"
189
+        ),
190
+        'buchbar'     => array
191
+        (
192
+            'exclude'   => true,
193
+            'toggle'    => true,
194
+            'filter'    => true,
195
+            'flag'      => DataContainer::SORT_INITIAL_LETTER_DESC,
196
+            'inputType' => 'checkbox',
197
+            'eval'      => array('doNotCopy' => true),
198
+            'sql'       => "char(1) NOT NULL default ''"
199
+        ),
200
+        'buchbar_bis' => array
201
+        (
202
+            'exclude'   => true,
203
+            'inputType' => 'text',
204
+            'eval'      => array('rgxp' => 'datim', 'mandatory' => true, 'datepicker' => true, 'tl_class' => 'clr w50 wizard'),
205
+            'sql'       => "int(10) unsigned NULL"
124 206
         ),
125 207
     )
126 208
 );
... ...
@@ -44,6 +44,11 @@ $GLOBALS['TL_DCA']['tl_vr_wa_standort'] = array
44 44
         ),
45 45
         'global_operations' => array
46 46
         (
47
+            'rebsorte' => array
48
+            (
49
+                'href'                => 'table=tl_vr_wa_rebsorte',
50
+                'class'               => 'header_rebsorte',
51
+            ),
47 52
             'all' => array
48 53
             (
49 54
                 'href'                => 'act=select',
50 55
new file mode 100644
... ...
@@ -0,0 +1,14 @@
1
+<?php
2
+
3
+/**
4
+ * This file is part of contao-weinanlieferung-bundle.
5
+ *
6
+ * (c) vonRotenberg
7
+ *
8
+ * @license commercial
9
+ */
10
+
11
+$GLOBALS['TL_LANG']['MOD']['weinanlieferung'][0] = 'Weinanlieferung';
12
+$GLOBALS['TL_LANG']['MOD']['weinanlieferung'][1] = 'Buchungstool zur Weinanlieferung';
13
+$GLOBALS['TL_LANG']['MOD']['tl_vr_wa_rebsorte'] = 'Rebsorten';
14
+$GLOBALS['TL_LANG']['MOD']['tl_vr_wa_slot'] = 'Zeitslots';
0 15
new file mode 100644
... ...
@@ -0,0 +1,16 @@
1
+<?php
2
+
3
+/**
4
+ * This file is part of contao-weinanlieferung-bundle.
5
+ *
6
+ * (c) vonRotenberg
7
+ *
8
+ * @license commercial
9
+ */
10
+
11
+$GLOBALS['TL_LANG']['tl_vr_wa_rebsorte']['title'][0] = 'Name';
12
+$GLOBALS['TL_LANG']['tl_vr_wa_rebsorte']['title'][1] = 'Der Name der Rebsorte.';
13
+
14
+$GLOBALS['TL_LANG']['tl_vr_wa_rebsorte']['title_legend'] = 'Rebsorte';
15
+
16
+$GLOBALS['TL_LANG']['tl_vr_wa_rebsorte']['back'] = 'Zurück';
0 17
new file mode 100644
... ...
@@ -0,0 +1,37 @@
1
+<?php
2
+
3
+/**
4
+ * This file is part of contao-weinanlieferung-bundle.
5
+ *
6
+ * (c) vonRotenberg
7
+ *
8
+ * @license commercial
9
+ */
10
+
11
+$GLOBALS['TL_LANG']['tl_vr_wa_slot']['date'][0] = 'Datum';
12
+$GLOBALS['TL_LANG']['tl_vr_wa_slot']['date'][1] = 'Der Tag der Anlieferung.';
13
+$GLOBALS['TL_LANG']['tl_vr_wa_slot']['time'][0] = 'Uhrzeit';
14
+$GLOBALS['TL_LANG']['tl_vr_wa_slot']['time'][1] = 'Uhrzeit dieses Anlieferungsslots.';
15
+$GLOBALS['TL_LANG']['tl_vr_wa_slot']['behaelter'][0] = 'Behälter';
16
+$GLOBALS['TL_LANG']['tl_vr_wa_slot']['behaelter'][1] = 'Anzahl der Behälter, die verarbeitet werden können.';
17
+$GLOBALS['TL_LANG']['tl_vr_wa_slot']['leseart'][0] = 'Leseart';
18
+$GLOBALS['TL_LANG']['tl_vr_wa_slot']['leseart'][1] = 'Die verwendete Leseart.';
19
+$GLOBALS['TL_LANG']['tl_vr_wa_slot']['sorte'][0] = 'Rebsorten';
20
+$GLOBALS['TL_LANG']['tl_vr_wa_slot']['sorte'][1] = 'Die Rebsorten, die in diesem Zeitslot verarbeitet werden.';
21
+$GLOBALS['TL_LANG']['tl_vr_wa_slot']['anmerkungen'][0] = 'Anmerkungen';
22
+$GLOBALS['TL_LANG']['tl_vr_wa_slot']['anmerkungen'][1] = 'Ergänzende Hinweise zu diesem Zeitslot.';
23
+$GLOBALS['TL_LANG']['tl_vr_wa_slot']['addEnclosure'][0] = 'Anhänge';
24
+$GLOBALS['TL_LANG']['tl_vr_wa_slot']['addEnclosure'][1] = 'Dateianhänge zum Download.';
25
+$GLOBALS['TL_LANG']['tl_vr_wa_slot']['enclosure'][0] = 'Dateien';
26
+$GLOBALS['TL_LANG']['tl_vr_wa_slot']['enclosure'][1] = 'Bitte die downloadbaren Dateien auswählen.';
27
+$GLOBALS['TL_LANG']['tl_vr_wa_slot']['buchbar'][0] = 'Buchbar';
28
+$GLOBALS['TL_LANG']['tl_vr_wa_slot']['buchbar'][1] = 'Steuert die Buchbarkeit dieses Zeitslots.';
29
+$GLOBALS['TL_LANG']['tl_vr_wa_slot']['buchbar_bis'][0] = 'Buchbar bis';
30
+$GLOBALS['TL_LANG']['tl_vr_wa_slot']['buchbar_bis'][1] = 'Zeitpunkt, bis wann der Slot spätestens gebucht werden kann.';
31
+
32
+$GLOBALS['TL_LANG']['tl_vr_wa_slot']['time_legend'] = 'Zeit';
33
+$GLOBALS['TL_LANG']['tl_vr_wa_slot']['type_legend'] = 'Verarbeitungs-Einstellungen';
34
+$GLOBALS['TL_LANG']['tl_vr_wa_slot']['info_legend'] = 'Zusätzliche Informationen';
35
+$GLOBALS['TL_LANG']['tl_vr_wa_slot']['booking_legend'] = 'Buchbarkeits-Einstellungen';
36
+
37
+$GLOBALS['TL_LANG']['tl_vr_wa_slot']['back'] = 'Zurück';
0 38
new file mode 100644
... ...
@@ -0,0 +1,16 @@
1
+<?php
2
+
3
+/**
4
+ * This file is part of contao-weinanlieferung-bundle.
5
+ *
6
+ * (c) vonRotenberg
7
+ *
8
+ * @license commercial
9
+ */
10
+
11
+$GLOBALS['TL_LANG']['tl_vr_wa_standort']['title'][0] = 'Titel';
12
+$GLOBALS['TL_LANG']['tl_vr_wa_standort']['title'][1] = 'Der Name des Anlieferungs-Standorts.';
13
+
14
+$GLOBALS['TL_LANG']['tl_vr_wa_standort']['title_legend'] = 'Standort';
15
+
16
+$GLOBALS['TL_LANG']['tl_vr_wa_standort']['rebsorte'] = 'Rebsorten';
0 17
deleted file mode 100644
... ...
@@ -1,27 +0,0 @@
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\DependencyInjection;
14
-
15
-use Symfony\Component\Config\FileLocator;
16
-use Symfony\Component\DependencyInjection\ContainerBuilder;
17
-use Symfony\Component\DependencyInjection\Extension\Extension;
18
-use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
19
-
20
-class ContaoSkeletonExtension extends Extension
21
-{
22
-    public function load(array $configs, ContainerBuilder $container): void
23
-    {
24
-        $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
25
-        $loader->load('services.yml');
26
-    }
27
-}
28 0
new file mode 100644
... ...
@@ -0,0 +1,27 @@
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\DependencyInjection;
14
+
15
+use Symfony\Component\Config\FileLocator;
16
+use Symfony\Component\DependencyInjection\ContainerBuilder;
17
+use Symfony\Component\DependencyInjection\Extension\Extension;
18
+use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
19
+
20
+class VonrotenbergWeinanlieferungExtension extends Extension
21
+{
22
+    public function load(array $configs, ContainerBuilder $container): void
23
+    {
24
+        $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../../config'));
25
+        $loader->load('services.yml');
26
+    }
27
+}
... ...
@@ -13,14 +13,42 @@ declare(strict_types=1);
13 13
 namespace vonRotenberg\WeinanlieferungBundle\EventListener\DataContainer;
14 14
 
15 15
 use Contao\CoreBundle\ServiceAnnotation\Callback;
16
+use Contao\DataContainer;
17
+use Contao\Date;
18
+use Doctrine\DBAL\Connection;
16 19
 
17 20
 class WeinanlieferungSlotContainerListener
18 21
 {
22
+    /** @var Connection */
23
+    protected $db;
24
+
25
+    public function __construct(Connection $db)
26
+    {
27
+        $this->db = $db;
28
+    }
29
+
30
+
19 31
     /**
20 32
      * @Callback(table="tl_vr_wa_slot", target="list.sorting.child_record")
21 33
      */
22 34
     public function onChildRecordCallback(array $row)
23 35
     {
24
-        return sprintf('%s %s',$row['date'],$row['time']);
36
+        return sprintf('<div class="tl_content_left">%s %s</div>',Date::parse(Date::getNumericDateFormat(),$row['date']), Date::parse(Date::getNumericTimeFormat(),$row['time']));
37
+    }
38
+
39
+    /**
40
+     * @Callback(table="tl_vr_wa_slot", target="config.onsubmit")
41
+     */
42
+    public function adjustTime(DataContainer $dc)
43
+    {
44
+        // Return if there is no active record (override all) or no start date has been set yet
45
+        if (!$dc->activeRecord || empty($dc->activeRecord->date))
46
+        {
47
+            return;
48
+        }
49
+
50
+        $arrSet['time'] = strtotime(date('Y-m-d', $dc->activeRecord->date) . ' ' . date('H:i:s', $dc->activeRecord->time));
51
+
52
+        $this->db->update("tl_vr_wa_slot",$arrSet,['id' => $dc->id]);
25 53
     }
26 54
 }