diff --git a/public/js/pages/Calendar/View.js b/public/js/pages/Calendar/View.js index 33dfe1c34..31cefe1d9 100644 --- a/public/js/pages/Calendar/View.js +++ b/public/js/pages/Calendar/View.js @@ -2378,6 +2378,8 @@ $(document).ready(function () { $('body').on('change', '#customer,#customer-info-type', function () { + if (!$('#customer').hasClass('select2-hidden-accessible')) return; + if ($('#name').val() == "") { $('#name').val('IBN: ' + $("#customer").select2('data')[0].name); } diff --git a/public/js/pages/WorkorderCompany/WorkorderCompany.js b/public/js/pages/WorkorderCompany/WorkorderCompany.js index b2b6eb959..6e68e65a2 100644 --- a/public/js/pages/WorkorderCompany/WorkorderCompany.js +++ b/public/js/pages/WorkorderCompany/WorkorderCompany.js @@ -143,7 +143,7 @@ Vue.component('workorder-company', { const opt = col?.table?.filterOptions?.find(o => o.value == preordercampaignId); return opt?.text || ''; }, - openCalendarWithPrefill(workorder, dateUnix) { + openCalendarWithPrefill(workorder, dateUnix, win) { const m = window.moment.unix(dateUnix); const zeitraum = m.hour() < 12 ? 'VM' : 'NM'; const campaignName = this.getCampaignName(workorder.preordercampaign_id); @@ -170,7 +170,7 @@ Vue.component('workorder-company', { attendee_names: ['Ziga Harc'], }; localStorage.setItem('Calendar_create', JSON.stringify(calendarData)); - window.open('/Calendar/View', '_blank'); + win.location.href = '/Calendar/View'; }, async setAppointment(workorder, date) { if (!date) return; @@ -178,14 +178,18 @@ Vue.component('workorder-company', { this.$refs.table.$refs.table.refreshTable(); return window.notify('error', 'Bitte Uhrzeit angeben!'); } + const calWin = window.open('about:blank', '_blank'); const {data} = await axios.post(`${window.TT_CONFIG.BASE_PATH}/WorkorderCompany/scheduleAppointment`, { workorderId: workorder.id, appointmentDate: date }); if (data.success) { window.notify('success', data.message); this.$refs.table.$refs.table.refreshTable(); - this.openCalendarWithPrefill(workorder, date); - } else window.notify('error', data.message || 'Ein Fehler ist aufgetreten.'); + this.openCalendarWithPrefill(workorder, date, calWin); + } else { + if (calWin) calWin.close(); + window.notify('error', data.message || 'Ein Fehler ist aufgetreten.'); + } }, openRescheduleModal(row) { this.rescheduleModalData = { workorder: row, newDate: row.appointmentDate, reason: '' }; @@ -194,15 +198,19 @@ Vue.component('workorder-company', { const { workorder, newDate, reason } = this.rescheduleModalData; if (!newDate || !reason) return window.notify('error', 'Bitte geben Sie ein neues Datum und einen Grund an.'); if (moment.unix(newDate).hour() >= 23 || moment.unix(newDate).hour() < 1) return window.notify('error', 'Bitte Uhrzeit angeben!'); + const calWin = window.open('about:blank', '_blank'); const {data} = await axios.post(`${window.TT_CONFIG.BASE_PATH}/WorkorderCompany/rescheduleAppointment`, { workorderId: workorder.id, appointmentDate: newDate, reason: reason }); if (data.success) { window.notify('success', data.message); this.$refs.table.$refs.table.refreshTable(); - this.openCalendarWithPrefill(workorder, newDate); + this.openCalendarWithPrefill(workorder, newDate, calWin); this.rescheduleModalData = null; - } else window.notify('error', data.message || 'Ein Fehler ist aufgetreten.'); + } else { + if (calWin) calWin.close(); + window.notify('error', data.message || 'Ein Fehler ist aufgetreten.'); + } }, async clearAppointment(workorder) { if (!confirm('Möchten Sie den Termin wirklich löschen?')) return;