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

added new features

See merge request fronk/thetool!1435
This commit is contained in:
Luca Haid
2025-06-11 10:24:07 +00:00
6 changed files with 129 additions and 1 deletions

View File

@@ -468,6 +468,21 @@ foreach ($owners as $owner):
</div>
<table class="consent-table">
<tr>
<th>Gst. Nr.</th>
<th>KG</th>
<th>EZ</th>
<th>LWL-Leerrohre und/oder LWL-Kabel (Künette, Inhouse etc.)</th>
</tr>
<tr>
<td><?= $owner->consent->gst ?></td>
<td><?= $owner->consent->kg ?></td>
<td><?= $owner->consent->ez ?></td>
<td>ca. <?= $owner->consent->usage_length ?> lfm (exkl. Beigest. LWL-Wohnungsverkabelung)</td>
</tr>
</table>
<div class="signature-line mt-4">
<div class="float-left" style="width: 25%;">Ort, Datum</div>
<div class="float-right" style="width: 75%;">

View File

@@ -155,6 +155,14 @@ $pagination_entity_name = "Zustimmungserklärungen";
<input type="text" class="form-control" name="filter[cwo]" id=filter_cwo value="<?=(array_key_exists('cwo', $filter)) ? $filter['cwo'] : ""?>" />
</div>
<div class="col-1">
<label class="form-label" for="filter_prioritize">Priorisiert</label>
<select name="filter[prioritize]" id="filter_prioritize" class="form-control">
<option value="">Alle</option>
<option value="!NULL" <?=(array_key_exists("prioritize", $filter) && $filter["prioritize"] == "!NULL") ? "selected='selected'" : ""?>>Ja</option>
<option value="NULL" <?=(array_key_exists("prioritize", $filter) && $filter["prioritize"] == "NULL") ? "selected='selected'" : ""?>>Nein</option>
</select>
</div>
</div>

View File

@@ -126,6 +126,12 @@ $pagination_entity_name = "Adressen";
<input type="checkbox" id="approve_override" class="switchery" data-size="small" data-color="#25b343" data-toggle-param="approve_override" <?=($item->approve_override) ? "checked='checked'" : ""?> />
</td>
</tr>
<tr>
<th>Priorisieren</th>
<td>
<input type="checkbox" id="prioritize" class="switchery" data-size="small" data-color="#25b343" data-toggle-param="prioritize" <?=($item->prioritize) ? "checked='checked'" : ""?> />
</td>
</tr>
<?php if($item->object_type == "building"): ?>
<tr>
<td colspan="2"><h4>Metadaten</h4></td>
@@ -1151,11 +1157,16 @@ $pagination_entity_name = "Adressen";
$("#approve_override").on("change", function() {
const reason = prompt("Bitte geben Sie einen Grund für das Überschreiben der Genehmigung ein:");
if (reason != null && reason.length < 3) {
notify("error", "Begründung muss mindestens 3 Zeichen lang sein");
$(this).prop("checked", false);
switcheries.forEach(s => s.setPosition());
ret
if (reason != null) {
$.post("<?php echo self::getUrl("ConstructionConsentJournal", "save")?>", {
consent_id: <?=$item->id?>,
text: `Genehmigung überschreiben wurde ${$(this).prop("checked") ? "aktiviert" : "deaktiviert"} | Begründung: ${reason}`
}, function(success) {
}, function (success) {
if (success.status != "OK") {
notify("error", "Status konnte nicht gespeichert werden");
} else {
@@ -1166,6 +1177,47 @@ $pagination_entity_name = "Adressen";
$.get("<?php echo self::getUrl("ConstructionConsent", "approveOverride")?>", {
consent_id: <?=$item->id?>,
checked: $(this).prop("checked") ? 1 : 0
}, function (success) {
if (success.status != "OK") {
notify("error", "Status konnte nicht gespeichert werden");
setTimeout(() => {
location.reload()
}, 150);
} else {
notify("success", "Status erfolgreich gespeichert");
setTimeout(() => {
location.reload()
}, 150);
}
}, 'json');
}
}});
// do the same for prioritize
$("#prioritize").on("change", function() {
const reason = prompt("Bitte geben Sie einen Grund für die Priorisierung ein:");
// reason must be atleast 3 characters long
if (reason != null && reason.length < 3) {
notify("error", "Begründung muss mindestens 3 Zeichen lang sein");
$(this).prop("checked", false);
switcheries.forEach(s => s.setPosition());
return;
}
if (reason != null) {
$.post("<?php echo self::getUrl("ConstructionConsentJournal", "save")?>", {
consent_id: <?=$item->id?>,
text: `Priorisierung wurde ${$(this).prop("checked") ? "aktiviert" : "deaktiviert"} | Begründung: ${reason}`
}, function(success) {
if (success.status != "OK") {
notify("error", "Status konnte nicht gespeichert werden");
} else {
notify("success", "Status erfolgreich gespeichert");
}
}, 'json');
$.get("<?php echo self::getUrl("ConstructionConsent", "prioritize")?>", {
consent_id: <?=$item->id?>,
checked: $(this).prop("checked") ? 1 : 0
}, function(success) {
if (success.status != "OK") {
notify("error", "Status konnte nicht gespeichert werden");
@@ -1177,6 +1229,7 @@ $pagination_entity_name = "Adressen";
}, 'json');
}
});
});
$(document).ready(function() {

View File

@@ -637,6 +637,15 @@ FROM ConstructionConsent
}
}
if(array_key_exists("prioritize", $filter)) {
$approve_override = $filter["prioritize"];
if($approve_override == "!NULL") {
$where .= " AND (prioritize IS NOT NULL AND prioritize != 0)";
} elseif($approve_override == "NULL") {
$where .= " AND (prioritize IS NULL OR prioritize = 0)";
}
}
if(array_key_exists("conduit_installed_ftu", $filter)) {
$conduit_installed_ftu = $filter["conduit_installed_ftu"];
if($conduit_installed_ftu == "!NULL") {

View File

@@ -1078,6 +1078,21 @@ class ConstructionConsentController extends mfBaseController {
}
protected function prioritizeAction() {
$consent_id = $this->request->consent_id;
$checked = $this->request->checked;
$consent = new ConstructionConsent($consent_id);
if(!$consent->id) {
$this->returnJson(["status" => "error"]);
}
$consent->update(["prioritize" => $checked]);
$consent->save();
$this->returnJson(["status" => "OK"]);
}
protected function importConstructionConsentOwnersAction() {
$projectId = $this->request->project_id;
$importData = json_decode(file_get_contents('php://input'), true);

View File

@@ -0,0 +1,28 @@
<?php
declare(strict_types = 1);
use Phinx\Migration\AbstractMigration;
final class ConstructionConsentAddPrioritize extends AbstractMigration {
public function up(): void {
if ($this->getEnvironment() == "thetool") {
$ConstructionConsentTable = $this->table("ConstructionConsent");
if (!$ConstructionConsentTable->hasColumn("prioritize")) {
$ConstructionConsentTable
->addColumn("approve_override", "tinyinteger", ["default" => 0])
->update();
}
}
}
public function down(): void {
if ($this->getEnvironment() == "thetool") {
$ConstructionConsentTable = $this->table("ConstructionConsent");
if ($ConstructionConsentTable->hasColumn("prioritize")) {
$ConstructionConsentTable
->removeColumn("prioritize")
->update();
}
}
}
}