From 8ea51b39008a9cf4c97f0099fe13867d4927c503 Mon Sep 17 00:00:00 2001 From: Luca Haid Date: Wed, 26 Nov 2025 10:58:18 +0100 Subject: [PATCH] Add spliceCompleted functionality and update WorkorderMph components --- .../WorkorderMphAdminController.php | 8 + .../WorkorderMphBaseController.php | 219 +++++++++++------- .../WorkorderMphWohneinheitModel.php | 14 -- ...completed_to_workorder_mph_wohneinheit.php | 36 +++ ...000_refactor_workorder_mph_wohneinheit.php | 60 +++++ docker-compose.yml | 2 +- .../WorkorderMphBase/WorkorderMphBase.css | 31 ++- .../WorkorderMphBase/WorkorderMphBase.js | 190 ++++++++------- 8 files changed, 383 insertions(+), 177 deletions(-) delete mode 100644 application/WorkorderMphWohneinheit/WorkorderMphWohneinheitModel.php create mode 100644 db/migrations/20251126090000_add_splice_completed_to_workorder_mph_wohneinheit.php create mode 100644 db/migrations/20251126100000_refactor_workorder_mph_wohneinheit.php diff --git a/application/WorkorderMphAdmin/WorkorderMphAdminController.php b/application/WorkorderMphAdmin/WorkorderMphAdminController.php index 94b6c3173..1e7571a11 100644 --- a/application/WorkorderMphAdmin/WorkorderMphAdminController.php +++ b/application/WorkorderMphAdmin/WorkorderMphAdminController.php @@ -118,6 +118,14 @@ class WorkorderMphAdminController extends WorkorderMphBaseController ]); } + protected function getWorkorderByIdAction() + { + if (empty($this->request->id)) self::sendError("ID fehlt."); + $workorder = WorkorderMphModel::get($this->request->id); + if (!$workorder) self::sendError("Arbeitsauftrag nicht gefunden."); + self::returnJson((array)$workorder); + } + protected function getCompaniesAction() { $companies = WorkorderCompanyModel::getAll(); diff --git a/application/WorkorderMphBase/WorkorderMphBaseController.php b/application/WorkorderMphBase/WorkorderMphBaseController.php index f0afa7a52..00943af3a 100644 --- a/application/WorkorderMphBase/WorkorderMphBaseController.php +++ b/application/WorkorderMphBase/WorkorderMphBaseController.php @@ -18,29 +18,12 @@ class WorkorderMphBaseController extends TTCrud protected array $additionalJS = ["js/pages/WorkorderMphBase/WorkorderMphBase.js"]; protected array $additionalHead = [""]; - // Wohneinheit status options - protected array $wohneinheitStatuses = [ - ['value' => 1, 'text' => '10 - new'], - ['value' => 12, 'text' => '241 - BEP installed (MD)'], - ['value' => 13, 'text' => '242 - Inhouse cabling finished'], - ['value' => 18, 'text' => '243 - Cable in stairwell'], - ['value' => 14, 'text' => '244 - BEP installed (SD)'], - ['value' => 15, 'text' => '245 - Installation Approved'], - ['value' => 16, 'text' => '300 - ONT installed'], - ]; - protected function getStatusText(string $statusKey): string { $statusMap = array_column($this->statusColumn['table']['filterOptions'] ?? [], 'text', 'value'); return $statusMap[$statusKey] ?? ucfirst(str_replace('_', ' ', $statusKey)); } - protected function getWohneinheitStatusText(int $statusValue): string - { - $statusMap = array_column($this->wohneinheitStatuses, 'text', 'value'); - return $statusMap[$statusValue] ?? "Status $statusValue"; - } - //region SHARED ACTIONS /** * Fetches documentation and journal entries for a given workorder. @@ -143,38 +126,75 @@ class WorkorderMphBaseController extends TTCrud $db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME); $hausnummerId = $db->escape($workorder->hausnummerId); - $sql = "SELECT w.id, w.bezeichner, w.contact, w.oaid, w.note + // Fetch statuses from addressdb + $statusSql = "SELECT id, code, name FROM Status WHERE type = 'wohneinheit' ORDER BY code ASC"; + $statusResult = $db->query($statusSql); + $statuses = $statusResult ? $statusResult->fetch_all(MYSQLI_ASSOC) : []; + + $statusOptions = array_map(function($s) { + return ['value' => intval($s['id']), 'text' => $s['code'] . ' - ' . $s['name'], 'code' => intval($s['code'])]; + }, $statuses); + + // Fetch Wohneinheiten directly + $sql = "SELECT w.id, w.zusatz, w.tuer, w.contact, w.oaid, w.note, w.status_id, w.splice_hak_completed FROM Wohneinheit w WHERE w.hausnummer_id = $hausnummerId - ORDER BY w.bezeichner"; + ORDER BY w.zusatz"; $result = $db->query($sql); $wohneinheiten = $result ? $result->fetch_all(MYSQLI_ASSOC) : []; - // Get existing WorkorderMphWohneinheit records - $existingRecords = WorkorderMphWohneinheitModel::getAll(['workorderMphId' => $workorderMphId]); - $recordsMap = []; - foreach ($existingRecords as $record) { - $recordsMap[$record->wohneinheitId] = $record; + // Get Preorders for this Hausnummer to fallback contact info + $preorders = []; + if (class_exists('PreorderModel')) { + $preorderList = PreorderModel::search(['adb_hausnummer_id' => $workorder->hausnummerId, 'deleted' => 0]); + foreach ($preorderList as $preorder) { + if ($preorder->adb_wohneinheit_id) { + $preorders[$preorder->adb_wohneinheit_id] = $preorder; + } + } } // Merge data $response = []; foreach ($wohneinheiten as $we) { - $record = $recordsMap[$we['id']] ?? null; - // Prefer WorkorderMphWohneinheit note, fallback to addressdb note - $note = $record ? $record->note : $we['note']; + // Contact info logic + $contact = $we['contact']; + $preorderContact = null; + $preorderUcode = null; + + if (isset($preorders[$we['id']])) { + $p = $preorders[$we['id']]; + $preorderUcode = $p->ucode; + $pContact = trim($p->firstname . ' ' . $p->lastname); + if ($p->phone) $pContact .= ' (' . $p->phone . ')'; + + $preorderContact = $pContact; + + // If address contact is empty, use preorder contact + if (empty($contact)) { + $contact = $pContact; + } + } + $response[] = [ 'wohneinheitId' => intval($we['id']), - 'bezeichner' => $we['bezeichner'], - 'contact' => $we['contact'], + 'zusatz' => $we['zusatz'], + 'tuer' => $we['tuer'], + 'contact' => $contact, + 'preorderContact' => $preorderContact, + 'preorderUcode' => $preorderUcode, 'oaid' => $we['oaid'], - 'status' => $record ? $record->status : 1, - 'note' => $note, - 'recordId' => $record ? $record->id : null, + 'status' => intval($we['status_id']), + 'spliceCompleted' => intval($we['splice_hak_completed'] ?? 0), + 'note' => $we['note'], ]; } - self::returnJson(['wohneinheiten' => $response, 'statusOptions' => $this->wohneinheitStatuses]); + self::returnJson([ + 'wohneinheiten' => $response, + 'statusOptions' => $statusOptions, + 'hausnummerId' => $workorder->hausnummerId + ]); } /** @@ -189,63 +209,86 @@ class WorkorderMphBaseController extends TTCrud $workorderMphId = intval($post['workorderMphId']); $wohneinheitId = intval($post['wohneinheitId']); - $status = intval($post['status'] ?? 1); - $note = $post['note'] ?? null; + $newStatusId = intval($post['status'] ?? 1); + $spliceCompleted = isset($post['spliceCompleted']) ? intval($post['spliceCompleted']) : 0; + $tuer = $post['tuer'] ?? null; + $zusatz = $post['zusatz'] ?? null; - // Check if record exists - $existing = WorkorderMphWohneinheitModel::getFirst([ - 'workorderMphId' => $workorderMphId, - 'wohneinheitId' => $wohneinheitId - ]); - - $oldStatus = $existing ? $existing->status : 1; - $oldNote = $existing ? $existing->note : null; - - if ($existing) { - $existing->status = $status; - $existing->note = $note; - $existing->edit = time(); - $existing->editBy = $this->user->id; - WorkorderMphWohneinheitModel::update((array)$existing); - } else { - WorkorderMphWohneinheitModel::create([ - 'workorderMphId' => $workorderMphId, - 'wohneinheitId' => $wohneinheitId, - 'status' => $status, - 'note' => $note, - 'create' => time(), - 'createBy' => $this->user->id - ]); - } - - // Also save note to addressdb.Wohneinheit $db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME); - $escapedNote = $note !== null ? "'" . $db->escape($note) . "'" : "NULL"; $escapedWohneinheitId = $db->escape($wohneinheitId); - $updateSql = "UPDATE Wohneinheit SET note = $escapedNote WHERE id = $escapedWohneinheitId"; + + // Fetch current state + $currentSql = "SELECT status_id, tuer, zusatz, splice_hak_completed FROM Wohneinheit WHERE id = $escapedWohneinheitId"; + $result = $db->query($currentSql); + $current = $result ? $result->fetch_assoc() : null; + + if (!$current) self::sendError("Wohneinheit nicht gefunden."); + + $oldStatusId = intval($current['status_id']); + $oldTuer = $current['tuer']; + $oldZusatz = $current['zusatz']; + $oldSplice = intval($current['splice_hak_completed'] ?? 0); + + // Update Wohneinheit + $escapedTuer = $tuer !== null ? "'" . $db->escape($tuer) . "'" : "NULL"; + $escapedZusatz = $zusatz !== null ? "'" . $db->escape($zusatz) . "'" : "NULL"; + $escapedStatusId = $db->escape($newStatusId); + $escapedSplice = $db->escape($spliceCompleted); + + $updateSql = "UPDATE Wohneinheit SET + status_id = $escapedStatusId, + tuer = $escapedTuer, + zusatz = $escapedZusatz, + splice_hak_completed = $escapedSplice + WHERE id = $escapedWohneinheitId"; + $db->query($updateSql); - // Add journal entry if status or note changed - if ($oldStatus !== $status || $oldNote !== $note) { - $changes = []; - if ($oldStatus !== $status) { - $changes[] = "Status: " . $this->getWohneinheitStatusText($oldStatus) . " → " . $this->getWohneinheitStatusText($status); - } - if ($oldNote !== $note) { - $changes[] = "Notiz aktualisiert"; - } + // Journaling + $changes = []; + if ($oldStatusId !== $newStatusId) { + // Fetch status names for better logging + $statusNamesSql = "SELECT id, code, name FROM Status WHERE id IN ($oldStatusId, $newStatusId)"; + $statusRes = $db->query($statusNamesSql); + $statusMap = []; + if ($statusRes) { + while($row = $statusRes->fetch_assoc()) { + $statusMap[$row['id']] = $row['code'] . ' - ' . $row['name']; + } + } + $oldText = $statusMap[$oldStatusId] ?? "ID $oldStatusId"; + $newText = $statusMap[$newStatusId] ?? "ID $newStatusId"; + $changes[] = "Status: $oldText → $newText"; + } + + if ($oldSplice !== $spliceCompleted) { + $changes[] = "Spleiß: " . ($spliceCompleted ? 'Erledigt' : 'Nicht erledigt'); + } + + if ($oldTuer !== $tuer) { + $changes[] = "Tür aktualisiert: '$oldTuer' -> '$tuer'"; + } + if ($oldZusatz !== $zusatz) { + $changes[] = "Zusatz aktualisiert: '$oldZusatz' -> '$zusatz'"; + } + if (!empty($changes)) { WorkorderMphJournalModel::create([ 'workorderMphId' => $workorderMphId, 'text' => "Wohneinheit $wohneinheitId: " . implode(', ', $changes), 'create' => time(), 'createBy' => $this->user->id, ]); - - // If status is 241 (BEP MD) or 300 (ONT installed), set statusflag 200 on Wohneinheit - if (in_array($status, [12, 16])) { // 12=241 BEP MD, 16=300 ONT - $this->setWohneinheitStatusflag($wohneinheitId, 200); - } + } + + // Status flag logic for BEP MD (241) and ONT (300). Need to check codes for these IDs. + // Since we only have IDs, we need to check the code of the newStatusId. + $newStatusCodeSql = "SELECT code FROM Status WHERE id = $escapedStatusId"; + $resCode = $db->query($newStatusCodeSql); + $newStatusCode = $resCode ? intval($resCode->fetch_assoc()['code']) : 0; + + if (in_array($newStatusCode, [241, 300])) { // 241=BEP MD, 300=ONT + $this->setWohneinheitStatusflag($wohneinheitId, 200); } self::returnJson(['success' => true, 'message' => 'Wohneinheit aktualisiert.']); @@ -286,6 +329,8 @@ class WorkorderMphBaseController extends TTCrud $changes = []; $checkboxFields = ['easement', 'btb', 'fttxLocationSupplied', 'conduitToHuepLaid', 'huepMounted', 'dropCableAvailable', 'spliceCompleted']; + $updateHausnummerStatus = false; + foreach ($checkboxFields as $field) { if (array_key_exists($field, $post)) { $oldValue = $workorder->$field; @@ -293,6 +338,11 @@ class WorkorderMphBaseController extends TTCrud if ($oldValue !== $newValue) { $workorder->$field = $newValue; $changes[] = "$field: " . ($newValue ? 'ja' : 'nein'); + + // Check for FTTx Location mit Leerrohr versorgt + if ($field === 'fttxLocationSupplied' && $newValue === 1) { + $updateHausnummerStatus = true; + } } } } @@ -300,6 +350,19 @@ class WorkorderMphBaseController extends TTCrud if (!empty($changes)) { WorkorderMphModel::update((array)$workorder); + if ($updateHausnummerStatus) { + $db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME); + // Find status ID for code 200 + $statusSql = "SELECT id FROM Status WHERE code = 200 AND type = 'hausnummer' LIMIT 1"; + $statusResult = $db->query($statusSql); + if ($statusResult && $row = $statusResult->fetch_assoc()) { + $statusId = $row['id']; + $hnId = $db->escape($workorder->hausnummerId); + $updateHnSql = "UPDATE Hausnummer SET status_id = $statusId WHERE id = $hnId"; + $db->query($updateHnSql); + } + } + WorkorderMphJournalModel::create([ 'workorderMphId' => $workorder->id, 'text' => "Dokumentation aktualisiert:\n" . implode("\n", $changes), diff --git a/application/WorkorderMphWohneinheit/WorkorderMphWohneinheitModel.php b/application/WorkorderMphWohneinheit/WorkorderMphWohneinheitModel.php deleted file mode 100644 index efa1b77d5..000000000 --- a/application/WorkorderMphWohneinheit/WorkorderMphWohneinheitModel.php +++ /dev/null @@ -1,14 +0,0 @@ -getEnvironment() == "thetool") { + $table = $this->table('WorkorderMphWohneinheit'); + if (!$table->hasColumn('spliceCompleted')) { + $table->addColumn('spliceCompleted', 'boolean', [ + 'null' => true, + 'default' => 0, + 'comment' => 'Spleiß im HÜP/HAK erledigt', + 'after' => 'status' + ]); + $table->update(); + } + } + } + + public function down(): void + { + if ($this->getEnvironment() == "thetool") { + $table = $this->table('WorkorderMphWohneinheit'); + if ($table->hasColumn('spliceCompleted')) { + $table->removeColumn('spliceCompleted'); + $table->save(); + } + } + } +} + +//SQL: ALTER TABLE `WorkorderMphWohneinheit` ADD COLUMN `spliceCompleted` TINYINT(1) NULL DEFAULT 0 COMMENT 'Spleiß im HÜP/HAK erledigt' AFTER `status`; \ No newline at end of file diff --git a/db/migrations/20251126100000_refactor_workorder_mph_wohneinheit.php b/db/migrations/20251126100000_refactor_workorder_mph_wohneinheit.php new file mode 100644 index 000000000..ed686d5f4 --- /dev/null +++ b/db/migrations/20251126100000_refactor_workorder_mph_wohneinheit.php @@ -0,0 +1,60 @@ +getEnvironment() == "addressdb") { + $table = $this->table('Wohneinheit'); + if (!$table->hasColumn('splice_hak_completed')) { + $table->addColumn('splice_hak_completed', 'boolean', [ + 'null' => true, + 'default' => 0, + 'after' => 'external_data' + ]); + $table->update(); + } + } + + // TheTool modifications + if ($this->getEnvironment() == "thetool") { + $table = $this->table('WorkorderMphWohneinheit'); + if ($table->exists()) { + $table->drop()->save(); + } + } + } + + public function down(): void + { + // AddressDB modifications + if ($this->getEnvironment() == "addressdb") { + $table = $this->table('Wohneinheit'); + if ($table->hasColumn('splice_hak_completed')) { + $table->removeColumn('splice_hak_completed'); + $table->update(); + } + } + + // TheTool modifications + if ($this->getEnvironment() == "thetool") { + $table = $this->table('WorkorderMphWohneinheit'); + if (!$table->exists()) { + $table->addColumn('workorderMphId', 'integer') + ->addColumn('wohneinheitId', 'integer') + ->addColumn('status', 'integer') + ->addColumn('spliceCompleted', 'boolean', ['null' => true, 'default' => 0]) + ->addColumn('note', 'text', ['null' => true]) + ->addColumn('create', 'integer') + ->addColumn('createBy', 'integer') + ->addColumn('edit', 'integer', ['null' => true]) + ->addColumn('editBy', 'integer', ['null' => true]) + ->create(); + } + } + } +} \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index ab2d14586..2748ee516 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,7 +7,7 @@ services: - "80:80" volumes: - ./docker/php/apache.conf:/etc/apache2/sites-available/000-default.conf - - ./docker/php/custom.ini:/etc/php/8.2/apache2/conf.d/99-custom.ini + - ./docker/php/custom.ini:/etc/php/8.4/apache2/conf.d/99-custom.ini - ./docker/php/logs:/var/log/apache2 - ./:/var/www/html - vendor:/var/www/html/vendor diff --git a/public/js/pages/WorkorderMphBase/WorkorderMphBase.css b/public/js/pages/WorkorderMphBase/WorkorderMphBase.css index ef63a4ac6..ea0d8fdc8 100644 --- a/public/js/pages/WorkorderMphBase/WorkorderMphBase.css +++ b/public/js/pages/WorkorderMphBase/WorkorderMphBase.css @@ -57,16 +57,21 @@ } .wohneinheit-manager .we-bezeichner { - width: 25%; + width: 20%; font-size: 0.9rem; } .wohneinheit-manager .we-status { - width: 20%; + width: 18%; +} + +.wohneinheit-manager .we-splice { + width: 12%; + padding: 4px 8px; } .wohneinheit-manager .we-note { - width: 40%; + width: 35%; } .wohneinheit-manager .we-actions { @@ -74,6 +79,26 @@ text-align: right; } +.wohneinheit-manager .we-splice .custom-checkbox-item { + padding: 4px; + justify-content: center; + flex-direction: column; + height: auto; + text-align: center; +} + +.wohneinheit-manager .we-splice .custom-checkbox-item .checkmark { + margin-right: 0; + margin-bottom: 2px; + width: 18px; + height: 18px; +} + +.wohneinheit-manager .we-splice .custom-checkbox-item .checkbox-label { + font-size: 0.7rem; + line-height: 1; +} + .contact-info { font-size: 0.85rem; margin-top: 4px; diff --git a/public/js/pages/WorkorderMphBase/WorkorderMphBase.js b/public/js/pages/WorkorderMphBase/WorkorderMphBase.js index c73b1d0b4..162b97403 100644 --- a/public/js/pages/WorkorderMphBase/WorkorderMphBase.js +++ b/public/js/pages/WorkorderMphBase/WorkorderMphBase.js @@ -27,8 +27,11 @@ Vue.component('wohneinheit-status-manager', { }, template: `
-
+
@@ -36,35 +39,56 @@ Vue.component('wohneinheit-status-manager', { Keine Wohneinheiten gefunden.
-
-
- {{ we.bezeichner }} +
+
+
+ Zusatz + +
OAID: {{ we.oaid }}
{{ we.contact }}
+
+ {{ we.preorderContact }} +
Keine Kontaktinfo
+ +
+ +
+
+ Tür + +
+
+
- + Status +
+ {{ getStatusText(we.status) }} +
+ +
Speichert...
-
- -
-
- - - - +
+
@@ -74,8 +98,16 @@ Vue.component('wohneinheit-status-manager', { data: () => ({ loading: true, wohneinheiten: [], - statusOptions: [] + statusOptions: [], + hausnummerId: null, + debounceTimers: {} }), + computed: { + filteredStatusOptions() { + // Filter out status with code 300 + return this.statusOptions.filter(opt => opt.code !== 300); + } + }, methods: { async fetchWohneinheiten() { this.loading = true; @@ -86,10 +118,11 @@ Vue.component('wohneinheit-status-manager', { }); this.wohneinheiten = data.wohneinheiten.map(we => ({ ...we, - changed: false, + spliceCompleted: !!we.spliceCompleted, saving: false })); this.statusOptions = data.statusOptions || []; + this.hausnummerId = data.hausnummerId; } catch (e) { window.notify('error', 'Wohneinheiten konnten nicht geladen werden.'); console.error(e); @@ -97,25 +130,33 @@ Vue.component('wohneinheit-status-manager', { this.loading = false; } }, - markAsChanged(we) { - we.changed = true; + isLocked(we) { + const status = this.statusOptions.find(s => s.value === we.status); + return status && status.code === 300; + }, + debouncedSave(we) { + we.saving = true; + if (this.debounceTimers[we.wohneinheitId]) { + clearTimeout(this.debounceTimers[we.wohneinheitId]); + } + this.debounceTimers[we.wohneinheitId] = setTimeout(() => { + this.saveWohneinheit(we); + }, 1000); }, async saveWohneinheit(we) { - if (!we.note || !we.note.trim()) { - return window.notify('error', 'Bitte eine Notiz eingeben.'); - } - we.saving = true; try { - const { data } = await axios.post(`${window.TT_CONFIG.BASE_PATH}/WorkorderMphCompany/updateWohneinheit`, { + const basePath = this.isAdmin ? '/WorkorderMphAdmin' : '/WorkorderMphCompany'; + const { data } = await axios.post(`${window.TT_CONFIG.BASE_PATH}${basePath}/updateWohneinheit`, { workorderMphId: this.workorderMphId, wohneinheitId: we.wohneinheitId, status: we.status, - note: we.note + spliceCompleted: we.spliceCompleted ? 1 : 0, + tuer: we.tuer, + zusatz: we.zusatz }); if (data.success) { - window.notify('success', data.message); - we.changed = false; + // Silent success or small indicator this.$emit('wohneinheit-updated'); } else { window.notify('error', data.message || 'Speichern fehlgeschlagen.'); @@ -149,51 +190,44 @@ Vue.component('checkbox-documentation', {
-
-
- +
+ Speichert...
@@ -208,15 +242,15 @@ Vue.component('checkbox-documentation', { fttxLocationSupplied: false, conduitToHuepLaid: false, huepMounted: false, - dropCableAvailable: false, - spliceCompleted: false + dropCableAvailable: false } }), methods: { async fetchCheckboxes() { this.loading = true; try { - const { data } = await axios.get(`${window.TT_CONFIG.BASE_PATH}/WorkorderMphCompany/getWorkorderById`, { + const basePath = this.isAdmin ? '/WorkorderMphAdmin' : '/WorkorderMphCompany'; + const { data } = await axios.get(`${window.TT_CONFIG.BASE_PATH}${basePath}/getWorkorderById`, { params: { id: this.workorderMphId } }); this.checkboxes = { @@ -225,8 +259,7 @@ Vue.component('checkbox-documentation', { fttxLocationSupplied: !!data.fttxLocationSupplied, conduitToHuepLaid: !!data.conduitToHuepLaid, huepMounted: !!data.huepMounted, - dropCableAvailable: !!data.dropCableAvailable, - spliceCompleted: !!data.spliceCompleted + dropCableAvailable: !!data.dropCableAvailable }; } catch (e) { window.notify('error', 'Checkboxen konnten nicht geladen werden.'); @@ -238,12 +271,13 @@ Vue.component('checkbox-documentation', { async saveCheckboxes() { this.saving = true; try { - const { data } = await axios.post(`${window.TT_CONFIG.BASE_PATH}/WorkorderMphCompany/updateCheckboxes`, { + const basePath = this.isAdmin ? '/WorkorderMphAdmin' : '/WorkorderMphCompany'; + const { data } = await axios.post(`${window.TT_CONFIG.BASE_PATH}${basePath}/updateCheckboxes`, { workorderMphId: this.workorderMphId, ...this.checkboxes }); if (data.success) { - window.notify('success', data.message); + // Silent success this.$emit('checkboxes-updated'); } else { window.notify('error', data.message || 'Speichern fehlgeschlagen.'); @@ -357,33 +391,21 @@ Vue.component('workorder-mph-details-manager', {
Neues Dokument hochladen
-
- -
- - - {{ getDocExample(uploadData.documentType) }} - -
+ +
+
+ + {{ getDocExample(uploadData.documentType) }} + +
-
- -
- -
-
+
- Erlaubt: Bilder (JPG, PNG) und PDF
@@ -417,6 +439,12 @@ Vue.component('workorder-mph-details-manager', { }, canComplete() { return this.wohneinheitenWithNotes && this.docs.length > 0; + }, + docTypeOptions() { + return [ + { value: '', text: '-- Bitte wählen --' }, + ...this.requiredDocs.map(doc => ({ value: doc.key, text: doc.label })) + ]; } }, methods: { @@ -490,7 +518,7 @@ Vue.component('workorder-mph-details-manager', { if (data.success) { window.notify('success', data.message); this.$refs.fileInput.value = ''; - this.uploadData = { files: [], documentType: 'photo', description: '' }; + this.uploadData = { files: [], documentType: '', description: '' }; await this.fetchData(); } else { window.notify('error', data.error || 'Upload fehlgeschlagen.');