added new file upload and bug fix

This commit is contained in:
Luca Haid
2025-06-18 14:51:51 +02:00
parent 2167ed1310
commit 2357a43911
5 changed files with 105 additions and 1 deletions

View File

@@ -164,6 +164,14 @@ $pagination_entity_name = "Zustimmungserklärungen";
</select>
</div>
<div class="col-1">
<label class="form-label" for="filter_deferred">Aufgeschoben</label>
<select name="filter[deferred]" id="filter_deferred" class="form-control">
<option value="">Alle</option>
<option value="!NULL" <?=(array_key_exists("deferred", $filter) && $filter["deferred"] == "!NULL") ? "selected='selected'" : ""?>>Ja</option>
<option value="NULL" <?=(array_key_exists("deferred", $filter) && $filter["deferred"] == "NULL") ? "selected='selected'" : ""?>>Nein</option>
</select>
</div>
</div>

View File

@@ -132,6 +132,13 @@ $pagination_entity_name = "Adressen";
<input type="checkbox" id="prioritize" class="switchery" data-size="small" data-color="#25b343" data-toggle-param="prioritize" <?=($item->prioritize) ? "checked='checked'" : ""?> />
</td>
</tr>
<tr>
<th>Aufschieben</th>
<td>
<input type="checkbox" id="deferred" class="switchery" data-size="small" data-color="#25b343" data-toggle-param="deferred" <?=($item->deferred) ? "checked='checked'" : ""?> />
</td>
</tr>
<?php if($item->object_type == "building"): ?>
<tr>
<td colspan="2"><h4>Metadaten</h4></td>
@@ -1205,7 +1212,45 @@ $pagination_entity_name = "Adressen";
}
}, 'json');
}
});
});
$("#deferred").on("change", function() {
const reason = prompt("Bitte geben Sie einen Grund für das Zurückstellen 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());
return;
} if (true) {
$.post("<?php echo self::getUrl("ConstructionConsentJournal", "save")?>", {
consent_id: <?=$item->id?>,
text: `Genehmigung zurückgestellt 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", "defer")?>", {
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() {

View File

@@ -646,6 +646,15 @@ FROM ConstructionConsent
}
}
if(array_key_exists("deferred", $filter)) {
$approve_override = $filter["deferred"];
if($approve_override == "!NULL") {
$where .= " AND (deferred IS NOT NULL AND deferred != 0)";
} elseif($approve_override == "NULL") {
$where .= " AND (deferred IS NULL OR deferred = 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 deferAction() {
$consent_id = $this->request->consent_id;
$checked = $this->request->checked;
$consent = new ConstructionConsent($consent_id);
if(!$consent->id) {
$this->returnJson(["status" => "error"]);
}
$consent->update(["deferred" => $checked]);
$consent->save();
$this->returnJson(["status" => "OK"]);
}
protected function prioritizeAction() {
$consent_id = $this->request->consent_id;
$checked = $this->request->checked;

View File

@@ -0,0 +1,27 @@
<?php /** @noinspection ALL */
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class ConstrConsentAddDeferred extends AbstractMigration
{
public function up(): void
{
if ($this->getEnvironment() == "thetool") {
$table = $this->table('ConstructionConsent');
$table->addColumn('deferred', 'boolean', ['null' => true, 'default' => false])
->save();
}
}
public function down(): void
{
if ($this->getEnvironment() == "thetool") {
$table = $this->table('ConstructionConsent');
$table->removeColumn('deferred')
->save();
}
}
}
// ALTER TABLE `ConstructionConsent` ADD COLUMN `deferred` BOOLEAN NULL DEFAULT FALSE AFTER `text`;