... | ... |
@@ -127,7 +127,7 @@ class WeinanlieferungSlotsListModuleController extends AbstractFrontendModuleCon |
127 | 127 |
$day = new Date($slot->date); |
128 | 128 |
$arrSorten = []; |
129 | 129 |
$arrErnteart = []; |
130 |
- $intAvailableBehaelter = $slot->getAvailableBehaelter(); |
|
130 |
+ $intAvailableBehaelter = max(0,$slot->getAvailableBehaelter()); |
|
131 | 131 |
|
132 | 132 |
$Sorten = StringUtil::deserialize($slot->sorten, true); |
133 | 133 |
foreach ($Sorten as $sorte) |
... | ... |
@@ -50,6 +50,7 @@ class WeinanlieferungSlotsListModuleController extends AbstractFrontendModuleCon |
50 | 50 |
protected function getResponse(Template $template, ModuleModel $model, Request $request): ?Response |
51 | 51 |
{ |
52 | 52 |
global $objPage; |
53 |
+ Controller::loadDataContainer('tl_vr_wa_slot'); |
|
53 | 54 |
$GLOBALS['TL_CSS']['vr_wa'] = 'bundles/vonrotenbergweinanlieferung/css/frontend.scss|static'; |
54 | 55 |
$standortIds = StringUtil::deserialize($model->vr_wa_standortId); |
55 | 56 |
$arrData = $template->getData(); |
... | ... |
@@ -68,6 +69,12 @@ class WeinanlieferungSlotsListModuleController extends AbstractFrontendModuleCon |
68 | 69 |
$arrOptions['column'][] = 'pid = ?'; |
69 | 70 |
$arrOptions['value'][] = $_GET['filter_standort']; |
70 | 71 |
} |
72 |
+ if (!empty($_GET['filter_ernteart'])) |
|
73 |
+ { |
|
74 |
+ $arrData['filter']['ernteart']['selected'] = $_GET['filter_ernteart']; |
|
75 |
+ $arrOptions['column'][] = 'FIND_IN_SET (?,ernteart)'; |
|
76 |
+ $arrOptions['value'][] = $_GET['filter_ernteart']; |
|
77 |
+ } |
|
71 | 78 |
if (!empty($_GET['filter_sorte']) && !empty($_GET['filter_leseart'])) |
72 | 79 |
{ |
73 | 80 |
$arrData['filter']['sorte']['selected'] = $_GET['filter_sorte']; |
... | ... |
@@ -93,6 +100,14 @@ class WeinanlieferungSlotsListModuleController extends AbstractFrontendModuleCon |
93 | 100 |
$arrData['filter']['standort']['options'] = array_combine($Standorte->fetchEach('id'),$Standorte->fetchEach('title')); |
94 | 101 |
} |
95 | 102 |
|
103 |
+ if (isset($GLOBALS['TL_DCA']['tl_vr_wa_slot']['fields']['ernteart']['options'])) |
|
104 |
+ { |
|
105 |
+ foreach ($GLOBALS['TL_DCA']['tl_vr_wa_slot']['fields']['ernteart']['options'] as $ernteart) |
|
106 |
+ { |
|
107 |
+ $arrData['filter']['ernteart']['options'][$ernteart] = $GLOBALS['TL_LANG']['REF']['wa_ernteart'][$ernteart] ?? $ernteart; |
|
108 |
+ } |
|
109 |
+ } |
|
110 |
+ |
|
96 | 111 |
if (($Sorten = WeinanlieferungRebsorteModel::findAll(['order'=>'title ASC'])) !== null) |
97 | 112 |
{ |
98 | 113 |
$arrData['filter']['sorte']['options'] = array_combine($Sorten->fetchEach('id'),$Sorten->fetchEach('title')); |
... | ... |
@@ -50,6 +50,7 @@ class WeinanlieferungSlotsListModuleController extends AbstractFrontendModuleCon |
50 | 50 |
protected function getResponse(Template $template, ModuleModel $model, Request $request): ?Response |
51 | 51 |
{ |
52 | 52 |
global $objPage; |
53 |
+ $GLOBALS['TL_CSS']['vr_wa'] = 'bundles/vonrotenbergweinanlieferung/css/frontend.scss|static'; |
|
53 | 54 |
$standortIds = StringUtil::deserialize($model->vr_wa_standortId); |
54 | 55 |
$arrData = $template->getData(); |
55 | 56 |
$arrOptions = []; |
... | ... |
@@ -135,16 +135,16 @@ class WeinanlieferungSlotsListModuleController extends AbstractFrontendModuleCon |
135 | 135 |
$strStandort = $Standort->title; |
136 | 136 |
} |
137 | 137 |
|
138 |
- $strLage = ''; |
|
138 |
+ $arrLage = []; |
|
139 | 139 |
if (($Lage = $slot->getRelated('lage')) !== null) |
140 | 140 |
{ |
141 |
- $strLage = $Lage->title; |
|
141 |
+ $arrLage = $Lage->fetchEach('title'); |
|
142 | 142 |
} |
143 | 143 |
|
144 | 144 |
$arrData['days'][$day->dayBegin][] = array_merge($slot->row(),[ |
145 | 145 |
'anmerkungen' => $slot->anmerkungen ? StringUtil::substr(strip_tags($slot->anmerkungen),110) : '', |
146 | 146 |
'standort' => $strStandort, |
147 |
- 'lage' => $strLage, |
|
147 |
+ 'lage' => $arrLage, |
|
148 | 148 |
'sorte' => $arrSorten, |
149 | 149 |
'ernteart' => $arrErnteart, |
150 | 150 |
'behaelterAvailable' => $intAvailableBehaelter, |
... | ... |
@@ -110,14 +110,23 @@ class WeinanlieferungSlotsListModuleController extends AbstractFrontendModuleCon |
110 | 110 |
{ |
111 | 111 |
$day = new Date($slot->date); |
112 | 112 |
$arrSorten = []; |
113 |
+ $arrErnteart = []; |
|
113 | 114 |
$intAvailableBehaelter = $slot->getAvailableBehaelter(); |
114 | 115 |
|
115 |
- $Sorten = StringUtil::deserialize($slot->sorten,true); |
|
116 |
- foreach($Sorten as $sorte) |
|
116 |
+ $Sorten = StringUtil::deserialize($slot->sorten, true); |
|
117 |
+ foreach ($Sorten as $sorte) |
|
117 | 118 |
{ |
118 | 119 |
$objSorte = WeinanlieferungRebsorteModel::findByPk($sorte['sorte']); |
119 | 120 |
$objLeseart = WeinanlieferungLeseartModel::findByPk($sorte['leseart']); |
120 |
- $arrSorten[] = ($objSorte !== null ? $objSorte->title : '') . ' ' . ($objLeseart !== null ? $objLeseart->title : ''); |
|
121 |
+ $arrSorten[] = ($objSorte !== null ? $objSorte->title : '') . ' ' . ($objLeseart !== null ? $objLeseart->title : ''); |
|
122 |
+ } |
|
123 |
+ |
|
124 |
+ if ($slot->ernteart !== null) |
|
125 |
+ { |
|
126 |
+ foreach (explode(',', $slot->ernteart) as $ernteart) |
|
127 |
+ { |
|
128 |
+ $arrErnteart[] = $GLOBALS['TL_LANG']['REF']['wa_ernteart'][$ernteart] ?? $ernteart; |
|
129 |
+ } |
|
121 | 130 |
} |
122 | 131 |
|
123 | 132 |
$strStandort = ''; |
... | ... |
@@ -126,10 +135,18 @@ class WeinanlieferungSlotsListModuleController extends AbstractFrontendModuleCon |
126 | 135 |
$strStandort = $Standort->title; |
127 | 136 |
} |
128 | 137 |
|
138 |
+ $strLage = ''; |
|
139 |
+ if (($Lage = $slot->getRelated('lage')) !== null) |
|
140 |
+ { |
|
141 |
+ $strLage = $Lage->title; |
|
142 |
+ } |
|
143 |
+ |
|
129 | 144 |
$arrData['days'][$day->dayBegin][] = array_merge($slot->row(),[ |
130 | 145 |
'anmerkungen' => $slot->anmerkungen ? StringUtil::substr(strip_tags($slot->anmerkungen),110) : '', |
131 | 146 |
'standort' => $strStandort, |
147 |
+ 'lage' => $strLage, |
|
132 | 148 |
'sorte' => $arrSorten, |
149 |
+ 'ernteart' => $arrErnteart, |
|
133 | 150 |
'behaelterAvailable' => $intAvailableBehaelter, |
134 | 151 |
'buchbar' => (boolean) $intAvailableBehaelter, |
135 | 152 |
'gebucht' => (boolean) WeinanlieferungReservationModel::countBy(["uid = ?","pid = ?"],[FrontendUser::getInstance()->id,$slot->id]) |
... | ... |
@@ -30,6 +30,7 @@ use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungLeseartModel; |
30 | 30 |
use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungRebsorteModel; |
31 | 31 |
use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungReservationModel; |
32 | 32 |
use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungSlotsModel; |
33 |
+use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungStandortModel; |
|
33 | 34 |
|
34 | 35 |
/** |
35 | 36 |
* @FrontendModule(WeinanlieferungSlotsListModuleController::TYPE, category="miscellaneous") |
... | ... |
@@ -60,6 +61,12 @@ class WeinanlieferungSlotsListModuleController extends AbstractFrontendModuleCon |
60 | 61 |
$arrOptions['column'][] = '(SELECT tl_vr_wa_slot.behaelter - IFNULL(SUM(tl_vr_wa_reservation.behaelter),0) FROM tl_vr_wa_reservation WHERE tl_vr_wa_reservation.pid = tl_vr_wa_slot.id) >= ?'; |
61 | 62 |
$arrOptions['value'][] = $_GET['filter_kapazitaet']; |
62 | 63 |
} |
64 |
+ if (!empty($_GET['filter_standort'])) |
|
65 |
+ { |
|
66 |
+ $arrData['filter']['standort']['selected'] = $_GET['filter_standort']; |
|
67 |
+ $arrOptions['column'][] = 'pid = ?'; |
|
68 |
+ $arrOptions['value'][] = $_GET['filter_standort']; |
|
69 |
+ } |
|
63 | 70 |
if (!empty($_GET['filter_sorte']) && !empty($_GET['filter_leseart'])) |
64 | 71 |
{ |
65 | 72 |
$arrData['filter']['sorte']['selected'] = $_GET['filter_sorte']; |
... | ... |
@@ -80,6 +87,11 @@ class WeinanlieferungSlotsListModuleController extends AbstractFrontendModuleCon |
80 | 87 |
|
81 | 88 |
$arrData['filter']['kapazitaet']['options'] = range(1,30); |
82 | 89 |
|
90 |
+ if (($Standorte = WeinanlieferungStandortModel::findBy(["id IN (".implode(',',$standortIds).")"],null,['order'=>'title ASC'])) !== null) |
|
91 |
+ { |
|
92 |
+ $arrData['filter']['standort']['options'] = array_combine($Standorte->fetchEach('id'),$Standorte->fetchEach('title')); |
|
93 |
+ } |
|
94 |
+ |
|
83 | 95 |
if (($Sorten = WeinanlieferungRebsorteModel::findAll(['order'=>'title ASC'])) !== null) |
84 | 96 |
{ |
85 | 97 |
$arrData['filter']['sorte']['options'] = array_combine($Sorten->fetchEach('id'),$Sorten->fetchEach('title')); |
... | ... |
@@ -107,12 +119,16 @@ class WeinanlieferungSlotsListModuleController extends AbstractFrontendModuleCon |
107 | 119 |
$objLeseart = WeinanlieferungLeseartModel::findByPk($sorte['leseart']); |
108 | 120 |
$arrSorten[] = ($objSorte !== null ? $objSorte->title : '') . ' ' . ($objLeseart !== null ? $objLeseart->title : ''); |
109 | 121 |
} |
110 |
- /*if (($Sorten = $slot->getRelated('sorte')) !== null) |
|
122 |
+ |
|
123 |
+ $strStandort = ''; |
|
124 |
+ if (($Standort = $slot->getRelated('pid')) !== null) |
|
111 | 125 |
{ |
112 |
- $arrSorten = $Sorten->fetchEach('title'); |
|
113 |
- }*/ |
|
126 |
+ $strStandort = $Standort->title; |
|
127 |
+ } |
|
114 | 128 |
|
115 | 129 |
$arrData['days'][$day->dayBegin][] = array_merge($slot->row(),[ |
130 |
+ 'anmerkungen' => $slot->anmerkungen ? StringUtil::substr(strip_tags($slot->anmerkungen),110) : '', |
|
131 |
+ 'standort' => $strStandort, |
|
116 | 132 |
'sorte' => $arrSorten, |
117 | 133 |
'behaelterAvailable' => $intAvailableBehaelter, |
118 | 134 |
'buchbar' => (boolean) $intAvailableBehaelter, |
... | ... |
@@ -64,17 +64,17 @@ class WeinanlieferungSlotsListModuleController extends AbstractFrontendModuleCon |
64 | 64 |
{ |
65 | 65 |
$arrData['filter']['sorte']['selected'] = $_GET['filter_sorte']; |
66 | 66 |
$arrData['filter']['leseart']['selected'] = $_GET['filter_leseart']; |
67 |
- $arrOptions['column'][] = "REGEXP_LIKE(sorten,'\"sorte\";s:[0-9]+:\"" . intval($_GET['filter_sorte']) . "\"[^\}]+\"leseart\";s:[0-9]+:\"" . intval($_GET['filter_leseart']) . "\"')"; |
|
67 |
+ $arrOptions['column'][] = "sorten REGEXP('\"sorte\";s:[0-9]+:\"" . intval($_GET['filter_sorte']) . "\"[^\}]+\"leseart\";s:[0-9]+:\"" . intval($_GET['filter_leseart']) . "\"')"; |
|
68 | 68 |
} else { |
69 | 69 |
if (!empty($_GET['filter_sorte'])) |
70 | 70 |
{ |
71 | 71 |
$arrData['filter']['sorte']['selected'] = $_GET['filter_sorte']; |
72 |
- $arrOptions['column'][] = "REGEXP_LIKE(sorten,'\"sorte\";s:[0-9]+:\"" . intval($_GET['filter_sorte']) . "\"')"; |
|
72 |
+ $arrOptions['column'][] = "sorten REGEXP('\"sorte\";s:[0-9]+:\"" . intval($_GET['filter_sorte']) . "\"')"; |
|
73 | 73 |
} |
74 | 74 |
if (!empty($_GET['filter_leseart'])) |
75 | 75 |
{ |
76 | 76 |
$arrData['filter']['leseart']['selected'] = $_GET['filter_leseart']; |
77 |
- $arrOptions['column'][] = "REGEXP_LIKE(sorten,'\"leseart\";s:[0-9]+:\"" . intval($_GET['filter_leseart']) . "\"')"; |
|
77 |
+ $arrOptions['column'][] = "sorten REGEXP('\"leseart\";s:[0-9]+:\"" . intval($_GET['filter_leseart']) . "\"')"; |
|
78 | 78 |
} |
79 | 79 |
} |
80 | 80 |
|
... | ... |
@@ -20,6 +20,7 @@ use Contao\CoreBundle\ServiceAnnotation\FrontendModule; |
20 | 20 |
use Contao\Date; |
21 | 21 |
use Contao\FrontendUser; |
22 | 22 |
use Contao\ModuleModel; |
23 |
+use Contao\PageModel; |
|
23 | 24 |
use Contao\StringUtil; |
24 | 25 |
use Contao\System; |
25 | 26 |
use Contao\Template; |
... | ... |
@@ -47,6 +48,7 @@ class WeinanlieferungSlotsListModuleController extends AbstractFrontendModuleCon |
47 | 48 |
|
48 | 49 |
protected function getResponse(Template $template, ModuleModel $model, Request $request): ?Response |
49 | 50 |
{ |
51 |
+ global $objPage; |
|
50 | 52 |
$standortIds = StringUtil::deserialize($model->vr_wa_standortId); |
51 | 53 |
$arrData = $template->getData(); |
52 | 54 |
$arrOptions = []; |
... | ... |
@@ -119,6 +121,12 @@ class WeinanlieferungSlotsListModuleController extends AbstractFrontendModuleCon |
119 | 121 |
} |
120 | 122 |
} |
121 | 123 |
|
124 |
+ // Add page URL |
|
125 |
+ if ($objPage instanceof PageModel) |
|
126 |
+ { |
|
127 |
+ $arrData['pageUrl'] = $objPage->getFrontendUrl(); |
|
128 |
+ } |
|
129 |
+ |
|
122 | 130 |
$template->setData($arrData); |
123 | 131 |
|
124 | 132 |
// Handle ajax |
... | ... |
@@ -58,18 +58,24 @@ class WeinanlieferungSlotsListModuleController extends AbstractFrontendModuleCon |
58 | 58 |
$arrOptions['column'][] = '(SELECT tl_vr_wa_slot.behaelter - IFNULL(SUM(tl_vr_wa_reservation.behaelter),0) FROM tl_vr_wa_reservation WHERE tl_vr_wa_reservation.pid = tl_vr_wa_slot.id) >= ?'; |
59 | 59 |
$arrOptions['value'][] = $_GET['filter_kapazitaet']; |
60 | 60 |
} |
61 |
- if (!empty($_GET['filter_sorte'])) |
|
61 |
+ if (!empty($_GET['filter_sorte']) && !empty($_GET['filter_leseart'])) |
|
62 | 62 |
{ |
63 | 63 |
$arrData['filter']['sorte']['selected'] = $_GET['filter_sorte']; |
64 |
-// $arrOptions['column'][] = 'FIND_IN_SET(?,sorte)'; |
|
65 |
- $arrOptions['column'][] = "REGEXP_LIKE(sorten,'\"sorte\";s:[0-9]+:\"" . intval($_GET['filter_sorte']) . "\"')"; |
|
66 |
-// $arrOptions['value'][] = $_GET['filter_sorte']; |
|
67 |
- } |
|
68 |
- if (!empty($_GET['filter_leseart'])) |
|
69 |
- { |
|
70 | 64 |
$arrData['filter']['leseart']['selected'] = $_GET['filter_leseart']; |
71 |
- $arrOptions['column'][] = "REGEXP_LIKE(sorten,'\"leseart\";s:[0-9]+:\"" . intval($_GET['filter_leseart']) . "\"')"; |
|
65 |
+ $arrOptions['column'][] = "REGEXP_LIKE(sorten,'\"sorte\";s:[0-9]+:\"" . intval($_GET['filter_sorte']) . "\"[^\}]+\"leseart\";s:[0-9]+:\"" . intval($_GET['filter_leseart']) . "\"')"; |
|
66 |
+ } else { |
|
67 |
+ if (!empty($_GET['filter_sorte'])) |
|
68 |
+ { |
|
69 |
+ $arrData['filter']['sorte']['selected'] = $_GET['filter_sorte']; |
|
70 |
+ $arrOptions['column'][] = "REGEXP_LIKE(sorten,'\"sorte\";s:[0-9]+:\"" . intval($_GET['filter_sorte']) . "\"')"; |
|
71 |
+ } |
|
72 |
+ if (!empty($_GET['filter_leseart'])) |
|
73 |
+ { |
|
74 |
+ $arrData['filter']['leseart']['selected'] = $_GET['filter_leseart']; |
|
75 |
+ $arrOptions['column'][] = "REGEXP_LIKE(sorten,'\"leseart\";s:[0-9]+:\"" . intval($_GET['filter_leseart']) . "\"')"; |
|
76 |
+ } |
|
72 | 77 |
} |
78 |
+ |
|
73 | 79 |
$arrData['filter']['kapazitaet']['options'] = range(1,30); |
74 | 80 |
|
75 | 81 |
if (($Sorten = WeinanlieferungRebsorteModel::findAll(['order'=>'title ASC'])) !== null) |
... | ... |
@@ -65,6 +65,11 @@ class WeinanlieferungSlotsListModuleController extends AbstractFrontendModuleCon |
65 | 65 |
$arrOptions['column'][] = "REGEXP_LIKE(sorten,'\"sorte\";s:[0-9]+:\"" . intval($_GET['filter_sorte']) . "\"')"; |
66 | 66 |
// $arrOptions['value'][] = $_GET['filter_sorte']; |
67 | 67 |
} |
68 |
+ if (!empty($_GET['filter_leseart'])) |
|
69 |
+ { |
|
70 |
+ $arrData['filter']['leseart']['selected'] = $_GET['filter_leseart']; |
|
71 |
+ $arrOptions['column'][] = "REGEXP_LIKE(sorten,'\"leseart\";s:[0-9]+:\"" . intval($_GET['filter_leseart']) . "\"')"; |
|
72 |
+ } |
|
68 | 73 |
$arrData['filter']['kapazitaet']['options'] = range(1,30); |
69 | 74 |
|
70 | 75 |
if (($Sorten = WeinanlieferungRebsorteModel::findAll(['order'=>'title ASC'])) !== null) |
... | ... |
@@ -72,6 +77,11 @@ class WeinanlieferungSlotsListModuleController extends AbstractFrontendModuleCon |
72 | 77 |
$arrData['filter']['sorte']['options'] = array_combine($Sorten->fetchEach('id'),$Sorten->fetchEach('title')); |
73 | 78 |
} |
74 | 79 |
|
80 |
+ if (($Leseart = WeinanlieferungLeseartModel::findAll(['order'=>'title ASC'])) !== null) |
|
81 |
+ { |
|
82 |
+ $arrData['filter']['leseart']['options'] = array_combine($Leseart->fetchEach('id'),$Leseart->fetchEach('title')); |
|
83 |
+ } |
|
84 |
+ |
|
75 | 85 |
// Get available slots |
76 | 86 |
if (($slots = WeinanlieferungSlotsModel::findMultiplePublishedByPids($standortIds,$arrOptions)) !== null) |
77 | 87 |
{ |
... | ... |
@@ -21,9 +21,11 @@ use Contao\Date; |
21 | 21 |
use Contao\FrontendUser; |
22 | 22 |
use Contao\ModuleModel; |
23 | 23 |
use Contao\StringUtil; |
24 |
+use Contao\System; |
|
24 | 25 |
use Contao\Template; |
25 | 26 |
use Symfony\Component\HttpFoundation\Request; |
26 | 27 |
use Symfony\Component\HttpFoundation\Response; |
28 |
+use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungLeseartModel; |
|
27 | 29 |
use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungRebsorteModel; |
28 | 30 |
use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungReservationModel; |
29 | 31 |
use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungSlotsModel; |
... | ... |
@@ -59,8 +61,9 @@ class WeinanlieferungSlotsListModuleController extends AbstractFrontendModuleCon |
59 | 61 |
if (!empty($_GET['filter_sorte'])) |
60 | 62 |
{ |
61 | 63 |
$arrData['filter']['sorte']['selected'] = $_GET['filter_sorte']; |
62 |
- $arrOptions['column'][] = 'FIND_IN_SET(?,sorte)'; |
|
63 |
- $arrOptions['value'][] = $_GET['filter_sorte']; |
|
64 |
+// $arrOptions['column'][] = 'FIND_IN_SET(?,sorte)'; |
|
65 |
+ $arrOptions['column'][] = "REGEXP_LIKE(sorten,'\"sorte\";s:[0-9]+:\"" . intval($_GET['filter_sorte']) . "\"')"; |
|
66 |
+// $arrOptions['value'][] = $_GET['filter_sorte']; |
|
64 | 67 |
} |
65 | 68 |
$arrData['filter']['kapazitaet']['options'] = range(1,30); |
66 | 69 |
|
... | ... |
@@ -79,10 +82,17 @@ class WeinanlieferungSlotsListModuleController extends AbstractFrontendModuleCon |
79 | 82 |
$arrSorten = []; |
80 | 83 |
$intAvailableBehaelter = $slot->getAvailableBehaelter(); |
81 | 84 |
|
82 |
- if (($Sorten = $slot->getRelated('sorte')) !== null) |
|
85 |
+ $Sorten = StringUtil::deserialize($slot->sorten,true); |
|
86 |
+ foreach($Sorten as $sorte) |
|
83 | 87 |
{ |
84 |
- $arrSorten = $Sorten->fetchEach('title'); |
|
88 |
+ $objSorte = WeinanlieferungRebsorteModel::findByPk($sorte['sorte']); |
|
89 |
+ $objLeseart = WeinanlieferungLeseartModel::findByPk($sorte['leseart']); |
|
90 |
+ $arrSorten[] = ($objSorte !== null ? $objSorte->title : '') . ' ' . ($objLeseart !== null ? $objLeseart->title : ''); |
|
85 | 91 |
} |
92 |
+ /*if (($Sorten = $slot->getRelated('sorte')) !== null) |
|
93 |
+ { |
|
94 |
+ $arrSorten = $Sorten->fetchEach('title'); |
|
95 |
+ }*/ |
|
86 | 96 |
|
87 | 97 |
$arrData['days'][$day->dayBegin][] = array_merge($slot->row(),[ |
88 | 98 |
'sorte' => $arrSorten, |
... | ... |
@@ -18,12 +18,14 @@ use Contao\CoreBundle\Exception\ResponseException; |
18 | 18 |
use Contao\CoreBundle\InsertTag\InsertTagParser; |
19 | 19 |
use Contao\CoreBundle\ServiceAnnotation\FrontendModule; |
20 | 20 |
use Contao\Date; |
21 |
+use Contao\FrontendUser; |
|
21 | 22 |
use Contao\ModuleModel; |
22 | 23 |
use Contao\StringUtil; |
23 | 24 |
use Contao\Template; |
24 | 25 |
use Symfony\Component\HttpFoundation\Request; |
25 | 26 |
use Symfony\Component\HttpFoundation\Response; |
26 | 27 |
use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungRebsorteModel; |
28 |
+use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungReservationModel; |
|
27 | 29 |
use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungSlotsModel; |
28 | 30 |
|
29 | 31 |
/** |
... | ... |
@@ -85,7 +87,8 @@ class WeinanlieferungSlotsListModuleController extends AbstractFrontendModuleCon |
85 | 87 |
$arrData['days'][$day->dayBegin][] = array_merge($slot->row(),[ |
86 | 88 |
'sorte' => $arrSorten, |
87 | 89 |
'behaelterAvailable' => $intAvailableBehaelter, |
88 |
- 'buchbar' => (boolean) $intAvailableBehaelter |
|
90 |
+ 'buchbar' => (boolean) $intAvailableBehaelter, |
|
91 |
+ 'gebucht' => (boolean) WeinanlieferungReservationModel::countBy(["uid = ?","pid = ?"],[FrontendUser::getInstance()->id,$slot->id]) |
|
89 | 92 |
]); |
90 | 93 |
} |
91 | 94 |
} |
... | ... |
@@ -51,7 +51,7 @@ class WeinanlieferungSlotsListModuleController extends AbstractFrontendModuleCon |
51 | 51 |
if (!empty($_GET['filter_kapazitaet'])) |
52 | 52 |
{ |
53 | 53 |
$arrData['filter']['kapazitaet']['selected'] = $_GET['filter_kapazitaet']; |
54 |
- $arrOptions['column'][] = 'behaelter = ?'; |
|
54 |
+ $arrOptions['column'][] = '(SELECT tl_vr_wa_slot.behaelter - IFNULL(SUM(tl_vr_wa_reservation.behaelter),0) FROM tl_vr_wa_reservation WHERE tl_vr_wa_reservation.pid = tl_vr_wa_slot.id) >= ?'; |
|
55 | 55 |
$arrOptions['value'][] = $_GET['filter_kapazitaet']; |
56 | 56 |
} |
57 | 57 |
if (!empty($_GET['filter_sorte'])) |
... | ... |
@@ -12,13 +12,18 @@ declare(strict_types=1); |
12 | 12 |
|
13 | 13 |
namespace vonRotenberg\WeinanlieferungBundle\Controller\Frontend\Module; |
14 | 14 |
|
15 |
+use Contao\Controller; |
|
15 | 16 |
use Contao\CoreBundle\Controller\FrontendModule\AbstractFrontendModuleController; |
17 |
+use Contao\CoreBundle\Exception\ResponseException; |
|
18 |
+use Contao\CoreBundle\InsertTag\InsertTagParser; |
|
16 | 19 |
use Contao\CoreBundle\ServiceAnnotation\FrontendModule; |
20 |
+use Contao\Date; |
|
17 | 21 |
use Contao\ModuleModel; |
18 | 22 |
use Contao\StringUtil; |
19 | 23 |
use Contao\Template; |
20 | 24 |
use Symfony\Component\HttpFoundation\Request; |
21 | 25 |
use Symfony\Component\HttpFoundation\Response; |
26 |
+use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungRebsorteModel; |
|
22 | 27 |
use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungSlotsModel; |
23 | 28 |
|
24 | 29 |
/** |
... | ... |
@@ -28,22 +33,71 @@ class WeinanlieferungSlotsListModuleController extends AbstractFrontendModuleCon |
28 | 33 |
{ |
29 | 34 |
public const TYPE = 'wa_slots_list'; |
30 | 35 |
|
36 |
+ private $insertTagParser; |
|
37 |
+ |
|
38 |
+ public function __construct(InsertTagParser $insertTagParser) |
|
39 |
+ { |
|
40 |
+ $this->insertTagParser = $insertTagParser; |
|
41 |
+ } |
|
42 |
+ |
|
43 |
+ |
|
31 | 44 |
protected function getResponse(Template $template, ModuleModel $model, Request $request): ?Response |
32 | 45 |
{ |
33 | 46 |
$standortIds = StringUtil::deserialize($model->vr_wa_standortId); |
34 |
- |
|
35 | 47 |
$arrData = $template->getData(); |
48 |
+ $arrOptions = []; |
|
36 | 49 |
|
37 |
- if (($slots = WeinanlieferungSlotsModel::findMultiplePublishedByPids($standortIds)) !== null) |
|
50 |
+ // Add filter values |
|
51 |
+ if (!empty($_GET['filter_kapazitaet'])) |
|
52 |
+ { |
|
53 |
+ $arrData['filter']['kapazitaet']['selected'] = $_GET['filter_kapazitaet']; |
|
54 |
+ $arrOptions['column'][] = 'behaelter = ?'; |
|
55 |
+ $arrOptions['value'][] = $_GET['filter_kapazitaet']; |
|
56 |
+ } |
|
57 |
+ if (!empty($_GET['filter_sorte'])) |
|
38 | 58 |
{ |
59 |
+ $arrData['filter']['sorte']['selected'] = $_GET['filter_sorte']; |
|
60 |
+ $arrOptions['column'][] = 'FIND_IN_SET(?,sorte)'; |
|
61 |
+ $arrOptions['value'][] = $_GET['filter_sorte']; |
|
62 |
+ } |
|
63 |
+ $arrData['filter']['kapazitaet']['options'] = range(1,30); |
|
64 |
+ |
|
65 |
+ if (($Sorten = WeinanlieferungRebsorteModel::findAll(['order'=>'title ASC'])) !== null) |
|
66 |
+ { |
|
67 |
+ $arrData['filter']['sorte']['options'] = array_combine($Sorten->fetchEach('id'),$Sorten->fetchEach('title')); |
|
68 |
+ } |
|
69 |
+ |
|
70 |
+ // Get available slots |
|
71 |
+ if (($slots = WeinanlieferungSlotsModel::findMultiplePublishedByPids($standortIds,$arrOptions)) !== null) |
|
72 |
+ { |
|
73 |
+ /** @var WeinanlieferungSlotsModel $slot */ |
|
39 | 74 |
foreach ($slots as $slot) |
40 | 75 |
{ |
41 |
- $arrData['slots'][] = $slot->row(); |
|
76 |
+ $day = new Date($slot->date); |
|
77 |
+ $arrSorten = []; |
|
78 |
+ $intAvailableBehaelter = $slot->getAvailableBehaelter(); |
|
79 |
+ |
|
80 |
+ if (($Sorten = $slot->getRelated('sorte')) !== null) |
|
81 |
+ { |
|
82 |
+ $arrSorten = $Sorten->fetchEach('title'); |
|
83 |
+ } |
|
84 |
+ |
|
85 |
+ $arrData['days'][$day->dayBegin][] = array_merge($slot->row(),[ |
|
86 |
+ 'sorte' => $arrSorten, |
|
87 |
+ 'behaelterAvailable' => $intAvailableBehaelter, |
|
88 |
+ 'buchbar' => (boolean) $intAvailableBehaelter |
|
89 |
+ ]); |
|
42 | 90 |
} |
43 | 91 |
} |
44 | 92 |
|
45 | 93 |
$template->setData($arrData); |
46 | 94 |
|
95 |
+ // Handle ajax |
|
96 |
+ if ($request->headers->get('VR-Ajax') == 'WaSlotsModule') |
|
97 |
+ { |
|
98 |
+ throw new ResponseException(new Response($this->insertTagParser->replace($template->parse()))); |
|
99 |
+ } |
|
100 |
+ |
|
47 | 101 |
return $template->getResponse(); |
48 | 102 |
} |
49 | 103 |
|
1 | 1 |
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 |
+} |