MAT / complaints /app.html
abualzait's picture
Upload folder using huggingface_hub
99c5472 verified
Raw History Blame Contribute Delete
56.3 kB
<!DOCTYPE html>
<html lang="ar" dir="rtl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MAT — حقيبة الأدوات المساعدة (Modular Assistant Toolkit)</title>
<!-- Google Fonts - IBM Plex Sans Arabic & Tajawal -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&family=Tajawal:wght@400;500;700;800&display=swap" rel="stylesheet">
<!-- Civic Horizon CSS Design System -->
<link rel="stylesheet" href="/complaints/css/design-system.css?v=21">
<!-- Leaflet CSS for unified map -->
<link rel="stylesheet" href="/leaflet.css">
</head>
<body>
<div class="app-layout">
<!-- Sidebar Navigation -->
<aside class="sidebar" id="mainSidebar">
<div class="sidebar-header">
<div class="logo-container" title="MAT (Modular Assistant Toolkit) — حقيبة الأدوات المساعدة">
<img src="/amman_logo.png" alt="شعار المحافظة" class="logo-img"
onerror="this.src='https://upload.wikimedia.org/wikipedia/commons/thumb/c/c1/Coat_of_arms_of_Jordan.svg/500px-Coat_of_arms_of_Jordan.svg.png'">
</div>
<div class="header-titles">
<div class="header-brand-badge">
<span class="brand-acronym">MAT</span>
<span class="brand-fullname">Modular Assistant Toolkit</span>
</div>
<h1 class="header-main-title">حقيبة الأدوات المساعدة</h1>
<p class="header-jurisdiction">
<span>محافظة العاصمة</span>
<span class="badge badge-purple" style="font-size:0.62rem; padding:1px 5px; border-radius:4px;">v1.40.0</span>
</p>
</div>
<button class="sidebar-close-btn" onclick="closeSidebarDrawer()" title="إغلاق القائمة" aria-label="إغلاق القائمة">
✕
</button>
</div>
<nav class="sidebar-menu" id="dynamicSidebarMenu">
<!-- Populated dynamically by JS -->
</nav>
<div class="sidebar-footer">
<div class="user-info-card">
<div class="user-avatar-wrapper">
<div class="user-avatar">👤</div>
<span class="user-status-dot" title="متصل"></span>
</div>
<div class="user-details">
<span id="userNameSidebar" class="user-name">...</span>
<span id="userRoleBadgeSidebar" class="role-badge-sidebar">...</span>
</div>
</div>
<button onclick="logout()" class="btn-logout-sidebar" title="تسجيل الخروج">
<span>🚪</span> <span class="logout-text">تسجيل الخروج</span>
</button>
</div>
</aside>
<!-- Main Content Area -->
<main class="main-content">
<!-- Top Bar -->
<header class="top-bar">
<div class="top-bar-left">
<button id="sidebarToggle" class="btn btn-ghost" onclick="toggleSidebar()" title="إظهار/إخفاء القائمة" style="color:#ffffff !important;font-size:1.2rem;background:rgba(255,255,255,0.1);border:1px solid rgba(255,255,255,0.25);">
☰
</button>
<div class="search-bar-container">
<span class="search-icon">🔍</span>
<input type="text" id="globalSearchInput"
placeholder="ابحث برقم القضية/الصادر، اسم المراجع..."
onkeyup="handleGlobalSearch(event)">
</div>
</div>
<div class="top-bar-right">
<!-- Meeting Room / Live Chat Button -->
<button class="btn btn-ghost meeting-room-top-btn" id="meetingRoomTopBtn"
onclick="toggleChatPane(true)"
title="غرفة الاجتماعات (المحادثة الفورية)">
<span class="meeting-btn-icon" style="font-size: 1.1rem;">💬</span>
<span class="meeting-btn-text">غرفة الاجتماعات</span>
<span id="chatActiveUsersCountTop" class="meeting-btn-badge">0</span>
</button>
<div style="position: relative;">
<button id="notificationToggleBtn" class="btn btn-ghost notification-btn" title="التنبيهات" onclick="toggleNotificationPanel()" style="position: relative;color:#ffffff !important;background:rgba(255,255,255,0.12);border:1px solid rgba(255,255,255,0.3);">
🔔 <span id="notificationBadge" class="badge badge-red" style="position: absolute; top: -5px; right: -5px; display: none;">0</span>
</button>
<!-- Notification Panel -->
<div id="notificationPanel" class="card" style="display: none; position: absolute; top: 100%; left: 0; width: 320px; z-index: 100; box-shadow: 0 10px 25px rgba(0,0,0,0.2); margin-top: 0.5rem; background:#ffffff; border:1px solid #cbd5e1;">
<div class="card-header" style="padding: 1rem; background:#f1f5f9; border-bottom:1px solid #cbd5e1;">
<h3 style="font-size: 1rem; margin: 0; color:#0f172a;">🔔 الإشعارات الواردة</h3>
</div>
<div id="notificationList" class="card-body" style="padding: 0; max-height: 300px; overflow-y: auto; color:#0f172a;">
<div style="padding: 1rem; text-align: center; color: #64748b; font-size: 0.9rem;">لا توجد إشعارات حالياً</div>
</div>
</div>
</div>
<!-- Top Bar Logout Button -->
<button class="btn btn-ghost top-logout-btn" onclick="logout()" title="تسجيل الخروج" aria-label="تسجيل الخروج">
<span style="font-size: 1.1rem;">🚪</span>
<span class="top-logout-text">تسجيل الخروج</span>
</button>
</div>
</header>
<!-- Search Results Panel -->
<div id="searchResultsContainer" class="search-results card mb-3">
<div class="card-header">
<h3>🔍 نتائج البحث عن المواعيد والقضايا</h3>
<button class="btn btn-ghost btn-sm" onclick="closeSearchResults()">إغلاق النتائج ✖</button>
</div>
<div class="card-body" id="searchResultsBody">
<!-- Populated dynamically -->
</div>
</div>
<!-- Tab 1: Dashboard (لوحة التحكم والملخص) -->
<div id="tab-dashboard" class="tab-content active">
<div class="page-title">
<div class="title-text">
📊 لوحة التحكم — ملخص المواعيد والاتصالات والأبحاث
</div>
<div style="display: flex; gap: 10px; align-items: center;">
<select id="dashboardTimeFilter" class="form-control" onchange="loadSimpleDashboard()" style="width: 200px; padding: 0.5rem;">
<option value="today">إحصائيات اليوم</option>
<option value="week">إحصائيات هذا الأسبوع</option>
<option value="month">إحصائيات هذا الشهر</option>
<option value="all">إحصائيات كل الوقت</option>
</select>
<button class="btn btn-primary" onclick="openNewSimpleAppointmentModal()">➕ حجز موعد جديد</button>
</div>
</div>
<!-- Stats Row -->
<div class="stats-grid stats-grid-3">
<!-- Card 1: عدد المواعيد للفترة المحددة -->
<div class="stat-card stat-card-primary">
<div class="stat-card-header">
<div class="stat-icon-wrapper icon-blue">
<span>📅</span>
</div>
<span class="stat-badge badge-blue" id="statPeriodBadge">اليوم</span>
</div>
<div class="stat-card-body">
<div class="stat-value-large text-primary" id="statFilteredTotalAppts">0</div>
<div class="stat-label">عدد المواعيد</div>
</div>
<div class="stat-card-footer">
<span class="stat-footer-text" id="statPeriodFooterText">إجمالي المواعيد للفترة المحددة</span>
</div>
</div>
<!-- Card 2: التي تم تأجيلها للفترة المحددة -->
<div class="stat-card stat-card-warning">
<div class="stat-card-header">
<div class="stat-icon-wrapper icon-purple">
<span>🔄</span>
</div>
<span class="stat-badge badge-purple" id="statPeriodBadgePostponed">اليوم</span>
</div>
<div class="stat-card-body">
<div class="stat-value-large text-purple" id="statFilteredPostponedAppts">0</div>
<div class="stat-label">التي تم تأجيلها</div>
</div>
<div class="stat-card-footer">
<span class="stat-footer-text" id="statPeriodFooterTextPostponed">مواعيد تم تحويلها وإعادة جدولتها</span>
</div>
</div>
<!-- Card 3: لم يحضر للفترة المحددة -->
<div class="stat-card stat-card-danger">
<div class="stat-card-header">
<div class="stat-icon-wrapper icon-red">
<span>❌</span>
</div>
<span class="stat-badge badge-red" id="statPeriodBadgeNoShow">اليوم</span>
</div>
<div class="stat-card-body">
<div class="stat-value-large text-danger" id="statFilteredNoShowAppts">0</div>
<div class="stat-label">لم يحضر</div>
</div>
<div class="stat-card-footer">
<span class="stat-footer-text" id="statPeriodFooterTextNoShow">تخلف المراجعين عن الحضور في الموعد</span>
</div>
</div>
</div>
<!-- Dashboard Grid -->
<div class="dashboard-grid">
<!-- My Reserved Files Widget -->
<div class="card" style="grid-column: 1 / -1;">
<div class="card-header">
<h3>📁 ملفاتي المحجوزة</h3>
<button class="btn btn-outline btn-sm" onclick="switchTab('file-reservations')">إدارة الملفات</button>
</div>
<div class="card-body">
<div class="smart-cards-grid" id="dashboardReservedFilesList">
<!-- Populated dynamically -->
</div>
</div>
</div>
<!-- No Answer List (Pending Suspension) -->
<div class="card" style="grid-column: 1 / -1;" id="dashboardNoAnswerWrapper" style="display:none;">
<div class="card-header" style="background: rgba(231, 76, 60, 0.1); border-bottom: 2px solid #e74c3c;">
<h3 style="color: #c0392b;">📵 جهات لم تجب على الاتصال (معلقة)</h3>
<button class="btn btn-outline btn-sm" onclick="switchTab('appointments')">إدارة المعلقين</button>
</div>
<div class="card-body">
<div class="smart-cards-grid" id="dashboardNoAnswerList">
<!-- Populated dynamically -->
</div>
</div>
</div>
<!-- Today's Schedule -->
<div class="card" style="grid-column: 1 / -1;">
<div class="card-header">
<h3>⏱️ مواعيد واتصالات اليوم المقررة</h3>
<button class="btn btn-outline btn-sm" onclick="switchTab('appointments')">الجدول الكامل</button>
</div>
<div class="card-body">
<div class="smart-cards-grid" id="dashboardTodaySimpleAppointmentsList">
<!-- Populated dynamically -->
</div>
</div>
</div>
<!-- Top Searched Areas Widget -->
<div class="card" style="grid-column: 1 / -1;">
<div class="card-header">
<h3>📍 أكثر المناطق بحثاً والمراكز الأمنية التابعة لها</h3>
<button class="btn btn-ghost btn-sm" onclick="switchTab('stations')">فتح الدليل</button>
</div>
<div class="card-body">
<div id="topSearchedAreasContainer" class="top-areas-list" style="display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1rem;">
<!-- Populated dynamically -->
</div>
</div>
</div>
</div>
</div>
<!-- Tab: Daily Appointments Cards View -->
<div id="tab-daily-view" class="tab-content">
<div class="page-title">
<div class="title-text">
🗓️ العرض اليومي للمواعيد
</div>
<div class="form-group mb-0" style="display:flex; align-items:center; gap:10px;">
<button class="btn btn-outline" onclick="window.print()">🖨️ طباعة الجدول</button>
<label style="margin:0; font-weight:bold; color:var(--text-color);">تاريخ العرض:</label>
<input type="date" id="dailyViewDatePicker" class="form-control" onchange="loadDailyView()"
style="width: 200px;">
</div>
</div>
<div id="dailyCardsContainer" class="daily-cards-grid">
<!-- Cards will be populated here -->
</div>
</div>
<!-- Tab: Calendar View -->
<div id="tab-calendar-view" class="tab-content">
<div class="page-title">
<div class="title-text">
📆 التقويم الشهري للمواعيد
</div>
<button class="btn btn-outline" onclick="loadCalendarView()">🔄 تحديث التقويم</button>
</div>
<div class="card">
<div class="card-body">
<div id="calendarHeader" style="display:flex; justify-content:space-between; align-items:center; margin-bottom: 1.5rem; background: var(--bg-tertiary); padding: 10px; border-radius: var(--radius-md);">
<button class="btn btn-outline" onclick="changeCalendarMonth(-1)">⬅️ الشهر السابق</button>
<h3 id="calendarMonthYear" style="margin:0; font-weight:bold; color:var(--primary-color);"></h3>
<button class="btn btn-outline" onclick="changeCalendarMonth(1)">الشهر التالي ➡️</button>
</div>
<div id="calendarGrid" class="modern-calendar-grid">
<!-- Populated dynamically -->
</div>
</div>
</div>
<!-- Modern Calendar Agenda Drawer -->
<div id="agendaDrawerOverlay" class="drawer-overlay" onclick="closeAgendaDrawer()"></div>
<div id="agendaDrawer" class="agenda-drawer">
<div class="drawer-header">
<h3 id="agendaDateTitle" style="margin:0; font-weight:bold; color:var(--text-primary);">تفاصيل اليوم</h3>
<button class="btn btn-outline" onclick="closeAgendaDrawer()" style="border:none; background:transparent; font-size:1.5rem; color:var(--text-primary);">&times;</button>
</div>
<div class="drawer-body" id="agendaContent">
<!-- Agenda items injected here -->
</div>
</div>
</div>
<!-- Tab 2: Appointments Scheduling (جدولة المواعيد والقضايا) -->
<div id="tab-appointments" class="tab-content">
<div class="page-title">
<div class="title-text">
📅 جدول المواعيد والقضايا والاتصالات المسجلة
</div>
<button class="btn btn-primary btn-lg" onclick="openNewSimpleAppointmentModal()">➕ حجز / إضافة موعد
جديد</button>
</div>
<!-- Filter & Search Row -->
<div class="card mb-2">
<div class="card-body" style="padding: 0.85rem 1.25rem;">
<div class="form-row align-center">
<div class="form-group mb-0">
<label>من تاريخ:</label>
<input type="date" id="apptFilterFrom" class="form-control"
onchange="loadSimpleAppointments()">
</div>
<div class="form-group mb-0">
<label>إلى تاريخ:</label>
<input type="date" id="apptFilterTo" class="form-control"
onchange="loadSimpleAppointments()">
</div>
<div class="form-group mb-0">
<label>حالة الموعد:</label>
<select id="apptFilterStatus" class="form-control" onchange="loadSimpleAppointments()">
<option value="">كل الحالات</option>
<option value="مُجدول">مُجدول</option>
<option value="مُؤجل">مُؤجل (إعادة جدولة)</option>
<option value="تم الحضور">تم الحضور</option>
<option value="لم يحضر">لم يحضر</option>
<option value="لم يجيبوا">لم يجيبوا (معلق)</option>
<option value="ملغى">ملغى</option>
</select>
</div>
</div>
</div>
</div>
<!-- Appointments Table -->
<div class="card">
<div class="card-body">
<div id="simpleAppointmentsTableContainer">
<!-- Populated dynamically -->
</div>
</div>
</div>
</div>
<!-- Tab 3: Security Stations Directory (دليل المراكز الأمنية) -->
<div id="tab-stations" class="tab-content" style="padding: 0;">
<div style="border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-card); border: 1px solid var(--border-color, rgba(255,255,255,0.12));">
<iframe id="stationsIframe"
src="about:blank"
style="width:100%; height:calc(100vh - 110px); border:none; display:block;"
title="دليل المراكز الأمنية">
</iframe>
</div>
</div>
<!-- Tab: File Reservations (حجز الملفات) -->
<div id="tab-reservations" class="tab-content">
<div class="page-title" style="display: flex; justify-content: space-between; align-items: center;">
<div class="title-text">
🔒 نظام تتبع الملفات المصغر
</div>
<label class="admin-only" id="adminAllReservationsLabel" style="display:none; align-items:center; gap:8px; font-weight: normal; cursor: pointer;">
<input type="checkbox" id="showAllReservationsCheck" onchange="loadReservations()">
عرض جميع ملفات المركز (صلاحية مشرف)
</label>
</div>
<!-- Quick Search Area -->
<div class="card mb-4" style="background: var(--bg-tertiary); border: 1px solid var(--primary-color); text-align: center; padding: 25px; border-radius: 12px; box-shadow: 0 4px 15px rgba(0,0,0,0.05);">
<h3 style="margin-bottom: 20px; color: var(--text-color);">🔍 أين يوجد هذا الملف؟</h3>
<div class="form-row align-center" style="max-width: 600px; margin: 0 auto; gap: 10px;">
<input type="text" id="searchReservationInput" class="form-control" placeholder="أدخل رقم الملف أو القضية للبحث..." style="flex:1; text-align: center; font-size: 1.2rem; padding: 12px; border-radius: 8px;">
<button class="btn btn-primary" onclick="searchReservations()" style="padding: 12px 25px; font-size: 1.1rem; border-radius: 8px;">ابحث فوراً</button>
</div>
<div id="reservationSearchResult" style="margin-top:20px; font-weight:bold; font-size: 1.1rem;"></div>
</div>
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; margin-bottom: 25px;">
<!-- New File Registration -->
<div class="card" style="border-top: 4px solid var(--primary-color);">
<div class="card-header">
<h3>➕ تسجيل ملف في عهدتي</h3>
</div>
<div class="card-body">
<form onsubmit="reserveFile(event)">
<div class="form-group">
<label>رقم الملف / القضية *</label>
<input type="text" id="newReservationFileNumber" class="form-control" placeholder="أدخل رقم الملف هنا..." required>
</div>
<div class="form-group">
<label>ملاحظات الاستلام (اختياري)</label>
<input type="text" id="newReservationNotes" class="form-control" placeholder="مثال: مستلم من الأرشيف...">
</div>
<button type="submit" class="btn btn-primary w-100">تأكيد الاستلام وحفظه باسمي</button>
</form>
</div>
</div>
<!-- Pending Transfers -->
<div class="card" style="border-top: 4px solid #f39c12;">
<div class="card-header" style="display: flex; justify-content: space-between;">
<h3>⏳ طلبات نقل العهدة</h3>
<button class="btn btn-ghost btn-sm" onclick="loadPendingTransfers()">🔄 تحديث</button>
</div>
<div class="card-body" style="max-height: 250px; overflow-y: auto; padding-top: 10px;" id="pendingTransfersContainer">
<div class="text-center text-light" style="padding: 20px;">جاري التحميل...</div>
</div>
</div>
</div>
<!-- My Files Table -->
<div class="card">
<div class="card-header" style="display: flex; justify-content: space-between;">
<h3 id="myReservationsTitle">📂 الملفات المحجوزة (في عهدتي)</h3>
<button class="btn btn-ghost btn-sm" onclick="loadReservations()">🔄 تحديث القائمة</button>
</div>
<div class="card-body">
<div class="table-wrapper">
<table>
<thead>
<tr>
<th>رقم الملف</th>
<th>المسؤول الحالي</th>
<th>تاريخ التسجيل</th>
<th>ملاحظات</th>
<th>الإجراءات / التتبع</th>
</tr>
</thead>
<tbody id="myReservationsTableBody">
<!-- Populated dynamically -->
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- Tab 4: Settings & User Management (Admin Only) -->
<div id="tab-officers" class="tab-content">
<div class="page-title">
<div class="title-text">
⚙️ إعدادات المنصة والصلاحيات
</div>
<button class="btn btn-primary" onclick="openNewOfficerModal()">➕ إضافة مستخدم جديد</button>
</div>
<div class="card">
<div class="card-body">
<div class="table-wrapper">
<table>
<thead>
<tr>
<th>الاسم الكامل</th>
<th>اسم المستخدم</th>
<th>الدور (الصلاحية)</th>
<th>الأدوات المتاحة</th>
<th>الحالة</th>
<th>إجراءات</th>
</tr>
</thead>
<tbody id="officersTableBody">
<!-- Populated dynamically -->
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- Tab 5: Admin Permissions Manager (Admin Mode Only) -->
<div id="tab-admin_permissions" class="tab-content">
<div class="page-title">
<div class="title-text">
🛡️ إدارة الصلاحيات المتقدمة (وضع المشرف السري)
</div>
</div>
<div class="card">
<div class="card-body">
<div class="table-wrapper">
<table>
<thead>
<tr>
<th>الاسم الكامل</th>
<th>لوحة التحكم</th>
<th>نظام المواعيد</th>
<th>دليل المراكز</th>
<th>أداة الملفات</th>
<th>غرفة الاجتماعات</th>
<th>الحالة العامة</th>
</tr>
</thead>
<tbody id="permissionsTableBody">
<!-- Populated dynamically -->
</tbody>
</table>
</div>
</div>
</div>
</div>
</main>
</div>
<!-- ════════════════════ MODALS ════════════════════ -->
<!-- Modal: New / Edit Simple Appointment -->
<div id="modalNewSimpleAppointment" class="modal-overlay">
<div class="modal" style="max-width: 600px;">
<div class="modal-header">
<h3>📅 حجز وإدخال موعد جديد</h3>
<button class="modal-close" onclick="closeModal('modalNewSimpleAppointment')">&times;</button>
</div>
<div class="modal-body">
<form id="formNewSimpleAppointment" onsubmit="submitNewSimpleAppointment(event)">
<input type="hidden" id="editSimpleApptId">
<input type="hidden" id="parentAppointmentId">
<div class="form-group">
<label>الضابط / الموظف طالب الاتصال (المتصل)</label>
<select id="simpleRequestedBy" class="form-control">
<option value="me">أنا (المستخدم الحالي)</option>
<option value="" disabled>-- أو اختر من قائمة الموظفين --</option>
</select>
</div>
<div class="form-row">
<div class="form-group">
<label>اسم المراجع / المتصل عليه</label>
<input type="text" id="simpleVisitorName" class="form-control"
placeholder="الاسم الكامل للمراجع">
</div>
<div class="form-group">
<label>رقم هاتف المراجع</label>
<input type="tel" id="simplePhone" class="form-control" placeholder="07XXXXXXXX">
</div>
</div>
<div class="form-group">
<label>رقم القضية / المعاملة (إن وجدت)</label>
<input type="text" id="simpleCaseNumber" class="form-control"
placeholder="مثال: ص-2026/1054 أو رقم الملف الداخلي">
</div>
<div class="form-row">
<div class="form-group">
<label>تاريخ الاجتماع / الموعد</label>
<input type="date" id="simpleDate" class="form-control">
</div>
<div class="form-group">
<label>وقت الاجتماع / الموعد</label>
<input type="time" id="simpleTime" class="form-control">
</div>
</div>
<div class="form-group">
<label>حالة الموعد</label>
<select id="simpleStatus" class="form-control">
<option value="مُجدول">مُجدول</option>
<option value="مُؤجل">مُؤجل (إعادة جدولة)</option>
<option value="تم الحضور">تم الحضور</option>
<option value="لم يحضر">لم يحضر</option>
<option value="لم يجيبوا">لم يجيبوا (معلق)</option>
<option value="ملغى">ملغى</option>
</select>
</div>
<div class="form-group">
<label>ملاحظات الموعد / بيانات إضافية بالأنظمة الداخلية</label>
<textarea id="simpleNotes" class="form-control"
placeholder="أدخل أي ملاحظات، تفاصيل كتاب الصادر، أو تعليمات خاصة بالمواجهة..."></textarea>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary btn-lg">حفظ الموعد</button>
<button type="button" class="btn btn-ghost"
onclick="closeModal('modalNewSimpleAppointment')">إلغاء</button>
</div>
</form>
</div>
</div>
</div>
<!-- Modal: New Officer (Admin) -->
<div id="modalNewOfficer" class="modal-overlay">
<div class="modal" style="max-width: 500px;">
<div class="modal-header">
<h3>👥 إضافة مستخدم جديد</h3>
<button class="modal-close" onclick="closeModal('modalNewOfficer')">&times;</button>
</div>
<div class="modal-body">
<form id="formNewOfficer" onsubmit="submitNewOfficer(event)">
<div class="form-group">
<label>الاسم الكامل *</label>
<input type="text" id="officerName" class="form-control" placeholder="مثال: النقيب أحمد علي"
required>
</div>
<div class="form-group">
<label>اسم المستخدم *</label>
<input type="text" id="officerUsername" class="form-control" placeholder="مثال: officer3"
required>
</div>
<div class="form-group">
<label>كلمة المرور *</label>
<input type="password" id="officerPassword" class="form-control" placeholder="••••••••"
required>
</div>
<div class="form-group">
<label>الدور / الصلاحية *</label>
<select id="officerRole" class="form-control" onchange="toggleAccessibleTools()">
<option value="officer">ضابط مواعيد / قضايا</option>
<option value="caller">موظف مقسم / اتصال</option>
<option value="admin">رئيس قسم (صلاحيات كاملة)</option>
</select>
</div>
<div class="form-group" id="accessibleToolsGroup">
<label>الأدوات المتاحة (الصلاحيات)</label><br>
<label><input type="checkbox" name="accessible_tool" value="dashboard" checked> 📊 لوحة التحكم والملخص</label><br>
<label><input type="checkbox" name="accessible_tool" value="complaints" checked> 📅 نظام المواعيد</label><br>
<label><input type="checkbox" name="accessible_tool" value="finder" checked> 🗺️ دليل المراكز الأمنية</label><br>
<label><input type="checkbox" name="accessible_tool" value="file_reservations" checked> 🔒 أداة حجز الملفات</label><br>
<label><input type="checkbox" name="accessible_tool" value="chat" checked> 💬 غرفة الاجتماعات (المحادثة)</label>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">إنشاء الحساب</button>
<button type="button" class="btn btn-ghost"
onclick="closeModal('modalNewOfficer')">إلغاء</button>
</div>
</form>
</div>
</div>
</div>
<!-- Transfer Custody Modal -->
<div id="modalTransferCustody" class="modal-overlay">
<div class="modal" style="max-width: 500px;">
<div class="modal-header">
<h3>🔄 طلب نقل عهدة ملف</h3>
<button class="modal-close" onclick="closeModal('modalTransferCustody')">&times;</button>
</div>
<div class="modal-body">
<div class="alert alert-info mb-3" style="background: rgba(46,204,113,0.1); border-left: 4px solid var(--primary-color); padding: 10px; border-radius: 4px;">
<strong>ملاحظة:</strong> سيتم إرسال طلب للضابط المستلم، ولن تنتقل العهدة رسمياً إلا بعد قبوله للطلب.
</div>
<form onsubmit="submitTransferCustody(event)">
<input type="hidden" id="transferReservationId">
<div class="form-group">
<label>رقم الملف</label>
<input type="text" id="transferFileNumber" class="form-control" disabled>
</div>
<div class="form-group">
<label>نقل إلى الضابط</label>
<select id="transferToOfficer" class="form-control" required>
<option value="">-- اختر الضابط --</option>
<!-- Populated dynamically -->
</select>
</div>
<div class="form-group">
<label>ملاحظات النقل</label>
<input type="text" id="transferNotes" class="form-control" placeholder="سبب النقل أو ملاحظات للمستلم...">
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">إرسال طلب النقل</button>
<button type="button" class="btn btn-ghost" onclick="closeModal('modalTransferCustody')">إلغاء</button>
</div>
</form>
</div>
</div>
</div>
<!-- Custody History Modal -->
<div id="modalCustodyHistory" class="modal-overlay">
<div class="modal" style="max-width: 650px;">
<div class="modal-header">
<h3>🕒 السجل الزمني لحركة الملف</h3>
<button class="modal-close" onclick="closeModal('modalCustodyHistory')">&times;</button>
</div>
<div class="modal-body">
<div style="background: var(--bg-tertiary); padding: 15px; border-radius: 8px; margin-bottom: 20px;">
<strong>الملف رقم: </strong> <span id="historyFileNumber" class="text-primary fw-bold">...</span><br>
<strong>موجود حالياً لدى: </strong> <span id="historyCurrentOwner">...</span>
</div>
<div class="timeline" id="custodyHistoryTimeline" style="position: relative; padding-left: 20px; border-left: 2px solid var(--border-color); max-height: 400px; overflow-y: auto;">
<!-- Populated dynamically -->
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-ghost" onclick="closeModal('modalCustodyHistory')">إغلاق</button>
</div>
</div>
</div>
<!-- Overdue Appointment Status Update & Notes Modal -->
<div id="modalOverdueUpdate" class="modal-overlay">
<div class="modal" style="max-width: 550px;">
<div class="modal-header" style="background:#FFFBEB; border-bottom: 2px solid #F59E0B;">
<h3 style="color:#B45309; display:flex; align-items:center; gap:8px;">
⏰ انقضاء وقت الموعد — إدخال النتيجة والملاحظات
</h3>
<button class="modal-close" onclick="closeModal('modalOverdueUpdate')">&times;</button>
</div>
<div class="modal-body">
<form id="formOverdueUpdate" onsubmit="submitOverdueUpdate(event)">
<input type="hidden" id="overdueApptId">
<div style="background:#F8FAFC; border:1px solid #E2E8F0; padding:12px; border-radius:8px; margin-bottom:15px; font-size:0.9rem; color:#0F172A;">
<div><strong>👤 اسم المراجع:</strong> <span id="overdueVisitorName">—</span></div>
<div><strong>📄 رقم القضية/الصادر:</strong> <span id="overdueCaseNumber">—</span></div>
<div><strong>⏱️ تاريخ ووقت الموعد:</strong> <span id="overdueApptDateTime">—</span></div>
</div>
<div class="form-group">
<label style="font-weight:700; color:#0F172A;">نتيجة الموعد / الحالة الجديدة *</label>
<select id="overdueStatusSelect" class="form-control" style="font-weight:700;" required onchange="toggleOverdueBranchFields()">
<option value="تم الحضور">✅ تم الحضور (حضر المراجع)</option>
<option value="لم يحضر">❌ لم يحضر (تخلف عن الموعد)</option>
<option value="مُؤجل">🔄 تأجيل وإعادة جدولة (حجز موعد فرعي جديد)</option>
<option value="لم يجيبوا">📵 لم يجيبوا (الاتصال معلق)</option>
<option value="ملغى">🚫 ملغى</option>
</select>
</div>
<!-- Additional Date & Time fields if 'مُؤجل' selected -->
<div id="overdueBranchFields" style="display:none; background:#F3E8FF; padding:12px; border-radius:8px; margin-bottom:15px; border:1px solid #DDD6FE;">
<div class="form-row">
<div class="form-group">
<label style="color:#6B21A8; font-weight:700;">تاريخ الموعد الجديد *</label>
<input type="date" id="overdueNewDate" class="form-control">
</div>
<div class="form-group">
<label style="color:#6B21A8; font-weight:700;">وقت الموعد الجديد *</label>
<input type="time" id="overdueNewTime" class="form-control">
</div>
</div>
</div>
<div class="form-group">
<label style="font-weight:700; color:#0F172A;">👤 إسناد / تحويل الموعد إلى الموظف (الضابط المسؤول)</label>
<select id="overdueAssignOfficerSelect" class="form-control" style="font-weight:700;">
<option value="">— جاري تحميل قائمة الموظفين... —</option>
</select>
</div>
<div class="form-group">
<label style="font-weight:700; color:#0F172A;">ملاحظات الإجراء والنتيجة التفصيلية *</label>
<textarea id="overdueActionNotes" class="form-control" rows="3" required
placeholder="أدخل ملاحظات الإجراء، سبب عدم الحضور، أو تفاصيل كتاب الصادر/المواجهة..."></textarea>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary btn-lg" style="background:#D97706; border-color:#D97706;">💾 حفظ النتيجة والملاحظات</button>
<button type="button" class="btn btn-ghost" onclick="closeModal('modalOverdueUpdate')">إلغاء</button>
</div>
</form>
</div>
</div>
</div>
<!-- ═══ Appointment Detail Modal ══════════════════════════════════════ -->
<div id="modalAppointmentDetail" class="modal-overlay">
<div class="modal" style="max-width: 760px;">
<div class="modal-header" style="background: linear-gradient(135deg, #1E3A8A 0%, #1E40AF 100%);">
<h3 style="color:#fff; display:flex; align-items:center; gap:0.5rem;">📋 <span id="apptDetailTitle">تفاصيل الموعد</span></h3>
<button class="modal-close" style="color:#fff;" onclick="closeModal('modalAppointmentDetail')">&times;</button>
</div>
<div class="modal-body" style="padding: 0;">
<!-- Info Cards Row -->
<div id="apptDetailInfoRow" style="display:grid; grid-template-columns: repeat(auto-fit,minmax(180px,1fr)); gap:0; border-bottom: 1px solid var(--border-color);">
<!-- Populated dynamically -->
</div>
<div style="display:grid; grid-template-columns: 1fr 1fr; gap:0;">
<!-- Left: Action History -->
<div style="padding: 1.25rem; border-left: 1px solid var(--border-color);">
<h4 style="margin-bottom:1rem; color:var(--accent-primary); font-size:0.95rem;">⚙️ سجل الإجراءات</h4>
<div id="apptDetailHistory" style="max-height:260px; overflow-y:auto;">
<div style="color:var(--text-muted); text-align:center; padding:2rem;">جاري التحميل...</div>
</div>
</div>
<!-- Right: Previous Appointments for same case -->
<div style="padding: 1.25rem;">
<h4 style="margin-bottom:1rem; color:var(--accent-primary); font-size:0.95rem;">🕰️ المواعيد السابقة لنفس القضية</h4>
<div id="apptDetailPrevious" style="max-height:260px; overflow-y:auto;">
<div style="color:var(--text-muted); text-align:center; padding:2rem;">جاري التحميل...</div>
</div>
</div>
</div>
</div>
<div class="modal-footer" style="justify-content:flex-end;">
<button type="button" class="btn btn-ghost" onclick="closeModal('modalAppointmentDetail')">إغلاق</button>
</div>
</div>
</div>
<!-- Toast Container -->
<div id="toastContainer" class="toast-container"></div>
<script src="/leaflet.js"></script>
<script src="/complaints/js/app.js?v=21"></script>
<!-- Map integration -->
<script src="/complaints/js/map.js"></script>
<!-- Floating Chat Widget (Rule 21 Modernized) -->
<div id="chatPane" class="chat-widget">
<div class="chat-widget-header" style="display: flex; justify-content: space-between; align-items: center; gap: 8px;">
<div style="flex:1; min-width:0;">
<h3 style="margin:0; font-size:0.95rem; display:flex; align-items:center; gap:6px; color:#ffffff !important; flex-wrap:wrap;">
<span>💬 غرفة الاجتماعات</span>
<span id="chatDateBadge" class="badge badge-purple" style="font-size:0.65rem; font-weight:700; padding:2px 6px;">المحادثة الفورية</span>
</h3>
<div style="font-size:0.68rem; color:rgba(255,255,255,0.85); margin-top:2px;">🧹 تتفرغ المحادثات وتُؤرشف تلقائياً يومياً</div>
</div>
<div style="display:flex; align-items:center; gap:6px; flex-shrink:0;">
<button class="btn btn-sm" onclick="toggleChatArchiveModal()" title="أرشيف المحادثات السابقة" style="color:#ffffff !important; background:rgba(255,255,255,0.18); border:1px solid rgba(255,255,255,0.35); font-size:0.75rem; padding:3px 8px; border-radius:var(--radius-sm); white-space:nowrap;">
📜 الأرشيف
</button>
<button class="modal-close" onclick="toggleChatPane()" style="color:#ffffff; font-size:1.4rem; cursor:pointer; background:none; border:none; padding:0 4px;">&times;</button>
</div>
</div>
<div class="chat-widget-body">
<!-- Active Room Participants Section -->
<div class="chat-online-users">
<strong>👥 المشاركون الفعّالون بالمحادثة الآن:</strong>
<div id="onlineUsersList" class="online-users-list"></div>
</div>
<div id="chatMessages" class="chat-messages">
<div class="chat-bubble system">مرحباً بك في نظام التواصل الداخلي. تتجدد الغرفة يومياً ويتم أرشفة الرسائل تلقائياً.</div>
</div>
</div>
<div class="chat-input-area">
<input type="text" id="chatInput" placeholder="اكتب رسالتك هنا..." onkeydown="handleChatKey(event)">
<button class="btn btn-primary" onclick="sendChatMessage()">إرسال</button>
</div>
</div>
<!-- Chat Archive Modal -->
<div id="modalChatArchive" class="modal-overlay">
<div class="modal" style="max-width: 650px;">
<div class="modal-header" style="background: var(--primary-color, #1e3a8a); color: white;">
<h3 style="margin:0; font-size:1.1rem; color:#ffffff !important;">📜 أرشيف المحادثات اليومية السابقة</h3>
<button class="modal-close" onclick="closeModal('modalChatArchive')" style="color: white;">&times;</button>
</div>
<div class="modal-body" style="padding: 1.25rem;">
<div style="display: flex; gap: 10px; align-items: center; margin-bottom: 1rem; background: #f8fafc; padding: 10px 14px; border-radius: var(--radius-md); border: 1px solid #e2e8f0;">
<label style="margin: 0; font-weight: bold; font-size:0.85rem; color:#1e293b;">اختر تاريخ الأرشيف:</label>
<input type="date" id="chatArchiveDatePicker" class="form-control" onchange="loadArchivedChatByPicker()" style="width: 170px; padding:0.4rem;">
<button class="btn btn-outline btn-sm" onclick="loadChatArchivesList()" style="font-size:0.8rem;">🔄 القائمة الكاملة</button>
</div>
<div style="font-size:0.8rem; font-weight:bold; color:var(--text-secondary); margin-bottom:6px;">الأيام المؤرشفة المتاحة:</div>
<div id="chatArchivesListContainer" style="margin-bottom: 1rem; display: flex; flex-wrap: wrap; gap: 6px; max-height: 100px; overflow-y: auto; padding:4px; background:#f1f5f9; border-radius:6px;">
<!-- Populated dynamically -->
</div>
<div style="border: 1px solid #cbd5e1; border-radius: var(--radius-md); padding: 12px; background: #ffffff; box-shadow:0 1px 3px rgba(0,0,0,0.05);">
<div id="archiveDateTitle" style="font-weight: 800; margin-bottom: 10px; color: #1e3a8a; font-size: 0.9rem; border-bottom:1px dashed #cbd5e1; padding-bottom:6px;">
اختر يوماً من الأرشيف أعلى الشاشة لعرض السجل كامل.
</div>
<div id="archivedChatMessages" class="chat-messages" style="background: #f8fafc; height: 260px; overflow-y: auto; padding:10px; border-radius:6px; border:1px solid #e2e8f0;">
<div style="text-align: center; color: #64748b; font-size: 0.85rem; padding: 2rem 0;">
لا توجد رسائل معروضة حالياً.
</div>
</div>
</div>
</div>
<div class="modal-footer" style="display:flex; justify-content:space-between; align-items:center;">
<button class="btn btn-outline" onclick="exportArchivedChatText()">📥 تصدير السجل نصياً (.txt)</button>
<button class="btn btn-ghost" onclick="closeModal('modalChatArchive')">إغلاق</button>
</div>
</div>
</div>
</body>
</html>