Skip to content

Commit

Permalink
Merge pull request #2 from contao-estatemanager/develop
Browse files Browse the repository at this point in the history
Delete existing third party real estate records with 'auftragsart' R,…
  • Loading branch information
eki89 authored Jun 30, 2020
2 parents 1fb34d5 + 71b4b91 commit 158fa62
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion src/Resources/contao/classes/WibImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,30 @@
namespace ContaoEstateManager\WibImport;


use Contao\Database;
use Contao\File;
use Contao\FilesModel;
use Contao\Input;
use Contao\System;
use ContaoEstateManager\FilesHelper;

/**
* Class WibImport
* @package ContaoEstateManager\Project
* @author Fabian Ekert <fabian@oveleon.de>
*/
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
*
Expand Down Expand Up @@ -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);
}
}
}
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit 158fa62

Please sign in to comment.