Browse code

Add buchbar dates to slot listing in backend

Benjamin Roth authored on18/09/2023 13:09:22
Showing1 changed files
... ...
@@ -51,13 +51,17 @@ class WeinanlieferungSlotContainerListener
51 51
 
52 52
         return sprintf('<div class="tl_content_left"><div class="row u-items-center">
53 53
             <div class="col-2 text-md">%s %s</div>
54
+            <div class="col-2">
55
+                <div class="t-label">Buchbar ab</div>%s
56
+                <div class="t-label">Buchbar bis</div>%s
57
+            </div>
54 58
             <div class="col-3">
55 59
               <div class="t-label">Behälterkapazität</div>%s
56 60
             </div>
57 61
             <div class="col-3">
58 62
               <div class="t-label">Sorten</div>%s
59 63
             </div>
60
-        </div></div>',Date::parse(Date::getNumericDateFormat(),$row['date']), Date::parse(Date::getNumericTimeFormat(),$row['time']),$Slot->behaelter,implode(', ',$arrSorten));
64
+        </div></div>',Date::parse(Date::getNumericDateFormat(),$row['date']), Date::parse(Date::getNumericTimeFormat(),$row['time']),Date::parse(Date::getNumericDatimFormat(),$row['buchbar_ab']),Date::parse(Date::getNumericDatimFormat(),$row['buchbar_bis']),$Slot->behaelter,implode(', ',$arrSorten));
61 65
     }
62 66
 
63 67
     /**
Browse code

Update

Benjamin Roth authored on17/08/2023 13:21:23
Showing1 changed files
... ...
@@ -15,7 +15,11 @@ namespace vonRotenberg\WeinanlieferungBundle\EventListener\DataContainer;
15 15
 use Contao\CoreBundle\ServiceAnnotation\Callback;
16 16
 use Contao\DataContainer;
17 17
 use Contao\Date;
18
+use Contao\StringUtil;
18 19
 use Doctrine\DBAL\Connection;
20
+use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungLeseartModel;
21
+use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungRebsorteModel;
22
+use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungSlotsModel;
19 23
 
20 24
 class WeinanlieferungSlotContainerListener
21 25
 {
... ...
@@ -33,7 +37,27 @@ class WeinanlieferungSlotContainerListener
33 37
      */
34 38
     public function onChildRecordCallback(array $row)
35 39
     {
36
-        return sprintf('<div class="tl_content_left">%s %s</div>',Date::parse(Date::getNumericDateFormat(),$row['date']), Date::parse(Date::getNumericTimeFormat(),$row['time']));
40
+        $Slot = WeinanlieferungSlotsModel::findByPk($row['id']);
41
+
42
+        $arrSorten = [];
43
+
44
+        $Sorten = StringUtil::deserialize($Slot->sorten,true);
45
+        foreach($Sorten as $sorte)
46
+        {
47
+            $objSorte = WeinanlieferungRebsorteModel::findByPk($sorte['sorte']);
48
+            $objLeseart = WeinanlieferungLeseartModel::findByPk($sorte['leseart']);
49
+            $arrSorten[] = ($objSorte !== null  ? $objSorte->title : '') . ' ' . ($objLeseart !== null  ? $objLeseart->title : '');
50
+        }
51
+
52
+        return sprintf('<div class="tl_content_left"><div class="row u-items-center">
53
+            <div class="col-2 text-md">%s %s</div>
54
+            <div class="col-3">
55
+              <div class="t-label">Behälterkapazität</div>%s
56
+            </div>
57
+            <div class="col-3">
58
+              <div class="t-label">Sorten</div>%s
59
+            </div>
60
+        </div></div>',Date::parse(Date::getNumericDateFormat(),$row['date']), Date::parse(Date::getNumericTimeFormat(),$row['time']),$Slot->behaelter,implode(', ',$arrSorten));
37 61
     }
38 62
 
39 63
     /**
Browse code

Update

Benjamin Roth authored on06/08/2023 22:56:38
Showing1 changed files
... ...
@@ -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
 }
Browse code

Update

Benjamin Roth authored on06/08/2023 18:36:03
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,26 @@
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
+
17
+class WeinanlieferungSlotContainerListener
18
+{
19
+    /**
20
+     * @Callback(table="tl_vr_wa_slot", target="list.sorting.child_record")
21
+     */
22
+    public function onChildRecordCallback(array $row)
23
+    {
24
+        return sprintf('%s %s',$row['date'],$row['time']);
25
+    }
26
+}