Merge branch 'ConstructionConsent/add-new' into 'master'

-

See merge request fronk/thetool!1291
This commit is contained in:
Luca Haid
2025-05-06 09:29:15 +00:00
6 changed files with 91 additions and 15 deletions

View File

@@ -457,10 +457,15 @@ foreach ($owners as $owner):
<div class="borderpoint">
<h3>Übersichtsplan / Planskizze</h3>
<?php if ($owner->consent->file && $owner->consent->file->file_id && $owner->consent->file->file->fileExists()): ?>
<?php if (
$owner->consent->file &&
$owner->consent->file->file_id &&
$owner->consent->file->file !== null && // Explicitly check if $owner->consent->file->file is not null
$owner->consent->file->file->fileExists()
): ?>
<img src="<?= $owner->consent->file->file->asDataUrl() ?>" style="max-width: 640px; max-height: 640px; border: 1px solid #000"/>
<?php endif; ?>
</div>
<div class="signature-line mt-4">

View File

@@ -170,7 +170,9 @@ $pagination_entity_name = "Zustimmungserklärungen";
<?php endif; ?>
</div>
<div class="col text-right">
<a class="btn btn-success" href="<?=self::getUrl("ConstructionConsent", "downloadMultiple", ["filter" => $filter])?>"><i class="fas fa-download"></i> Zustimmungserklärungen herunterladen</a>
<a class="btn btn-success text-white" style="cursor: pointer" data-toggle="modal" data-target="#downloadModal">
<i class="fas fa-download"></i> Zustimmungserklärungen herunterladen
</a>
</div>
</div>
</form>
@@ -397,8 +399,11 @@ $pagination_entity_name = "Zustimmungserklärungen";
} elseif (isset($item->owner_result_counts['denied']) && $item->owner_result_counts['denied'] > 0) {
$status_class = 'red';
// Red if at least one denied
} elseif ((isset($item->owner_result_counts['unresolvable']) && $item->owner_result_counts['unresolvable'] > 0) ||
(isset($item->owner_result_counts['moved']) && $item->owner_result_counts['moved'] > 0)) {
} elseif (
(isset($item->owner_result_counts['unresolvable']) && $item->owner_result_counts['unresolvable'] > 0) ||
(isset($item->owner_result_counts['moved']) && $item->owner_result_counts['moved'] > 0) ||
(isset($item->owner_result_counts['open']) && $item->owner_result_counts['open'] > 0)
) {
$status_class = 'yellow'; // Yellow if at least one unresolvable or moved
} elseif (isset($item->owner_result_counts['accepted']) &&
$item->owner_result_counts['accepted'] === count($item->owners)) {
@@ -431,6 +436,30 @@ $pagination_entity_name = "Zustimmungserklärungen";
</div>
</div>
<div class="modal fade" id="downloadModal" tabindex="-1" role="dialog" aria-labelledby="downloadModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="downloadModalLabel">Zustimmungserklärungen herunterladen</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="markAsSentCheckbox">
<label class="custom-control-label text-danger" for="markAsSentCheckbox">Zustimmungserklärungen auf verschickt setzen?</label>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Abbrechen</button>
<button type="button" class="btn btn-success" id="confirmDownload">Herunterladen</button>
</div>
</div>
</div>
</div>
<style>
/* Styles for the status circle */
.status-circle {
@@ -505,6 +534,17 @@ $pagination_entity_name = "Zustimmungserklärungen";
window.notify('error', 'Fehler beim Verarbeiten oder Importieren der CSV-Daten.');
}
});
const downloadURLWithoutMarkAsSent = '<?=self::getUrl("ConstructionConsent", "downloadMultiple", ["filter" => $filter])?>';
const downloadURLWithMarkAsSent = '<?=self::getUrl("ConstructionConsent", "downloadMultiple", ["filter" => $filter, "markAsSent" => 1])?>';
document.getElementById('confirmDownload').addEventListener('click', () => {
const markAsSent = document.getElementById('markAsSentCheckbox').checked;
const downloadURL = markAsSent ? downloadURLWithMarkAsSent : downloadURLWithoutMarkAsSent;
window.open(downloadURL, '_blank');
$('#downloadModal').modal('hide');
});
});
</script>

View File

@@ -286,8 +286,11 @@ $pagination_entity_name = "Adressen";
$status_class = 'blue'; // Default to blue (all open)
if (isset($item->owner_result_counts['denied']) && $item->owner_result_counts['denied'] > 0) {
$status_class = 'red'; // Red if at least one denied
} elseif ((isset($item->owner_result_counts['unresolvable']) && $item->owner_result_counts['unresolvable'] > 0) ||
(isset($item->owner_result_counts['moved']) && $item->owner_result_counts['moved'] > 0)) {
} elseif (
(isset($item->owner_result_counts['unresolvable']) && $item->owner_result_counts['unresolvable'] > 0) ||
(isset($item->owner_result_counts['moved']) && $item->owner_result_counts['moved'] > 0) ||
(isset($item->owner_result_counts['open']) && $item->owner_result_counts['open'] > 0)
) {
$status_class = 'yellow'; // Yellow if at least one unresolvable or moved
} elseif (isset($item->owner_result_counts['accepted']) &&
$item->owner_result_counts['accepted'] === count($item->owners)) {
@@ -930,8 +933,15 @@ $pagination_entity_name = "Adressen";
.addClass("text-success")
.data("status-id", update.status);
// find result-id-text and result-it-resulttext and set it to "Offen" / open if data-result-id has nothing
if($("#result-" + update.id + "-text").data("result-id") == "") {
$("#result-" + update.id + "-text").data("result-id", "open").addClass("text-success");
$("#result-" + update.id + "-resulttext").text("Offen");
}
setTimeout(() => {
$("#status-" + update.id + "-text").removeClass("text-success")
$("#result-" + update.id + "-text").removeClass("text-success")
}, 1500);
toggleStatusControl(oid);
@@ -1180,7 +1190,7 @@ $pagination_entity_name = "Adressen";
.ConstructionConsentOwnerResult-open {
/*grey background color here for this tr*/
background-color: #eaeaea
background-color: #ffe58e
}
.ConstructionConsentOwnerResult-accepted {

View File

@@ -422,6 +422,10 @@ class ConstructionConsent extends mfBaseModel {
WHEN approve_override = 1 THEN 0
ELSE (cwo.result = 'unresolvable')
END), 0) > 0
OR COALESCE(SUM(CASE
WHEN approve_override = 1 THEN 0
ELSE (cwo.result = 'open')
END), 0) > 0
OR COALESCE(SUM(CASE
WHEN approve_override = 1 THEN 0
ELSE (cwo.result = 'moved')

View File

@@ -189,20 +189,33 @@ class ConstructionConsentController extends mfBaseController {
protected function downloadMultipleAction()
{
// Reuse index filter logic
$filter = $this->getPreparedFilter($this->request->filter);
$owners = [];
foreach (ConstructionConsent::search($filter, []) as $consent) {
foreach (ConstructionConsent::search($this->getPreparedFilter($this->request->filter), []) as $consent)
$owners = array_merge($owners, $consent->owners ?: []);
}
if (empty($owners)) {
$this->layout()->setFlash("Keine Besitzer gefunden", "error");
$this->redirect("ConstructionConsent");
}
// Use first consent as base - might need adjustment for your use case
if ($this->request->markAsSent === '1') {
foreach ($owners as $owner) {
$update = $owner->status === 'new' || $owner->status === null;
if ($owner->status === 'new') $owner->status = 'sent';
if ($owner->result === null) $owner->result = 'open';
if ($update) {
$owner->save();
$history = ConstructionConsentHistory::create([
"constructionconsent_id" => $owner->consent->id,
"key" => "status",
"old_value" => 'new',
"new_value" => 'sent'
]);
$history->save();
}
}
}
if (!($filename = $this->generatePdf($owners, $owners[0]->consent))) {
$this->layout()->setFlash("PDF-Erstellung fehlgeschlagen", "error");
$this->redirect("ConstructionConsent");
@@ -214,7 +227,7 @@ class ConstructionConsentController extends mfBaseController {
private function sendPdfResponse(string $filename, string $downloadName): void
{
header('Content-Type: ' . mime_content_type($filename));
header('Content-disposition: attachment; filename="' . $downloadName . '"');
header('Content-disposition: attachment; filename="' . rawurlencode($downloadName) . '"');
header('Content-Length: ' . filesize($filename));
readfile($filename);
exit;

View File

@@ -9,6 +9,10 @@ class ConstructionConsentOwner extends mfBaseModel {
protected function afterSave() {
$this->createHistory();
if($this->data->status !== 'new' && $this->data->result === null) {
$this->data->result = 'open';
$this->save();
}
}
protected function beforeDelete() {