Merge branch 'fronkdev' into 'master'

PreorderstatusJournal & preorder flags -> ADBHausnummer flags sync

See merge request fronk/thetool!1739
This commit is contained in:
Frank Schubert
2025-09-10 15:41:55 +00:00
11 changed files with 486 additions and 65 deletions

View File

@@ -654,12 +654,6 @@ $pagination_entity_name = "Vorbestellungen";
</div>
</div>
<style>
#email-log-modal p {
margin-top: 8px;
margin-bottom: 8px;
}
</style>
<div class="modal" tabindex="-1" id="email-log-modal" style="max-height: 100vh;">
<div class="modal-dialog modal-dialog-centered modal-xl">
<div class="modal-content" style="overflow: auto;">
@@ -697,7 +691,7 @@ $pagination_entity_name = "Vorbestellungen";
</div>
<div class="row mb-2" id="email-log-body-section">
<div class="col">
<div id="email-log-body-view" style="min-height: 48px; width:100%; border: 1px solid #000; padding: 8px; font-family: sans-serif; overflow-y: auto;"></div>
<iframe id="email-log-body-view" style="height: 50vh; width:100%; border: 1px solid #000; padding: 8px; font-family: sans-serif; overflow-y: auto;"></iframe>
</div>
</div>
@@ -779,11 +773,11 @@ $pagination_entity_name = "Vorbestellungen";
// do: setStatusFlag, preorder_id, flag_id: 1, value (0 or 1)
if (attrib == "inhouse_cabling_supplied") {
var flag_id = 1;
const code = 145;
$.post("<?=self::getUrl("Preorder", "Api")?>", {
do: "setStatusFlag",
preorder_id: preorder_id,
flag_id: flag_id,
code: 145,
value: value
},
function(success) {
@@ -838,6 +832,58 @@ $pagination_entity_name = "Vorbestellungen";
$("#attributes_" + attribute + "-" + id).prop("checked", !$("#attributes_" + attribute + "-" + id).is(":checked"));
}
async function submitStatusJournal(pid) {
var text = $("#preorder-" + pid + "-status-journal-input").val();
if(!text) return;
// disable elements
$("#preorder-" + pid + "-status-journal-input").attr("disabled", "disabled");
$("#preorder-" + pid + "-status-journal button").attr("disabled", "disabled");
// save text
await fetch("<?=self::getUrl("Preorder", "Api")?>", {
method: "POST",
headers: {
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
},
body: new URLSearchParams({
do: "saveStatusJournal",
preorder_id: pid,
text: text
})
}).then(resp => {
if(resp.ok) {
return resp.json();
}
}).then((data) => {
// enable items
$("#preorder-" + pid + "-status-journal-input").attr("disabled", false);
$("#preorder-" + pid + "-status-journal button").attr("disabled", false);
if(data.status == "OK") {
$("#preorder-" + pid + "-status-journal-input").val("");
// get returned data
var new_text = data.result.text;
var creator = data.result.creator;
var create_date = new Date(data.result.create);
var date_ts = create_date.getTime();
var date_string = create_date.toLocaleString("de-DE", {year: "numeric", month: "2-digit", day: "2-digit"}) + " " + String(create_date.getHours()).padStart(2, 0) + ":" + String(create_date.getMinutes()).padStart(2, 0);
// add new journal item
$("#preorder-" + pid + "-status-journal-list").prepend('<tr id="preorder-' + pid + '-status-journal-list-' + date_ts + '"><td class="text-monospace"><small style="white-space: nowrap"><i class="fas fa-clock fa-fw"></i> ' + date_string + '</small> <span style="white-space: nowrap">(' + creator + ')<span></span></td> <td class="text-left">' + new_text + '</td></tr>');
// visual effects
$('#preorder-' + pid + '-status-journal-list-' + date_ts).addClass("text-success").fadeOut(10).fadeIn(400);
setTimeout(() => {$('#preorder-' + pid + '-status-journal-list-' + date_ts).removeClass("text-success")}, 300)
window.notify("success", "Journaleintrag erfolgreich gespeichert.");
} else {
window.notify("error", "Fehler beim Speichern des Journaleintrags");
}
});
return true;
}
/*
@@ -1113,6 +1159,7 @@ $pagination_entity_name = "Vorbestellungen";
var elem = e.target;
var preorder_id = $(elem).data("preorder_id");
var flag_id = $(elem).data("flag_id");
var flag_code = $(elem).data("flag_code");
var value = $(elem).prop("checked") ? 1 : 0;
$.ajax({
@@ -1121,7 +1168,7 @@ $pagination_entity_name = "Vorbestellungen";
data: {
do: "setStatusFlag",
preorder_id: preorder_id,
flag_id: flag_id,
code: flag_code,
value: value
},
dataType: "json",
@@ -1129,9 +1176,10 @@ $pagination_entity_name = "Vorbestellungen";
elem: elem,
preorder_id: preorder_id,
flag_id: flag_id,
flag_code: flag_code,
},
success: function (success) {
var textelem = $("#preorder-" + this.preorder_id + "-statusflag-" + this.flag_id + "-text");
var textelem = $("#preorder-" + this.preorder_id + "-statusflag-" + this.flag_code + "-text");
if(success.status != "OK") {
notify("error","Fehler beim Speichern des Statusflags");
$(this.elem).prop("checked", !$(this.elem).prop("checked"));
@@ -1145,7 +1193,7 @@ $pagination_entity_name = "Vorbestellungen";
// find all inputs with this data-preorder_id="21969" and data-flag_id="3" and set the text to the new value
// always with their own fields and then select / unselect the checkbox
$("input.preorder-statusflag[data-preorder_id='" + this.preorder_id + "'][data-flag_id='" + this.flag_id + "']").each(function() {
$("input.preorder-statusflag[data-preorder_id='" + this.preorder_id + "'][data-flag_code='" + this.flag_code + "']").each(function() {
if(value) {
$(this).prop("checked", true);
} else {
@@ -1771,7 +1819,9 @@ $pagination_entity_name = "Vorbestellungen";
$("#email-log-to-value").text("");
$("#email-log-log-sent-value").text("");
$("#email-log-subject-value").text("");
$("#email-log-view").empty();
document.getElementById("email-log-body-view").contentWindow.document.open();
document.getElementById("email-log-body-view").contentWindow.document.write("<html><body>&nbsp;</body></html>");
document.getElementById("email-log-body-view").contentWindow.document.close();
$("#email-log-attachments-section").hide();
$("#email-log-attachment-list").empty();
hideEmailLogHeaders();
@@ -1816,11 +1866,17 @@ $pagination_entity_name = "Vorbestellungen";
$("#email-log-attachments-section").show();
}
document.getElementById("email-log-body-view").contentWindow.document.open();
if(email.bodyIsHtml) {
$("#email-log-body-view").html(email.body);
document.getElementById("email-log-body-view").contentWindow.document.write(email.body);
} else {
$("#email-logbody-view").text(email.body);
var html_body = '<html lang="de"><head><meta charset="utf-8"></head><body><p>';
html_body += email.body.replaceAll("\r", "").replaceAll("\n", "<br />");
html_body += '</p></body></html>';
document.getElementById("email-log-body-view").contentWindow.document.write(html_body);
}
document.getElementById("email-log-body-view").contentWindow.document.close();
$("#email-log-modal").modal("show");

View File

@@ -749,6 +749,29 @@
</div>
</div>
</div>
<div class="row mt-2" id="preorder-<?=$preorder->id?>-status-journal">
<div class="col">
<h3>Journal</h3>
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text">Neuer Journaleintrag:</span>
</div>
<input type="text" class="form-control preorder-status-journal-input" id="preorder-<?=$preorder->id?>-status-journal-input" />
<div class="input-group-append">
<button type="button" class="btn btn-primary" onclick="submitStatusJournal(<?=$preorder->id?>)">Speichern</button>
</div>
</div>
<table class="table table-sm table-striped" id="preorder-<?=$preorder->id?>-status-journal-list">
<?php foreach(array_reverse($preorder->statusjournals) as $journal): ?>
<tr>
<td class="text-monospace"><small style="white-space: nowrap"><i class="fas fa-clock fa-fw"></i> <?=date("d.m.Y H:i", $journal->create)?></small> <span style="white-space: nowrap">(<?=htmlentities($journal->creator->name)?>)<span></span></td>
<td class="text-left"><?=htmlentities($journal->text)?></td>
</tr>
<?php endforeach; ?>
</table>
</div>
</div>
</div>
<div class="col-6">
<h3>Statusflags</h3>
@@ -757,9 +780,10 @@
<tr>
<th class="text-right">
<input type="checkbox" class="form-control preorder-statusflag"
id="preorder-<?=$preorder->id?>-statusflag-<?=$flag->id?>"
id="preorder-<?=$preorder->id?>-statusflag-<?=$flag->code?>"
data-preorder_id="<?=$preorder->id?>"
data-flag_id="<?=$flag->id?>"
data-flag_code="<?=$flag->code?>"
<?=(array_key_exists($flag->id, $preorder->statusflags) && $preorder->statusflags[$flag->id]->value && $preorder->statusflags[$flag->id]->value->value) ? "checked='checked'" : ""?>
/>
</th>