Browse code

Add geodata fields

Benjamin Roth authored on01/10/2024 12:50:57
Showing2 changed files
... ...
@@ -396,6 +396,22 @@ $GLOBALS['TL_DCA']['tl_vr_real_estate_assets'] = array
396 396
             'inputType' => 'text',
397 397
             'eval'      => array('rgxp' => 'datim', 'datepicker' => true, 'tl_class' => 'w50 wizard'),
398 398
             'sql'       => "varchar(10) NOT NULL default ''"
399
+        ),
400
+        'geox' => array
401
+        (
402
+            'exclude'                 => true,
403
+            'inputType'               => 'c4g_text',
404
+            'eval'                    => ['mandatory'=>false, 'maxlength'=>20, 'tl_class'=>'w50 wizard'],
405
+            'wizard'                  => [['\con4gis\MapsBundle\Classes\GeoPicker', 'getPickerLink']],
406
+            'sql'                     => "varchar(20) NOT NULL default ''"
407
+        ),
408
+        'geoy' => array
409
+        (
410
+            'exclude'                 => true,
411
+            'inputType'               => 'c4g_text',
412
+            'eval'                    => ['mandatory'=>false, 'maxlength'=>20, 'tl_class'=>'w50 wizard'],
413
+            'wizard'                  => [['\con4gis\MapsBundle\Classes\GeoPicker', 'getPickerLink']],
414
+            'sql'                     => "varchar(20) NOT NULL default ''"
399 415
         )
400 416
     )
401 417
 );
402 418
new file mode 100644
... ...
@@ -0,0 +1,30 @@
1
+<?php
2
+
3
+/**
4
+ * OBG Customizations
5
+ *
6
+ * Copyright (c) 2021 vonRotenberg
7
+ *
8
+ * @license commercial
9
+ */
10
+
11
+namespace vonRotenberg\RealEstateListingBundle\EventListener;
12
+
13
+use Contao\CoreBundle\ServiceAnnotation\Callback;
14
+use Contao\DataContainer;
15
+use vonRotenberg\RealEstateListingBundle\Model\ManagedPropertyModel;
16
+
17
+class ReManagedPropertiesContainerListener
18
+{
19
+    /**
20
+     * @Callback(table="tl_vr_re_managedProperties", target="config.onsubmit")
21
+     */
22
+    public function setCoordinatesToAssets(DataContainer $dc)
23
+    {
24
+        if (!$dc->id || ($Property = ManagedPropertyModel::findByPk($dc->id)) === null) {
25
+            return;
26
+        }
27
+
28
+        $this->db->update('tl_vr_real_estate_assets', ['managedPropertyId' => $dc->id], ['geox' => $Property->geox, 'geoy' => $Property->geoy]);
29
+    }
30
+}