Browse code

Add uploaded file to reservaations backend view

Benjamin Roth authored on01/09/2025 14:38:22
Showing2 changed files
... ...
@@ -166,6 +166,15 @@
166 166
                                                                     </div>
167 167
                                                                 {% endif %}
168 168
                                                             </div>
169
+                                                            {% if booking.upload_file %}
170
+                                                            <div class="row u-items-flex-start pt-0">
171
+                                                                <div class="col-1"></div>
172
+                                                                <div class="col-11 icon-file-outline">
173
+                                                                    <div class="t-label">Datei</div>
174
+                                                                    <a href="{{ booking.upload_file.popup_href }}" onclick="Backend.openModalIframe({'title':'{{ booking.upload_file.popup_title|e('js') }}','url':this.href});return false">{{ booking.upload_file.name }}</a>
175
+                                                                </div>
176
+                                                            </div>
177
+                                                            {% endif %}
169 178
                                                         </div>
170 179
                                                     </div>
171 180
                                                 </div>
... ...
@@ -22,6 +22,7 @@ use Contao\Input;
22 22
 use Contao\MemberModel;
23 23
 use Contao\StringUtil;
24 24
 use Contao\System;
25
+use Contao\FilesModel;
25 26
 use Doctrine\DBAL\Connection;
26 27
 use Symfony\Component\HttpFoundation\RequestStack;
27 28
 use Symfony\Component\HttpFoundation\Response;
... ...
@@ -291,6 +292,23 @@ class WeinanlieferungBookingsController extends AbstractController
291 292
                         }
292 293
                     }
293 294
 
295
+                    // Prepare upload file info if available
296
+                    $uploadFile = null;
297
+                    if (!empty($booking->upload)) {
298
+                        $objFile = FilesModel::findByUuid($booking->upload);
299
+                        if ($objFile !== null) {
300
+                            $router = System::getContainer()->get('router');
301
+                            $popupHref = $router->generate('contao_backend_popup', ['src' => base64_encode($objFile->path)]);
302
+                            $uploadFile = [
303
+                                'name' => $objFile->name,
304
+                                'filename' => $objFile->name,
305
+                                'path' => $objFile->path,
306
+                                'popup_href' => $popupHref,
307
+                                'popup_title' => $objFile->name
308
+                            ];
309
+                        }
310
+                    }
311
+
294 312
                     $arrData['days'][$day->dayBegin][$Slot->pid]['times'][$Slot->time]['items'][] = array_merge($booking->row(), [
295 313
                         'sorte'              => $arrSorten,
296 314
                         'ernteart' => $arrErnteart,
... ...
@@ -298,7 +316,8 @@ class WeinanlieferungBookingsController extends AbstractController
298 316
                         'slot'  => $Slot->row(),
299 317
                         'standort' => $strStandort,
300 318
                         'member' => $booking->getRelated('uid') !== null ? $booking->getRelated('uid')->row() : null,
301
-                        'behaelter_numbers' => $behaelterNumbers
319
+                        'behaelter_numbers' => $behaelterNumbers,
320
+                        'upload_file' => $uploadFile
302 321
                     ]);
303 322
                 }
304 323
             }