Merge branch 'ConstructionConsent/add-faulty-owner-view' into 'master'
added faulty owner view See merge request fronk/thetool!1373
This commit is contained in:
@@ -247,7 +247,7 @@ foreach ($owners as $owner):
|
|||||||
|
|
||||||
<p style="margin-top: 50pt;">
|
<p style="margin-top: 50pt;">
|
||||||
<?= ($owner->title) ? $owner->title . "<br />" : "" ?>
|
<?= ($owner->title) ? $owner->title . "<br />" : "" ?>
|
||||||
<?= $owner->firstname ?> <?= $owner->lastname ?><br/>
|
<?= $owner->company ? $owner->company : $owner->firstname . ' ' . $owner->lastname ?><br/>
|
||||||
<?= $owner->street ?><br/>
|
<?= $owner->street ?><br/>
|
||||||
<?php if ($owner->country): ?>
|
<?php if ($owner->country): ?>
|
||||||
<?= $owner->zip ?> <?= $owner->city ?>
|
<?= $owner->zip ?> <?= $owner->city ?>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
$pagination_baseurl = $this->getUrl($Mod,"Index");
|
$pagination_baseurl = $this->getUrl($Mod,"Index");
|
||||||
$pagination_baseurl_params = ["filter" => $filter];
|
$pagination_baseurl_params = ["filter" => $filter];
|
||||||
$pagination_entity_name = "Zustimmungserklärungen";
|
$pagination_entity_name = "Zustimmungserklärungen";
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
|
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
|
||||||
|
|
||||||
@@ -184,6 +185,20 @@ $pagination_entity_name = "Zustimmungserklärungen";
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- display card if $hasFaultyEntries is true with danger class and text
|
||||||
|
"ACHTUNG: Dieses Zustimmungserklärungsprojekt enthält fehlerhafte Besitzerdaten. (BUTTON) Hier klicken um fehlerhafte Einträge zu sehen"
|
||||||
|
-->
|
||||||
|
<?php if ($hasFaultyEntries): ?>
|
||||||
|
<div class="card text-center mb-3">
|
||||||
|
<div class="card-body">
|
||||||
|
<h5 class="card-title text-danger">ACHTUNG: Dieses Zustimmungserklärungsprojekt enthält fehlerhafte Besitzerdaten.</h5>
|
||||||
|
<p class="card-text">
|
||||||
|
<a href="<?=self::getUrl("ConstructionConsent", "FaultyEntries", ["project_id" => $filter["project_id"] ?? ""])?>" class="btn btn-danger mt-2">Hier klicken, um fehlerhafte Einträge zu sehen</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
// if results are more than 0
|
// if results are more than 0
|
||||||
if (count($items) > 0) : ?>
|
if (count($items) > 0) : ?>
|
||||||
|
|||||||
@@ -343,7 +343,11 @@ $pagination_entity_name = "Adressen";
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
|
||||||
|
<?php if($owner->company): ?>
|
||||||
|
<strong><?=$owner->company?></strong><br />
|
||||||
|
<?php else: ?>
|
||||||
<strong><?=($owner->title) ? $owner->title." " : ""?><?=$owner->firstname?> <?=$owner->lastname?></strong><br />
|
<strong><?=($owner->title) ? $owner->title." " : ""?><?=$owner->firstname?> <?=$owner->lastname?></strong><br />
|
||||||
|
<?php endif; ?>
|
||||||
<?=$owner->street?><br />
|
<?=$owner->street?><br />
|
||||||
<?=$owner->zip?> <?=$owner->city?><br />
|
<?=$owner->zip?> <?=$owner->city?><br />
|
||||||
<?=$owner->country?>
|
<?=$owner->country?>
|
||||||
@@ -515,6 +519,11 @@ $pagination_entity_name = "Adressen";
|
|||||||
<input type="text" class="form-control" name="title" id="title" />
|
<input type="text" class="form-control" name="title" id="title" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="company" class="col-form-label">Firma:</label>
|
||||||
|
<input type="text" required class="form-control" name="company" id="company" />
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="firnstname" class="col-form-label">Vorname:</label>
|
<label for="firnstname" class="col-form-label">Vorname:</label>
|
||||||
<input type="text" required class="form-control" name="firstname" id="firstname" />
|
<input type="text" required class="form-control" name="firstname" id="firstname" />
|
||||||
@@ -1168,10 +1177,49 @@ $pagination_entity_name = "Adressen";
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('#company').on('input', function() {
|
||||||
|
if ($(this).val().length > 0) {
|
||||||
|
$('#firstname').prop('required', false);
|
||||||
|
$('#lastname').prop('required', false);
|
||||||
|
} else {
|
||||||
|
$('#firstname').prop('required', true);
|
||||||
|
$('#lastname').prop('required', true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#firstname, #lastname').on('input', function() {
|
||||||
|
if ($('#firstname').val().length > 0 && $('#lastname').val().length > 0) {
|
||||||
|
$('#company').prop('required', false);
|
||||||
|
} else {
|
||||||
|
$('#company').prop('required', true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
|
const highlightOwnerId = urlParams.get('highlight_owner_id');
|
||||||
|
|
||||||
|
if (highlightOwnerId) {
|
||||||
|
const targetRow = document.querySelector(`#owner-data-${highlightOwnerId}`);
|
||||||
|
if (targetRow) {
|
||||||
|
targetRow.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||||
|
targetRow.classList.add('highlight');
|
||||||
|
setTimeout(() => {
|
||||||
|
targetRow.classList.remove('highlight');
|
||||||
|
}, 1500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
.highlight {
|
||||||
|
background-color: #ffeb3b !important;
|
||||||
|
transition: background-color 0.5s ease;
|
||||||
|
}
|
||||||
/* Styles for the status circle */
|
/* Styles for the status circle */
|
||||||
.status-circle {
|
.status-circle {
|
||||||
width: 14px;
|
width: 14px;
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ class ConstructionConsentController extends mfBaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$filter = [];
|
$filter = [];
|
||||||
|
$hasFaultyEntries = false;
|
||||||
|
|
||||||
if(is_array($this->request->filter)) {
|
if(is_array($this->request->filter)) {
|
||||||
$filter = $this->request->filter;
|
$filter = $this->request->filter;
|
||||||
@@ -41,6 +42,7 @@ class ConstructionConsentController extends mfBaseController {
|
|||||||
} else {
|
} else {
|
||||||
$_SESSION[MFAPPNAME . '-ConstructionConsent-filter-project-' . $filter["project_id"]] = $filter;
|
$_SESSION[MFAPPNAME . '-ConstructionConsent-filter-project-' . $filter["project_id"]] = $filter;
|
||||||
}
|
}
|
||||||
|
$hasFaultyEntries = ConstructionConsentProject::hasFaultyOwnerEntries($filter["project_id"]);
|
||||||
} else {
|
} else {
|
||||||
$_SESSION[MFAPPNAME . '-ConstructionConsent-filter'] = $filter;
|
$_SESSION[MFAPPNAME . '-ConstructionConsent-filter'] = $filter;
|
||||||
}
|
}
|
||||||
@@ -59,6 +61,7 @@ class ConstructionConsentController extends mfBaseController {
|
|||||||
//var_dump($_SESSION, $filter);exit;
|
//var_dump($_SESSION, $filter);exit;
|
||||||
|
|
||||||
$this->layout->set("allowed_projects", $this->constructionConsentProjects);
|
$this->layout->set("allowed_projects", $this->constructionConsentProjects);
|
||||||
|
$this->layout->set("hasFaultyEntries", $hasFaultyEntries);
|
||||||
$this->layout->set("filter", $filter);
|
$this->layout->set("filter", $filter);
|
||||||
$filter = $this->getPreparedFilter($filter);
|
$filter = $this->getPreparedFilter($filter);
|
||||||
|
|
||||||
@@ -1373,4 +1376,37 @@ class ConstructionConsentController extends mfBaseController {
|
|||||||
self::returnJson(["success" => true]);
|
self::returnJson(["success" => true]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function faultyEntriesAction() {
|
||||||
|
// Get project ID from request if available
|
||||||
|
$projectId = isset($_GET['project_id']) ? intval($_GET['project_id']) : null;
|
||||||
|
if ($projectId === null) {
|
||||||
|
$this->layout()->setFlash("Projekt nicht gefunden", "error");
|
||||||
|
$this->redirect("ConstructionConsentProject");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Get faulty owner entries
|
||||||
|
$faultyEntries = ConstructionConsentProject::getFaultyOwnerEntries($projectId);
|
||||||
|
|
||||||
|
$JSGlobals = [
|
||||||
|
"BASE_URL" => self::getUrl(""),
|
||||||
|
"DASHBOARD_URL" => self::getUrl("Dashboard"),
|
||||||
|
"MFAPPNAME" => MFAPPNAME_SLUG,
|
||||||
|
"PAGE_TITLE" => "Fehlerhafte Einträge - Zustimmungserklärungen",
|
||||||
|
"PATH" => [
|
||||||
|
["text" => MFAPPNAME_SLUG, "href" => self::getUrl("Dashboard")],
|
||||||
|
["text" => "Zustimmungserklärungen", "href" => self::getUrl("ConstructionConsent")],
|
||||||
|
["text" => "Fehlerhafte Einträge", "href" => self::getUrl("ConstructionConsent", "faultyEntries")],
|
||||||
|
],
|
||||||
|
"FAULTY_ENTRIES" => $faultyEntries,
|
||||||
|
"SELECTED_PROJECT" => $projectId,
|
||||||
|
"IS_ADMIN" => $this->me->is("Admin"),
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->layout()->set("vueViewName", "ConstructionConsentFaultyEntries");
|
||||||
|
$this->layout()->set("JSGlobals", $JSGlobals);
|
||||||
|
$this->layout()->setTemplate("VueViews/Vue");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ class ConstructionConsentOwner extends mfBaseModel {
|
|||||||
$model = new ConstructionConsentOwner();
|
$model = new ConstructionConsentOwner();
|
||||||
|
|
||||||
$table_fields = [
|
$table_fields = [
|
||||||
"constructionconsent_id", "title", "firstname", "lastname", "street", "zip", "city", "country",
|
"constructionconsent_id", "title", "company", "firstname", "lastname", "street", "zip", "city", "country",
|
||||||
"phone", "phone2", "birthdate", "fax", "email", "status", "result", "create_by","edit_by","create","edit"
|
"phone", "phone2", "birthdate", "fax", "email", "status", "result", "create_by","edit_by","create","edit"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ class ConstructionConsentOwnerController extends mfBaseController
|
|||||||
$data["constructionconsent_id"] = $cc_id;
|
$data["constructionconsent_id"] = $cc_id;
|
||||||
$data["title"] = $r->title;
|
$data["title"] = $r->title;
|
||||||
$data["firstname"] = $r->firstname;
|
$data["firstname"] = $r->firstname;
|
||||||
|
$data["company"] = $r->company;
|
||||||
$data["lastname"] = $r->lastname;
|
$data["lastname"] = $r->lastname;
|
||||||
$data["street"] = $r->street;
|
$data["street"] = $r->street;
|
||||||
$data["zip"] = $r->zip;
|
$data["zip"] = $r->zip;
|
||||||
@@ -123,7 +124,7 @@ class ConstructionConsentOwnerController extends mfBaseController
|
|||||||
} else {
|
} else {
|
||||||
$journal = ConstructionConsentJournal::create([
|
$journal = ConstructionConsentJournal::create([
|
||||||
"constructionconsent_id" => $cc->id,
|
"constructionconsent_id" => $cc->id,
|
||||||
"text" => "Eigentümer " . $item->firstname . " " . $item->lastname . " wurde hinzugefügt"
|
"text" => "Eigentümer " . ($item->company ? $item->company : $item->firstname . " " . $item->lastname) . " wurde hinzugefügt"
|
||||||
]);
|
]);
|
||||||
$journal->save();
|
$journal->save();
|
||||||
|
|
||||||
@@ -151,7 +152,7 @@ class ConstructionConsentOwnerController extends mfBaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach($owner->files as $file) {
|
foreach($owner->files as $file) {
|
||||||
$file->file->delete();
|
if ($file->file) $file->file->delete();
|
||||||
$file->delete();
|
$file->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -237,4 +237,179 @@ class ConstructionConsentProject extends mfBaseModel {
|
|||||||
//var_dump($filter, $where);exit;
|
//var_dump($filter, $where);exit;
|
||||||
return $where;
|
return $where;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if there are faulty owner entries in the Construction Consent system
|
||||||
|
* for a specific project
|
||||||
|
*
|
||||||
|
* A faulty entry is defined as one where:
|
||||||
|
* - Title is empty AND (first name is empty OR last name is empty OR city is empty OR zip code is invalid)
|
||||||
|
* - For Austrian addresses, zip code must be exactly 4 digits
|
||||||
|
* - For other countries, zip code must not be empty
|
||||||
|
*
|
||||||
|
* @param int $projectId The ID of the construction consent project to check
|
||||||
|
* @return bool Returns true if faulty entries exist, false otherwise
|
||||||
|
*/
|
||||||
|
public static function hasFaultyOwnerEntries(int $projectId): bool {
|
||||||
|
if (empty($projectId)) return false;
|
||||||
|
|
||||||
|
$db = FronkDB::singleton();
|
||||||
|
|
||||||
|
$sql = "SELECT 1
|
||||||
|
FROM ConstructionConsentOwner cco
|
||||||
|
JOIN ConstructionConsent cc ON cc.id = cco.constructionconsent_id
|
||||||
|
WHERE cc.constructionconsentproject_id = $projectId
|
||||||
|
AND (
|
||||||
|
(
|
||||||
|
(
|
||||||
|
(cco.company IS NOT NULL AND TRIM(cco.company) <> '') OR
|
||||||
|
(
|
||||||
|
(cco.firstname IS NOT NULL AND TRIM(cco.firstname) <> '') AND
|
||||||
|
(cco.lastname IS NOT NULL AND TRIM(cco.lastname) <> '')
|
||||||
|
)
|
||||||
|
) OR
|
||||||
|
(cco.city IS NULL OR TRIM(cco.city) = '')
|
||||||
|
)
|
||||||
|
AND
|
||||||
|
(
|
||||||
|
(
|
||||||
|
(LOWER(cco.country) = 'österreich' OR LOWER(cco.country) = 'austria') AND
|
||||||
|
(cco.zip IS NULL OR cco.zip NOT REGEXP '^[0-9]{4}')
|
||||||
|
)
|
||||||
|
OR
|
||||||
|
/* For other countries: ZIP must not be empty */
|
||||||
|
(
|
||||||
|
(LOWER(cco.country) != 'österreich' AND LOWER(cco.country) != 'austria') AND
|
||||||
|
(cco.zip IS NULL OR TRIM(cco.zip) = '')
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
LIMIT 1";
|
||||||
|
|
||||||
|
$res = $db->query($sql);
|
||||||
|
|
||||||
|
return ($res->num_rows > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getFaultyOwnerEntries($projectId = null) {
|
||||||
|
$faultyEntries = [];
|
||||||
|
$db = FronkDB::singleton();
|
||||||
|
|
||||||
|
$whereClause = "";
|
||||||
|
if (!empty($projectId)) {
|
||||||
|
$projectId = (int)$projectId;
|
||||||
|
$whereClause = "WHERE cc.constructionconsentproject_id = $projectId";
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = "
|
||||||
|
SELECT
|
||||||
|
cco.id as owner_id,
|
||||||
|
cco.firstname,
|
||||||
|
cco.lastname,
|
||||||
|
cco.title,
|
||||||
|
cco.street,
|
||||||
|
cco.zip,
|
||||||
|
cco.city,
|
||||||
|
cco.country,
|
||||||
|
cco.email,
|
||||||
|
cco.phone,
|
||||||
|
cco.status,
|
||||||
|
cco.result,
|
||||||
|
cc.id as consent_id,
|
||||||
|
cc.name as building_name,
|
||||||
|
cc.object_type,
|
||||||
|
ccp.id as project_id,
|
||||||
|
ccp.name as project_name,
|
||||||
|
cco.create,
|
||||||
|
cco.edit
|
||||||
|
FROM
|
||||||
|
ConstructionConsentOwner cco
|
||||||
|
JOIN
|
||||||
|
ConstructionConsent cc ON cc.id = cco.constructionconsent_id
|
||||||
|
JOIN
|
||||||
|
ConstructionConsentProject ccp ON ccp.id = cc.constructionconsentproject_id
|
||||||
|
$whereClause
|
||||||
|
AND (
|
||||||
|
(
|
||||||
|
(cco.company IS NOT NULL AND TRIM(cco.company) <> '') OR
|
||||||
|
(
|
||||||
|
(cco.firstname IS NOT NULL AND TRIM(cco.firstname) <> '') AND
|
||||||
|
(cco.lastname IS NOT NULL AND TRIM(cco.lastname) <> '')
|
||||||
|
)
|
||||||
|
) OR
|
||||||
|
(cco.city IS NULL OR TRIM(cco.city) = '')
|
||||||
|
) -- Fixed parenthesis balance here
|
||||||
|
AND (
|
||||||
|
(
|
||||||
|
(LOWER(cco.country) = 'österreich' OR LOWER(cco.country) = 'austria') AND
|
||||||
|
(cco.zip IS NULL OR cco.zip NOT REGEXP '^[0-9]{4}')
|
||||||
|
)
|
||||||
|
OR
|
||||||
|
(
|
||||||
|
(LOWER(cco.country) != 'österreich' AND LOWER(cco.country) != 'austria') AND
|
||||||
|
(cco.zip IS NULL OR TRIM(cco.zip) = '')
|
||||||
|
)
|
||||||
|
)
|
||||||
|
ORDER BY
|
||||||
|
ccp.name, cc.name, cco.lastname, cco.firstname
|
||||||
|
|
||||||
|
";
|
||||||
|
|
||||||
|
$res = $db->query($sql);
|
||||||
|
|
||||||
|
while($data = $res->fetch_assoc()) {
|
||||||
|
$errors = [];
|
||||||
|
|
||||||
|
// Check if company is empty, OR if both firstname and lastname are empty
|
||||||
|
if (empty(trim($data['company']))) {
|
||||||
|
if (empty(trim($data['firstname']))) {
|
||||||
|
$errors[] = 'firstname';
|
||||||
|
}
|
||||||
|
if (empty(trim($data['lastname']))) {
|
||||||
|
$errors[] = 'lastname';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Existing city check (assuming it's still relevant for faulty entries)
|
||||||
|
if (empty(trim($data['city']))) {
|
||||||
|
$errors[] = 'city';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check ZIP based on country
|
||||||
|
$isAustria = (strtolower($data['country']) === 'österreich' || strtolower($data['country']) === 'austria');
|
||||||
|
|
||||||
|
if ($isAustria && (!isset($data['zip']) || !preg_match('/^[0-9]{4}$/', $data['zip']))) {
|
||||||
|
$errors[] = 'zip';
|
||||||
|
} elseif (!$isAustria && empty(trim($data['zip']))) {
|
||||||
|
$errors[] = 'zip';
|
||||||
|
}
|
||||||
|
|
||||||
|
$faultyEntries[] = [
|
||||||
|
'owner_id' => $data['owner_id'],
|
||||||
|
'consent_id' => $data['consent_id'],
|
||||||
|
'project_id' => $data['project_id'],
|
||||||
|
'project_name' => $data['project_name'],
|
||||||
|
'building_name' => $data['building_name'],
|
||||||
|
'object_type' => $data['object_type'],
|
||||||
|
'title' => $data['title'],
|
||||||
|
'firstname' => $data['firstname'],
|
||||||
|
'lastname' => $data['lastname'],
|
||||||
|
'street' => $data['street'],
|
||||||
|
'zip' => $data['zip'],
|
||||||
|
'city' => $data['city'],
|
||||||
|
'country' => $data['country'],
|
||||||
|
'email' => $data['email'],
|
||||||
|
'phone' => $data['phone'],
|
||||||
|
'status' => $data['status'],
|
||||||
|
'result' => $data['result'],
|
||||||
|
'create' => $data['create'],
|
||||||
|
'edit' => $data['edit'],
|
||||||
|
'errors' => $errors
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $faultyEntries;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Phinx\Migration\AbstractMigration;
|
||||||
|
|
||||||
|
final class ConstrConsOwnerAddCompany extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
if($this->getEnvironment() == "addressdb") {
|
||||||
|
$ConstructionConsentOwner = $this->table("ConstructionConsentOwner");
|
||||||
|
$ConstructionConsentOwner->addColumn("company", "string", ["limit" => 255, "null" => true]);
|
||||||
|
|
||||||
|
$ConstructionConsentOwner->update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
if($this->getEnvironment() == "addressdb") {
|
||||||
|
$ConstructionConsentOwner = $this->table("ConstructionConsentOwner");
|
||||||
|
$ConstructionConsentOwner->removeColumn("company");
|
||||||
|
|
||||||
|
$ConstructionConsentOwner->update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,200 @@
|
|||||||
|
Vue.component('construction-consent-faulty-entries', {
|
||||||
|
//language=Vue
|
||||||
|
template: `
|
||||||
|
<div>
|
||||||
|
<tt-card>
|
||||||
|
|
||||||
|
<tt-table :data="window['TT_CONFIG']['FAULTY_ENTRIES']" :config="FaultyEntriesTableConfig" excel-export>
|
||||||
|
<template v-slot:project_name="{ row }">
|
||||||
|
{{ row.project_name }}
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template v-slot:building_info="{ row }">
|
||||||
|
<div>
|
||||||
|
<strong>Name:</strong> {{ row.building_name || 'N/A' }} <br>
|
||||||
|
<strong>Typ:</strong> {{ formatObjectType(row.object_type) }}
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template v-slot:owner_info="{ row }">
|
||||||
|
<div>
|
||||||
|
<div v-if="row.company" :class="{'text-danger': row.errors.includes('company')}">
|
||||||
|
<strong>Firma:</strong> {{ row.company }}
|
||||||
|
</div>
|
||||||
|
<div v-else>
|
||||||
|
<div :class="{'text-danger': row.errors.includes('firstname')}">
|
||||||
|
<strong>Vorname:</strong> {{ row.firstname || '⚠️ Fehlt' }}
|
||||||
|
</div>
|
||||||
|
<div :class="{'text-danger': row.errors.includes('lastname')}">
|
||||||
|
<strong>Nachname:</strong> {{ row.lastname || '⚠️ Fehlt' }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template v-slot:address_info="{ row }">
|
||||||
|
<div>
|
||||||
|
<div>
|
||||||
|
<strong>Straße:</strong> {{ row.street || 'N/A' }}
|
||||||
|
</div>
|
||||||
|
<div :class="{'text-danger': row.errors.includes('zip')}">
|
||||||
|
<strong>PLZ:</strong> {{ row.zip || '⚠️ Fehlt' }}
|
||||||
|
<span v-if="row.errors.includes('zip') && isAustria(row)" class="badge badge-warning">
|
||||||
|
Muss 4-stellig sein
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div :class="{'text-danger': row.errors.includes('city')}">
|
||||||
|
<strong>Stadt:</strong> {{ row.city || '⚠️ Fehlt' }}
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<strong>Land:</strong> {{ row.country || 'N/A' }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template v-slot:contact_info="{ row }">
|
||||||
|
<div>
|
||||||
|
<div>
|
||||||
|
<strong>Email:</strong> {{ row.email || 'N/A' }}
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<strong>Telefon:</strong> {{ row.phone || 'N/A' }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template v-slot:status="{ row }">
|
||||||
|
<span :class="getStatusBadgeClass(row.status)">
|
||||||
|
{{ formatStatus(row.status) }}
|
||||||
|
</span>
|
||||||
|
<br>
|
||||||
|
<span v-if="row.result" :class="getResultBadgeClass(row.result)">
|
||||||
|
{{ formatResult(row.result) }}
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template v-slot:errors="{ row }">
|
||||||
|
<div class="error-list">
|
||||||
|
<ul class="mb-0 pl-3">
|
||||||
|
<li v-for="error in row.errors" :key="error">
|
||||||
|
{{ formatErrorType(error) }}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template v-slot:actions="{ row }">
|
||||||
|
<div class="btn-group btn-group-sm">
|
||||||
|
<a :href="window['TT_CONFIG']['BASE_URL'] + '/ConstructionConsent/View?id=' + row.consent_id + '&highlight_owner_id=' + row.owner_id"
|
||||||
|
class="btn btn-primary"
|
||||||
|
target="_blank"
|
||||||
|
title="Zustimmungserklärung bearbeiten">
|
||||||
|
<i class="fas fa-edit"></i>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</tt-table>
|
||||||
|
</tt-card>
|
||||||
|
</div>
|
||||||
|
`,
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
window: window,
|
||||||
|
selectedProject: window['TT_CONFIG']['SELECTED_PROJECT'] || '',
|
||||||
|
FaultyEntriesTableConfig: {
|
||||||
|
key: 'FaultyEntriesTable',
|
||||||
|
tableHeader: 'Fehlerhafte Eigentümer-Einträge',
|
||||||
|
defaultPageSize: 20,
|
||||||
|
headers: [
|
||||||
|
{text: 'Projekt', key: 'project_name', sortable: true, class: 'text-nowrap', priority: 10},
|
||||||
|
{text: 'Objekt', key: 'building_info', sortable: true, sortKey: 'building_name', class: 'text-nowrap', priority: 9},
|
||||||
|
{text: 'Eigentümer', key: 'owner_info', sortable: true, sortKey: 'lastname', class: '', priority: 8},
|
||||||
|
{text: 'Adresse', key: 'address_info', sortable: true, sortKey: 'city', class: '', priority: 7},
|
||||||
|
{text: 'Kontakt', key: 'contact_info', sortable: false, class: '', priority: 6},
|
||||||
|
{text: 'Status', key: 'status', sortable: true, class: 'text-center', priority: 5, filter: 'select', filterOptions: [
|
||||||
|
{text: 'Neu', value: 'new'},
|
||||||
|
{text: 'Gesendet', value: 'sent'},
|
||||||
|
{text: 'Zurückgekehrt', value: 'returned'},
|
||||||
|
{text: 'Ausstehend', value: 'outstanding'},
|
||||||
|
]},
|
||||||
|
{text: 'Fehler', key: 'errors', sortable: false, class: '', priority: 4},
|
||||||
|
{text: 'Aktionen', key: 'actions', sortable: false, class: 'text-center', filter: false, priority: 3},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
formatDate(timestamp) {
|
||||||
|
if (!timestamp) return 'N/A';
|
||||||
|
return this.window.moment.unix(timestamp).format('DD.MM.YYYY HH:mm:ss');
|
||||||
|
},
|
||||||
|
formatObjectType(type) {
|
||||||
|
const types = {
|
||||||
|
'building': 'Gebäude',
|
||||||
|
'street': 'Straße'
|
||||||
|
};
|
||||||
|
return types[type] || type;
|
||||||
|
},
|
||||||
|
formatStatus(status) {
|
||||||
|
const statuses = {
|
||||||
|
'new': 'Neu',
|
||||||
|
'sent': 'Gesendet',
|
||||||
|
'returned': 'Zurückgekehrt',
|
||||||
|
'outstanding': 'Ausstehend'
|
||||||
|
};
|
||||||
|
return statuses[status] || status;
|
||||||
|
},
|
||||||
|
formatResult(result) {
|
||||||
|
const results = {
|
||||||
|
'open': 'Offen',
|
||||||
|
'accepted': 'Akzeptiert',
|
||||||
|
'denied': 'Abgelehnt',
|
||||||
|
'unresolvable': 'Nicht lösbar',
|
||||||
|
'moved': 'Umgezogen'
|
||||||
|
};
|
||||||
|
return results[result] || result;
|
||||||
|
},
|
||||||
|
formatErrorType(error) {
|
||||||
|
const errors = {
|
||||||
|
'company': 'Fehlende Firma',
|
||||||
|
'firstname': 'Fehlender Vorname',
|
||||||
|
'lastname': 'Fehlender Nachname',
|
||||||
|
'city': 'Fehlende Stadt',
|
||||||
|
'zip': 'Ungültige PLZ'
|
||||||
|
};
|
||||||
|
return errors[error] || error;
|
||||||
|
},
|
||||||
|
getStatusBadgeClass(status) {
|
||||||
|
const classes = {
|
||||||
|
'new': 'badge badge-secondary',
|
||||||
|
'sent': 'badge badge-primary',
|
||||||
|
'returned': 'badge badge-success',
|
||||||
|
'outstanding': 'badge badge-warning'
|
||||||
|
};
|
||||||
|
return classes[status] || 'badge badge-secondary';
|
||||||
|
},
|
||||||
|
getResultBadgeClass(result) {
|
||||||
|
const classes = {
|
||||||
|
'open': 'badge badge-info',
|
||||||
|
'accepted': 'badge badge-success',
|
||||||
|
'denied': 'badge badge-danger',
|
||||||
|
'unresolvable': 'badge badge-dark',
|
||||||
|
'moved': 'badge badge-warning'
|
||||||
|
};
|
||||||
|
return classes[result] || 'badge badge-secondary';
|
||||||
|
},
|
||||||
|
isAustria(row) {
|
||||||
|
return row.country && (row.country.toLowerCase() === 'österreich' || row.country.toLowerCase() === 'austria');
|
||||||
|
},
|
||||||
|
filterByProject() {
|
||||||
|
// Redirect to same page with project filter
|
||||||
|
window.location.href = this.window['TT_CONFIG']['BASE_URL'] +
|
||||||
|
'/ConstructionConsent/faultyEntries' +
|
||||||
|
(this.selectedProject ? '?project_id=' + this.selectedProject : '');
|
||||||
|
},
|
||||||
|
refreshData() {
|
||||||
|
// Reload the current page
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user