-
-
-
-
+
+
-
+
@@ -77,7 +85,8 @@ Vue.component('workorder-mph-company', {
title="Termin verschieben" @submit="rescheduleAppointment">
Aktueller Termin: {{ formatDate(rescheduleModalData.currentDate, true) }}
+ :date-range="false" sm row required
+ :additional-props="{ timePicker: true, timePicker24Hour: true, locale: { format: 'DD.MM.YYYY HH:mm' }, singleDatePicker: true }"/>
@@ -94,7 +103,8 @@ Vue.component('workorder-mph-company', {
data() {
return {
window,
- editingAppointmentId: null,
+ editingAdditionalInfoId: null,
+ tempAdditionalInfo: '',
rescheduleModalData: null,
completeModalData: null,
crudConfig: {
@@ -102,7 +112,7 @@ Vue.component('workorder-mph-company', {
selectable: false,
expandable: true,
customRowClass: (row) => {
- if (['completed', 'new', 'cancelled'].includes(row.status)) return 'tt-mph-workorder-irrelevant';
+ if (['completed', 'new', 'cancelled', 'archived'].includes(row.status)) return 'tt-mph-workorder-irrelevant';
const deadlineDate = moment.unix(row.deadlineDate);
if (!deadlineDate.isValid()) return 'tt-mph-workorder-irrelevant';
const daysLeft = deadlineDate.diff(moment(), 'days');
@@ -123,17 +133,46 @@ Vue.component('workorder-mph-company', {
return window.moment.unix(timestamp).format(withTime ? 'DD.MM.YYYY HH:mm' : 'DD.MM.YYYY');
},
canSchedule(row) {
- return ['assigned', 'scheduled'].includes(row.status);
+ return ['assigned', 'scheduled', 'in_progress'].includes(row.status);
},
- async scheduleAppointment(row, newDate) {
- if (!newDate) {
- this.editingAppointmentId = null;
+ startAdditionalInfoEdit(row) {
+ this.editingAdditionalInfoId = row.id;
+ this.tempAdditionalInfo = row.additionalInfo || '';
+ this.$nextTick(() => this.$refs.editTextarea?.$el.querySelector('textarea').focus());
+ },
+ cancelEdit() {
+ this.editingAdditionalInfoId = null;
+ this.tempAdditionalInfo = '';
+ },
+ async updateAdditionalInfo(row) {
+ if (row.additionalInfo === this.tempAdditionalInfo) {
+ this.cancelEdit();
return;
}
+ try {
+ const { data } = await axios.post(`${window.TT_CONFIG.BASE_PATH}/WorkorderMphCompany/updateAdditionalInfo`, {
+ workorderMphId: row.id,
+ additionalInfo: this.tempAdditionalInfo
+ });
+ if (data.success) {
+ window.notify('success', data.message);
+ row.additionalInfo = data.newInfo;
+ } else {
+ window.notify('error', data.message || 'Update fehlgeschlagen.');
+ }
+ } catch (e) {
+ window.notify('error', 'Netzwerkfehler.');
+ } finally {
+ this.cancelEdit();
+ }
+ },
+ async scheduleAppointment(row, newDate) {
+ if (!newDate) return;
const hour = parseInt(moment.unix(newDate).format('H'));
if (hour >= 23 || hour < 1) {
window.notify('error', 'Bitte geben Sie eine Uhrzeit zwischen 01:00 und 22:59 an!');
+ this.$refs.table.$refs.table.refreshTable();
return;
}
@@ -150,8 +189,6 @@ Vue.component('workorder-mph-company', {
}
} catch (e) {
window.notify('error', 'Netzwerkfehler.');
- } finally {
- this.editingAppointmentId = null;
}
},
openRescheduleModal(row) {
@@ -169,8 +206,7 @@ Vue.component('workorder-mph-company', {
const hour = parseInt(moment.unix(this.rescheduleModalData.newDate).format('H'));
if (hour >= 23 || hour < 1) {
- window.notify('error', 'Bitte geben Sie eine Uhrzeit zwischen 01:00 und 22:59 an!');
- return;
+ return window.notify('error', 'Bitte geben Sie eine Uhrzeit zwischen 01:00 und 22:59 an!');
}
try {
@@ -225,10 +261,6 @@ Vue.component('workorder-mph-company', {
} catch (e) {
window.notify('error', 'Ein Netzwerkfehler ist aufgetreten.');
}
- },
- async checkAllWohneinheitenHaveNotes(workorderId) {
- // This is called when a wohneinheit is updated
- // Could be used to enable/disable the complete button
}
}
});
diff --git a/public/js/pages/WorkorderTenantConfig/WorkorderTenantConfig.js b/public/js/pages/WorkorderTenantConfig/WorkorderTenantConfig.js
index 76406c561..681f3bca6 100644
--- a/public/js/pages/WorkorderTenantConfig/WorkorderTenantConfig.js
+++ b/public/js/pages/WorkorderTenantConfig/WorkorderTenantConfig.js
@@ -78,6 +78,11 @@ Vue.component('workorder-tenant-config', {
Optionen
+
+
+
+
Workorder: {{ config.enableWorkorder ? 'Aktiviert' : 'Deaktiviert' }}
+
WorkorderMPH: {{ config.enableWorkorderMph ? 'Aktiviert' : 'Deaktiviert' }}
+
Tiefbau-Doku: {{ config.civilEngineeringDocsRequired ? 'Ja' : 'Nein' }}
Kabellänge-Doku: {{ config.requireCableLength ? 'Ja' : 'Nein' }}
Kabeltyp-Doku: {{ config.requireCableType ? 'Ja' : 'Nein' }}
@@ -324,7 +332,9 @@ Vue.component('workorder-tenant-config', {
workorderActiveFilters: '{}',
civilEngineeringDocsRequired: 0,
requireCableLength: 0,
- requireCableType: 0
+ requireCableType: 0,
+ enableWorkorder: 1,
+ enableWorkorderMph: 1
}
: {visibleForAddressId: []};
this.showModal = true;
diff --git a/public/plugins/vue/tt-components/tt-table.js b/public/plugins/vue/tt-components/tt-table.js
index b50dc6fd8..440d01cb5 100644
--- a/public/plugins/vue/tt-components/tt-table.js
+++ b/public/plugins/vue/tt-components/tt-table.js
@@ -160,7 +160,7 @@ Vue.component('tt-table', {
-
+
diff --git a/scripts/workorder-mph-create-from-hausnummer.php b/scripts/workorder-mph-create-from-hausnummer.php
new file mode 100644
index 000000000..21f0df667
--- /dev/null
+++ b/scripts/workorder-mph-create-from-hausnummer.php
@@ -0,0 +1,109 @@
+#!/usr/bin/php
+ $db->escape($id), $netzgebietIds);
+ $netzgebietFilter = " AND hn.netzgebiet_id IN (" . implode(',', $escapedIds) . ")";
+}
+
+// Find Hausnummer with >2 Wohneinheiten and state not in grossplaning/not2connect
+$sql = "
+ SELECT hn.id, hn.netzgebiet_id, COUNT(we.id) as we_count
+ FROM Hausnummer hn
+ LEFT JOIN Wohneinheit we ON hn.id = we.hausnummer_id
+ WHERE hn.rimo_ex_state NOT IN ('grossplaning', 'not2connect')
+ AND hn.rimo_op_state NOT IN ('grossplaning', 'not2connect')
+ $netzgebietFilter
+ GROUP BY hn.id
+ HAVING we_count > 2
+";
+
+$result = $db->query($sql);
+$hausnummern = $result ? $result->fetch_all(MYSQLI_ASSOC) : [];
+
+echo "[" . date('Y-m-d H:i:s') . "] Found " . count($hausnummern) . " Hausnummern with >2 Wohneinheiten\n";
+
+// Get valid hausnummer IDs
+$validHausnummerIds = array_column($hausnummern, 'id');
+
+$createdCount = 0;
+$reactivatedCount = 0;
+
+foreach ($hausnummern as $hn) {
+ // Check if WorkorderMph already exists
+ $existing = WorkorderMphModel::getFirst(['hausnummerId' => $hn['id']]);
+
+ if (!$existing) {
+ // Create new WorkorderMph
+ WorkorderMphModel::create([
+ 'hausnummerId' => $hn['id'],
+ 'status' => 'new',
+ 'create' => time(),
+ 'createBy' => 1 // System user
+ ]);
+ $createdCount++;
+ echo "[" . date('Y-m-d H:i:s') . "] Created new WorkorderMph for Hausnummer ID {$hn['id']}\n";
+ } elseif ($existing->status === 'archived') {
+ // Reactivate archived workorder
+ $existing->status = 'new';
+ $existing->companyId = null;
+ $existing->deadlineDate = null;
+ $existing->appointmentDate = null;
+ WorkorderMphModel::update((array)$existing);
+
+ WorkorderMphJournalModel::create([
+ 'workorderMphId' => $existing->id,
+ 'text' => 'Arbeitsauftrag wurde automatisch reaktiviert.',
+ 'statusChange' => 'archiviert -> neu',
+ 'create' => time(),
+ 'createBy' => 1,
+ ]);
+ $reactivatedCount++;
+ echo "[" . date('Y-m-d H:i:s') . "] Reactivated WorkorderMph #{$existing->id} for Hausnummer ID {$hn['id']}\n";
+ }
+}
+
+echo "[" . date('Y-m-d H:i:s') . "] Created: $createdCount, Reactivated: $reactivatedCount\n";
+
+// Archive workorders for Hausnummer that are no longer in allowed netzgebiete or don't meet criteria
+if (!empty($netzgebietIds)) {
+ $allWorkorders = WorkorderMphModel::getAll(['status' => ['new', 'assigned', 'scheduled', 'in_progress']]);
+ $archivedCount = 0;
+ foreach ($allWorkorders as $workorder) {
+ if (!in_array($workorder->hausnummerId, $validHausnummerIds)) {
+ $workorder->status = 'archived';
+ WorkorderMphModel::update((array)$workorder);
+
+ WorkorderMphJournalModel::create([
+ 'workorderMphId' => $workorder->id,
+ 'text' => 'Arbeitsauftrag automatisch archiviert (Netzgebiet deaktiviert oder Kriterien nicht mehr erfüllt).',
+ 'statusChange' => 'active -> archived',
+ 'create' => time(),
+ 'createBy' => 1,
+ ]);
+ $archivedCount++;
+ echo "[" . date('Y-m-d H:i:s') . "] Archived WorkorderMph #{$workorder->id}\n";
+ }
+ }
+ echo "[" . date('Y-m-d H:i:s') . "] Archived: $archivedCount\n";
+}
+
+echo "[" . date('Y-m-d H:i:s') . "] WorkorderMph creation/update completed successfully\n";