Browse code

Attributes done

Benjamin Roth authored on06/08/2025 15:56:58
Showing2 changed files
... ...
@@ -40,8 +40,8 @@ $GLOBALS['TL_LANG']['tl_vr_wa_slot']['buchbar_ab'][0] = 'Buchbar ab';
40 40
 $GLOBALS['TL_LANG']['tl_vr_wa_slot']['buchbar_ab'][1] = 'Zeitpunkt, ab wann der Slot gebucht werden kann.';
41 41
 $GLOBALS['TL_LANG']['tl_vr_wa_slot']['buchbar_bis'][0] = 'Buchbar bis';
42 42
 $GLOBALS['TL_LANG']['tl_vr_wa_slot']['buchbar_bis'][1] = 'Zeitpunkt, bis wann der Slot spätestens gebucht werden kann.';
43
-$GLOBALS['TL_LANG']['tl_vr_wa_slot']['attribute_groups'][0] = 'Attributgruppen';
44
-$GLOBALS['TL_LANG']['tl_vr_wa_slot']['attribute_groups'][1] = 'Wählen Sie die Attributgruppen aus, die für diesen Slot verfügbar sein sollen.';
43
+$GLOBALS['TL_LANG']['tl_vr_wa_slot']['attributes'][0] = 'Attribute';
44
+$GLOBALS['TL_LANG']['tl_vr_wa_slot']['attributes'][1] = 'Wählen Sie die Attribute aus, die für diesen Slot verfügbar sein sollen.';
45 45
 
46 46
 $GLOBALS['TL_LANG']['tl_vr_wa_slot']['time_legend'] = 'Zeit';
47 47
 $GLOBALS['TL_LANG']['tl_vr_wa_slot']['type_legend'] = 'Verarbeitungs-Einstellungen';
... ...
@@ -15,12 +15,14 @@ namespace vonRotenberg\WeinanlieferungBundle\Controller\Backend;
15 15
 use Contao\Ajax;
16 16
 use Contao\Backend;
17 17
 use Contao\BackendTemplate;
18
+use Contao\CheckBox;
18 19
 use Contao\Config;
19 20
 use Contao\Controller;
20 21
 use Contao\CoreBundle\Controller\AbstractController;
21 22
 use Contao\CoreBundle\Csrf\ContaoCsrfTokenManager;
22 23
 use Contao\Date;
23 24
 use Contao\DC_File;
25
+use Contao\DC_Table;
24 26
 use Contao\Environment;
25 27
 use Contao\FileTree;
26 28
 use Contao\FrontendUser;
... ...
@@ -79,6 +81,9 @@ class WeinanlieferungSlotAssistantController extends AbstractController
79 81
         $session = $objSession->get($strKey);
80 82
         $session[$strRefererId]['current'] = substr(Environment::get('requestUri'), \strlen(Environment::get('path')) + 1);
81 83
         $objSession->set($strKey, $session);
84
+
85
+        Controller::loadDataContainer('tl_vr_wa_slot');
86
+        System::loadLanguageFile('tl_vr_wa_slot');
82 87
     }
83 88
 
84 89
     public function __invoke(): Response
... ...
@@ -214,14 +219,30 @@ class WeinanlieferungSlotAssistantController extends AbstractController
214 219
                 ]
215 220
             ],
216 221
             'slot_legend' => [
222
+                /*[
223
+                  'class'    => 'clr',
224
+                  'help'     => 'Wählen Sie die Attribute aus, die für diesen Slot gelten sollen.',
225
+                  'widget'   => new CheckBox([
226
+                      'name'        => 'attributes',
227
+                      'mandatory'   => false,
228
+                      'label'       => 'Attribute',
229
+                      'options_callback'        => array('vonRotenberg\WeinanlieferungBundle\EventListener\DataContainer\WeinanlieferungSlotContainerListener', 'getAttributeOptions'),
230
+                  ])
231
+                ],*/
217 232
                 [
218
-                    'class'  => 'w50',
233
+                    'class'    => 'clr',
234
+                    'help'     => 'Wählen Sie die Attribute aus, die für diesen Slot gelten sollen.',
235
+                    'widget'   => new CheckBox(CheckBox::getAttributesFromDca($GLOBALS['TL_DCA']['tl_vr_wa_slot']['fields']['attributes'],'attributes',null,'Attribute','tl_vr_wa_slot',new DC_Table('tl_vr_wa_slot')))
236
+                ],
237
+                [
238
+                    'class'  => 'w50 wizard',
219 239
                     'help'   => 'Der Beginn des Zeitraums, ab wann der Slot im Vorfeld gebucht werden kann.',
220 240
                     'widget' => new TextField([
221 241
                         'name'      => 'bookableFrom',
222 242
                         'mandatory' => true,
223
-                        'label'     => 'Buchbar ab in h',
224
-                        'rgxp'      => 'natural'
243
+                        'label'     => 'Buchbar ab',
244
+                        'rgxp'      => 'datim',
245
+                        'datepicker' => true
225 246
                     ])
226 247
                 ],
227 248
                 [
... ...
@@ -495,6 +516,7 @@ class WeinanlieferungSlotAssistantController extends AbstractController
495 516
 
496 517
                 $NewDateTime = new Date($intTime);
497 518
                 $NewSlot = new WeinanlieferungSlotsModel();
519
+                $bookableFrom = new Date(Input::post('bookableFrom'), Date::getNumericDatimFormat());
498 520
                 $NewSlot->setRow([
499 521
                     'pid' => $SlotType->pid,
500 522
                     'tstamp' => $now,
... ...
@@ -504,7 +526,8 @@ class WeinanlieferungSlotAssistantController extends AbstractController
504 526
                     'behaelter' => $SlotType->containers,
505 527
                     'overcapacity' => $SlotType->overcapacity,
506 528
                     'anmerkungen' => Input::post('annotation'),
507
-                    'buchbar_ab' => (int) $intTime-intval(Input::post('bookableFrom'))*3600,
529
+                    'attributes' => \implode(',',\is_array(Input::post('attributes')) ? Input::post('attributes') : []),
530
+                    'buchbar_ab' => (int) $bookableFrom->tstamp,
508 531
                     'buchbar_bis' => (int) $intTime-intval(Input::post('bookableTill'))*3600,
509 532
                     'published' => '1'
510 533
                 ]);