Browse code

Add day and location filter to BE booking list and remove month filter

Benjamin Roth authored on10/09/2024 10:09:41
Showing2 changed files
... ...
@@ -18,13 +18,25 @@
18 18
                     <button name="filter" id="filter" class="tl_img_submit filter_apply" title="">Anwenden</button>
19 19
                     <button name="filter_reset" id="filter_reset" value="1" class="tl_img_submit filter_reset" title="">Zurücksetzen</button>
20 20
                 </div>
21
-                <div class="tl_sorting tl_subpanel">
21
+                <div class="tl_filter tl_subpanel">
22 22
                     <strong>Filter:</strong>
23
-                    <select name="tl_month" id="tl_month" class="tl_select tl_chosen">
23
+                    <select name="tl_day" id="tl_day" class="tl_select tl_chosen">
24
+                        <option value=""{{ filter.day.selected is not defined or not filter.day.selected ? ' selected' : '' }}>Tag</option>
25
+                        {% for value, label in filter.day.options %}
26
+                            <option value="{{ value }}"{{ filter.day.selected is defined and filter.day.selected == value ? ' selected' : '' }}>{{ label }}</option>
27
+                        {% endfor %}
28
+                    </select>
29
+                    {#<select name="tl_month" id="tl_month" class="tl_select tl_chosen">
24 30
                         <option value=""{{ filter.month.selected is not defined or not filter.month.selected ? ' selected' : '' }}>Monat</option>
25 31
                         {% for value, label in filter.month.options %}
26 32
                             <option value="{{ value }}"{{ filter.month.selected is defined and filter.month.selected == value ? ' selected' : '' }}>{{ label }}</option>
27 33
                         {% endfor %}
34
+                    </select>#}
35
+                    <select name="tl_standort" id="tl_standort" class="tl_select tl_chosen">
36
+                        <option value=""{{ filter.standort.selected is not defined or not filter.standort.selected ? ' selected' : '' }}>Standort</option>
37
+                        {% for value, label in filter.standort.options %}
38
+                            <option value="{{ value }}"{{ filter.standort.selected is defined and filter.standort.selected == value ? ' selected' : '' }}>{{ label }}</option>
39
+                        {% endfor %}
28 40
                     </select>
29 41
                 </div>
30 42
             </div>
... ...
@@ -74,7 +74,20 @@ class WeinanlieferungBookingsController extends AbstractController
74 74
                 ->select('id')
75 75
                 ->from(WeinanlieferungSlotsModel::getTable());
76 76
 
77
-            if (!empty(Input::post('tl_month')) && is_numeric(Input::post('tl_month')))
77
+            if (!empty(Input::post('tl_day')) && is_numeric(Input::post('tl_day')))
78
+            {
79
+                $Day = new Date(Input::post('tl_day'));
80
+                $arrData['filter']['day']['selected'] = Input::post('tl_day');
81
+                $queryBuilder->andWhere('date BETWEEN :day_start AND :day_end')
82
+                    ->setParameter('day_start', $Day->dayBegin)
83
+                    ->setParameter('day_end', $Day->dayEnd);
84
+            } else {
85
+                $Today = new Date();
86
+                $queryBuilder->andWhere("time >= :today")
87
+                    ->setParameter('today',$Today->dayBegin);
88
+            }
89
+
90
+            /*if (!empty(Input::post('tl_month')) && is_numeric(Input::post('tl_month')))
78 91
             {
79 92
                 $Month = new Date(Input::post('tl_month'));
80 93
                 $arrData['filter']['month']['selected'] = Input::post('tl_month');
... ...
@@ -85,20 +98,46 @@ class WeinanlieferungBookingsController extends AbstractController
85 98
                 $Today = new Date();
86 99
                 $queryBuilder->andWhere("time >= :today")
87 100
                     ->setParameter('today',$Today->dayBegin);
101
+            }*/
102
+
103
+            if (!empty(Input::post('tl_standort')) && is_numeric(Input::post('tl_standort')))
104
+            {
105
+                $Month = new Date(Input::post('tl_standort'));
106
+                $arrData['filter']['standort']['selected'] = Input::post('tl_standort');
107
+                $queryBuilder->andWhere('pid = :pid')
108
+                    ->setParameter('pid', (int) Input::post('tl_standort'));
88 109
             }
89 110
 
90 111
             $arrSlots = $queryBuilder->fetchFirstColumn();
91 112
 
92 113
         }
93
-        $arrMonthOptions = [];
114
+
115
+        $arrDayOptions = [];
116
+        $DayRequest = $this->db->executeQuery("SELECT s.date, DATE_FORMAT(FROM_UNIXTIME(s.date),'%d.%m.%Y') as 'day_label' FROM tl_vr_wa_reservation r INNER JOIN tl_vr_wa_slot s ON s.id = r.pid GROUP BY day_label ORDER BY s.date ASC");
117
+
118
+        foreach ($DayRequest->iterateAssociative() as $day)
119
+        {
120
+            $arrDayOptions[$day['date']] = $day['day_label'];
121
+        }
122
+
123
+        /*$arrMonthOptions = [];
94 124
         $MonthRequest = $this->db->executeQuery("SELECT s.date, DATE_FORMAT(FROM_UNIXTIME(s.date),'%m/%Y') as 'month_label' FROM tl_vr_wa_reservation r INNER JOIN tl_vr_wa_slot s ON s.id = r.pid GROUP BY month_label ORDER BY s.date ASC");
95 125
 
96 126
         foreach ($MonthRequest->iterateAssociative() as $month)
97 127
         {
98 128
             $arrMonthOptions[$month['date']] = $month['month_label'];
129
+        }*/
130
+
131
+        $arrStandortOptions = [];
132
+        $StandortRequest = $this->db->executeQuery("SELECT l.id, l.title FROM tl_vr_wa_reservation r INNER JOIN tl_vr_wa_slot s ON s.id = r.pid INNER JOIN tl_vr_wa_standort l ON l.id = s.pid GROUP BY l.id ORDER BY l.title ASC");
133
+        foreach ($StandortRequest->iterateAssociative() as $standort)
134
+        {
135
+            $arrStandortOptions[$standort['id']] = $standort['title'];
99 136
         }
100 137
 
101
-        $arrData['filter']['month']['options'] = $arrMonthOptions;
138
+        $arrData['filter']['day']['options'] = $arrDayOptions;
139
+//        $arrData['filter']['month']['options'] = $arrMonthOptions;
140
+        $arrData['filter']['standort']['options'] = $arrStandortOptions;
102 141
 
103 142
 
104 143
         // Get bookings