From b912b4250d4473081db289b06f61fe753bc278d7 Mon Sep 17 00:00:00 2001 From: Luca Haid Date: Tue, 26 Aug 2025 10:27:47 +0200 Subject: [PATCH] added multiple selection for problems --- .../RMLWorkorderAdminController.php | 7 ++ .../RMLWorkorderCompany.js | 105 +++++++++++++----- 2 files changed, 83 insertions(+), 29 deletions(-) diff --git a/application/RMLWorkorderAdmin/RMLWorkorderAdminController.php b/application/RMLWorkorderAdmin/RMLWorkorderAdminController.php index 846aae84a..2d2c82ae8 100644 --- a/application/RMLWorkorderAdmin/RMLWorkorderAdminController.php +++ b/application/RMLWorkorderAdmin/RMLWorkorderAdminController.php @@ -327,6 +327,13 @@ class RMLWorkorderAdminController extends TTCrud self::sendError("Die Dokumentation muss zuerst von der Firma als fertig markiert werden."); } + $preorder = new Preorder($workorder->preorderId); + if ($preorder) { + $preorder->status_id = 11; // Assuming 11 is the status for "fiber in building" + $preorder->edit_by = $this->user->id; + $preorder->save(); + } + $oldStatus = $workorder->status; $workorder->status = 'completed'; RMLWorkorderModel::update((array)$workorder); diff --git a/public/js/pages/RMLWorkorderCompany/RMLWorkorderCompany.js b/public/js/pages/RMLWorkorderCompany/RMLWorkorderCompany.js index b46060da3..79c0f2bd5 100644 --- a/public/js/pages/RMLWorkorderCompany/RMLWorkorderCompany.js +++ b/public/js/pages/RMLWorkorderCompany/RMLWorkorderCompany.js @@ -300,18 +300,27 @@ Vue.component('documentation-manager', { - - +
+ + +
`, @@ -326,6 +335,13 @@ Vue.component('documentation-manager', { newJournalMessage: '', addingJournalEntry: false, interventionData: null, + interventionTypes: [ + {value: 'stuck', text: 'Ab X Laufmeter stecken geblieben'}, + {value: 'stuck_fcp', text: 'Vom FCP nach HÜP nach X Laufmetern stecken geblieben'}, + {value: 'stuck_hup', text: 'Vom HÜP nach FCP nach X Laufmetern stecken geblieben'}, + {value: 'no_air', text: 'Keine Luftverbindung'}, + {value: 'other', text: 'Sonstiges'} + ], uploadData: { files: [], documentType: 'photo_hup_mounted', @@ -508,31 +524,62 @@ Vue.component('documentation-manager', { this.addingJournalEntry = false; } }, + getInterventionLabel(type) { + return this.interventionTypes.find(t => t.value === type)?.text || type; + }, openInterventionModal() { - this.interventionData = { type: 'stuck', distance: '', otherReason: '' }; + this.interventionData = { + types: [], + details: { + stuck: { distance: '' }, + stuck_fcp: { distance: '' }, + stuck_hup: { distance: '' }, + other: { reason: '' } + } + }; }, async requestIntervention() { - let journalText = ''; - const { type, distance, otherReason } = this.interventionData; - - if (type === 'stuck') { - if (!distance || isNaN(distance)) return window.notify('error', 'Bitte eine gültige Distanz eingeben.'); - journalText = `Ab ${distance} Laufmeter stecken geblieben.`; - } else if (type === 'stuck_fcp') { - if (!distance || isNaN(distance)) return window.notify('error', 'Bitte eine gültige Distanz eingeben.'); - journalText = `Vom FCP nach HÜP nach ${distance} Laufmetern stecken geblieben.`; - } else if (type === 'stuck_hup') { - if (!distance || isNaN(distance)) return window.notify('error', 'Bitte eine gültige Distanz eingeben.'); - journalText = `Vom HÜP nach FCP nach ${distance} Laufmetern stecken geblieben.`; - } else if (type === 'no_air') { - journalText = 'Keine Luftverbindung.'; - } else if (type === 'other') { - if (!otherReason.trim()) return window.notify('error', 'Bitte geben Sie einen Grund an.'); - journalText = otherReason.trim(); - } else { - return window.notify('error', 'Ungültiger Problemtyp.'); + const { types, details } = this.interventionData; + if (types.length === 0) { + return window.notify('error', 'Bitte wählen Sie mindestens ein Problem aus.'); } + let journalParts = []; + // Sort types to have a consistent order in the journal message + types.sort(); + + for (const type of types) { + let text = ''; + const problemOption = this.interventionTypes.find(o => o.value === type); + const problemText = problemOption ? problemOption.text : 'Unbekanntes Problem'; + + if (['stuck', 'stuck_fcp', 'stuck_hup'].includes(type)) { + const distance = details[type]?.distance; + if (!distance || isNaN(distance) || distance <= 0) { + return window.notify('error', `Bitte eine gültige Distanz für "${problemText}" eingeben.`); + } + text = problemText.replace('X', distance); + } else if (type === 'no_air') { + text = problemText; + } else if (type === 'other') { + const reason = details.other?.reason; + if (!reason || !reason.trim()) { + return window.notify('error', 'Bitte geben Sie einen Grund für "Sonstiges" an.'); + } + text = `Sonstiges: ${reason.trim()}`; + } + + if (text) { + journalParts.push(text); + } + } + + const journalText = journalParts.join('\\n'); + if (!journalText) { + return window.notify('error', 'Keine gültigen Problemdetails zum Senden gefunden.'); + } + + try { const response = await axios.post(`${window.TT_CONFIG.BASE_PATH}/RMLWorkorderCompany/requestIntervention`, { workorderId: this.workorderId,