Files
Projektarbeit-MYP/backend/app/templates/calendar.html

772 lines
34 KiB
HTML

{% extends "base.html" %}
{% block title %}Schichtplan - Mercedes-Benz MYP Platform{% endblock %}
{% block head %}
{{ super() }}
<meta name="csrf-token" content="{{ csrf_token() }}">
<!-- FullCalendar CSS -->
<link href="{{ url_for('static', filename='js/fullcalendar/main.min.css') }}" rel="stylesheet">
{% endblock %}
{% block extra_css %}
<style>
/* Mercedes-Benz Corporate Design */
.text-mercedes-black { color: #000000; }
.text-mercedes-gray { color: #6b7280; }
.text-mercedes-silver { color: #9ca3af; }
.text-mercedes-blue { color: #0073ce; }
.text-mercedes-green { color: #008c32; }
.text-mercedes-red { color: #dc2626; }
.bg-mercedes-black { background-color: #000000; }
.bg-mercedes-silver { background-color: #e5e7eb; }
.bg-mercedes-blue { background-color: #0073ce; }
.bg-mercedes-green { background-color: #008c32; }
.border-mercedes-silver { border-color: #d1d5db; }
.border-mercedes-blue { border-color: #0073ce; }
/* Enhanced Calendar Styling */
.fc {
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.fc-header-toolbar {
margin-bottom: 1.5rem !important;
padding: 1rem;
background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
border: 1px solid #e2e8f0;
border-radius: 12px;
}
.dark .fc-header-toolbar {
background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
border-color: #334155;
}
.fc-button {
background: #0073ce !important;
border: none !important;
border-radius: 8px !important;
padding: 0.5rem 1rem !important;
font-weight: 500 !important;
transition: all 0.2s ease !important;
}
.fc-button:hover {
background: #005ba3 !important;
transform: translateY(-1px) !important;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1) !important;
}
.fc-button:focus {
box-shadow: 0 0 0 3px rgba(0, 115, 206, 0.3) !important;
}
.fc-button-active {
background: #003d82 !important;
}
.fc-today-button {
background: #16a34a !important;
}
.fc-today-button:hover {
background: #15803d !important;
}
.fc-toolbar-title {
color: #000000 !important;
font-size: 1.5rem !important;
font-weight: 700 !important;
}
.dark .fc-toolbar-title {
color: #ffffff !important;
}
.fc-col-header {
background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%) !important;
border: 1px solid #e2e8f0 !important;
}
.dark .fc-col-header {
background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%) !important;
border-color: #334155 !important;
}
.fc-col-header-cell {
padding: 1rem !important;
font-weight: 600 !important;
color: #000000 !important;
}
.dark .fc-col-header-cell {
color: #ffffff !important;
}
.fc-daygrid-day, .fc-timegrid-slot {
border-color: #e2e8f0 !important;
}
.dark .fc-daygrid-day, .dark .fc-timegrid-slot {
border-color: #334155 !important;
}
.fc-day-today {
background: rgba(0, 115, 206, 0.05) !important;
}
.dark .fc-day-today {
background: rgba(0, 115, 206, 0.1) !important;
}
/* Enhanced Event Styling */
.fc-event {
border-radius: 8px !important;
border: none !important;
padding: 0.25rem 0.5rem !important;
margin: 2px !important;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
transition: all 0.2s ease !important;
}
.fc-event:hover {
transform: translateY(-1px) !important;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15) !important;
}
.fc-event-title {
font-weight: 600 !important;
font-size: 0.875rem !important;
}
.fc-event-time {
font-size: 0.75rem !important;
opacity: 0.9 !important;
}
/* Job Status Colors */
.fc-event.event-running {
background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
color: white !important;
}
.fc-event.event-queued {
background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%) !important;
color: white !important;
}
.fc-event.event-completed {
background: linear-gradient(135deg, #16a34a 0%, #15803d 100%) !important;
color: white !important;
}
.fc-event.event-cancelled {
background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
color: white !important;
}
.fc-event.event-maintenance {
background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%) !important;
color: white !important;
}
.fc-event.event-high-priority {
box-shadow: 0 0 0 2px #f59e0b !important;
}
.fc-event.event-urgent {
box-shadow: 0 0 0 2px #ef4444 !important;
animation: urgent-pulse 2s infinite;
}
@keyframes urgent-pulse {
0%, 100% { opacity: 1; }
50% { opacity: 0.8; }
}
/* Enhanced Form Elements */
.mercedes-form-input {
transition: all 0.2s ease;
border: 1px solid #d1d5db;
background: rgba(255, 255, 255, 0.9);
backdrop-filter: blur(10px);
}
.mercedes-form-input:focus {
border-color: #0073ce;
box-shadow:
0 0 0 3px rgba(0, 115, 206, 0.1),
0 4px 6px -1px rgba(0, 0, 0, 0.1);
transform: translateY(-1px);
background: rgba(255, 255, 255, 1);
}
.dark .mercedes-form-input {
background: rgba(30, 41, 59, 0.8);
border-color: #475569;
color: #f8fafc;
}
.dark .mercedes-form-input:focus {
border-color: #0ea5e9;
box-shadow:
0 0 0 3px rgba(14, 165, 233, 0.1),
0 4px 6px -1px rgba(0, 0, 0, 0.3);
background: rgba(30, 41, 59, 1);
}
/* Enhanced Statistics Cards */
.stat-card {
background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
border: 1px solid #e2e8f0;
border-radius: 12px;
transition: all 0.3s ease;
position: relative;
overflow: hidden;
}
.dark .stat-card {
background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
border-color: #334155;
}
.stat-card:hover {
transform: translateY(-2px);
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}
.stat-card.active {
border-left: 4px solid #10b981;
}
.stat-card.queued {
border-left: 4px solid #3b82f6;
}
.stat-card.time {
border-left: 4px solid #f59e0b;
}
/* Enhanced Modals */
.mercedes-modal {
background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
border: 1px solid #e2e8f0;
box-shadow:
0 25px 50px -12px rgba(0, 0, 0, 0.25),
0 4px 6px -1px rgba(0, 0, 0, 0.1);
border-radius: 16px;
backdrop-filter: blur(10px);
}
.dark .mercedes-modal {
background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
border-color: #334155;
box-shadow:
0 25px 50px -12px rgba(0, 0, 0, 0.5),
0 4px 6px -1px rgba(0, 0, 0, 0.3);
}
</style>
{% endblock %}
{% block content %}
<div class="space-y-8">
<!-- Enhanced Page Header -->
<div class="dashboard-card p-6">
<div class="flex flex-col md:flex-row md:items-center md:justify-between gap-6">
<div class="flex items-center gap-6">
<div class="w-16 h-16 flex-shrink-0 bg-mercedes-blue text-white rounded-xl flex items-center justify-center">
<svg class="w-8 h-8" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"/>
</svg>
</div>
<div>
<h1 class="text-4xl font-bold text-mercedes-black dark:text-white tracking-tight">Produktionsplanung</h1>
<p class="text-mercedes-gray dark:text-slate-400 mt-1 text-lg">Intelligente Planung und Überwachung Ihrer 3D-Druckprozesse</p>
<div class="flex items-center mt-2 text-sm text-mercedes-blue">
<svg class="w-4 h-4 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z"/>
</svg>
<span id="calendar-status">Live-Synchronisation aktiv</span>
</div>
</div>
</div>
<div class="flex flex-wrap gap-3">
{% if can_edit %}
<button onclick="openCreateEventModal()"
class="btn-primary flex items-center gap-2">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6v6m0 0v6m0-6h6m-6 0H6"/>
</svg>
<span>Neuen Job planen</span>
</button>
<button onclick="openBatchPlanningModal()"
class="btn-secondary flex items-center gap-2">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 10h16M4 14h16M4 18h16"/>
</svg>
<span>Batch-Planung</span>
</button>
{% endif %}
<button onclick="refreshCalendar()" id="refresh-button"
class="btn-secondary flex items-center gap-2">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"/>
</svg>
<span>Aktualisieren</span>
</button>
<button onclick="exportCalendar()"
class="btn-secondary flex items-center gap-2">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/>
</svg>
<span>Exportieren</span>
</button>
<button onclick="toggleAutoOptimization()" id="auto-opt-toggle"
class="btn-secondary flex items-center gap-2">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z"/>
</svg>
<span>Auto-Optimierung</span>
</button>
</div>
</div>
</div>
<!-- Enhanced Filter and Analytics Section -->
<div class="filter-section p-6">
<div class="flex items-center justify-between mb-6">
<div>
<h3 class="text-lg font-semibold text-mercedes-black dark:text-white mb-2">Intelligente Filter & Analyse</h3>
<p class="text-sm text-mercedes-gray dark:text-slate-400">Optimieren Sie Ihre Produktionsplanung mit erweiterten Filteroptionen</p>
</div>
<button onclick="clearAllFilters()" class="text-sm text-mercedes-blue hover:text-blue-700 transition-colors">
<svg class="w-4 h-4 inline mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/>
</svg>
Alle Filter zurücksetzen
</button>
</div>
<div class="grid grid-cols-1 lg:grid-cols-4 gap-6 mb-6">
<!-- Enhanced Drucker Filter -->
<div>
<label for="printerFilter" class="block text-sm font-medium text-mercedes-black dark:text-slate-300 mb-2">
<svg class="w-4 h-4 inline mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 12h14M5 12a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v4a2 2 0 01-2 2M5 12a2 2 0 00-2 2v4a2 2 0 002 2h14a2 2 0 002-2v-4a2 2 0 00-2-2m-2-4h.01M17 16h.01"/>
</svg>
Produktionseinheit
</label>
<select id="printerFilter" class="mercedes-form-input block w-full px-4 py-3 rounded-lg">
<option value="">Alle Produktionseinheiten</option>
{% for printer in printers %}
<option value="{{ printer.id }}">{{ printer.name }} {% if printer.location %}({{ printer.location }}){% endif %}</option>
{% endfor %}
</select>
</div>
<!-- Enhanced Status Filter -->
<div>
<label for="statusFilter" class="block text-sm font-medium text-mercedes-black dark:text-slate-300 mb-2">
<svg class="w-4 h-4 inline mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 4a1 1 0 011-1h16a1 1 0 011 1v2.586a1 1 0 01-.293.707l-6.414 6.414a1 1 0 00-.293.707V17l-4 4v-6.586a1 1 0 00-.293-.707L3.293 7.414A1 1 0 013 6.707V4z"/>
</svg>
Produktionsstatus
</label>
<select id="statusFilter" class="mercedes-form-input block w-full px-4 py-3 rounded-lg">
<option value="">Alle Status</option>
<option value="running">Aktiv</option>
<option value="queued">Warteschlange</option>
<option value="completed">Abgeschlossen</option>
<option value="cancelled">Abgebrochen</option>
<option value="maintenance">Wartung</option>
</select>
</div>
<!-- Priority Filter -->
<div>
<label for="priorityFilter" class="block text-sm font-medium text-mercedes-black dark:text-slate-300 mb-2">
<svg class="w-4 h-4 inline mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z"/>
</svg>
Prioritätsstufe
</label>
<select id="priorityFilter" class="mercedes-form-input block w-full px-4 py-3 rounded-lg">
<option value="">Alle Prioritäten</option>
<option value="urgent">Dringend</option>
<option value="high">Hoch</option>
<option value="normal">Standard</option>
<option value="low">Niedrig</option>
</select>
</div>
<!-- Time Range Filter -->
<div>
<label for="timeRangeFilter" class="block text-sm font-medium text-mercedes-black dark:text-slate-300 mb-2">
<svg class="w-4 h-4 inline mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg>
Zeitbereich
</label>
<select id="timeRangeFilter" class="mercedes-form-input block w-full px-4 py-3 rounded-lg">
<option value="">Alle Zeiten</option>
<option value="today">Heute</option>
<option value="tomorrow">Morgen</option>
<option value="week">Diese Woche</option>
<option value="month">Dieser Monat</option>
</select>
</div>
</div>
<!-- Quick Analytics -->
<div class="grid grid-cols-2 md:grid-cols-4 gap-4">
<div class="stat-card active p-4">
<div class="flex justify-between items-center">
<div>
<h3 class="text-sm font-medium text-mercedes-gray dark:text-slate-400 mb-1">Aktive Jobs</h3>
<div class="text-2xl font-bold text-green-600 dark:text-green-400" id="active-jobs">-</div>
<div class="text-xs text-mercedes-gray dark:text-slate-400">Läuft derzeit</div>
</div>
<div class="w-10 h-10 bg-green-100 dark:bg-green-900/30 rounded-lg flex items-center justify-center">
<div class="w-3 h-3 bg-green-500 rounded-full animate-pulse"></div>
</div>
</div>
</div>
<div class="stat-card queued p-4">
<div class="flex justify-between items-center">
<div>
<h3 class="text-sm font-medium text-mercedes-gray dark:text-slate-400 mb-1">Warteschlange</h3>
<div class="text-2xl font-bold text-blue-600 dark:text-blue-400" id="queued-jobs">-</div>
<div class="text-xs text-mercedes-gray dark:text-slate-400">Geplant</div>
</div>
<div class="w-10 h-10 bg-blue-100 dark:bg-blue-900/30 rounded-lg flex items-center justify-center">
<div class="w-3 h-3 bg-blue-500 rounded-full"></div>
</div>
</div>
</div>
<div class="stat-card time p-4">
<div class="flex justify-between items-center">
<div>
<h3 class="text-sm font-medium text-mercedes-gray dark:text-slate-400 mb-1">Heute geplant</h3>
<div class="text-2xl font-bold text-orange-600 dark:text-orange-400" id="total-time">-h</div>
<div class="text-xs text-mercedes-gray dark:text-slate-400">Produktionszeit</div>
</div>
<div class="w-10 h-10 bg-orange-100 dark:bg-orange-900/30 rounded-lg flex items-center justify-center">
<svg class="w-5 h-5 text-orange-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg>
</div>
</div>
</div>
<div class="stat-card p-4">
<div class="flex justify-between items-center">
<div>
<h3 class="text-sm font-medium text-mercedes-gray dark:text-slate-400 mb-1">Auslastung</h3>
<div class="text-2xl font-bold text-mercedes-blue dark:text-blue-400" id="utilization">-%</div>
<div class="text-xs text-mercedes-gray dark:text-slate-400">Durchschnitt</div>
</div>
<div class="w-10 h-10 bg-mercedes-silver rounded-lg flex items-center justify-center">
<svg class="w-5 h-5 text-mercedes-black dark:text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"/>
</svg>
</div>
</div>
</div>
</div>
</div>
<!-- Calendar Container -->
<div class="dashboard-card p-6">
<div id="calendar"></div>
</div>
<!-- Legend Section -->
<div class="dashboard-card p-6">
<h3 class="section-title mb-6">Status-Legende</h3>
<div class="grid grid-cols-2 md:grid-cols-4 gap-6">
<div class="flex items-center gap-3 p-3 rounded-lg bg-gray-50 dark:bg-slate-700/30">
<div class="w-6 h-6 bg-gradient-to-br from-green-400 to-green-600 rounded-lg"></div>
<div>
<div class="text-sm font-medium text-slate-900 dark:text-white">Produktiv</div>
<div class="text-xs text-slate-500 dark:text-slate-400">Druckvorgang läuft</div>
</div>
</div>
<div class="flex items-center gap-3 p-3 rounded-lg bg-gray-50 dark:bg-slate-700/30">
<div class="w-6 h-6 bg-gradient-to-br from-blue-400 to-blue-600 rounded-lg"></div>
<div>
<div class="text-sm font-medium text-slate-900 dark:text-white">Warteschlange</div>
<div class="text-xs text-slate-500 dark:text-slate-400">Wartet auf Start</div>
</div>
</div>
<div class="flex items-center gap-3 p-3 rounded-lg bg-gray-50 dark:bg-slate-700/30">
<div class="w-6 h-6 bg-gradient-to-br from-emerald-400 to-emerald-600 rounded-lg"></div>
<div>
<div class="text-sm font-medium text-slate-900 dark:text-white">Abgeschlossen</div>
<div class="text-xs text-slate-500 dark:text-slate-400">Erfolgreich gedruckt</div>
</div>
</div>
<div class="flex items-center gap-3 p-3 rounded-lg bg-gray-50 dark:bg-slate-700/30">
<div class="w-6 h-6 bg-gradient-to-br from-red-400 to-red-600 rounded-lg"></div>
<div>
<div class="text-sm font-medium text-slate-900 dark:text-white">Abgebrochen</div>
<div class="text-xs text-slate-500 dark:text-slate-400">Fehler aufgetreten</div>
</div>
</div>
</div>
</div>
</div>
{% if can_edit %}
<!-- Event Modal -->
<div id="eventModal" class="fixed inset-0 bg-black/60 backdrop-blur-sm hidden z-50">
<div class="flex items-center justify-center min-h-screen p-4">
<div class="dashboard-card max-w-2xl w-full p-8 transform transition-all duration-300 scale-95 opacity-0" id="modalContent">
<div class="flex justify-between items-center mb-6">
<div>
<h3 id="modalTitle" class="text-xl font-bold text-slate-900 dark:text-white mb-2">
Neuen Produktionsauftrag erstellen
</h3>
<p class="text-slate-500 dark:text-slate-400">Planen Sie Ihren nächsten 3D-Druckauftrag</p>
</div>
<button onclick="closeEventModal()" class="p-2 hover:bg-gray-100 dark:hover:bg-slate-700 rounded-lg transition-colors">
<svg class="w-6 h-6 text-slate-500 dark:text-slate-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
</svg>
</button>
</div>
<form id="eventForm" class="space-y-6">
<input type="hidden" id="eventId" name="eventId">
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<!-- Titel -->
<div class="md:col-span-2">
<label for="eventTitle" class="block text-sm font-medium text-slate-700 dark:text-slate-300 mb-2">
Auftrags-Bezeichnung <span class="text-red-500">*</span>
</label>
<input type="text" id="eventTitle" name="title" required
class="block w-full px-3 py-2 border border-gray-300 dark:border-slate-600 rounded-lg bg-white dark:bg-slate-800 text-slate-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
placeholder="z.B. Prototyp Mercedes C-Klasse Bauteil">
</div>
<!-- Beschreibung -->
<div class="md:col-span-2">
<label for="eventDescription" class="block text-sm font-medium text-slate-700 dark:text-slate-300 mb-2">
Detaillierte Beschreibung
</label>
<textarea id="eventDescription" name="description" rows="3"
class="block w-full px-3 py-2 border border-gray-300 dark:border-slate-600 rounded-lg bg-white dark:bg-slate-800 text-slate-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-blue-500 resize-none"
placeholder="Beschreiben Sie den Druckauftrag und besondere Anforderungen..."></textarea>
</div>
<!-- Drucker -->
<div>
<label for="eventPrinter" class="block text-sm font-medium text-slate-700 dark:text-slate-300 mb-2">
Produktionseinheit <span class="text-red-500">*</span>
</label>
<select id="eventPrinter" name="printerId" required
class="block w-full px-3 py-2 border border-gray-300 dark:border-slate-600 rounded-lg bg-white dark:bg-slate-800 text-slate-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
<option value="">Drucker auswählen</option>
{% for printer in printers %}
<option value="{{ printer.id }}">{{ printer.name }} {% if printer.location %}({{ printer.location }}){% endif %}</option>
{% endfor %}
</select>
</div>
<!-- Priorität -->
<div>
<label for="eventPriority" class="block text-sm font-medium text-slate-700 dark:text-slate-300 mb-2">
Prioritätsstufe
</label>
<select id="eventPriority" name="priority"
class="block w-full px-3 py-2 border border-gray-300 dark:border-slate-600 rounded-lg bg-white dark:bg-slate-800 text-slate-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
<option value="normal">Standard</option>
<option value="high">Hoch</option>
<option value="urgent">Dringend</option>
</select>
</div>
<!-- Start-Zeit -->
<div>
<label for="eventStart" class="block text-sm font-medium text-slate-700 dark:text-slate-300 mb-2">
Produktionsstart <span class="text-red-500">*</span>
</label>
<input type="datetime-local" id="eventStart" name="start" required
class="block w-full px-3 py-2 border border-gray-300 dark:border-slate-600 rounded-lg bg-white dark:bg-slate-800 text-slate-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
</div>
<!-- End-Zeit -->
<div>
<label for="eventEnd" class="block text-sm font-medium text-slate-700 dark:text-slate-300 mb-2">
Produktionsende <span class="text-red-500">*</span>
</label>
<input type="datetime-local" id="eventEnd" name="end" required
class="block w-full px-3 py-2 border border-gray-300 dark:border-slate-600 rounded-lg bg-white dark:bg-slate-800 text-slate-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
</div>
</div>
<!-- Buttons -->
<div class="flex items-center justify-end gap-3 pt-6 border-t border-gray-200 dark:border-slate-600">
<button type="button" onclick="closeEventModal()"
class="btn-secondary">
Abbrechen
</button>
<button type="submit"
class="btn-primary">
Auftrag speichern
</button>
<button type="button" id="deleteEventBtn" onclick="deleteEvent()" style="display: none;"
class="px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg transition-colors">
Löschen
</button>
</div>
</form>
</div>
</div>
</div>
{% endif %}
<!-- FullCalendar JS -->
<script src="{{ url_for('static', filename='js/fullcalendar/main.min.js') }}"></script>
<input type="hidden" id="canEditFlag" value="{% if can_edit %}true{% else %}false{% endif %}">
<script>
document.addEventListener('DOMContentLoaded', function() {
const calendarEl = document.getElementById('calendar');
const printerFilter = document.getElementById('printerFilter');
const statusFilter = document.getElementById('statusFilter');
const canEdit = document.getElementById('canEditFlag').value === 'true';
// Modal Animation
const modal = document.getElementById('eventModal');
const modalContent = document.getElementById('modalContent');
window.openCreateEventModal = function() {
modal.classList.remove('hidden');
setTimeout(() => {
modalContent.classList.remove('scale-95', 'opacity-0');
modalContent.classList.add('scale-100', 'opacity-100');
}, 10);
};
window.closeEventModal = function() {
modalContent.classList.remove('scale-100', 'opacity-100');
modalContent.classList.add('scale-95', 'opacity-0');
setTimeout(() => {
modal.classList.add('hidden');
}, 200);
};
let calendar = new FullCalendar.Calendar(calendarEl, {
initialView: 'timeGridWeek',
locale: 'de',
headerToolbar: {
left: 'prev,next today',
center: 'title',
right: 'dayGridMonth,timeGridWeek,timeGridDay'
},
height: 'auto',
slotMinTime: '06:00:00',
slotMaxTime: '22:00:00',
businessHours: {
daysOfWeek: [1, 2, 3, 4, 5],
startTime: '08:00',
endTime: '18:00'
},
events: '/api/calendar/events',
editable: canEdit,
selectable: canEdit,
selectMirror: true,
eventDidMount: function(info) {
const event = info.event;
const element = info.el;
element.style.borderRadius = '8px';
element.style.border = 'none';
element.style.boxShadow = '0 2px 8px rgba(0,0,0,0.1)';
},
select: function(info) {
if (canEdit) {
openCreateEventModal();
document.getElementById('eventStart').value = info.startStr.slice(0, 16);
document.getElementById('eventEnd').value = info.endStr.slice(0, 16);
}
},
eventClick: function(info) {
if (canEdit) {
openCreateEventModal();
document.getElementById('modalTitle').textContent = 'Produktionsauftrag bearbeiten';
document.getElementById('eventId').value = info.event.id;
document.getElementById('eventTitle').value = info.event.title;
document.getElementById('eventDescription').value = info.event.extendedProps.description || '';
document.getElementById('eventPrinter').value = info.event.extendedProps.printerId || '';
document.getElementById('eventStart').value = info.event.startStr.slice(0, 16);
document.getElementById('eventEnd').value = info.event.endStr.slice(0, 16);
document.getElementById('deleteEventBtn').style.display = 'block';
}
}
});
calendar.render();
// Filter Event Handlers
printerFilter.addEventListener('change', function() {
calendar.refetchEvents();
});
statusFilter.addEventListener('change', function() {
calendar.refetchEvents();
});
// Form Submit Handler
document.getElementById('eventForm').addEventListener('submit', async function(e) {
e.preventDefault();
const formData = new FormData(e.target);
const data = Object.fromEntries(formData);
try {
const response = await fetch('/api/calendar/events', {
method: data.eventId ? 'PUT' : 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': document.querySelector('meta[name="csrf-token"]').getAttribute('content')
},
body: JSON.stringify(data)
});
if (response.ok) {
calendar.refetchEvents();
closeEventModal();
document.getElementById('eventForm').reset();
} else {
alert('Fehler beim Speichern des Events');
}
} catch (error) {
console.error('Error:', error);
alert('Fehler beim Speichern des Events');
}
});
// Global Functions
window.refreshCalendar = function() {
calendar.refetchEvents();
};
window.exportCalendar = function() {
alert('Export-Funktion wird implementiert...');
};
window.deleteEvent = function() {
const eventId = document.getElementById('eventId').value;
if (eventId && confirm('Möchten Sie diesen Produktionsauftrag wirklich löschen?')) {
closeEventModal();
}
};
});
</script>
{% endblock %}