Added saving Remarks to workorder and to rimo in Preorder

This commit is contained in:
Frank Schubert
2025-03-04 18:26:27 +01:00
parent dc4755d7fd
commit cf7f70b7ea
4 changed files with 123 additions and 0 deletions

View File

@@ -1273,5 +1273,44 @@ $pagination_entity_name = "Vorbestellungen";
});
}
async function saveRemark(pid, wid) {
if(!pid || !wid) return false;
var new_remark_elem = $("#wo-remark-" + pid + "-" + wid + " input[name='new_remark']");
var new_remark = new_remark_elem.val();
new_remark_elem.prop("readonly", true);
await fetch("<?=self::getUrl("Preorder", "Api")?>", {
method: "POST",
headers: {
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
},
body: new URLSearchParams({
do: "addWorkorderRemark",
preorder_id: pid,
workorder_id: wid,
remark: new_remark
})
}).then(resp => {
if(resp.ok) {
return resp.json();
}
}).then((data) => {
if(data.status == "OK") {
var remark = data.result.remark.replaceAll("\n", "<br />");
$("#wo-remark-" + pid + "-" + wid + " div.remark-text").html(remark);
new_remark_elem.val("");
window.notify("success", "Bemerkung gespeichert");
} else {
window.notify("error", "Fehler beim Speichern der Bemerkung");
}
});
new_remark_elem.prop("readonly", false);
}
</script>
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>

View File

@@ -425,6 +425,20 @@
<th>Erstellt</th>
<td class="text-monospace"><?=date("d.m.Y H:i:s", $wo->create)?></td>
</tr>
<tr>
<th>Bemerkung</th>
<td id="wo-remark-<?=$preorder->id?>-<?=$wo->id?>">
<div class="input-group mb-2">
<input type="text" class="form-control" name="new_remark" placeholder="Bemerkung hinzufügen" />
<div class="input-group-append">
<button class="btn btn-primary" type="button" id="button-addon2" onclick="saveRemark(<?=$preorder->id?>, <?=$wo->id?>)">Hinzufügen</button>
</div>
</div>
<div class="remark-text border p-1 text-monospace" id="preorder-detail-<?=$preorder->id?>-workorder-<?=$wo->id?>-remarks">
<?=nl2br(htmlentities($wo->remarks))?>
</div>
</td>
</tr>
</table>
<?php endforeach; ?>