diff --git a/application/WorkorderCompany/WorkorderCompanyController.php b/application/WorkorderCompany/WorkorderCompanyController.php
index 78e825809..553465c3a 100644
--- a/application/WorkorderCompany/WorkorderCompanyController.php
+++ b/application/WorkorderCompany/WorkorderCompanyController.php
@@ -121,6 +121,23 @@ class WorkorderCompanyController extends WorkorderBaseController {
self::returnJson(['success' => true, 'message' => 'Termin erfolgreich verschoben.']);
}
+ protected function clearAppointmentAction() {
+ if (empty($this->postData['workorderId'])) self::sendError("Arbeitsauftrags-ID fehlt.");
+ $workorder = WorkorderModel::get($this->postData['workorderId']);
+ if (!$workorder) self::sendError("Arbeitsauftrag nicht gefunden.");
+
+ $oldDateFormatted = $workorder->appointmentDate ? date('d.m.Y H:i', $workorder->appointmentDate) : 'N/A';
+ $workorder->appointmentDate = null;
+ $workorder->status = 'assigned';
+ WorkorderModel::update((array)$workorder);
+
+ WorkorderJournalModel::create([
+ 'workorderId' => $workorder->id, 'text' => "Termin gelöscht (war: {$oldDateFormatted}).",
+ 'create' => time(), 'createBy' => $this->user->id,
+ ]);
+ self::returnJson(['success' => true, 'message' => 'Termin erfolgreich gelöscht.']);
+ }
+
protected function requestInterventionAction() {
if (empty($this->postData['workorderId']) || empty($this->postData['journalText'])) self::sendError("Erforderliche Felder fehlen.");
$workorder = WorkorderModel::get($this->postData['workorderId']);
diff --git a/public/js/pages/WorkorderCompany/WorkorderCompany.js b/public/js/pages/WorkorderCompany/WorkorderCompany.js
index ed6e0ec46..a974eb9bc 100644
--- a/public/js/pages/WorkorderCompany/WorkorderCompany.js
+++ b/public/js/pages/WorkorderCompany/WorkorderCompany.js
@@ -65,6 +65,9 @@ Vue.component('workorder-company', {
+
–
@@ -157,6 +160,16 @@ Vue.component('workorder-company', {
this.rescheduleModalData = null;
} else window.notify('error', data.message || 'Ein Fehler ist aufgetreten.');
},
+ async clearAppointment(workorder) {
+ if (!confirm('Möchten Sie den Termin wirklich löschen?')) return;
+ const {data} = await axios.post(`${window.TT_CONFIG.BASE_PATH}/WorkorderCompany/clearAppointment`, {
+ workorderId: workorder.id
+ });
+ if (data.success) {
+ window.notify('success', data.message);
+ this.$refs.table.$refs.table.refreshTable();
+ } else window.notify('error', data.message || 'Ein Fehler ist aufgetreten.');
+ },
startAdditionalInfoEdit(row) {
this.editingAdditionalInfoId = row.id;
this.tempAdditionalInfo = row.additionalInfo || '';