Browse code

First draft for slot-overcapacity-request feature

Benjamin Roth authored on02/09/2024 16:26:53
Showing6 changed files
... ...
@@ -97,7 +97,7 @@ $GLOBALS['TL_DCA']['tl_vr_wa_reservation'] = array
97 97
     'palettes' => array
98 98
     (
99 99
         '__selector__' => array(),
100
-        'default' => 'pid,uid,behaelter,sorten,lage,ernteart,upload'
100
+        'default' => 'pid,uid,behaelter,sorten,lage,ernteart,upload,approved'
101 101
     ),
102 102
 
103 103
     // Subpalettes
... ...
@@ -151,7 +151,7 @@ $GLOBALS['TL_DCA']['tl_vr_wa_reservation'] = array
151 151
             'exclude'                 => true,
152 152
             'inputType'               => 'text',
153 153
             'eval'       => array('rgxp'=>'natural','tl_class'=>'w50'),
154
-            'sql'        => "smallint(3) unsigned NOT NULL default 0",
154
+            'sql'        => "int(4) unsigned NOT NULL default 0",
155 155
         ),
156 156
         'sorten'       => array
157 157
         (
... ...
@@ -185,5 +185,19 @@ $GLOBALS['TL_DCA']['tl_vr_wa_reservation'] = array
185 185
             ),
186 186
             'sql'                     => "varchar(255) BINARY NOT NULL default ''"
187 187
         ),
188
+        'approved' => array
189
+        (
190
+            'exclude'                 => true,
191
+            'inputType'               => 'checkbox',
192
+            'eval'                    => array('tl_class'=>'w50 m12'),
193
+            'sql'                     => "char(1) NOT NULL default '1'"
194
+        ),
195
+        'approved_on' => array
196
+        (
197
+            'exclude'                 => true,
198
+            'inputType'               => 'text',
199
+            'eval'                    => array('rgxp' => 'datim', 'datepicker' => true, 'tl_class' => 'clr w50 wizard'),
200
+            'sql'                     => "int(10) unsigned NOT NULL default '0'"
201
+        ),
188 202
     )
189 203
 );
... ...
@@ -151,20 +151,20 @@ $GLOBALS['TL_DCA']['tl_vr_wa_slot'] = array
151 151
             'sql'       => "blob NULL",
152 152
             'relation'   => array('type' => 'hasMany', 'load' => 'lazy')
153 153
         ),
154
-        'behaelter'   => array
154
+        'behaelter' => array
155 155
         (
156 156
             'exclude'   => true,
157
-            'inputType' => 'select',
158
-            'options_callback'   => function () {
159
-                $range = [];
160
-                for ($i = 1; $i <= 30; $i++)
161
-                {
162
-                    $range[] = $i;
163
-                }
164
-                return $range;
165
-            },
166
-            'eval'      => array('rgxp' => 'natural', 'mandatory' => true, 'includeBlankOption' => true, 'tl_class' => 'w50'),
167
-            'sql'       => "smallint(3) unsigned NOT NULL default 0"
157
+            'inputType' => 'text',
158
+            'eval'      => array
159
+            (
160
+                'mandatory' => true,
161
+                'maxlength' => 4,
162
+                'maxval'    => 9999,
163
+                'minval'    => 1,
164
+                'rgxp'      => 'natural',
165
+                'tl_class'  => 'w50'
166
+            ),
167
+            'sql'       => "int(4) unsigned NOT NULL default 0"
168 168
         ),
169 169
         'sorten'       => array
170 170
         (
... ...
@@ -10,6 +10,7 @@
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_approval_needed'] = 'erfordert Freigabe';
13 14
 
14 15
 $GLOBALS['TL_LANG']['REF']['wa_ernteart'] = [
15 16
     'handlese' => 'Handlese',
... ...
@@ -46,8 +46,15 @@
46 46
                     <select id="res-behaelter" name="behaelter" required>
47 47
                         <option value="">-</option>
48 48
                         {% for option in buchen.behaelter %}
49
-                            <option value="{{ option }}"{{ buchung.behaelter == option ? ' selected' : '' }}>{{ option }}</option>
49
+                            {% if option > slot.behaelter %}
50
+                                <option value="{{ option }}"{{ buchung.behaelter == option ? ' selected' : '' }}>{{ option }} ({{ 'MSC.wa_approval_needed'|trans([], 'contao_default') }})</option>
51
+                            {% else %}
52
+                                <option value="{{ option }}"{{ buchung.behaelter == option ? ' selected' : '' }}>{{ option }}</option>
53
+                            {% endif %}
50 54
                         {% endfor %}
55
+                        {#{% for option in buchen.behaelter %}
56
+                            <option value="{{ option }}"{{ buchung.behaelter == option ? ' selected' : '' }}>{{ option }}</option>
57
+                        {% endfor %}#}
51 58
                     </select>
52 59
                 </fieldset>
53 60
                 <fieldset>
... ...
@@ -109,8 +109,15 @@
109 109
                             <select id="res-behaelter" name="behaelter" required>
110 110
                                 <option value="">-</option>
111 111
                                 {% for option in buchen.behaelter %}
112
-                                    <option value="{{ option }}">{{ option }}</option>
112
+                                    {% if option > slot.behaelterAvailable %}
113
+                                        <option value="{{ option }}">{{ option }} ({{ 'MSC.wa_approval_needed'|trans([], 'contao_default') }})</option>
114
+                                    {% else %}
115
+                                        <option value="{{ option }}">{{ option }}</option>
116
+                                    {% endif %}
113 117
                                 {% endfor %}
118
+                                {#{% for option in buchen.behaelter %}
119
+                                    <option value="{{ option }}">{{ option }}</option>
120
+                                {% endfor %}#}
114 121
                             </select>
115 122
                         </fieldset>
116 123
                         <fieldset>
... ...
@@ -182,7 +182,7 @@ class SlotAjaxController extends AbstractController
182 182
             'ernteart' => $arrErnteart,
183 183
             'buchen' => [
184 184
                 'buchbar' => (boolean) $intAvailableBehaelter,
185
-                'behaelter' => range(min($intAvailableBehaelter,1),$intAvailableBehaelter),
185
+                'behaelter' => range(min($intAvailableBehaelter,1),$Slot->behaelter*3),
186 186
                 'sorten' => $arrSorten,
187 187
                 'lage' => $arrLage,
188 188
                 'ernteart' => $arrErnteart,
... ...
@@ -384,7 +384,7 @@ class SlotAjaxController extends AbstractController
384 384
             'standort' => $Slot->getRelated('pid'),
385 385
             'buchen' => [
386 386
                 'buchbar' => (boolean) $intAvailableBehaelter,
387
-                'behaelter' => range(min($intAvailableBehaelter,1),$intAvailableBehaelter+$Booking->behaelter),
387
+                'behaelter' => range(min($intAvailableBehaelter,1),max($intAvailableBehaelter+$Booking->behaelter,$Slot->behaelter*3)),
388 388
                 'sorten' => $arrSortenAvailable,
389 389
                 'ernteart' => $arrErnteartAvailable,
390 390
                 'lage' => $arrLagenAvailable,
... ...
@@ -433,7 +433,8 @@ class SlotAjaxController extends AbstractController
433 433
         // Form validation
434 434
         if (($Slot = WeinanlieferungSlotsModel::findByPk($_REQUEST['id'])) !== null)
435 435
         {
436
-            if (Input::post('behaelter') > $Slot->getAvailableBehaelter())
436
+//            if (Input::post('behaelter') > $Slot->getAvailableBehaelter())
437
+            if (Input::post('behaelter') > $Slot->behaelter*3)
437 438
             {
438 439
                 return $this->renderDetails(false,sprintf('<div class="toast toast--danger mx-0">Fehler: Es sind mittlerweile nur noch %s Behälter verfügbar.</div>',$Slot->getAvailableBehaelter()));
439 440
             }
... ...
@@ -532,7 +533,8 @@ class SlotAjaxController extends AbstractController
532 533
         // Form validation
533 534
         if (($Slot = $Reservation->getRelated('pid')) !== null)
534 535
         {
535
-            if (Input::post('behaelter') > $Slot->getAvailableBehaelter()+$Reservation->behaelter)
536
+//            if (Input::post('behaelter') > $Slot->getAvailableBehaelter()+$Reservation->behaelter)
537
+            if (Input::post('behaelter') > $Slot->behaelter*3)
536 538
             {
537 539
                 return $this->renderBooking(false,sprintf('<div class="toast toast--danger mx-0">Fehler: Es sind mittlerweile nur noch %s Behälter verfügbar.</div>',$Slot->getAvailableBehaelter()+$Reservation->behaelter));
538 540
             }