... | ... |
@@ -8,8 +8,14 @@ |
8 | 8 |
* @license commercial |
9 | 9 |
*/ |
10 | 10 |
|
11 |
+use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungSlotsModel; |
|
12 |
+use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungStandortModel; |
|
13 |
+ |
|
11 | 14 |
$GLOBALS['BE_MOD']['content']['weinanlieferung'] = array |
12 | 15 |
( |
13 | 16 |
'tables' => array('tl_vr_wa_standort', 'tl_vr_wa_slot', 'tl_vr_wa_rebsorte'), |
14 | 17 |
'stylesheet' => array('bundles/vonrotenbergweinanlieferung/css/backend.css') |
15 | 18 |
); |
19 |
+ |
|
20 |
+$GLOBALS['TL_MODELS']['tl_vr_wa_slot'] = WeinanlieferungSlotsModel::class; |
|
21 |
+$GLOBALS['TL_MODELS']['tl_vr_wa_standort'] = WeinanlieferungStandortModel::class; |
16 | 22 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,23 @@ |
1 |
+<?php |
|
2 |
+ |
|
3 |
+/* |
|
4 |
+ * This file is part of contao-weinanlieferung-bundle. |
|
5 |
+ * |
|
6 |
+ * (c) vonRotenberg |
|
7 |
+ * |
|
8 |
+ * @license commercial |
|
9 |
+ */ |
|
10 |
+ |
|
11 |
+use vonRotenberg\WeinanlieferungBundle\Controller\Frontend\Module\WeinanlieferungSlotsListModuleController; |
|
12 |
+ |
|
13 |
+$GLOBALS['TL_DCA']['tl_module']['palettes'][WeinanlieferungSlotsListModuleController::TYPE] = '{title_legend},name,headline,type;{wa_config_legend},vr_wa_standortId;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},cssID'; |
|
14 |
+ |
|
15 |
+ |
|
16 |
+$GLOBALS['TL_DCA']['tl_module']['fields']['vr_wa_standortId'] = array( |
|
17 |
+ 'exclude' => true, |
|
18 |
+ 'inputType' => 'checkbox', |
|
19 |
+ 'foreignKey' => 'tl_vr_wa_standort.title', |
|
20 |
+ 'eval' => array('mandatory' => true, 'multiple' => true,), |
|
21 |
+ 'sql' => "blob NULL", |
|
22 |
+ 'relation' => array('type' => 'hasMany', 'load' => 'lazy') |
|
23 |
+); |
... | ... |
@@ -8,7 +8,12 @@ |
8 | 8 |
* @license commercial |
9 | 9 |
*/ |
10 | 10 |
|
11 |
+use vonRotenberg\WeinanlieferungBundle\Controller\Frontend\Module\WeinanlieferungSlotsListModuleController; |
|
12 |
+ |
|
11 | 13 |
$GLOBALS['TL_LANG']['MOD']['weinanlieferung'][0] = 'Weinanlieferung'; |
12 | 14 |
$GLOBALS['TL_LANG']['MOD']['weinanlieferung'][1] = 'Buchungstool zur Weinanlieferung'; |
13 | 15 |
$GLOBALS['TL_LANG']['MOD']['tl_vr_wa_rebsorte'] = 'Rebsorten'; |
14 | 16 |
$GLOBALS['TL_LANG']['MOD']['tl_vr_wa_slot'] = 'Zeitslots'; |
17 |
+ |
|
18 |
+$GLOBALS['TL_LANG']['FMD'][WeinanlieferungSlotsListModuleController::TYPE][0] = 'Weinanlieferung-Zeitslotliste'; |
|
19 |
+$GLOBALS['TL_LANG']['FMD'][WeinanlieferungSlotsListModuleController::TYPE][1] = 'Gibt eine Liste mit buchbaren Zeitslots aus.'; |
15 | 20 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,14 @@ |
1 |
+<?php |
|
2 |
+ |
|
3 |
+/** |
|
4 |
+ * This file is part of contao-weinanlieferung-bundle. |
|
5 |
+ * |
|
6 |
+ * (c) vonRotenberg |
|
7 |
+ * |
|
8 |
+ * @license commercial |
|
9 |
+ */ |
|
10 |
+ |
|
11 |
+$GLOBALS['TL_LANG']['tl_module']['vr_wa_standortId'][0] = 'Standort'; |
|
12 |
+$GLOBALS['TL_LANG']['tl_module']['vr_wa_standortId'][1] = 'Wählen Sie hier die Standorte aus, deren Zeitslots sie auflisten möchten.'; |
|
13 |
+ |
|
14 |
+$GLOBALS['TL_LANG']['tl_module']['wa_config_legend'] = 'Weinanlieferung-Einstellungen'; |
0 | 15 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,9 @@ |
1 |
+<div hx-get="{{ insert_tag('env::request') }}" hx-headers='{"SR-Ajax": "CommunityFriendsModule"}' hx-trigger="updateWaList from:body" class="{{ class }} content-wrapper block"{{ cssID }}{% if style is defined and style is not empty %} style="{{ style }}"{% endif %}> |
|
2 |
+ |
|
3 |
+{% block content %} |
|
4 |
+ {% for slot in slots %} |
|
5 |
+ {{ slot.time|date('d.m.Y H:i') }} |
|
6 |
+ {% endfor %} |
|
7 |
+{% endblock %} |
|
8 |
+ |
|
9 |
+</div> |
0 | 10 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,50 @@ |
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\Controller\Frontend\Module; |
|
14 |
+ |
|
15 |
+use Contao\CoreBundle\Controller\FrontendModule\AbstractFrontendModuleController; |
|
16 |
+use Contao\CoreBundle\ServiceAnnotation\FrontendModule; |
|
17 |
+use Contao\ModuleModel; |
|
18 |
+use Contao\StringUtil; |
|
19 |
+use Contao\Template; |
|
20 |
+use Symfony\Component\HttpFoundation\Request; |
|
21 |
+use Symfony\Component\HttpFoundation\Response; |
|
22 |
+use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungSlotsModel; |
|
23 |
+ |
|
24 |
+/** |
|
25 |
+ * @FrontendModule(WeinanlieferungSlotsListModuleController::TYPE, category="miscellaneous") |
|
26 |
+ */ |
|
27 |
+class WeinanlieferungSlotsListModuleController extends AbstractFrontendModuleController |
|
28 |
+{ |
|
29 |
+ public const TYPE = 'wa_slots_list'; |
|
30 |
+ |
|
31 |
+ protected function getResponse(Template $template, ModuleModel $model, Request $request): ?Response |
|
32 |
+ { |
|
33 |
+ $standortIds = StringUtil::deserialize($model->vr_wa_standortId); |
|
34 |
+ |
|
35 |
+ $arrData = $template->getData(); |
|
36 |
+ |
|
37 |
+ if (($slots = WeinanlieferungSlotsModel::findMultiplePublishedByPids($standortIds)) !== null) |
|
38 |
+ { |
|
39 |
+ foreach ($slots as $slot) |
|
40 |
+ { |
|
41 |
+ $arrData['slots'][] = $slot->row(); |
|
42 |
+ } |
|
43 |
+ } |
|
44 |
+ |
|
45 |
+ $template->setData($arrData); |
|
46 |
+ |
|
47 |
+ return $template->getResponse(); |
|
48 |
+ } |
|
49 |
+ |
|
50 |
+} |
0 | 51 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,78 @@ |
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\Model; |
|
14 |
+ |
|
15 |
+use Contao\Database; |
|
16 |
+use Contao\Model; |
|
17 |
+use Contao\Model\Registry; |
|
18 |
+ |
|
19 |
+class WeinanlieferungSlotsModel extends Model |
|
20 |
+{ |
|
21 |
+ /** |
|
22 |
+ * Table name |
|
23 |
+ * @var string |
|
24 |
+ */ |
|
25 |
+ protected static $strTable = 'tl_vr_wa_slot'; |
|
26 |
+ |
|
27 |
+ public static function findPublishedByPid($intPid, array $arrOptions=array()) |
|
28 |
+ { |
|
29 |
+ $time = time(); |
|
30 |
+ $t = static::$strTable; |
|
31 |
+ $arrColumns = array("$t.pid=?"); |
|
32 |
+ |
|
33 |
+ // Skip unsaved elements (see #2708) |
|
34 |
+ $arrColumns[] = "$t.tstamp!=0"; |
|
35 |
+ |
|
36 |
+ $arrColumns[] = "$t.buchbar='1' AND $t.buchbar_bis>$time"; |
|
37 |
+ |
|
38 |
+ if (!isset($arrOptions['order'])) |
|
39 |
+ { |
|
40 |
+ $arrOptions['order'] = "$t.time ASC"; |
|
41 |
+ } |
|
42 |
+ |
|
43 |
+ return static::findBy($arrColumns, $intPid, $arrOptions); |
|
44 |
+ } |
|
45 |
+ |
|
46 |
+ public static function findMultiplePublishedByPids(array $arrPids, array $arrOptions=array()) |
|
47 |
+ { |
|
48 |
+ if (empty($arrPids) || !\is_array($arrPids)) |
|
49 |
+ { |
|
50 |
+ return null; |
|
51 |
+ } |
|
52 |
+ |
|
53 |
+ $arrPids = array_filter($arrPids, function($var) { |
|
54 |
+ return is_numeric($var); |
|
55 |
+ }); |
|
56 |
+ |
|
57 |
+ if (empty($arrPids)) |
|
58 |
+ { |
|
59 |
+ return null; |
|
60 |
+ } |
|
61 |
+ |
|
62 |
+ $time = time(); |
|
63 |
+ $t = static::$strTable; |
|
64 |
+ $arrColumns = array("$t.pid IN (".implode(',',$arrPids).")"); |
|
65 |
+ |
|
66 |
+ // Skip unsaved elements (see #2708) |
|
67 |
+ $arrColumns[] = "$t.tstamp!=0"; |
|
68 |
+ |
|
69 |
+ $arrColumns[] = "$t.buchbar='1' AND $t.buchbar_bis>$time"; |
|
70 |
+ |
|
71 |
+ if (!isset($arrOptions['order'])) |
|
72 |
+ { |
|
73 |
+ $arrOptions['order'] = "$t.time ASC"; |
|
74 |
+ } |
|
75 |
+ |
|
76 |
+ return static::findBy($arrColumns,null,$arrOptions); |
|
77 |
+ } |
|
78 |
+} |
0 | 79 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,24 @@ |
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\Model; |
|
14 |
+ |
|
15 |
+use Contao\Model; |
|
16 |
+ |
|
17 |
+class WeinanlieferungStandortModel extends Model |
|
18 |
+{ |
|
19 |
+ /** |
|
20 |
+ * Table name |
|
21 |
+ * @var string |
|
22 |
+ */ |
|
23 |
+ protected static $strTable = 'tl_vr_wa_standort'; |
|
24 |
+} |