From 71b4b9165e8c93f4f974b07e58e988ea2cb9a9b7 Mon Sep 17 00:00:00 2001 From: eki89 Date: Tue, 30 Jun 2020 16:19:03 +0200 Subject: [PATCH] Delete existing third party real estate records with 'auftragsart' R, V, S, SB, Z and G. --- src/Resources/contao/classes/WibImport.php | 34 +++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/Resources/contao/classes/WibImport.php b/src/Resources/contao/classes/WibImport.php index c241f1b..04254e3 100644 --- a/src/Resources/contao/classes/WibImport.php +++ b/src/Resources/contao/classes/WibImport.php @@ -11,9 +11,11 @@ namespace ContaoEstateManager\WibImport; +use Contao\Database; use Contao\File; use Contao\FilesModel; use Contao\Input; +use Contao\System; use ContaoEstateManager\FilesHelper; /** @@ -21,8 +23,18 @@ * @package ContaoEstateManager\Project * @author Fabian Ekert */ -class WibImport +class WibImport extends System { + /** + * Import the Config instance + */ + protected function __construct() + { + $this->import(Database::class, 'Database'); + + parent::__construct(); + } + /** * Download an WIB open immo file manually * @@ -91,6 +103,11 @@ public function skipPartnerRecord($realEstate, &$re, &$contactPerson, &$skip, $c if (in_array($re['AUFTRAGSART'], array('R', 'V', 'S', 'SB', 'Z', 'G'))) { $skip = true; + + $objektnrExtern = $this->getObjektnrExtern($realEstate, $context); + + $this->Database->prepare("DELETE FROM tl_real_estate WHERE objektnrExtern=?") + ->execute($objektnrExtern); } } } @@ -130,6 +147,21 @@ protected function getWibAuftragsart($realEstate, $context): string return ''; } + /** + * Return field "objecktr_extern" from real estate xpath object + * + * @param $realEstate + * @param $context + * + * @return string + */ + protected function getObjektnrExtern($realEstate, $context): string + { + $groups = $realEstate->xpath('verwaltung_techn'); + + return $context->getFieldData('objektnr_extern', $groups[0]); + } + public function downloadImage($objFilesFolder, &$value, $tmpGroup, &$values, &$skip, $context): void { if ($context->interface->type === 'wib')