mohadese-dashboards/dashboards/cockpit.html

2577 lines
106 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="fa" dir="rtl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ExecCockpit | سیستم عامل مدیریت اجرایی حامد فلاحی</title>
<!-- Vazirmatn Font -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800;900&display=swap" rel="stylesheet">
<style>
:root {
--bg-base: #090a0f;
--bg-surface: #11131a;
--bg-surface-elevated: #181b24;
--bg-surface-hover: #222634;
--border-subtle: #252a38;
--border-strong: #384054;
--text-main: #f1f5f9;
--text-muted: #94a3b8;
--text-faint: #64748b;
--primary: #3b82f6;
--primary-hover: #2563eb;
--primary-glow: rgba(59, 130, 246, 0.25);
--accent-green: #10b981;
--accent-amber: #f59e0b;
--accent-rose: #f43f5e;
--accent-purple: #8b5cf6;
--radius-sm: 8px;
--radius-md: 12px;
--radius-lg: 16px;
--transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
font-feature-settings: "tnum" 1;
}
body {
background-color: var(--bg-base);
color: var(--text-main);
min-height: 100vh;
display: flex;
flex-direction: column;
overflow-x: hidden;
line-height: 1.6;
}
/* Scrollbars */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }
/* Top Header */
header {
background: rgba(17, 19, 26, 0.9);
backdrop-filter: blur(12px);
border-bottom: 1px solid var(--border-subtle);
position: sticky;
top: 0;
z-index: 50;
padding: 0.75rem 1.5rem;
}
.header-inner {
max-width: 1440px;
margin: 0 auto;
display: flex;
align-items: center;
justify-content: space-between;
gap: 1rem;
}
.brand {
display: flex;
align-items: center;
gap: 0.75rem;
text-decoration: none;
color: inherit;
}
.brand-logo {
width: 36px;
height: 36px;
background: linear-gradient(135deg, #3b82f6, #8b5cf6);
border-radius: var(--radius-sm);
display: flex;
align-items: center;
justify-content: center;
font-weight: 800;
color: white;
font-size: 1.15rem;
box-shadow: 0 0 16px var(--primary-glow);
}
.brand-title {
font-size: 1.05rem;
font-weight: 700;
letter-spacing: -0.02em;
}
.brand-subtitle {
font-size: 0.75rem;
color: var(--text-muted);
}
.user-pill {
display: flex;
align-items: center;
gap: 0.6rem;
background: var(--bg-surface-elevated);
border: 1px solid var(--border-subtle);
padding: 0.35rem 0.85rem;
border-radius: 20px;
font-size: 0.82rem;
color: var(--text-main);
}
.sync-status {
display: flex;
align-items: center;
gap: 0.5rem;
font-size: 0.8rem;
padding: 0.35rem 0.75rem;
border-radius: 20px;
background: var(--bg-surface-elevated);
border: 1px solid var(--border-subtle);
color: var(--text-muted);
}
.sync-dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--accent-green);
box-shadow: 0 0 8px var(--accent-green);
}
.sync-dot.syncing {
background: var(--accent-amber);
box-shadow: 0 0 8px var(--accent-amber);
animation: pulse 1s infinite alternate;
}
@keyframes pulse {
0% { opacity: 0.4; transform: scale(0.9); }
100% { opacity: 1; transform: scale(1.1); }
}
/* Master Tabs */
.nav-tabs {
display: flex;
gap: 0.5rem;
overflow-x: auto;
padding: 0.65rem 1.5rem;
background: var(--bg-surface);
border-bottom: 1px solid var(--border-subtle);
max-width: 1440px;
margin: 0 auto;
width: 100%;
}
.tab-btn {
padding: 0.45rem 0.9rem;
border-radius: var(--radius-sm);
border: 1px solid transparent;
background: transparent;
color: var(--text-muted);
font-size: 0.85rem;
font-weight: 500;
cursor: pointer;
white-space: nowrap;
transition: var(--transition);
display: flex;
align-items: center;
gap: 0.45rem;
}
.tab-btn:hover {
background: var(--bg-surface-hover);
color: var(--text-main);
}
.tab-btn.active {
background: var(--bg-surface-elevated);
border-color: var(--border-strong);
color: var(--primary);
font-weight: 600;
}
/* Badges */
.badge {
display: inline-flex;
align-items: center;
justify-content: center;
padding: 0.15rem 0.45rem;
border-radius: 12px;
font-size: 0.72rem;
font-weight: 700;
line-height: 1;
}
.badge-primary { background: rgba(59, 130, 246, 0.18); color: #60a5fa; }
.badge-rose { background: rgba(244, 63, 94, 0.18); color: #fb7185; }
.badge-amber { background: rgba(245, 158, 11, 0.18); color: #fcd34d; }
.badge-green { background: rgba(16, 185, 129, 0.18); color: #34d399; }
.badge-purple { background: rgba(139, 92, 246, 0.18); color: #c084fc; }
/* Main Container */
main {
flex: 1;
max-width: 1440px;
width: 100%;
margin: 0 auto;
padding: 1.5rem;
}
/* Gateway Landing Screen */
.gateway-container {
max-width: 960px;
margin: 2.5rem auto;
padding: 1rem;
}
.gateway-header {
text-align: center;
margin-bottom: 2.5rem;
}
.gateway-title {
font-size: 1.8rem;
font-weight: 800;
margin-bottom: 0.5rem;
background: linear-gradient(135deg, #ffffff, #94a3b8);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
.gateway-desc {
font-size: 0.95rem;
color: var(--text-muted);
max-width: 600px;
margin: 0 auto;
}
.gateway-cards {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
gap: 1.5rem;
}
.gateway-card {
background: var(--bg-surface);
border: 1px solid var(--border-subtle);
border-radius: var(--radius-lg);
padding: 1.75rem 1.5rem;
display: flex;
flex-direction: column;
justify-content: space-between;
transition: var(--transition);
cursor: pointer;
position: relative;
overflow: hidden;
}
.gateway-card::before {
content: '';
position: absolute;
top: 0;
right: 0;
width: 100%;
height: 4px;
background: var(--border-strong);
transition: var(--transition);
}
.gateway-card:hover {
border-color: var(--primary);
transform: translateY(-4px);
box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}
.gateway-card.card-hamed:hover::before { background: #3b82f6; }
.gateway-card.card-mohadese:hover::before { background: #8b5cf6; }
.gateway-card.card-team:hover::before { background: #10b981; }
.gateway-icon {
width: 48px;
height: 48px;
border-radius: var(--radius-md);
display: flex;
align-items: center;
justify-content: center;
font-size: 1.5rem;
margin-bottom: 1.25rem;
background: var(--bg-surface-elevated);
border: 1px solid var(--border-strong);
}
.gateway-card-title {
font-size: 1.2rem;
font-weight: 700;
margin-bottom: 0.35rem;
}
.gateway-card-desc {
font-size: 0.85rem;
color: var(--text-muted);
line-height: 1.6;
margin-bottom: 1.5rem;
flex-grow: 1;
}
/* Cards & Containers */
.card {
background: var(--bg-surface);
border: 1px solid var(--border-subtle);
border-radius: var(--radius-md);
padding: 1.25rem;
transition: var(--transition);
position: relative;
}
.card:hover {
border-color: var(--border-strong);
}
.card-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 1rem;
padding-bottom: 0.75rem;
border-bottom: 1px solid var(--border-subtle);
}
.card-title {
font-size: 1rem;
font-weight: 700;
display: flex;
align-items: center;
gap: 0.5rem;
}
/* Info Tooltip Icon */
.info-icon {
display: inline-flex;
align-items: center;
justify-content: center;
width: 18px;
height: 18px;
border-radius: 50%;
background: var(--bg-surface-elevated);
color: var(--text-muted);
border: 1px solid var(--border-strong);
font-size: 0.75rem;
font-style: normal;
cursor: help;
transition: var(--transition);
position: relative;
}
.info-icon:hover {
color: var(--primary);
border-color: var(--primary);
}
.info-icon[data-tooltip]::after {
content: attr(data-tooltip);
position: absolute;
bottom: 125%;
right: 50%;
transform: translateX(50%);
background: #1e2230;
color: #f1f5f9;
padding: 0.5rem 0.75rem;
border-radius: var(--radius-sm);
font-size: 0.75rem;
font-weight: 400;
white-space: normal;
width: 240px;
line-height: 1.4;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
border: 1px solid var(--border-strong);
pointer-events: none;
opacity: 0;
visibility: hidden;
transition: opacity 0.2s ease, visibility 0.2s;
z-index: 100;
text-align: right;
}
.info-icon:hover::after {
opacity: 1;
visibility: visible;
}
/* Buttons */
.btn {
display: inline-flex;
align-items: center;
gap: 0.4rem;
padding: 0.5rem 1rem;
border-radius: var(--radius-sm);
border: 1px solid var(--border-strong);
background: var(--bg-surface-elevated);
color: var(--text-main);
font-size: 0.85rem;
font-weight: 500;
cursor: pointer;
transition: var(--transition);
text-decoration: none;
}
.btn:hover {
background: var(--bg-surface-hover);
border-color: var(--text-faint);
}
.btn-primary {
background: var(--primary);
border-color: var(--primary);
color: white;
}
.btn-primary:hover {
background: var(--primary-hover);
box-shadow: 0 0 12px var(--primary-glow);
}
.btn-success {
background: rgba(16, 185, 129, 0.15);
border-color: rgba(16, 185, 129, 0.3);
color: #34d399;
}
.btn-success:hover {
background: var(--accent-green);
color: white;
}
.btn-danger {
background: rgba(244, 63, 94, 0.15);
border-color: rgba(244, 63, 94, 0.3);
color: #fb7185;
}
.btn-danger:hover {
background: var(--accent-rose);
color: white;
}
.btn-sm {
padding: 0.3rem 0.65rem;
font-size: 0.78rem;
}
/* Forms & Inputs */
.form-group {
margin-bottom: 1rem;
}
.form-label {
display: block;
font-size: 0.8rem;
font-weight: 600;
color: var(--text-muted);
margin-bottom: 0.4rem;
}
.form-control {
width: 100%;
padding: 0.6rem 0.85rem;
background: var(--bg-base);
border: 1px solid var(--border-strong);
border-radius: var(--radius-sm);
color: var(--text-main);
font-size: 0.9rem;
transition: var(--transition);
}
.form-control:focus {
outline: none;
border-color: var(--primary);
box-shadow: 0 0 0 3px var(--primary-glow);
}
textarea.form-control {
resize: vertical;
min-height: 80px;
}
/* Grids */
.grid-2 {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
gap: 1.25rem;
}
.grid-3 {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
gap: 1.25rem;
}
/* Tables */
.table-container {
overflow-x: auto;
border-radius: var(--radius-sm);
border: 1px solid var(--border-subtle);
}
table {
width: 100%;
border-collapse: collapse;
text-align: right;
font-size: 0.85rem;
}
th {
background: var(--bg-surface-elevated);
color: var(--text-muted);
padding: 0.75rem 1rem;
font-weight: 600;
border-bottom: 1px solid var(--border-subtle);
white-space: nowrap;
}
td {
padding: 0.75rem 1rem;
border-bottom: 1px solid var(--border-subtle);
color: var(--text-main);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-surface-hover); }
/* Action bar */
.action-bar {
display: flex;
align-items: center;
justify-content: space-between;
gap: 1rem;
margin-bottom: 1.25rem;
flex-wrap: wrap;
}
.search-box {
flex: 1;
min-width: 240px;
position: relative;
}
.search-input {
width: 100%;
padding: 0.55rem 2.2rem 0.55rem 0.85rem;
background: var(--bg-surface);
border: 1px solid var(--border-strong);
border-radius: var(--radius-sm);
color: var(--text-main);
font-size: 0.85rem;
}
.search-icon {
position: absolute;
right: 0.75rem;
top: 50%;
transform: translateY(-50%);
color: var(--text-faint);
}
/* Modals */
.modal-overlay {
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.78);
backdrop-filter: blur(4px);
display: flex;
align-items: center;
justify-content: center;
z-index: 100;
padding: 1rem;
opacity: 0;
pointer-events: none;
transition: opacity 0.2s ease;
}
.modal-overlay.active {
opacity: 1;
pointer-events: auto;
}
.modal-content {
background: var(--bg-surface);
border: 1px solid var(--border-strong);
border-radius: var(--radius-lg);
width: 100%;
max-width: 550px;
max-height: 90vh;
overflow-y: auto;
padding: 1.5rem;
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}
.modal-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 1.25rem;
padding-bottom: 0.75rem;
border-bottom: 1px solid var(--border-subtle);
}
.modal-title { font-size: 1.1rem; font-weight: 700; }
.modal-close {
background: none;
border: none;
color: var(--text-muted);
cursor: pointer;
font-size: 1.25rem;
line-height: 1;
}
.modal-close:hover { color: var(--text-main); }
/* Toast */
.toast-container {
position: fixed;
bottom: 1.5rem;
left: 1.5rem;
z-index: 200;
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.toast {
background: var(--bg-surface-elevated);
border: 1px solid var(--border-strong);
color: var(--text-main);
padding: 0.75rem 1.25rem;
border-radius: var(--radius-sm);
box-shadow: 0 4px 20px rgba(0,0,0,0.4);
display: flex;
align-items: center;
gap: 0.6rem;
font-size: 0.85rem;
animation: slideIn 0.2s ease;
}
@keyframes slideIn {
from { transform: translateY(20px); opacity: 0; }
to { transform: translateY(0); opacity: 1; }
}
/* Footer */
footer {
border-top: 1px solid var(--border-subtle);
padding: 1.25rem 1.5rem;
background: var(--bg-surface);
font-size: 0.8rem;
color: var(--text-muted);
margin-top: auto;
}
.footer-inner {
max-width: 1440px;
margin: 0 auto;
display: flex;
align-items: center;
justify-content: space-between;
flex-wrap: wrap;
gap: 1rem;
}
/* Responsive */
@media (max-width: 768px) {
.header-inner { flex-direction: column; align-items: stretch; }
.nav-tabs { padding: 0.5rem 1rem; }
main { padding: 1rem; }
.action-bar { flex-direction: column; align-items: stretch; }
}
</style>
</head>
<body>
<!-- Top Header -->
<header>
<div class="header-inner">
<div class="brand">
<div class="brand-logo">H</div>
<div>
<div class="brand-title">ExecCockpit | سیستم عامل مدیریت اجرایی حامد فلاحی</div>
<div class="brand-subtitle" id="topSubtitle">پورتال هماهنگی عملیات و تصمیمات راهبردی</div>
</div>
</div>
<!-- User & Status Bar -->
<div style="display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;">
<div class="user-pill" id="userPill" style="display: none;">
<span id="userNameLabel">کاربر فعال</span>
<button class="btn btn-sm" onclick="logout()" style="padding: 0.2rem 0.5rem; font-size: 0.75rem; border-color: var(--border-strong);">
خروج 🚪
</button>
</div>
<div class="sync-status">
<span class="sync-dot" id="syncDot"></span>
<span id="syncText">🟢 اصالت داده: PostgreSQL 17 زنده (/api/db/state)</span>
<i class="info-icon" data-tooltip="این سیستم داده‌ها را بدون وابستگی به localStorage مستقیماً در جدول دائمی ekeepa_bi.dashboard_app_storage ذخیره و همگام می‌کند.">ⓘ</i>
</div>
</div>
</div>
</header>
<!-- Master Sub-navigation (Only in Mohadese Master View) -->
<nav class="nav-tabs" id="masterNav" style="display: none;">
<button class="tab-btn active" onclick="switchMasterTab('approvals')">
⚡ صف تاییدیه‌ها <span class="badge badge-rose" id="badgeApprovals">0</span>
<i class="info-icon" data-tooltip="درخواست‌های ارسالی همکاران یا مواردی که منتظر تایید نهایی حامد هستند.">ⓘ</i>
</button>
<button class="tab-btn" onclick="switchMasterTab('meetings')">
📅 جلسات و تردد <span class="badge badge-primary" id="badgeMeetings">0</span>
<i class="info-icon" data-tooltip="برنامه جلسات آنلاین با لینک میت، و حضوری با پین نشان و بافر ترافیک تهران.">ⓘ</i>
</button>
<button class="tab-btn" onclick="switchMasterTab('tasks')">
📋 تسک‌های اجرایی <span class="badge badge-amber" id="badgeTasks">0</span>
<i class="info-icon" data-tooltip="مدیریت تسک‌های تیم با تفکیک اولویت، مسئول و مهلت تحویل.">ⓘ</i>
</button>
<button class="tab-btn" onclick="switchMasterTab('finance')">
💳 رادار مالی و اقساط <span class="badge badge-green" id="badgeFinance">0</span>
<i class="info-icon" data-tooltip="سررسید اقساط تسهیلات بانکی، تنخواه‌ها و واریزی‌های معین.">ⓘ</i>
</button>
<button class="tab-btn" onclick="switchMasterTab('contacts')">
📇 مخاطبین VIP <span class="badge badge-purple" id="badgeContacts">0</span>
<i class="info-icon" data-tooltip="دفترچه راهبردی تفکیک‌شده: ایکیپا، مایندرو، شخصی و سرمایه‌گذاران.">ⓘ</i>
</button>
<button class="tab-btn" onclick="switchMasterTab('vault')">
📁 آرشیو و اسناد درایو
<i class="info-icon" data-tooltip="لینک‌های دسترسی سریع به فولدرهای گوگل‌درایو، مدارک شرکتی، هویتی و قراردادها.">ⓘ</i>
</button>
<button class="tab-btn" onclick="switchMasterTab('recycle')">
🗑️ سطل بازیافت و بکاپ <span class="badge badge-primary" id="badgeRecycle">0</span>
<i class="info-icon" data-tooltip="تمامی آیتم‌های حذف‌شده در اینجا نگهداری می‌شوند و قابل بازگردانی کامل هستند.">ⓘ</i>
</button>
</nav>
<!-- Hamed Sub-navigation (Only in Hamed View) -->
<nav class="nav-tabs" id="hamedNav" style="display: none;">
<button class="tab-btn active" onclick="switchHamedTab('today')">
⚡ تصمیمات و جلسات امروز
<i class="info-icon" data-tooltip="تاییدیه‌های فوری P0 و لیست جلسات آنلاین و حضوری امروز با دسترسی سریع.">ⓘ</i>
</button>
<button class="tab-btn" onclick="switchHamedTab('finance')">
💳 سررسید اقساط و چک‌ها <span class="badge badge-amber" id="badgeHamedFinance">0</span>
<i class="info-icon" data-tooltip="جزئیات تعهدات مالی و اقساط ۷ روز آینده و ماهانه همراه با روزشمار باقی‌مانده.">ⓘ</i>
</button>
<button class="tab-btn" onclick="switchHamedTab('contacts')">
📇 مخاطبین VIP
<i class="info-icon" data-tooltip="دفترچه مخاطبین مهم کاری، شرکا و سرمایه‌گذاران با امکان تماس مستقیم.">ⓘ</i>
</button>
<button class="tab-btn" onclick="switchHamedTab('vault')">
📁 آرشیو و اسناد درایو
<i class="info-icon" data-tooltip="دسترسی سریع به پوشه‌های اسناد حقوقی، مدارک هویتی و قراردادهای شرکت.">ⓘ</i>
</button>
</nav>
<!-- Main Viewports -->
<main>
<!-- ==================== 1. GATEWAY SCREEN ==================== -->
<section id="viewGateway" class="gateway-container">
<div class="gateway-header">
<h1 class="gateway-title">دروازه ورود به سامانه ExecCockpit</h1>
<p class="gateway-desc">لطفاً پروفایل مورد نظر خود را جهت ورود به میز کار اختصاصی یا ثبت درخواست انتخاب نمایید.</p>
</div>
<div class="gateway-cards">
<!-- Card 1: Hamed -->
<div class="gateway-card card-hamed" onclick="openLoginModal('hamed')">
<div>
<div class="gateway-icon">👤</div>
<div class="gateway-card-title">حامد فلاحی</div>
<span class="badge badge-primary" style="margin-bottom: 0.75rem;">ورود مدیریت (Executive Focus)</span>
<p class="gateway-card-desc">
نمای اختصاصی و متمرکز؛ دسترسی سریع به تاییدیه‌های فوری، جلسات امروز، سررسید اقساط، مخاطبین VIP و اسناد درایو.
</p>
</div>
<button class="btn btn-primary" style="width: 100%; justify-content: center;">
ورود به میز کار حامد 🔒
</button>
</div>
<!-- Card 2: Mohadese -->
<div class="gateway-card card-mohadese" onclick="openLoginModal('mohadese')">
<div>
<div class="gateway-icon">⚙️</div>
<div class="gateway-card-title">محدثه معصومی</div>
<span class="badge badge-purple" style="margin-bottom: 0.75rem;">سرپرست عملیات (Master Ops)</span>
<p class="gateway-card-desc">
پنل مدیریت جامع فرآیندها؛ کنترل کامل CRUD، مدیریت جلسات، تسک‌ها، رادار مالی، سطل بازیافت و دانلود بکاپ آفلاین.
</p>
</div>
<button class="btn btn-primary" style="width: 100%; justify-content: center; background: #8b5cf6; border-color: #8b5cf6;">
ورود به پنل مستر محدثه 🔒
</button>
</div>
<!-- Card 3: Team Intake -->
<div class="gateway-card card-team" onclick="openGuestTeamPortal()">
<div>
<div class="gateway-icon">📥</div>
<div class="gateway-card-title">ثبت تسک‌های نیاز به تایید</div>
<span class="badge badge-green" style="margin-bottom: 0.75rem;">پرتال اعضای تیم (ورودی امن)</span>
<p class="gateway-card-desc">
ارسال مستقیم درخواست تاییدیه یا موضوع کاری به کارتابل حامد فلاحی؛ بدون نیاز به رمز و بدون دسترسی به سایر اطلاعات سیستم.
</p>
</div>
<button class="btn btn-success" style="width: 100%; justify-content: center;">
ورود به فرم ثبت درخواست 🚀
</button>
</div>
</div>
</section>
<!-- ==================== 2. HAMED VIEW ==================== -->
<section id="viewHamed" style="display: none;">
<!-- Welcome Banner -->
<div style="background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(139, 92, 246, 0.1)); border: 1px solid rgba(59, 130, 246, 0.3); border-radius: var(--radius-md); padding: 1.25rem 1.5rem; margin-bottom: 1.5rem; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1rem;">
<div>
<h2 style="font-size: 1.25rem; margin-bottom: 0.3rem;">درود حامد عزیز؛ میز کار تصمیم‌گیری و برنامه‌ریزی</h2>
<p style="color: var(--text-muted); font-size: 0.85rem;">این نما برای حفظ تمرکز شما بر اولویت‌های اجرایی، جلسات، بدهی‌ها و اسناد کلیدی بهینه‌سازی شده است.</p>
</div>
<div style="display: flex; gap: 0.5rem;">
<button class="btn btn-sm btn-primary" onclick="exportFullBackup()">📥 دانلود بکاپ آفلاین</button>
<button class="btn btn-sm btn-danger" onclick="logout()">خروج از حساب</button>
</div>
</div>
<!-- KPI Ribbon -->
<div class="grid-3" style="margin-bottom: 1.5rem;">
<div class="card" style="padding: 1rem;">
<div style="font-size: 0.8rem; color: var(--text-muted); display: flex; align-items: center; gap: 0.35rem; margin-bottom: 0.3rem;">
⚡ تاییدیه‌های فوری معطل اقدام شما
<i class="info-icon" data-tooltip="درخواست‌های مهم اعضای تیم که بدون نظر شما متوقف مانده‌اند.">ⓘ</i>
</div>
<div style="font-size: 1.8rem; font-weight: 800; color: var(--accent-rose);" id="kpiHamedApprovals">0</div>
</div>
<div class="card" style="padding: 1rem;">
<div style="font-size: 0.8rem; color: var(--text-muted); display: flex; align-items: center; gap: 0.35rem; margin-bottom: 0.3rem;">
📅 جلسات زمان‌بندی‌شده امروز
<i class="info-icon" data-tooltip="جلسات آنلاین و حضوری با احتساب بافرهای استراحت و ترافیک.">ⓘ</i>
</div>
<div style="font-size: 1.8rem; font-weight: 800; color: var(--primary);" id="kpiHamedMeetings">0</div>
</div>
<div class="card" style="padding: 1rem;">
<div style="font-size: 0.8rem; color: var(--text-muted); display: flex; align-items: center; gap: 0.35rem; margin-bottom: 0.3rem;">
💳 اقساط و چک‌های در انتظار پرداخت
<i class="info-icon" data-tooltip="سرجمع اقساط و تعهدات مالی ۷ روز آینده.">ⓘ</i>
</div>
<div style="font-size: 1.8rem; font-weight: 800; color: var(--accent-amber);" id="kpiHamedFinance">0</div>
</div>
</div>
<!-- Hamed Tab: Today Focus -->
<div id="hamedTabToday" class="hamed-tab-content">
<div class="grid-2">
<!-- Approvals Queue -->
<div class="card">
<div class="card-header">
<div class="card-title">
⚡ کارتابل تاییدیه فوری حامد
<i class="info-icon" data-tooltip="درخواست‌های ارسالی همکاران؛ با یک کلیک تایید یا رد کنید.">ⓘ</i>
</div>
<span class="badge badge-rose">نیاز به تصمیم</span>
</div>
<div id="hamedApprovalsList" style="display: flex; flex-direction: column; gap: 0.75rem;"></div>
</div>
<!-- Today Meetings -->
<div class="card">
<div class="card-header">
<div class="card-title">
📅 جلسات امروز و دسترسی سریع
<i class="info-icon" data-tooltip="جلسات آنلاین با لینک میت، و حضوری با بافر ترافیک و پین نشان.">ⓘ</i>
</div>
<span class="badge badge-primary">برنامه امروز</span>
</div>
<div id="hamedMeetingsList" style="display: flex; flex-direction: column; gap: 0.75rem;"></div>
</div>
</div>
</div>
<!-- Hamed Tab: Detailed Finance -->
<div id="hamedTabFinance" class="hamed-tab-content" style="display: none;">
<div class="card">
<div class="card-header">
<div class="card-title">
💳 جزئیات سررسید اقساط، چک‌ها و تعهدات مالی
<i class="info-icon" data-tooltip="فهرست تسهیلات، وام‌ها، مبالغ به تومان و روزشمار باقی‌مانده تا سررسید.">ⓘ</i>
</div>
<span class="badge badge-amber">تعهدات مالی</span>
</div>
<div class="table-container">
<table>
<thead>
<tr>
<th>موضوع تسهیلات / تعهد</th>
<th>بانک / مرجع</th>
<th>مبلغ (تومان)</th>
<th>تاریخ سررسید</th>
<th>روزشمار باقی‌مانده</th>
<th>شماره قرارداد / یادداشت</th>
<th>وضعیت</th>
<th>اقدام</th>
</tr>
</thead>
<tbody id="tableBodyHamedFinance"></tbody>
</table>
</div>
</div>
</div>
<!-- Hamed Tab: Contacts VIP -->
<div id="hamedTabContacts" class="hamed-tab-content" style="display: none;">
<div class="card">
<div class="card-header">
<div class="card-title">
📇 دفترچه مخاطبین کلیدی و VIP
<i class="info-icon" data-tooltip="فهرست شماره تماس‌ها و آیدی‌های تلگرام همکاران، شرکا و سرمایه‌گذاران.">ⓘ</i>
</div>
<div class="search-box" style="max-width: 320px;">
<span class="search-icon">🔍</span>
<input type="text" class="search-input" placeholder="جستجوی نام یا سازمان..." oninput="filterHamedContacts(this.value)">
</div>
</div>
<div class="table-container">
<table>
<thead>
<tr>
<th>نام و نام خانوادگی</th>
<th>دسته‌بندی</th>
<th>سازمان و سمت</th>
<th>شماره تماس</th>
<th>آیدی تلگرام</th>
<th>نکات و ترجیحات</th>
<th>ارتباط مستقیم</th>
</tr>
</thead>
<tbody id="tableBodyHamedContacts"></tbody>
</table>
</div>
</div>
</div>
<!-- Hamed Tab: Vault Drive -->
<div id="hamedTabVault" class="hamed-tab-content" style="display: none;">
<div class="card">
<div class="card-header">
<div class="card-title">
📁 آرشیو اسناد و پوشه‌های گوگل درایو
<i class="info-icon" data-tooltip="دسترسی سریع و مستقیم به فولدرهای حقوقی، مالی، مدارک هویتی و قراردادها.">ⓘ</i>
</div>
<span class="badge badge-primary">اسناد و فایل‌ها</span>
</div>
<div class="table-container">
<table>
<thead>
<tr>
<th>عنوان پوشه یا سند</th>
<th>دسته‌بندی</th>
<th>سطح محرمانگی</th>
<th>توضیحات و محتویات</th>
<th>لینک مستقیم</th>
</tr>
</thead>
<tbody id="tableBodyHamedVault"></tbody>
</table>
</div>
</div>
</div>
</section>
<!-- ==================== 3. MOHADESE MASTER VIEW ==================== -->
<section id="viewMaster" style="display: none;">
<!-- Sub Tab: Approvals -->
<div id="tabContentApprovals" class="master-tab-content">
<div class="action-bar">
<div class="search-box">
<span class="search-icon">🔍</span>
<input type="text" class="search-input" placeholder="جستجو در تاییدیه‌ها..." oninput="filterData('approvals', this.value)">
</div>
<button class="btn btn-primary btn-sm" onclick="openNewModal('approval')">+ تاییدیه جدید برای حامد</button>
</div>
<div class="table-container">
<table>
<thead>
<tr>
<th>عنوان تصمیم / درخواست</th>
<th>درخواست‌کننده</th>
<th>فوریت</th>
<th>پیشنهاد / توضیحات</th>
<th>پیوست</th>
<th>وضعیت</th>
<th>عملیات</th>
</tr>
</thead>
<tbody id="tableBodyApprovals"></tbody>
</table>
</div>
</div>
<!-- Sub Tab: Meetings -->
<div id="tabContentMeetings" class="master-tab-content" style="display: none;">
<div class="action-bar">
<div class="search-box">
<span class="search-icon">🔍</span>
<input type="text" class="search-input" placeholder="جستجو در جلسات..." oninput="filterData('meetings', this.value)">
</div>
<button class="btn btn-primary btn-sm" onclick="openNewModal('meeting')">+ ثبت جلسه جدید</button>
</div>
<div class="table-container">
<table>
<thead>
<tr>
<th>عنوان جلسه</th>
<th>نوع</th>
<th>تاریخ و ساعت</th>
<th>طرفین جلسه</th>
<th>بافر / زمان حرکت</th>
<th>لینک میت / لوکیشن</th>
<th>عملیات</th>
</tr>
</thead>
<tbody id="tableBodyMeetings"></tbody>
</table>
</div>
</div>
<!-- Sub Tab: Tasks -->
<div id="tabContentTasks" class="master-tab-content" style="display: none;">
<div class="action-bar">
<div class="search-box">
<span class="search-icon">🔍</span>
<input type="text" class="search-input" placeholder="جستجو در تسک‌ها..." oninput="filterData('tasks', this.value)">
</div>
<button class="btn btn-primary btn-sm" onclick="openNewModal('task')">+ افزودن تسک اجرایی</button>
</div>
<div class="table-container">
<table>
<thead>
<tr>
<th>عنوان تسک</th>
<th>مسئول</th>
<th>دسته</th>
<th>اولویت</th>
<th>مهلت تحویل</th>
<th>وضعیت</th>
<th>عملیات</th>
</tr>
</thead>
<tbody id="tableBodyTasks"></tbody>
</table>
</div>
</div>
<!-- Sub Tab: Finance -->
<div id="tabContentFinance" class="master-tab-content" style="display: none;">
<div class="action-bar">
<div class="search-box">
<span class="search-icon">🔍</span>
<input type="text" class="search-input" placeholder="جستجو در تسهیلات و اقساط..." oninput="filterData('finance', this.value)">
</div>
<button class="btn btn-primary btn-sm" onclick="openNewModal('finance')">+ ثبت تسهیلات یا قسط</button>
</div>
<div class="table-container">
<table>
<thead>
<tr>
<th>موضوع تسهیلات / قسط</th>
<th>بانک / مرجع</th>
<th>مبلغ (تومان)</th>
<th>تاریخ سررسید</th>
<th>شماره قرارداد / تسهیلات</th>
<th>وضعیت</th>
<th>عملیات</th>
</tr>
</thead>
<tbody id="tableBodyFinance"></tbody>
</table>
</div>
</div>
<!-- Sub Tab: Contacts -->
<div id="tabContentContacts" class="master-tab-content" style="display: none;">
<div class="action-bar">
<div class="search-box">
<span class="search-icon">🔍</span>
<input type="text" class="search-input" placeholder="جستجو در مخاطبین..." oninput="filterData('contacts', this.value)">
</div>
<button class="btn btn-primary btn-sm" onclick="openNewModal('contact')">+ افزودن مخاطب VIP</button>
</div>
<div class="table-container">
<table>
<thead>
<tr>
<th>نام و نام خانوادگی</th>
<th>دسته‌بندی</th>
<th>سازمان و سمت</th>
<th>شماره تماس</th>
<th>آیدی تلگرام</th>
<th>نکات و ترجیحات</th>
<th>عملیات</th>
</tr>
</thead>
<tbody id="tableBodyContacts"></tbody>
</table>
</div>
</div>
<!-- Sub Tab: Vault -->
<div id="tabContentVault" class="master-tab-content" style="display: none;">
<div class="action-bar">
<div class="search-box">
<span class="search-icon">🔍</span>
<input type="text" class="search-input" placeholder="جستجو در اسناد و درایو..." oninput="filterData('vault', this.value)">
</div>
<button class="btn btn-primary btn-sm" onclick="openNewModal('vault')">+ افزودن سند یا لینک درایو</button>
</div>
<div class="table-container">
<table>
<thead>
<tr>
<th>عنوان سند یا فولدر</th>
<th>دسته‌بندی</th>
<th>لینک درایو / دسترسی</th>
<th>سطح محرمانگی</th>
<th>توضیحات</th>
<th>عملیات</th>
</tr>
</thead>
<tbody id="tableBodyVault"></tbody>
</table>
</div>
</div>
<!-- Sub Tab: Recycle Bin -->
<div id="tabContentRecycle" class="master-tab-content" style="display: none;">
<div class="action-bar">
<div style="display: flex; gap: 0.5rem; align-items: center;">
<button class="btn btn-primary btn-sm" onclick="exportFullBackup()">📥 دانلود بکاپ جامع (JSON)</button>
<button class="btn btn-sm" onclick="restoreFromBackupFile()">📤 بازیابی از فایل بکاپ</button>
</div>
<div class="search-box">
<span class="search-icon">🔍</span>
<input type="text" class="search-input" placeholder="جستجو در سطل بازیافت..." oninput="filterData('recycle', this.value)">
</div>
</div>
<div class="card" style="margin-bottom: 1rem;">
<div style="font-size: 0.85rem; color: var(--text-muted); display: flex; align-items: center; gap: 0.5rem;">
🛡️ <strong>قانون عدم ابطال اطلاعات:</strong> تمامی داده‌های حذف‌شده از همه بخش‌ها به این سطل منتقل می‌شوند و تاریخ دقیق حذف ثبت می‌گردد. با دکمه «بازیابی» در هر زمان قابل بازگرداندن هستند.
</div>
</div>
<div class="table-container">
<table>
<thead>
<tr>
<th>نوع آیتم</th>
<th>عنوان / محتوا</th>
<th>تاریخ حذف</th>
<th>جزئیات داده قبلی</th>
<th>عملیات</th>
</tr>
</thead>
<tbody id="tableBodyRecycle"></tbody>
</table>
</div>
</div>
</section>
<!-- ==================== 4. ISOLATED TEAM INTAKE PORTAL ==================== -->
<section id="viewTeamGuest" style="display: none;">
<div style="max-width: 640px; margin: 1.5rem auto;">
<div style="display: flex; justify-content: flex-end; margin-bottom: 1rem;">
<button class="btn btn-sm" onclick="logout()">
بازگشت به صفحه اصلی ↩️
</button>
</div>
<div class="card">
<div class="card-header">
<div class="card-title">
📥 پرتال ثبت تسک‌های نیاز به تایید
<i class="info-icon" data-tooltip="فرم ایزوله جهت ثبت درخواست تاییدیه یا موضوع کاری در کارتابل حامد فلاحی.">ⓘ</i>
</div>
<span class="badge badge-green">ورودی امن همکاران</span>
</div>
<form id="teamGuestForm" onsubmit="handleTeamGuestSubmit(event)">
<div class="form-group">
<label class="form-label">نام و سمت سازمانی شما *</label>
<input type="text" class="form-control" id="tgRequester" required>
</div>
<div class="form-group">
<label class="form-label">موضوع درخواست یا تصمیم نیازمند تایید *</label>
<input type="text" class="form-control" id="tgTitle" required>
</div>
<div class="form-group">
<label class="form-label">درجه فوریت *</label>
<select class="form-control" id="tgPriority">
<option value="P0">⚡ P0 - فوری (کار متوقف است)</option>
<option value="P1" selected>⏳ P1 - مهم (تا ۲۴ ساعت آینده)</option>
<option value="P2">🟢 P2 - عادی (تا پایان هفته)</option>
</select>
</div>
<div class="form-group">
<label class="form-label">توضیح کوتاه و پیشنهاد شما *</label>
<textarea class="form-control" id="tgDescription" required></textarea>
</div>
<div class="form-group">
<label class="form-label">لینک سند یا فایل ضمیمه (در صورت وجود)</label>
<input type="url" class="form-control" id="tgLink">
</div>
<button type="submit" class="btn btn-primary" style="width: 100%; justify-content: center; padding: 0.75rem;">
🚀 ثبت قطعی در کارتابل حامد فلاحی
</button>
</form>
</div>
</div>
</section>
</main>
<!-- Login Modal -->
<div class="modal-overlay" id="modalLogin">
<div class="modal-content" style="max-width: 420px;">
<div class="modal-header">
<div class="modal-title" id="loginModalTitle">ورود امن</div>
<button class="modal-close" onclick="closeModal('modalLogin')">&times;</button>
</div>
<form onsubmit="handleLoginSubmit(event)">
<input type="hidden" id="loginTargetUser">
<div class="form-group">
<label class="form-label">نام کاربری</label>
<input type="text" class="form-control" id="loginUsername" required autocomplete="username">
</div>
<div class="form-group">
<label class="form-label">رمز عبور</label>
<input type="password" class="form-control" id="loginPassword" required autocomplete="current-password">
</div>
<div id="loginError" style="color: var(--accent-rose); font-size: 0.8rem; margin-bottom: 0.75rem; display: none;"></div>
<div style="display: flex; gap: 0.5rem; justify-content: flex-end;">
<button type="button" class="btn" onclick="closeModal('modalLogin')">انصراف</button>
<button type="submit" class="btn btn-primary">تایید و ورود 🔑</button>
</div>
</form>
</div>
</div>
<!-- CRUD Modals for Master Operations -->
<!-- 1. Modal Approval -->
<div class="modal-overlay" id="modalApproval">
<div class="modal-content">
<div class="modal-header">
<div class="modal-title" id="modalApprovalTitle">ثبت تاییدیه جدید برای حامد</div>
<button class="modal-close" onclick="closeModal('modalApproval')">&times;</button>
</div>
<form id="formApproval" onsubmit="saveMasterItem(event, 'approvals')">
<input type="hidden" id="approvalId">
<div class="form-group">
<label class="form-label">عنوان تصمیم / درخواست *</label>
<input type="text" class="form-control" id="approvalTitleInput" required>
</div>
<div class="form-group">
<label class="form-label">درخواست‌کننده *</label>
<input type="text" class="form-control" id="approvalRequesterInput" required>
</div>
<div class="form-group">
<label class="form-label">فوریت</label>
<select class="form-control" id="approvalPriorityInput">
<option value="P0">P0 - فوری</option>
<option value="P1" selected>P1 - مهم</option>
<option value="P2">P2 - عادی</option>
</select>
</div>
<div class="form-group">
<label class="form-label">پیشنهاد / توضیحات *</label>
<textarea class="form-control" id="approvalDescriptionInput" required></textarea>
</div>
<div class="form-group">
<label class="form-label">لینک پیوست</label>
<input type="url" class="form-control" id="approvalLinkInput">
</div>
<div class="form-group">
<label class="form-label">وضعیت</label>
<select class="form-control" id="approvalStatusInput">
<option value="pending">در انتظار تایید حامد</option>
<option value="approved">تایید شده ✅</option>
<option value="rejected">رد شده / نیاز به اصلاح ❌</option>
</select>
</div>
<div style="display: flex; gap: 0.5rem; justify-content: flex-end;">
<button type="button" class="btn" onclick="closeModal('modalApproval')">انصراف</button>
<button type="submit" class="btn btn-primary">ذخیره تاییدیه</button>
</div>
</form>
</div>
</div>
<!-- 2. Modal Meeting -->
<div class="modal-overlay" id="modalMeeting">
<div class="modal-content">
<div class="modal-header">
<div class="modal-title" id="modalMeetingTitle">ثبت جلسه جدید</div>
<button class="modal-close" onclick="closeModal('modalMeeting')">&times;</button>
</div>
<form id="formMeeting" onsubmit="saveMasterItem(event, 'meetings')">
<input type="hidden" id="meetingId">
<div class="form-group">
<label class="form-label">عنوان جلسه *</label>
<input type="text" class="form-control" id="meetingTitleInput" required>
</div>
<div class="form-group">
<label class="form-label">نوع جلسه</label>
<select class="form-control" id="meetingTypeInput">
<option value="online">💻 آنلاین (گوگل‌میت / ادوبی)</option>
<option value="in_person">🚗 حضوری (تهران / همراه با تردد)</option>
</select>
</div>
<div class="form-group">
<label class="form-label">تاریخ و ساعت *</label>
<input type="text" class="form-control" id="meetingTimeInput" required>
</div>
<div class="form-group">
<label class="form-label">افراد حاضر و نقش‌ها</label>
<input type="text" class="form-control" id="meetingAttendeesInput">
</div>
<div class="form-group">
<label class="form-label">بافر ترافیک / زمان خروج پیشنهادی (جلسه حضوری)</label>
<input type="text" class="form-control" id="meetingBufferInput">
</div>
<div class="form-group">
<label class="form-label">لینک میت آنلاین یا آدرس/پین نشان</label>
<input type="text" class="form-control" id="meetingLinkInput">
</div>
<div class="form-group">
<label class="form-label">یادداشت پیش از جلسه و فایل‌ها</label>
<textarea class="form-control" id="meetingNotesInput"></textarea>
</div>
<div style="display: flex; gap: 0.5rem; justify-content: flex-end;">
<button type="button" class="btn" onclick="closeModal('modalMeeting')">انصراف</button>
<button type="submit" class="btn btn-primary">ذخیره جلسه</button>
</div>
</form>
</div>
</div>
<!-- 3. Modal Task -->
<div class="modal-overlay" id="modalTask">
<div class="modal-content">
<div class="modal-header">
<div class="modal-title" id="modalTaskTitle">ثبت تسک اجرایی جدید</div>
<button class="modal-close" onclick="closeModal('modalTask')">&times;</button>
</div>
<form id="formTask" onsubmit="saveMasterItem(event, 'tasks')">
<input type="hidden" id="taskId">
<div class="form-group">
<label class="form-label">عنوان تسک *</label>
<input type="text" class="form-control" id="taskTitleInput" required>
</div>
<div class="form-group">
<label class="form-label">مسئول انجام</label>
<input type="text" class="form-control" id="taskAssigneeInput">
</div>
<div class="form-group">
<label class="form-label">دسته‌بندی</label>
<select class="form-control" id="taskCategoryInput">
<option value="ایکیپا">ایکیپا</option>
<option value="مایندرو">مایندرو</option>
<option value="مالی و وام">مالی و وام</option>
<option value="حقوقی و ثنا">حقوقی و ثنا</option>
<option value="شخصی">شخصی</option>
</select>
</div>
<div class="form-group">
<label class="form-label">اولویت</label>
<select class="form-control" id="taskPriorityInput">
<option value="P0">P0 - بحرانی</option>
<option value="P1" selected>P1 - بالا</option>
<option value="P2">P2 - عادی</option>
</select>
</div>
<div class="form-group">
<label class="form-label">مهلت تحویل (ددلاین)</label>
<input type="text" class="form-control" id="taskDeadlineInput">
</div>
<div class="form-group">
<label class="form-label">وضعیت</label>
<select class="form-control" id="taskStatusInput">
<option value="todo">در صف انجام</option>
<option value="in_progress">در حال اقدام</option>
<option value="waiting_approval">منتظر تایید حامد</option>
<option value="done">تکمیل شده</option>
</select>
</div>
<div style="display: flex; gap: 0.5rem; justify-content: flex-end;">
<button type="button" class="btn" onclick="closeModal('modalTask')">انصراف</button>
<button type="submit" class="btn btn-primary">ذخیره تسک</button>
</div>
</form>
</div>
</div>
<!-- 4. Modal Finance -->
<div class="modal-overlay" id="modalFinance">
<div class="modal-content">
<div class="modal-header">
<div class="modal-title" id="modalFinanceTitle">ثبت موعد قسط یا تسهیلات</div>
<button class="modal-close" onclick="closeModal('modalFinance')">&times;</button>
</div>
<form id="formFinance" onsubmit="saveMasterItem(event, 'finance')">
<input type="hidden" id="financeId">
<div class="form-group">
<label class="form-label">موضوع قسط یا واریزی *</label>
<input type="text" class="form-control" id="financeTitleInput" required>
</div>
<div class="form-group">
<label class="form-label">بانک یا مرجع</label>
<input type="text" class="form-control" id="financeBankInput">
</div>
<div class="form-group">
<label class="form-label">مبلغ (تومان) *</label>
<input type="text" class="form-control" id="financeAmountInput" required>
</div>
<div class="form-group">
<label class="form-label">تاریخ سررسید *</label>
<input type="text" class="form-control" id="financeDueDateInput" required>
</div>
<div class="form-group">
<label class="form-label">شماره تسهیلات / شبا یا یادداشت</label>
<input type="text" class="form-control" id="financeNotesInput">
</div>
<div class="form-group">
<label class="form-label">وضعیت پرداخت</label>
<select class="form-control" id="financeStatusInput">
<option value="pending">در انتظار پرداخت</option>
<option value="paid">پرداخت شده ✅</option>
<option value="overdue">معوق / اخطار ⚠️</option>
</select>
</div>
<div style="display: flex; gap: 0.5rem; justify-content: flex-end;">
<button type="button" class="btn" onclick="closeModal('modalFinance')">انصراف</button>
<button type="submit" class="btn btn-primary">ذخیره رکورد مالی</button>
</div>
</form>
</div>
</div>
<!-- 5. Modal Contact -->
<div class="modal-overlay" id="modalContact">
<div class="modal-content">
<div class="modal-header">
<div class="modal-title" id="modalContactTitle">ثبت مخاطب کلیدی VIP</div>
<button class="modal-close" onclick="closeModal('modalContact')">&times;</button>
</div>
<form id="formContact" onsubmit="saveMasterItem(event, 'contacts')">
<input type="hidden" id="contactId">
<div class="form-group">
<label class="form-label">نام و نام خانوادگی *</label>
<input type="text" class="form-control" id="contactNameInput" required>
</div>
<div class="form-group">
<label class="form-label">دسته‌بندی</label>
<select class="form-control" id="contactCategoryInput">
<option value="ایکیپا">ایکیپا</option>
<option value="مایندرو">مایندرو</option>
<option value="سرمایه‌گذار و استراتژیک">سرمایه‌گذار و استراتژیک</option>
<option value="بانکی و حقوقی">بانکی و حقوقی</option>
<option value="شخصی">شخصی</option>
</select>
</div>
<div class="form-group">
<label class="form-label">سازمان و سمت</label>
<input type="text" class="form-control" id="contactRoleInput">
</div>
<div class="form-group">
<label class="form-label">شماره همراه *</label>
<input type="text" class="form-control" id="contactPhoneInput" required>
</div>
<div class="form-group">
<label class="form-label">آیدی تلگرام / واتس‌اپ</label>
<input type="text" class="form-control" id="contactSocialInput">
</div>
<div class="form-group">
<label class="form-label">ترجیحات، سوابق و نکات حساسیت</label>
<textarea class="form-control" id="contactNotesInput"></textarea>
</div>
<div style="display: flex; gap: 0.5rem; justify-content: flex-end;">
<button type="button" class="btn" onclick="closeModal('modalContact')">انصراف</button>
<button type="submit" class="btn btn-primary">ذخیره مخاطب</button>
</div>
</form>
</div>
</div>
<!-- 6. Modal Vault -->
<div class="modal-overlay" id="modalVault">
<div class="modal-content">
<div class="modal-header">
<div class="modal-title" id="modalVaultTitle">ثبت سند یا پوشه درایو</div>
<button class="modal-close" onclick="closeModal('modalVault')">&times;</button>
</div>
<form id="formVault" onsubmit="saveMasterItem(event, 'vault')">
<input type="hidden" id="vaultId">
<div class="form-group">
<label class="form-label">عنوان پوشه یا سند *</label>
<input type="text" class="form-control" id="vaultTitleInput" required>
</div>
<div class="form-group">
<label class="form-label">دسته‌بندی</label>
<select class="form-control" id="vaultCategoryInput">
<option value="اسناد حقوقی و ثنا">اسناد حقوقی و ثنا</option>
<option value="مدارک هویتی شرکت و حامد">مدارک هویتی شرکت و حامد</option>
<option value="قراردادها و NDA">قراردادها و NDA</option>
<option value="امور شعب و مایندرو">امور شعب و مایندرو</option>
<option value="مالی و وام‌ها">مالی و وام‌ها</option>
</select>
</div>
<div class="form-group">
<label class="form-label">لینک دسترسی گوگل درایو *</label>
<input type="url" class="form-control" id="vaultLinkInput" required>
</div>
<div class="form-group">
<label class="form-label">سطح محرمانگی</label>
<select class="form-control" id="vaultSecInput">
<option value="محرمانه (فقط حامد و محدثه)">محرمانه (فقط حامد و محدثه)</option>
<option value="تیم داخلی">تیم داخلی</option>
<option value="عمومی">عمومی</option>
</select>
</div>
<div class="form-group">
<label class="form-label">توضیحات و محتویات</label>
<textarea class="form-control" id="vaultDescInput"></textarea>
</div>
<div style="display: flex; gap: 0.5rem; justify-content: flex-end;">
<button type="button" class="btn" onclick="closeModal('modalVault')">انصراف</button>
<button type="submit" class="btn btn-primary">ذخیره سند</button>
</div>
</form>
</div>
</div>
<!-- Toast Container -->
<div class="toast-container" id="toastContainer"></div>
<!-- Footer with Data Provenance -->
<footer>
<div class="footer-inner">
<div>
<span>🟢 <strong>اصالت داده (Data Provenance):</strong> متصل مستقیم به PostgreSQL 17</span>
<span style="margin: 0 0.5rem;">|</span>
<span>جدول: <code>ekeepa_bi.dashboard_app_storage</code></span>
<span style="margin: 0 0.5rem;">|</span>
<span>کلید دیتابیس: <code>exec_cockpit_state</code></span>
</div>
<div>
<span>سیستم حفاظت از داده‌ها: سطل بازیافت فعال (Soft-Delete & Full Audit Log)</span>
</div>
</div>
</footer>
<!-- Application Logic -->
<script>
// Initial Seed Data
const defaultData = {
approvals: [
{
id: "app_1",
title: "تایید قرارداد NDA با شریک راهبردی باغ کتاب",
requester: "صالح اسکندرزاده (حقوقی)",
priority: "P0",
description: "بند عدم رقابت به ۳ سال تقلیل یافت؛ در صورت موافقت تایید کنید تا نسخه نهایی پرینت شود.",
link: "https://drive.google.com",
status: "pending",
createdAt: "۱۴۰۴/۰۸/۲۲"
},
{
id: "app_2",
title: "تخصیص بودجه ادز بلک‌فرایدی ایکیپا",
requester: "الهه فلاحی (مارکتینگ)",
priority: "P1",
description: "برآورد ۳۵ میلیون تومان برای کمپین ریتارگتینگ؛ پیش‌بینی ROI ۳.۴ برابری.",
link: "https://drive.google.com",
status: "pending",
createdAt: "۱۴۰۴/۰۸/۲۲"
}
],
meetings: [
{
id: "meet_1",
title: "جلسه هماهنگی بازاریابی و پکیج‌های جدید مایندرو",
type: "online",
time: "امروز ۱۰:۳۰ تا ۱۱:۳۰",
attendees: "حامد، سارا محمودزاده، غزاله مددی",
buffer: "آنلاین (بدون بافر تردد)",
link: "https://meet.google.com/abc-defg-hij",
notes: "بررسی قیمت‌گذاری سانس‌های آخر هفته نیایش مال و بازی چهارم"
},
{
id: "meet_2",
title: "جلسه حضوری با مدیران باغ کتاب تهران",
type: "in_person",
time: "امروز ۱۵:۰۰ تا ۱۶:۳۰",
attendees: "حامد فلاحی، خانم ارشادی",
buffer: "خروج ساعت ۱۴:۱۵ (۴۵ دقیقه بافر ترافیک همت)",
link: "https://neshan.org",
notes: "تحویل وسایل و نهایی‌سازی تسویه‌حساب تابستان؛ هماهنگی ورود با پارکینگ شماره ۱"
}
],
tasks: [
{
id: "task_1",
title: "ارسال مدارک تکمیلی وام دیجی‌شهر به شعبه",
assignee: "حامد فلاحی / محدثه",
category: "مالی و وام",
priority: "P0",
deadline: "امروز ساعت ۱۴",
status: "in_progress"
},
{
id: "task_2",
title: "بررسی کارکرد و حقوق ماهانه پرسنل مایندرو با پورصمد",
assignee: "محدثه معصومی",
category: "مایندرو",
priority: "P1",
deadline: "چهارشنبه",
status: "todo"
}
],
finance: [
{
id: "fin_1",
title: "قسط تسهیلات دیجی‌شهر (حامد و آقای فلاحی)",
bank: "بانک شهر",
amount: "14,800,000",
dueDate: "۲۸ آبان ماه",
daysLeft: "۶ روز مانده",
notes: "تسهیلات شماره ۴۸۸۹۲ - حساب بانک شهر",
status: "pending"
},
{
id: "fin_2",
title: "تسویه تنخواه هفتگی بلوبانک مایندرو",
bank: "بلو بانک",
amount: "8,500,000",
dueDate: "پایان هفته",
daysLeft: "۳ روز مانده",
notes: "حساب مشترک هزینه‌های جاری شعب",
status: "pending"
},
{
id: "fin_3",
title: "قسط طرح توسعه دیجی‌پی",
bank: "دیجی‌پی",
amount: "11,200,000",
dueDate: "۰۵ آذر ماه",
daysLeft: "۱۳ روز مانده",
notes: "اقساط سرورها و زیرساخت فنی",
status: "pending"
}
],
contacts: [
{
id: "cnt_1",
name: "ایمان پورصمد",
category: "مایندرو",
role: "توسعه و حسابرسی مالی",
phone: "09120000000",
social: "iman_pour",
notes: "هماهنگی روزهای سه‌شنبه و چهارشنبه؛ حساسیت روی تطابق ریالی واریزی‌ها"
},
{
id: "cnt_2",
name: "سارا محمودزاده",
category: "ایکیپا",
role: "Product & Operations Lead",
phone: "09121111111",
social: "sara_m",
notes: "فیلتر اصلی مسائل محصول و تیم فنی؛ هماهنگی روتین روزانه"
},
{
id: "cnt_3",
name: "فدیا ارشادی",
category: "مایندرو",
role: "سوپروایزر باغ کتاب",
phone: "09122222222",
social: "f_ershadi",
notes: "امور هماهنگی تخلیه، تحویل تجهیزات و تسویه‌های پرسنلی"
},
{
id: "cnt_4",
name: "الهه فلاحی",
category: "ایکیپا",
role: "Lead Growth & Marketing",
phone: "09123333333",
social: "elaheh_flh",
notes: "مدیریت کمپین‌ها، بودجه ادز و جذب کاربر"
}
],
vault: [
{
id: "vlt_1",
title: "پوشه مدارک هویتی، آگهی تاسیس و روزنامه رسمی",
category: "مدارک هویتی شرکت و حامد",
link: "https://drive.google.com",
sec: "محرمانه (فقط حامد و محدثه)",
desc: "شناسنامه‌ها، کارت‌های ملی، نمونه امضاها و آخرین آگهی تغییرات هلدینگ"
},
{
id: "vlt_2",
title: "قراردادهای شعب نیایش و باغ کتاب مایندرو",
category: "امور شعب و مایندرو",
link: "https://drive.google.com",
sec: "محرمانه (فقط حامد و محدثه)",
desc: "اجاره‌نامه‌ها، الحاقیه‌ها و نسخه‌های اسکن‌شده امضاشده"
},
{
id: "vlt_3",
title: "پرونده وام‌ها و معرفی‌نامه‌های بانکی",
category: "مالی و وام‌ها",
link: "https://drive.google.com",
sec: "محرمانه (فقط حامد و محدثه)",
desc: "مدارک دیجی‌شهر، دیجی‌پی و مکاتبات بانک شهر"
}
],
recycle: []
};
let appState = JSON.parse(JSON.stringify(defaultData));
let currentUser = null; // 'hamed' | 'mohadese' | 'team_guest' | null
let currentMasterTab = 'approvals';
let currentHamedTab = 'today';
let saveTimeout = null;
// Database Sync
async function loadFromPostgres() {
const syncDot = document.getElementById('syncDot');
const syncText = document.getElementById('syncText');
syncDot.className = 'sync-dot syncing';
syncText.innerText = 'در حال بازیابی اطلاعات از PostgreSQL 17...';
try {
const res = await fetch('/api/db/state?key=exec_cockpit_state');
if (res.ok) {
const json = await res.json();
if (json && json.data && typeof json.data === 'object' && json.data.approvals) {
appState = json.data;
} else {
await saveToPostgres();
}
}
} catch (err) {
console.warn('PostgreSQL fetch error, using cache:', err);
} finally {
syncDot.className = 'sync-dot';
syncText.innerText = '🟢 اصالت داده: PostgreSQL 17 زنده (/api/db/state)';
renderAll();
}
}
async function saveToPostgres() {
const syncDot = document.getElementById('syncDot');
const syncText = document.getElementById('syncText');
syncDot.className = 'sync-dot syncing';
syncText.innerText = 'در حال ذخیره‌سازی ابری...';
try {
const payload = {
state_key: 'exec_cockpit_state',
data: appState
};
const res = await fetch('/api/db/state', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload)
});
if (res.ok) {
syncDot.className = 'sync-dot';
syncText.innerText = '🟢 اصالت داده: PostgreSQL 17 ذخیره شد';
}
} catch (err) {
console.error('Error saving state:', err);
syncDot.className = 'sync-dot';
syncText.innerText = '⚠️ خطای ذخیره‌سازی ابری؛ کش فعال';
}
}
function triggerStateChange() {
if (saveTimeout) clearTimeout(saveTimeout);
saveTimeout = setTimeout(saveToPostgres, 400);
renderAll();
}
// Auth & Navigation
function openLoginModal(role) {
document.getElementById('loginTargetUser').value = role;
document.getElementById('loginUsername').value = (role === 'hamed') ? 'hamed' : 'mohadese';
document.getElementById('loginPassword').value = '';
document.getElementById('loginError').style.display = 'none';
document.getElementById('loginModalTitle').innerText = (role === 'hamed') ? 'ورود به میز کار حامد فلاحی' : 'ورود به پنل مستر محدثه معصومی';
openModal('modalLogin');
}
function handleLoginSubmit(e) {
e.preventDefault();
const role = document.getElementById('loginTargetUser').value;
const u = document.getElementById('loginUsername').value.trim().toLowerCase();
const p = document.getElementById('loginPassword').value.trim();
const errBox = document.getElementById('loginError');
// Accepted default credentials
const isValidHamed = (role === 'hamed') && (u === 'hamed' || u === 'hamed.fallahi') && (p === '123' || p === 'Hamed@1404');
const isValidMohadese = (role === 'mohadese') && (u === 'mohadese' || u === 'mohadese.masoumi') && (p === '123' || p === 'Mohadese@1404');
if (isValidHamed || isValidMohadese) {
closeModal('modalLogin');
currentUser = role;
try { sessionStorage.setItem('exec_cockpit_user', role); } catch (e) {}
showToast('✅ ورود موفقیت‌آمیز بود.');
updateViewVisibility();
} else {
errBox.innerText = 'نام کاربری یا رمز عبور اشتباه است. (پیش‌فرض: 123)';
errBox.style.display = 'block';
}
}
function openGuestTeamPortal() {
currentUser = 'team_guest';
updateViewVisibility();
}
function logout() {
currentUser = null;
try { sessionStorage.removeItem('exec_cockpit_user'); } catch (e) {}
updateViewVisibility();
showToast('از حساب کاربری خارج شدید.');
}
function updateViewVisibility() {
const viewGateway = document.getElementById('viewGateway');
const viewHamed = document.getElementById('viewHamed');
const viewMaster = document.getElementById('viewMaster');
const viewTeamGuest = document.getElementById('viewTeamGuest');
const masterNav = document.getElementById('masterNav');
const hamedNav = document.getElementById('hamedNav');
const userPill = document.getElementById('userPill');
const userNameLabel = document.getElementById('userNameLabel');
const topSubtitle = document.getElementById('topSubtitle');
// Hide all
viewGateway.style.display = 'none';
viewHamed.style.display = 'none';
viewMaster.style.display = 'none';
viewTeamGuest.style.display = 'none';
masterNav.style.display = 'none';
hamedNav.style.display = 'none';
userPill.style.display = 'none';
if (!currentUser) {
viewGateway.style.display = 'block';
topSubtitle.innerText = 'پورتال هماهنگی عملیات و تصمیمات راهبردی';
} else if (currentUser === 'hamed') {
viewHamed.style.display = 'block';
hamedNav.style.display = 'flex';
userPill.style.display = 'flex';
userNameLabel.innerText = '👤 حامد فلاحی';
topSubtitle.innerText = 'میز کار اختصاصی و متمرکز مدیر ارشد';
} else if (currentUser === 'mohadese') {
viewMaster.style.display = 'block';
masterNav.style.display = 'flex';
userPill.style.display = 'flex';
userNameLabel.innerText = '⚙️ محدثه معصومی (Master Ops)';
topSubtitle.innerText = 'پنل مستر سرپرست عملیات و فرآیندها';
} else if (currentUser === 'team_guest') {
viewTeamGuest.style.display = 'block';
topSubtitle.innerText = 'پرتال ثبت تسک‌های نیاز به تایید همکاران';
}
renderAll();
}
function switchMasterTab(tab) {
currentMasterTab = tab;
document.querySelectorAll('#masterNav .tab-btn').forEach(btn => btn.classList.remove('active'));
const activeBtn = Array.from(document.querySelectorAll('#masterNav .tab-btn')).find(b => b.innerText.includes(getTabPersianName(tab)));
if (activeBtn) activeBtn.classList.add('active');
document.querySelectorAll('.master-tab-content').forEach(tc => tc.style.display = 'none');
const target = document.getElementById('tabContent' + capitalize(tab));
if (target) target.style.display = 'block';
}
function switchHamedTab(tab) {
currentHamedTab = tab;
document.querySelectorAll('#hamedNav .tab-btn').forEach(btn => btn.classList.remove('active'));
const activeBtn = Array.from(document.querySelectorAll('#hamedNav .tab-btn')).find(b => b.innerText.includes(getHamedTabPersianName(tab)));
if (activeBtn) activeBtn.classList.add('active');
document.querySelectorAll('.hamed-tab-content').forEach(tc => tc.style.display = 'none');
const target = document.getElementById('hamedTab' + capitalize(tab));
if (target) target.style.display = 'block';
}
function getTabPersianName(t) {
const map = { approvals: 'تاییدیه‌ها', meetings: 'جلسات', tasks: 'تسک‌های', finance: 'مالی', contacts: 'مخاطبین', vault: 'آرشیو', recycle: 'سطل' };
return map[t] || '';
}
function getHamedTabPersianName(t) {
const map = { today: 'تصمیمات', finance: 'اقساط', contacts: 'مخاطبین', vault: 'آرشیو' };
return map[t] || '';
}
function capitalize(s) {
return s.charAt(0).toUpperCase() + s.slice(1);
}
// Modal Control & Bugfix: Clear forms when adding new
function openModal(id) {
document.getElementById(id).classList.add('active');
}
function closeModal(id) {
document.getElementById(id).classList.remove('active');
}
function openNewModal(entity) {
const form = document.getElementById('form' + capitalize(entity));
if (form) form.reset();
const idField = document.getElementById(entity + 'Id');
if (idField) idField.value = '';
const titleMap = {
approval: 'ثبت تاییدیه جدید برای حامد',
meeting: 'ثبت جلسه جدید',
task: 'ثبت تسک اجرایی جدید',
finance: 'ثبت موعد قسط یا تسهیلات جدید',
contact: 'ثبت مخاطب کلیدی VIP جدید',
vault: 'ثبت سند یا پوشه درایو جدید'
};
const titleEl = document.getElementById('modal' + capitalize(entity) + 'Title');
if (titleEl) titleEl.innerText = titleMap[entity] || 'ثبت آیتم جدید';
openModal('modal' + capitalize(entity));
}
// Toast
function showToast(msg) {
const container = document.getElementById('toastContainer');
const toast = document.createElement('div');
toast.className = 'toast';
toast.innerHTML = `<span>${msg}</span>`;
container.appendChild(toast);
setTimeout(() => {
toast.style.opacity = '0';
toast.style.transition = 'opacity 0.3s ease';
setTimeout(() => toast.remove(), 300);
}, 3000);
}
// Render Logic
function renderAll() {
updateBadges();
if (currentUser === 'hamed') {
renderHamedApprovals();
renderHamedMeetings();
renderHamedFinanceTable();
renderHamedContactsTable();
renderHamedVaultTable();
} else if (currentUser === 'mohadese') {
renderMasterApprovals();
renderMasterMeetings();
renderMasterTasks();
renderMasterFinance();
renderMasterContacts();
renderMasterVault();
renderRecycleBin();
}
}
function updateBadges() {
const pApprovals = appState.approvals.filter(a => a.status === 'pending').length;
const mCount = appState.meetings.length;
const tCount = appState.tasks.filter(t => t.status !== 'done').length;
const fCount = appState.finance.filter(f => f.status === 'pending').length;
const cCount = appState.contacts.length;
const rCount = appState.recycle.length;
document.getElementById('badgeApprovals').innerText = pApprovals;
document.getElementById('badgeMeetings').innerText = mCount;
document.getElementById('badgeTasks').innerText = tCount;
document.getElementById('badgeFinance').innerText = fCount;
document.getElementById('badgeContacts').innerText = cCount;
document.getElementById('badgeRecycle').innerText = rCount;
document.getElementById('kpiHamedApprovals').innerText = pApprovals;
document.getElementById('kpiHamedMeetings').innerText = mCount;
document.getElementById('kpiHamedFinance').innerText = fCount;
document.getElementById('badgeHamedFinance').innerText = fCount;
}
// Hamed Renderers
function renderHamedApprovals() {
const list = document.getElementById('hamedApprovalsList');
const pending = appState.approvals.filter(a => a.status === 'pending');
if (!pending.length) {
list.innerHTML = `<div style="padding: 1.5rem; text-align: center; color: var(--text-muted); font-size: 0.88rem;">✨ تمامی موارد بررسی شده و موردی در صف انتظار تصمیم شما نیست.</div>`;
return;
}
list.innerHTML = pending.map(appr => `
<div style="background: var(--bg-surface-elevated); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 1rem;">
<div style="display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0.5rem;">
<div style="font-weight: 700; font-size: 0.95rem;">${appr.title}</div>
<span class="badge ${appr.priority === 'P0' ? 'badge-rose' : 'badge-amber'}">${appr.priority}</span>
</div>
<div style="font-size: 0.8rem; color: var(--primary); margin-bottom: 0.4rem;">👤 درخواست‌کننده: ${appr.requester}</div>
<p style="font-size: 0.85rem; color: var(--text-muted); line-height: 1.5; margin-bottom: 0.75rem;">${appr.description}</p>
${appr.link ? `<div style="margin-bottom: 0.75rem;"><a href="${appr.link}" target="_blank" class="btn btn-sm" style="font-size: 0.75rem;">🔗 مشاهده فایل / سند ضمیمه</a></div>` : ''}
<div style="display: flex; gap: 0.5rem; justify-content: flex-end;">
<button class="btn btn-sm btn-danger" onclick="setApprovalStatus('${appr.id}', 'rejected')">❌ رد / اصلاح</button>
<button class="btn btn-sm btn-success" onclick="setApprovalStatus('${appr.id}', 'approved')">✅ تایید فوری</button>
</div>
</div>
`).join('');
}
function renderHamedMeetings() {
const list = document.getElementById('hamedMeetingsList');
if (!appState.meetings.length) {
list.innerHTML = `<div style="padding: 1.5rem; text-align: center; color: var(--text-muted); font-size: 0.88rem;">جلسه‌ای برای امروز در تقویم ثبت نشده است.</div>`;
return;
}
list.innerHTML = appState.meetings.map(m => `
<div style="background: var(--bg-surface-elevated); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); padding: 1rem;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.35rem;">
<div style="font-weight: 700; font-size: 0.95rem;">${m.title}</div>
<span class="badge ${m.type === 'online' ? 'badge-primary' : 'badge-amber'}">${m.type === 'online' ? '💻 آنلاین' : '🚗 حضوری'}</span>
</div>
<div style="font-size: 0.82rem; color: var(--text-muted); margin-bottom: 0.3rem;">⏰ ${m.time} | 👥 ${m.attendees || 'بدون لیست حاضرین'}</div>
${m.buffer ? `<div style="font-size: 0.78rem; color: #fbbf24; margin-bottom: 0.5rem;">⚠️ ${m.buffer}</div>` : ''}
${m.notes ? `<div style="font-size: 0.8rem; background: var(--bg-base); padding: 0.5rem; border-radius: 6px; margin-bottom: 0.6rem; color: var(--text-muted);">${m.notes}</div>` : ''}
<div style="display: flex; gap: 0.5rem;">
${m.link ? `<a href="${m.link}" target="_blank" class="btn btn-sm btn-primary" style="flex: 1; justify-content: center;">${m.type === 'online' ? '🚀 ورود مستقیم به میت' : '📍 مسیریابی لوکیشن در نشان'}</a>` : ''}
</div>
</div>
`).join('');
}
function renderHamedFinanceTable() {
const tbody = document.getElementById('tableBodyHamedFinance');
tbody.innerHTML = appState.finance.map(f => `
<tr>
<td><strong>${f.title}</strong></td>
<td>${f.bank}</td>
<td style="font-weight: 700; color: var(--accent-green); font-size: 0.95rem;">${f.amount}</td>
<td>${f.dueDate}</td>
<td><span class="badge ${f.status === 'paid' ? 'badge-green' : 'badge-amber'}">${f.daysLeft || 'معین'}</span></td>
<td style="font-size: 0.8rem; color: var(--text-muted);">${f.notes || '-'}</td>
<td>
<span class="badge ${f.status === 'paid' ? 'badge-green' : (f.status === 'overdue' ? 'badge-rose' : 'badge-amber')}">
${f.status === 'paid' ? 'پرداخت شد ✅' : 'در انتظار پرداخت'}
</span>
</td>
<td>
<button class="btn btn-sm ${f.status === 'paid' ? '' : 'btn-success'}" onclick="toggleFinanceStatus('${f.id}')">
${f.status === 'paid' ? 'بازنشانی' : 'ثبت پرداخت'}
</button>
</td>
</tr>
`).join('');
}
function toggleFinanceStatus(id) {
const item = appState.finance.find(f => f.id === id);
if (item) {
item.status = (item.status === 'paid') ? 'pending' : 'paid';
showToast(item.status === 'paid' ? '✅ پرداخت با موفقیت ثبت شد.' : 'وضعیت به در انتظار تغییر یافت.');
triggerStateChange();
}
}
function renderHamedContactsTable() {
const tbody = document.getElementById('tableBodyHamedContacts');
tbody.innerHTML = appState.contacts.map(c => `
<tr>
<td><strong>${c.name}</strong></td>
<td><span class="badge badge-purple">${c.category}</span></td>
<td>${c.role || '-'}</td>
<td style="direction: ltr; text-align: right;"><a href="tel:${c.phone}" style="color: var(--primary); text-decoration: none;">${c.phone}</a></td>
<td style="direction: ltr; text-align: right;">${c.social ? `<a href="https://t.me/${c.social.replace('@','')}" target="_blank" style="color: #60a5fa; text-decoration: none;">@${c.social.replace('@','')}</a>` : '-'}</td>
<td style="max-width: 250px; font-size: 0.8rem; color: var(--text-muted);">${c.notes || '-'}</td>
<td>
<div style="display: flex; gap: 0.35rem;">
<a href="tel:${c.phone}" class="btn btn-sm">📞 تماس</a>
${c.social ? `<a href="https://t.me/${c.social.replace('@','')}" target="_blank" class="btn btn-sm btn-primary">💬 تلگرام</a>` : ''}
</div>
</td>
</tr>
`).join('');
}
function filterHamedContacts(q) {
const query = q.trim().toLowerCase();
const rows = document.querySelectorAll('#tableBodyHamedContacts tr');
rows.forEach(r => {
r.style.display = r.innerText.toLowerCase().includes(query) ? '' : 'none';
});
}
function renderHamedVaultTable() {
const tbody = document.getElementById('tableBodyHamedVault');
tbody.innerHTML = appState.vault.map(v => `
<tr>
<td><strong>${v.title}</strong></td>
<td><span class="badge badge-primary">${v.category}</span></td>
<td><span class="badge badge-rose">${v.sec}</span></td>
<td style="font-size: 0.8rem; color: var(--text-muted);">${v.desc || '-'}</td>
<td><a href="${v.link}" target="_blank" class="btn btn-sm btn-primary">🔗 باز کردن پوشه درایو</a></td>
</tr>
`).join('');
}
function setApprovalStatus(id, status) {
const appr = appState.approvals.find(a => a.id === id);
if (appr) {
appr.status = status;
showToast(status === 'approved' ? '✅ تاییدیه صادر شد.' : '❌ درخواست جهت اصلاح ارجاع شد.');
triggerStateChange();
}
}
// Master Renderers
function renderMasterApprovals() {
const tbody = document.getElementById('tableBodyApprovals');
tbody.innerHTML = appState.approvals.map(appr => `
<tr>
<td><strong>${appr.title}</strong></td>
<td>${appr.requester}</td>
<td><span class="badge ${appr.priority === 'P0' ? 'badge-rose' : 'badge-amber'}">${appr.priority}</span></td>
<td style="max-width: 250px;">${appr.description}</td>
<td>${appr.link ? `<a href="${appr.link}" target="_blank" class="btn btn-sm">لینک</a>` : '-'}</td>
<td>
<span class="badge ${appr.status === 'approved' ? 'badge-green' : (appr.status === 'rejected' ? 'badge-rose' : 'badge-primary')}">
${appr.status === 'approved' ? 'تایید شد' : (appr.status === 'rejected' ? 'رد شد' : 'در انتظار')}
</span>
</td>
<td>
<div style="display: flex; gap: 0.3rem;">
<button class="btn btn-sm" onclick="editMasterItem('approval', '${appr.id}')">✏️</button>
<button class="btn btn-sm btn-danger" onclick="deleteMasterItem('approvals', '${appr.id}')">🗑️</button>
</div>
</td>
</tr>
`).join('');
}
function renderMasterMeetings() {
const tbody = document.getElementById('tableBodyMeetings');
tbody.innerHTML = appState.meetings.map(m => `
<tr>
<td><strong>${m.title}</strong></td>
<td><span class="badge ${m.type === 'online' ? 'badge-primary' : 'badge-amber'}">${m.type === 'online' ? 'آنلاین' : 'حضوری'}</span></td>
<td>${m.time}</td>
<td>${m.attendees || '-'}</td>
<td>${m.buffer || '-'}</td>
<td>${m.link ? `<a href="${m.link}" target="_blank" class="btn btn-sm">باز کردن</a>` : '-'}</td>
<td>
<div style="display: flex; gap: 0.3rem;">
<button class="btn btn-sm" onclick="editMasterItem('meeting', '${m.id}')">✏️</button>
<button class="btn btn-sm btn-danger" onclick="deleteMasterItem('meetings', '${m.id}')">🗑️</button>
</div>
</td>
</tr>
`).join('');
}
function renderMasterTasks() {
const tbody = document.getElementById('tableBodyTasks');
tbody.innerHTML = appState.tasks.map(t => `
<tr>
<td><strong>${t.title}</strong></td>
<td>${t.assignee || '-'}</td>
<td><span class="badge badge-primary">${t.category}</span></td>
<td><span class="badge ${t.priority === 'P0' ? 'badge-rose' : (t.priority === 'P1' ? 'badge-amber' : 'badge-green')}">${t.priority}</span></td>
<td>${t.deadline || '-'}</td>
<td>
<span class="badge ${t.status === 'done' ? 'badge-green' : (t.status === 'waiting_approval' ? 'badge-rose' : 'badge-primary')}">
${t.status === 'done' ? 'تکمیل' : (t.status === 'waiting_approval' ? 'منتظر تایید' : (t.status === 'in_progress' ? 'در اقدام' : 'در صف'))}
</span>
</td>
<td>
<div style="display: flex; gap: 0.3rem;">
<button class="btn btn-sm" onclick="editMasterItem('task', '${t.id}')">✏️</button>
<button class="btn btn-sm btn-danger" onclick="deleteMasterItem('tasks', '${t.id}')">🗑️</button>
</div>
</td>
</tr>
`).join('');
}
function renderMasterFinance() {
const tbody = document.getElementById('tableBodyFinance');
tbody.innerHTML = appState.finance.map(f => `
<tr>
<td><strong>${f.title}</strong></td>
<td>${f.bank}</td>
<td style="font-weight: 700; color: var(--accent-green);">${f.amount}</td>
<td>${f.dueDate}</td>
<td>${f.notes || '-'}</td>
<td>
<span class="badge ${f.status === 'paid' ? 'badge-green' : (f.status === 'overdue' ? 'badge-rose' : 'badge-amber')}">
${f.status === 'paid' ? 'پرداخت شد' : (f.status === 'overdue' ? 'معوق' : 'در انتظار')}
</span>
</td>
<td>
<div style="display: flex; gap: 0.3rem;">
<button class="btn btn-sm" onclick="editMasterItem('finance', '${f.id}')">✏️</button>
<button class="btn btn-sm btn-danger" onclick="deleteMasterItem('finance', '${f.id}')">🗑️</button>
</div>
</td>
</tr>
`).join('');
}
function renderMasterContacts() {
const tbody = document.getElementById('tableBodyContacts');
tbody.innerHTML = appState.contacts.map(c => `
<tr>
<td><strong>${c.name}</strong></td>
<td><span class="badge badge-purple">${c.category}</span></td>
<td>${c.role || '-'}</td>
<td style="direction: ltr; text-align: right;">${c.phone}</td>
<td style="direction: ltr; text-align: right;">${c.social || '-'}</td>
<td style="max-width: 250px;">${c.notes || '-'}</td>
<td>
<div style="display: flex; gap: 0.3rem;">
<button class="btn btn-sm" onclick="editMasterItem('contact', '${c.id}')">✏️</button>
<button class="btn btn-sm btn-danger" onclick="deleteMasterItem('contacts', '${c.id}')">🗑️</button>
</div>
</td>
</tr>
`).join('');
}
function renderMasterVault() {
const tbody = document.getElementById('tableBodyVault');
tbody.innerHTML = appState.vault.map(v => `
<tr>
<td><strong>${v.title}</strong></td>
<td><span class="badge badge-primary">${v.category}</span></td>
<td><a href="${v.link}" target="_blank" class="btn btn-sm btn-primary">🔗 باز کردن درایو</a></td>
<td><span class="badge badge-rose">${v.sec}</span></td>
<td>${v.desc || '-'}</td>
<td>
<div style="display: flex; gap: 0.3rem;">
<button class="btn btn-sm" onclick="editMasterItem('vault', '${v.id}')">✏️</button>
<button class="btn btn-sm btn-danger" onclick="deleteMasterItem('vault', '${v.id}')">🗑️</button>
</div>
</td>
</tr>
`).join('');
}
function renderRecycleBin() {
const tbody = document.getElementById('tableBodyRecycle');
if (!appState.recycle || !appState.recycle.length) {
tbody.innerHTML = `<tr><td colspan="5" style="text-align: center; color: var(--text-muted); padding: 1.5rem;">سطل بازیافت خالی است؛ هیچ آیتم حذف‌شده‌ای وجود ندارد.</td></tr>`;
return;
}
tbody.innerHTML = appState.recycle.map((item, idx) => `
<tr>
<td><span class="badge badge-primary">${item.entityType}</span></td>
<td><strong>${item.title || item.name || 'بدون عنوان'}</strong></td>
<td>${item.deletedAt}</td>
<td style="max-width: 300px; font-size: 0.75rem; color: var(--text-muted); direction: ltr; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">
${JSON.stringify(item.data)}
</td>
<td>
<div style="display: flex; gap: 0.4rem;">
<button class="btn btn-sm btn-success" onclick="restoreItem(${idx})">♻️ بازگردانی</button>
<button class="btn btn-sm btn-danger" onclick="permanentDeleteItem(${idx})">حذف قطعی</button>
</div>
</td>
</tr>
`).join('');
}
// CRUD Handlers
function saveMasterItem(event, entity) {
event.preventDefault();
const entitySingle = (entity === 'approvals') ? 'approval' : (entity === 'meetings') ? 'meeting' : (entity === 'tasks') ? 'task' : (entity === 'finance') ? 'finance' : (entity === 'contacts') ? 'contact' : 'vault';
const idField = document.getElementById(entitySingle + 'Id');
const isEdit = idField && idField.value;
const itemId = isEdit ? idField.value : (entity + '_' + Date.now());
let itemObj = { id: itemId };
if (entity === 'approvals') {
itemObj.title = document.getElementById('approvalTitleInput').value;
itemObj.requester = document.getElementById('approvalRequesterInput').value;
itemObj.priority = document.getElementById('approvalPriorityInput').value;
itemObj.description = document.getElementById('approvalDescriptionInput').value;
itemObj.link = document.getElementById('approvalLinkInput').value;
itemObj.status = document.getElementById('approvalStatusInput').value;
itemObj.createdAt = new Date().toLocaleDateString('fa-IR');
closeModal('modalApproval');
} else if (entity === 'meetings') {
itemObj.title = document.getElementById('meetingTitleInput').value;
itemObj.type = document.getElementById('meetingTypeInput').value;
itemObj.time = document.getElementById('meetingTimeInput').value;
itemObj.attendees = document.getElementById('meetingAttendeesInput').value;
itemObj.buffer = document.getElementById('meetingBufferInput').value;
itemObj.link = document.getElementById('meetingLinkInput').value;
itemObj.notes = document.getElementById('meetingNotesInput').value;
closeModal('modalMeeting');
} else if (entity === 'tasks') {
itemObj.title = document.getElementById('taskTitleInput').value;
itemObj.assignee = document.getElementById('taskAssigneeInput').value;
itemObj.category = document.getElementById('taskCategoryInput').value;
itemObj.priority = document.getElementById('taskPriorityInput').value;
itemObj.deadline = document.getElementById('taskDeadlineInput').value;
itemObj.status = document.getElementById('taskStatusInput').value;
closeModal('modalTask');
} else if (entity === 'finance') {
itemObj.title = document.getElementById('financeTitleInput').value;
itemObj.bank = document.getElementById('financeBankInput').value;
itemObj.amount = document.getElementById('financeAmountInput').value;
itemObj.dueDate = document.getElementById('financeDueDateInput').value;
itemObj.notes = document.getElementById('financeNotesInput').value;
itemObj.status = document.getElementById('financeStatusInput').value;
closeModal('modalFinance');
} else if (entity === 'contacts') {
itemObj.name = document.getElementById('contactNameInput').value;
itemObj.category = document.getElementById('contactCategoryInput').value;
itemObj.role = document.getElementById('contactRoleInput').value;
itemObj.phone = document.getElementById('contactPhoneInput').value;
itemObj.social = document.getElementById('contactSocialInput').value;
itemObj.notes = document.getElementById('contactNotesInput').value;
closeModal('modalContact');
} else if (entity === 'vault') {
itemObj.title = document.getElementById('vaultTitleInput').value;
itemObj.category = document.getElementById('vaultCategoryInput').value;
itemObj.link = document.getElementById('vaultLinkInput').value;
itemObj.sec = document.getElementById('vaultSecInput').value;
itemObj.desc = document.getElementById('vaultDescInput').value;
closeModal('modalVault');
}
if (isEdit) {
const idx = appState[entity].findIndex(i => i.id === itemId);
if (idx !== -1) appState[entity][idx] = itemObj;
showToast('✏️ اطلاعات ویرایش و ذخیره شد.');
} else {
appState[entity].unshift(itemObj);
showToast('✅ رکورد جدید با موفقیت ایجاد شد.');
}
triggerStateChange();
}
function editMasterItem(entitySingle, id) {
const entityPlural = (entitySingle === 'approval') ? 'approvals' : (entitySingle === 'meeting') ? 'meetings' : (entitySingle === 'task') ? 'tasks' : (entitySingle === 'finance') ? 'finance' : (entitySingle === 'contact') ? 'contacts' : 'vault';
const item = appState[entityPlural].find(i => i.id === id);
if (!item) return;
if (entitySingle === 'approval') {
document.getElementById('approvalId').value = item.id;
document.getElementById('approvalTitleInput').value = item.title;
document.getElementById('approvalRequesterInput').value = item.requester;
document.getElementById('approvalPriorityInput').value = item.priority;
document.getElementById('approvalDescriptionInput').value = item.description;
document.getElementById('approvalLinkInput').value = item.link || '';
document.getElementById('approvalStatusInput').value = item.status;
document.getElementById('modalApprovalTitle').innerText = 'ویرایش تاییدیه حامد';
openModal('modalApproval');
} else if (entitySingle === 'meeting') {
document.getElementById('meetingId').value = item.id;
document.getElementById('meetingTitleInput').value = item.title;
document.getElementById('meetingTypeInput').value = item.type;
document.getElementById('meetingTimeInput').value = item.time;
document.getElementById('meetingAttendeesInput').value = item.attendees || '';
document.getElementById('meetingBufferInput').value = item.buffer || '';
document.getElementById('meetingLinkInput').value = item.link || '';
document.getElementById('meetingNotesInput').value = item.notes || '';
document.getElementById('modalMeetingTitle').innerText = 'ویرایش جلسه';
openModal('modalMeeting');
} else if (entitySingle === 'task') {
document.getElementById('taskId').value = item.id;
document.getElementById('taskTitleInput').value = item.title;
document.getElementById('taskAssigneeInput').value = item.assignee || '';
document.getElementById('taskCategoryInput').value = item.category;
document.getElementById('taskPriorityInput').value = item.priority;
document.getElementById('taskDeadlineInput').value = item.deadline || '';
document.getElementById('taskStatusInput').value = item.status;
document.getElementById('modalTaskTitle').innerText = 'ویرایش تسک';
openModal('modalTask');
} else if (entitySingle === 'finance') {
document.getElementById('financeId').value = item.id;
document.getElementById('financeTitleInput').value = item.title;
document.getElementById('financeBankInput').value = item.bank || '';
document.getElementById('financeAmountInput').value = item.amount;
document.getElementById('financeDueDateInput').value = item.dueDate;
document.getElementById('financeNotesInput').value = item.notes || '';
document.getElementById('financeStatusInput').value = item.status;
document.getElementById('modalFinanceTitle').innerText = 'ویرایش قسط / تعهد';
openModal('modalFinance');
} else if (entitySingle === 'contact') {
document.getElementById('contactId').value = item.id;
document.getElementById('contactNameInput').value = item.name;
document.getElementById('contactCategoryInput').value = item.category;
document.getElementById('contactRoleInput').value = item.role || '';
document.getElementById('contactPhoneInput').value = item.phone;
document.getElementById('contactSocialInput').value = item.social || '';
document.getElementById('contactNotesInput').value = item.notes || '';
document.getElementById('modalContactTitle').innerText = 'ویرایش مخاطب VIP';
openModal('modalContact');
} else if (entitySingle === 'vault') {
document.getElementById('vaultId').value = item.id;
document.getElementById('vaultTitleInput').value = item.title;
document.getElementById('vaultCategoryInput').value = item.category;
document.getElementById('vaultLinkInput').value = item.link;
document.getElementById('vaultSecInput').value = item.sec;
document.getElementById('vaultDescInput').value = item.desc || '';
document.getElementById('modalVaultTitle').innerText = 'ویرایش سند درایو';
openModal('modalVault');
}
}
function deleteMasterItem(entity, id) {
const idx = appState[entity].findIndex(i => i.id === id);
if (idx === -1) return;
const item = appState[entity][idx];
const rec = {
recycleId: 'rec_' + Date.now(),
entityType: entity,
title: item.title || item.name || 'بدون عنوان',
deletedAt: new Date().toLocaleDateString('fa-IR') + ' ' + new Date().toLocaleTimeString('fa-IR'),
data: item
};
if (!appState.recycle) appState.recycle = [];
appState.recycle.unshift(rec);
appState[entity].splice(idx, 1);
showToast('🗑️ به سطل بازیافت منتقل شد (قابل بازگردانی است).');
triggerStateChange();
}
function restoreItem(index) {
const rec = appState.recycle[index];
if (!rec) return;
const entity = rec.entityType;
if (!appState[entity]) appState[entity] = [];
appState[entity].unshift(rec.data);
appState.recycle.splice(index, 1);
showToast(`♻️ «${rec.title}» بازگردانده شد.`);
triggerStateChange();
}
function permanentDeleteItem(index) {
if (confirm('آیا از حذف دائمی این رکورد اطمینان دارید؟ این عمل غیرقابل بازگشت است.')) {
appState.recycle.splice(index, 1);
showToast('حذف قطعی شد.');
triggerStateChange();
}
}
// Team Guest Intake
function handleTeamGuestSubmit(e) {
e.preventDefault();
const req = document.getElementById('tgRequester').value;
const title = document.getElementById('tgTitle').value;
const priority = document.getElementById('tgPriority').value;
const desc = document.getElementById('tgDescription').value;
const link = document.getElementById('tgLink').value;
const newApproval = {
id: 'team_' + Date.now(),
title: title,
requester: req,
priority: priority,
description: desc,
link: link || '',
status: 'pending',
createdAt: new Date().toLocaleDateString('fa-IR')
};
appState.approvals.unshift(newApproval);
triggerStateChange();
document.getElementById('teamGuestForm').reset();
showToast('🚀 درخواست شما با موفقیت در صف حامد فلاحی ثبت شد.');
alert('درخواست شما برای تایید در کارتابل حامد فلاحی ثبت گردید.');
}
// Backups
function exportFullBackup() {
const dataStr = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(appState, null, 2));
const downloadAnchor = document.createElement('a');
downloadAnchor.setAttribute("href", dataStr);
downloadAnchor.setAttribute("download", `ExecCockpit_Backup_${new Date().toISOString().slice(0,10)}.json`);
document.body.appendChild(downloadAnchor);
downloadAnchor.click();
downloadAnchor.remove();
showToast('📥 فایل بکاپ کامل JSON دانلود شد.');
}
function restoreFromBackupFile() {
const input = document.createElement('input');
input.type = 'file';
input.accept = '.json';
input.onchange = e => {
const file = e.target.files[0];
const reader = new FileReader();
reader.readAsText(file, 'UTF-8');
reader.onload = readerEvent => {
try {
const content = JSON.parse(readerEvent.target.result);
if (content.approvals && content.meetings) {
appState = content;
triggerStateChange();
showToast('✅ بازگردانی از بکاپ انجام شد.');
} else {
alert('فایل نامعتبر است.');
}
} catch (err) {
alert('خطا در خواندن فایل.');
}
}
}
input.click();
}
function filterData(entity, query) {
const q = query.trim().toLowerCase();
const rows = document.querySelectorAll(`#tableBody${capitalize(entity)} tr`);
rows.forEach(r => {
r.style.display = r.innerText.toLowerCase().includes(q) ? '' : 'none';
});
}
// Init
window.addEventListener('DOMContentLoaded', () => {
try {
const savedUser = sessionStorage.getItem('exec_cockpit_user');
if (savedUser && ['hamed', 'mohadese', 'team_guest'].includes(savedUser)) {
currentUser = savedUser;
}
} catch (e) {}
updateViewVisibility();
loadFromPostgres();
});
</script>
</body>
</html>