Browse code

Add units entity

Benjamin Roth authored on17/07/2024 14:23:50
Showing6 changed files
... ...
@@ -8,6 +8,7 @@
8 8
  * @license commercial
9 9
  */
10 10
 
11
+use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungUnitsModel;
11 12
 use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungLageModel;
12 13
 use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungRebsorteModel;
13 14
 use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungLeseartModel;
... ...
@@ -21,11 +22,16 @@ ArrayUtil::arrayInsert($GLOBALS['BE_MOD'],1,[
21 22
         'weinanlieferung' => [
22 23
             'tables'     => array('tl_vr_wa_standort', 'tl_vr_wa_slot', 'tl_vr_wa_rebsorte','tl_vr_wa_leseart','tl_vr_wa_lage','tl_vr_wa_reservation'),
23 24
             'stylesheet' => array('bundles/vonrotenbergweinanlieferung/css/backend.css')
25
+        ],
26
+        'wa_units' => [
27
+            'tables'     => array('tl_vr_wa_units'),
28
+            'stylesheet' => array('bundles/vonrotenbergweinanlieferung/css/backend.css')
24 29
         ]
25 30
     ]
26 31
 ]);
27 32
 
28 33
 
34
+$GLOBALS['TL_MODELS']['tl_vr_wa_units'] = WeinanlieferungUnitsModel::class;
29 35
 $GLOBALS['TL_MODELS']['tl_vr_wa_slot'] = WeinanlieferungSlotsModel::class;
30 36
 $GLOBALS['TL_MODELS']['tl_vr_wa_standort'] = WeinanlieferungStandortModel::class;
31 37
 $GLOBALS['TL_MODELS']['tl_vr_wa_rebsorte'] = WeinanlieferungRebsorteModel::class;
32 38
new file mode 100644
... ...
@@ -0,0 +1,148 @@
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_units'] = 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','description'),
42
+            'format'                  => '%s',
43
+            'showColumns'             => true
44
+        ),
45
+        'global_operations' => array
46
+        (
47
+            'all' => array
48
+            (
49
+                'href'                => 'act=select',
50
+                'class'               => 'header_edit_all',
51
+                'attributes'          => 'onclick="Backend.getScrollOffset()" accesskey="e"'
52
+            )
53
+        ),
54
+        'operations' => array
55
+        (
56
+            'edit' => array
57
+            (
58
+                'href'                => 'act=edit',
59
+                'icon'                => 'edit.gif',
60
+            ),
61
+            'copy' => array
62
+            (
63
+                'href'                => 'act=copy',
64
+                'icon'                => 'copy.svg'
65
+            ),
66
+            'cut' => array
67
+            (
68
+                'href'                => 'act=paste&amp;mode=cut',
69
+                'icon'                => 'cut.svg',
70
+                'attributes'          => 'onclick="Backend.getScrollOffset()"'
71
+            ),
72
+            'delete' => array
73
+            (
74
+                'href'                => 'act=delete',
75
+                'icon'                => 'delete.gif',
76
+            ),
77
+            'show' => array
78
+            (
79
+                'icon'                => 'show.gif',
80
+            ),
81
+        )
82
+    ),
83
+
84
+    // Palettes
85
+    'palettes' => array
86
+    (
87
+        'default' => '{title_legend},title,description;{unit_legend},containers'
88
+    ),
89
+
90
+    // Subpalettes
91
+    'subpalettes' => array
92
+    (
93
+    ),
94
+
95
+    // Fields
96
+    'fields' => array
97
+    (
98
+        'id' => array
99
+        (
100
+            'sql'                     => "int(10) unsigned NOT NULL auto_increment"
101
+        ),
102
+        'tstamp' => array
103
+        (
104
+            'sql'                     => "int(10) unsigned NOT NULL default 0"
105
+        ),
106
+        'title' => array
107
+        (
108
+            'exclude'                 => true,
109
+            'sorting'                 => true,
110
+            'flag'                    => DataContainer::SORT_INITIAL_LETTER_ASC,
111
+            'inputType'               => 'text',
112
+            'eval'                    => array
113
+            (
114
+                'mandatory' => true,
115
+                'maxlength' => 64,
116
+                'tl_class' => 'w50'
117
+            ),
118
+            'sql'                     => "varchar(64) NOT NULL default ''"
119
+        ),
120
+        'description' => array
121
+        (
122
+            'exclude'                 => true,
123
+            'inputType'               => 'text',
124
+            'eval'                    => array
125
+            (
126
+                'mandatory' => false,
127
+                'maxlength' => 64,
128
+                'tl_class' => 'w50'
129
+            ),
130
+            'sql'                     => "varchar(64) NOT NULL default ''"
131
+        ),
132
+        'containers' => array
133
+        (
134
+            'exclude'                 => true,
135
+            'inputType'               => 'text',
136
+            'eval'                    => array
137
+            (
138
+                'mandatory' => true,
139
+                'maxlength' => 4,
140
+                'maxval'    => 9999,
141
+                'minval'    => 1,
142
+                'rgxp'      => 'natural',
143
+                'tl_class' => 'w50'
144
+            ),
145
+            'sql'                     => "int(4) NOT NULL default 0"
146
+        )
147
+    )
148
+);
... ...
@@ -13,6 +13,8 @@ use vonRotenberg\WeinanlieferungBundle\Controller\Frontend\Module\Weinanlieferun
13 13
 
14 14
 $GLOBALS['TL_LANG']['MOD']['weinanlieferung'][0] = 'Weinanlieferung';
15 15
 $GLOBALS['TL_LANG']['MOD']['weinanlieferung'][1] = 'Buchungstool zur Weinanlieferung';
16
+$GLOBALS['TL_LANG']['MOD']['wa_units'][0] = 'Behältereinheiten';
17
+$GLOBALS['TL_LANG']['MOD']['wa_units'][1] = 'Ermöglicht es auf Behältermengen basierende Einheiten zu definieren.';
16 18
 $GLOBALS['TL_LANG']['MOD']['tl_vr_wa_rebsorte'] = 'Rebsorten';
17 19
 $GLOBALS['TL_LANG']['MOD']['tl_vr_wa_leseart'] = 'Leseart';
18 20
 $GLOBALS['TL_LANG']['MOD']['tl_vr_wa_slot'] = 'Zeitslots';
19 21
new file mode 100644
... ...
@@ -0,0 +1,19 @@
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_units']['title'][0] = 'Titel';
12
+$GLOBALS['TL_LANG']['tl_vr_wa_units']['title'][1] = 'Der interne Titel der Einheit.';
13
+$GLOBALS['TL_LANG']['tl_vr_wa_units']['description'][0] = 'Bezeichnung';
14
+$GLOBALS['TL_LANG']['tl_vr_wa_units']['description'][1] = 'DIe Bezeichnung wird dem Zulieferer anstatt des Titels angezeigt, wenn vorhanden.';
15
+$GLOBALS['TL_LANG']['tl_vr_wa_units']['containers'][0] = 'Behälter';
16
+$GLOBALS['TL_LANG']['tl_vr_wa_units']['containers'][1] = 'Die Anzahl an Behälter, die dieser Einheit entsprechen.';
17
+
18
+$GLOBALS['TL_LANG']['tl_vr_wa_standort']['title_legend'] = 'Bezeichnung';
19
+$GLOBALS['TL_LANG']['tl_vr_wa_standort']['unit_legend'] = 'Einheit-Konfiguration';
0 20
new file mode 100644
... ...
@@ -0,0 +1,46 @@
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 WeinanlieferungUnitsContainerListener
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_units", target="list.label.label")
35
+     */
36
+    public function onNcNotificationOptionsCallback(array $row, string $label, DataContainer $dc, array $labels): array
37
+    {
38
+        $fieldName = 'title';
39
+        $fields = $GLOBALS['TL_DCA'][$dc->table]['list']['label']['fields'];
40
+        $key = array_search($fieldName, $fields, true);
41
+
42
+        $labels[$key] .= ' ('.$row['containers'].' '.$this->translator->trans('tl_vr_wa_units.containers.0', [], 'contao_tl_vr_wa_units').')';
43
+
44
+        return $labels;
45
+    }
46
+}
0 47
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 WeinanlieferungUnitsModel extends Model
18
+{
19
+    /**
20
+     * Table name
21
+     * @var string
22
+     */
23
+    protected static $strTable = 'tl_vr_wa_units';
24
+}