... | ... |
@@ -98,14 +98,15 @@ $GLOBALS['TL_DCA']['tl_vr_real_estate_assets'] = array |
98 | 98 |
// Palettes |
99 | 99 |
'palettes' => array |
100 | 100 |
( |
101 |
- '__selector__' => array('availability'), |
|
102 |
- 'default' => '{title_legend},title,assetNo,address,floor,postal,city;{availability_legend},availability;{misc_legend},description;{basic_data_legend},livingSpace,numberOfRooms,rent,coldRent,advanceOperatingCosts,constructionYear,deposit,entitlementCertificate;{features_legend},features,parking,heatingType,energyPassType,energyConsumption;{images_legend},gallerySRC,floorPlansSRC;{publish_legend},published,start,stop', |
|
101 |
+ '__selector__' => array('availability','managedPropertyId'), |
|
102 |
+ 'default' => '{title_legend},title,assetNo,floor,managedPropertyId;{availability_legend},availability;{misc_legend},description;{basic_data_legend},livingSpace,numberOfRooms,rent,coldRent,advanceOperatingCosts,constructionYear,deposit,entitlementCertificate;{features_legend},features,parking,heatingType,energyPassType,energyConsumption;{images_legend},gallerySRC,floorPlansSRC;{publish_legend},published,start,stop', |
|
103 | 103 |
), |
104 | 104 |
|
105 | 105 |
// Subpalettes |
106 | 106 |
'subpalettes' => array |
107 | 107 |
( |
108 | 108 |
'availability_from' => 'availableFrom', |
109 |
+ 'managedPropertyId_0' => 'address,postal,city' |
|
109 | 110 |
), |
110 | 111 |
|
111 | 112 |
// Fields |
... | ... |
@@ -171,6 +172,15 @@ $GLOBALS['TL_DCA']['tl_vr_real_estate_assets'] = array |
171 | 172 |
'eval' => array('mandatory' => true, 'maxlength' => 8, 'tl_class' => 'w50'), |
172 | 173 |
'sql' => "varchar(8) NOT NULL default ''" |
173 | 174 |
), |
175 |
+ 'managedPropertyId' => array |
|
176 |
+ ( |
|
177 |
+ 'exclude' => true, |
|
178 |
+ 'inputType' => 'select', |
|
179 |
+ 'foreignKey' => 'tl_vr_re_managedProperties.address', |
|
180 |
+ 'eval' => array('mandatory' => false, 'includeBlankOption' => true, 'submitOnChange' => true, 'tl_class' => 'w50', 'chosen' => true), |
|
181 |
+ 'sql' => "int(10) unsigned NOT NULL", |
|
182 |
+ 'relation' => array('type' => 'belongsTo', 'load' => 'lazy') |
|
183 |
+ ), |
|
174 | 184 |
'livingSpace' => array |
175 | 185 |
( |
176 | 186 |
'exclude' => true, |
... | ... |
@@ -38,6 +38,12 @@ |
38 | 38 |
<trans-unit id="tl_vr_real_estate_assets.floor.1"> |
39 | 39 |
<source>Die Etagenangabe des Objekts (z.B. 2. OG links).</source> |
40 | 40 |
</trans-unit> |
41 |
+ <trans-unit id="tl_vr_real_estate_assets.managedPropertyId.0"> |
|
42 |
+ <source>Verwaltetes Objekt</source> |
|
43 |
+ </trans-unit> |
|
44 |
+ <trans-unit id="tl_vr_real_estate_assets.managedPropertyId.1"> |
|
45 |
+ <source>Wählen Sie hier das verwaltete Objekt, zu dem dieser Eintrag gehört.</source> |
|
46 |
+ </trans-unit> |
|
41 | 47 |
<trans-unit id="tl_vr_real_estate_assets.livingSpace.0"> |
42 | 48 |
<source>Wohnfläche</source> |
43 | 49 |
</trans-unit> |
... | ... |
@@ -10,49 +10,27 @@ |
10 | 10 |
|
11 | 11 |
namespace vonRotenberg\RealEstateListingBundle\EventListener; |
12 | 12 |
|
13 |
-use Contao\CoreBundle\ServiceAnnotation\Hook; |
|
14 |
-use Contao\Validator; |
|
15 |
-use Contao\Widget; |
|
13 |
+use Contao\CoreBundle\ServiceAnnotation\Callback; |
|
14 |
+use Contao\DataContainer; |
|
15 |
+use vonRotenberg\RealEstateListingBundle\Model\ManagedPropertyModel; |
|
16 | 16 |
|
17 | 17 |
class RealEstateAssetsContainerListener |
18 | 18 |
{ |
19 | 19 |
/** |
20 |
- * @param string $strRegexp |
|
21 |
- * @param $varValue |
|
22 |
- * @param Widget $objWidget |
|
23 |
- * |
|
24 |
- * @return bool |
|
25 |
- * @Hook("addCustomRegexp") |
|
20 |
+ * @Callback(table="tl_vr_real_estate_assets", target="fields.managedPropertyId.options") |
|
26 | 21 |
*/ |
27 |
- public function onAddCustomRegexp(string $strRegexp, &$varValue, Widget $objWidget): bool |
|
22 |
+ public function onAddCustomRegexp(?DataContainer $dc): array |
|
28 | 23 |
{ |
29 |
- switch ($strRegexp) |
|
30 |
- { |
|
31 |
- case 'currency': |
|
32 |
- case 'float': |
|
24 |
+ $arrOptions = []; |
|
33 | 25 |
|
34 |
- if ((substr_count($varValue, ',') == 1 && strpos($varValue, '.') === false) |
|
35 |
- || (substr_count($varValue, ',') == 1 && ($dotPos = strpos($varValue, '.')) !== false && $dotPos < strpos($varValue, ','))) |
|
36 |
- { |
|
37 |
- $varValue = str_replace('.', '', $varValue); |
|
38 |
- $varValue = str_replace(',', '.', $varValue); |
|
39 |
- } |
|
26 |
+ if (($Properties = ManagedPropertyModel::findAllPublished()) !== null) |
|
27 |
+ { |
|
28 |
+ foreach ($Properties as $property) |
|
29 |
+ { |
|
30 |
+ $arrOptions[$property->city][$property->id] = $property->address . ' [' . $property->city . ']'; |
|
31 |
+ } |
|
32 |
+ } |
|
40 | 33 |
|
41 |
- if (!Validator::isNumeric($varValue)) |
|
42 |
- { |
|
43 |
- if ($strRegexp == 'currency') |
|
44 |
- { |
|
45 |
- $objWidget->addError(sprintf($GLOBALS['TL_LANG']['ERR']['currency'], $objWidget->label)); |
|
46 |
- } else { |
|
47 |
- $objWidget->addError(sprintf($GLOBALS['TL_LANG']['ERR']['digit'], $objWidget->label)); |
|
48 |
- } |
|
49 |
- |
|
50 |
- return true; |
|
51 |
- } |
|
52 |
- |
|
53 |
- break; |
|
54 |
- } |
|
55 |
- |
|
56 |
- return false; |
|
34 |
+ return $arrOptions; |
|
57 | 35 |
} |
58 | 36 |
} |
... | ... |
@@ -123,7 +123,7 @@ class ManagedPropertyModel extends Model |
123 | 123 |
|
124 | 124 |
if (!isset($arrOptions['order'])) |
125 | 125 |
{ |
126 |
- $arrOptions['order'] = "$t.city ASC, $t.livingSpace ASC"; |
|
126 |
+ $arrOptions['order'] = "$t.city ASC, $t.address ASC"; |
|
127 | 127 |
} |
128 | 128 |
|
129 | 129 |
$arrOptions['limit'] = $intLimit; |