sara-dashboards/escape_room_crm_dashboard.html

1045 lines
47 KiB
HTML
Raw Permalink 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>داشبورد CRM و پایپ‌لاین جذب اتاق فرارها | اکیپا (Ekeepa)</title>
<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=Vazirmatn:wght@300;400;500;600;700;800;900&display=swap" rel="stylesheet">
<script src="https://cdn.plot.ly/plotly-2.27.0.min.js"></script>
<style>
:root {
--bg-body: #F8FAFC;
--bg-card: #FFFFFF;
--border: #E2E8F0;
--border-focus: #2563EB;
--text-main: #0F172A;
--text-muted: #475569;
--text-light: #94A3B8;
--primary: #2563EB;
--primary-light: #EFF6FF;
--success: #16A34A;
--success-light: #F0FDF4;
--warning: #D97706;
--warning-light: #FFFBEB;
--danger: #DC2626;
--danger-light: #FEF2F2;
--purple: #7C3AED;
--purple-light: #F5F3FF;
--cyan: #0284C7;
--cyan-light: #F0F9FF;
--shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
--shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
--shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08);
--radius-sm: 8px;
--radius-md: 12px;
--radius-lg: 16px;
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, sans-serif;
font-feature-settings: "tnum" 1;
}
body {
background-color: var(--bg-body);
color: var(--text-main);
direction: rtl;
padding: 24px;
font-size: 13px;
line-height: 1.6;
}
.container {
max-width: 1560px;
margin: 0 auto;
}
/* Header */
.header-bar {
background: var(--bg-card);
border: 1px solid var(--border);
border-radius: var(--radius-lg);
padding: 20px 24px;
margin-bottom: 24px;
box-shadow: var(--shadow);
display: flex;
justify-content: space-between;
align-items: center;
flex-wrap: wrap;
gap: 16px;
}
.header-title-box h1 {
font-size: 20px;
font-weight: 800;
color: var(--text-main);
display: flex;
align-items: center;
gap: 10px;
}
.header-title-box p {
font-size: 12px;
color: var(--text-muted);
margin-top: 4px;
}
.header-actions {
display: flex;
align-items: center;
gap: 12px;
}
.badge-live {
display: inline-flex;
align-items: center;
gap: 6px;
background: #ECFDF5;
color: #065F46;
padding: 6px 12px;
border-radius: 9999px;
font-size: 11px;
font-weight: 700;
border: 1px solid #A7F3D0;
}
.pulse-dot {
width: 8px;
height: 8px;
background: #10B981;
border-radius: 50%;
animation: pulse 2s infinite;
}
@keyframes pulse {
0% { transform: scale(0.95); opacity: 0.9; }
50% { transform: scale(1.2); opacity: 0.4; }
100% { transform: scale(0.95); opacity: 0.9; }
}
.btn-primary {
background: var(--primary);
color: #FFFFFF;
border: none;
border-radius: var(--radius-sm);
padding: 9px 18px;
font-size: 12px;
font-weight: 700;
cursor: pointer;
display: inline-flex;
align-items: center;
gap: 8px;
transition: all 0.2s;
}
.btn-primary:hover {
background: #1D4ED8;
}
.btn-secondary {
background: #FFFFFF;
color: var(--text-main);
border: 1px solid var(--border);
border-radius: var(--radius-sm);
padding: 9px 16px;
font-size: 12px;
font-weight: 600;
cursor: pointer;
display: inline-flex;
align-items: center;
gap: 6px;
transition: all 0.2s;
}
.btn-secondary:hover {
background: #F1F5F9;
}
/* KPI Cards Grid */
.kpi-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
gap: 16px;
margin-bottom: 24px;
}
.kpi-card {
background: var(--bg-card);
border: 1px solid var(--border);
border-radius: var(--radius-md);
padding: 16px 20px;
box-shadow: var(--shadow);
position: relative;
overflow: hidden;
}
.kpi-card::after {
content: '';
position: absolute;
top: 0;
right: 0;
left: 0;
height: 3px;
}
.kpi-card.blue::after { background: var(--primary); }
.kpi-card.green::after { background: var(--success); }
.kpi-card.purple::after { background: var(--purple); }
.kpi-card.amber::after { background: var(--warning); }
.kpi-card.cyan::after { background: var(--cyan); }
.kpi-label {
font-size: 11px;
font-weight: 600;
color: var(--text-muted);
margin-bottom: 6px;
display: flex;
align-items: center;
justify-content: space-between;
}
.kpi-number {
font-size: 24px;
font-weight: 800;
color: var(--text-main);
}
.kpi-subtext {
font-size: 11px;
color: var(--text-light);
margin-top: 4px;
}
/* Chart Section */
.charts-row {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20px;
margin-bottom: 24px;
}
@media (max-width: 1024px) {
.charts-row {
grid-template-columns: 1fr;
}
}
.chart-box {
background: var(--bg-card);
border: 1px solid var(--border);
border-radius: var(--radius-md);
padding: 18px 20px;
box-shadow: var(--shadow);
}
.chart-title {
font-size: 14px;
font-weight: 700;
color: var(--text-main);
margin-bottom: 12px;
display: flex;
align-items: center;
gap: 8px;
}
/* Tab Switcher (Kanban vs Table) */
.view-tabs {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 18px;
border-bottom: 2px solid var(--border);
padding-bottom: 8px;
}
.view-btn {
background: transparent;
border: none;
padding: 8px 18px;
font-size: 13px;
font-weight: 700;
color: var(--text-muted);
border-radius: var(--radius-sm);
cursor: pointer;
transition: all 0.2s;
display: inline-flex;
align-items: center;
gap: 8px;
}
.view-btn.active {
background: var(--primary-light);
color: var(--primary);
}
/* Kanban Board */
.kanban-board {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
gap: 16px;
overflow-x: auto;
padding-bottom: 16px;
}
.kanban-col {
background: #F1F5F9;
border: 1px solid var(--border);
border-radius: var(--radius-md);
padding: 14px;
min-width: 250px;
display: flex;
flex-direction: column;
gap: 12px;
}
.kanban-col-header {
display: flex;
justify-content: space-between;
align-items: center;
padding-bottom: 8px;
border-bottom: 2px solid #E2E8F0;
}
.kanban-col-title {
font-size: 13px;
font-weight: 800;
color: var(--text-main);
display: flex;
align-items: center;
gap: 8px;
}
.kanban-col-count {
background: #E2E8F0;
color: var(--text-muted);
padding: 2px 8px;
border-radius: 9999px;
font-size: 11px;
font-weight: 700;
}
.kanban-card {
background: var(--bg-card);
border: 1px solid var(--border);
border-radius: var(--radius-sm);
padding: 14px;
box-shadow: var(--shadow-sm);
cursor: pointer;
transition: transform 0.15s, box-shadow 0.15s;
}
.kanban-card:hover {
transform: translateY(-2px);
box-shadow: var(--shadow-md);
border-color: #CBD5E1;
}
.card-header-flex {
display: flex;
justify-content: space-between;
align-items: flex-start;
margin-bottom: 8px;
}
.card-room-name {
font-size: 14px;
font-weight: 800;
color: var(--text-main);
}
.card-complex-name {
font-size: 11px;
color: var(--text-muted);
margin-top: 2px;
}
.priority-badge {
font-size: 10px;
font-weight: 700;
padding: 2px 6px;
border-radius: 4px;
}
.priority-فوری { background: #FEE2E2; color: #DC2626; }
.priority-بالا { background: #FEF3C7; color: #D97706; }
.priority-متوسط { background: #EFF6FF; color: #2563EB; }
.priority-کم { background: #F1F5F9; color: #64748B; }
.card-meta-row {
display: flex;
justify-content: space-between;
font-size: 11px;
color: var(--text-muted);
margin-top: 10px;
padding-top: 8px;
border-top: 1px dashed var(--border);
}
.card-owner-badge {
display: inline-flex;
align-items: center;
gap: 4px;
font-weight: 600;
}
/* Table View */
.table-view-container {
background: var(--bg-card);
border: 1px solid var(--border);
border-radius: var(--radius-md);
padding: 20px;
box-shadow: var(--shadow);
}
.filter-toolbar {
display: flex;
flex-wrap: wrap;
gap: 12px;
margin-bottom: 16px;
align-items: center;
justify-content: space-between;
}
.filter-group {
display: flex;
gap: 8px;
flex-wrap: wrap;
align-items: center;
}
.search-box {
padding: 8px 14px;
border: 1px solid var(--border);
border-radius: var(--radius-sm);
font-size: 12px;
width: 260px;
outline: none;
}
.search-box:focus {
border-color: var(--primary);
}
.select-filter {
padding: 8px 12px;
border: 1px solid var(--border);
border-radius: var(--radius-sm);
font-size: 12px;
background: #FFFFFF;
color: var(--text-main);
outline: none;
cursor: pointer;
}
table {
width: 100%;
border-collapse: collapse;
font-size: 12.5px;
}
th {
background: #F8FAFC;
color: var(--text-muted);
font-weight: 700;
text-align: right;
padding: 12px 14px;
border-bottom: 2px solid var(--border);
cursor: pointer;
user-select: none;
white-space: nowrap;
}
th:hover {
background: #F1F5F9;
}
td {
padding: 12px 14px;
border-bottom: 1px solid var(--border);
color: var(--text-main);
vertical-align: middle;
}
tr:hover td {
background: #F8FAFC;
}
/* Status Pills */
.status-pill {
display: inline-flex;
align-items: center;
gap: 4px;
padding: 4px 10px;
border-radius: 9999px;
font-size: 11px;
font-weight: 700;
}
.status-new { background: #F1F5F9; color: #475569; }
.status-contacted { background: #E0F2FE; color: #0369A1; }
.status-proposal { background: #FEF3C7; color: #B45309; }
.status-negotiation { background: #F3E8FF; color: #7E22CE; }
.status-contract { background: #DCFCE7; color: #15803D; }
.status-active { background: #D1FAE5; color: #047857; }
.status-lost { background: #FFE4E6; color: #BE123C; }
/* Drawer */
.drawer-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(15, 23, 42, 0.4);
backdrop-filter: blur(2px);
z-index: 1000;
display: none;
}
.drawer {
position: fixed;
top: 0;
left: 0;
bottom: 0;
width: 480px;
max-width: 90vw;
background: #FFFFFF;
z-index: 1001;
box-shadow: -4px 0 25px rgba(0,0,0,0.15);
padding: 28px;
transform: translateX(-100%);
transition: transform 0.3s ease-in-out;
overflow-y: auto;
}
.drawer.open {
transform: translateX(0);
}
.drawer-close {
position: absolute;
top: 20px;
left: 20px;
background: #F1F5F9;
border: none;
width: 32px;
height: 32px;
border-radius: 50%;
cursor: pointer;
font-weight: 800;
color: var(--text-muted);
display: flex;
align-items: center;
justify-content: center;
}
.drawer-section {
margin-top: 20px;
padding-top: 16px;
border-top: 1px solid var(--border);
}
.drawer-section-title {
font-size: 13px;
font-weight: 800;
color: var(--text-main);
margin-bottom: 10px;
}
.drawer-field {
margin-bottom: 10px;
display: flex;
justify-content: space-between;
}
.drawer-field-key {
color: var(--text-muted);
font-size: 12px;
}
.drawer-field-val {
color: var(--text-main);
font-weight: 700;
font-size: 12px;
}
.callout-box {
background: #F8FAFC;
border: 1px solid var(--border);
border-right: 4px solid var(--primary);
border-radius: var(--radius-sm);
padding: 12px;
font-size: 12px;
color: var(--text-muted);
line-height: 1.6;
margin-top: 12px;
}
</style>
</head>
<body>
<div class="container">
<!-- Header -->
<div class="header-bar">
<div class="header-title-box">
<h1>
<span>🎯</span>
<span>سامانه CRM و خط لوله (Pipeline) جذب اتاق فرارها</span>
</h1>
<p>پایش لیدها، پیشرفت مذاکرات، پکیج‌های تبلیغاتی و نرخ تبدیل بازی‌ها در پلتفرم اکیپا (Ekeepa)</p>
</div>
<div class="header-actions">
<span class="badge-live">
<span class="pulse-dot"></span>
پایپ‌لاین زنده مارکتینگ و BD
</span>
<button class="btn-secondary" onclick="exportLeadsCSV()">
📥 دریافت خروجی اکسل / CSV
</button>
<button class="btn-primary" onclick="alert('فرم ثبت لید جدید در پرسلاین یا پنل سلر')">
➕ افزودن مجموعه جدید
</button>
</div>
</div>
<!-- KPI Summary Row -->
<div class="kpi-grid">
<div class="kpi-card blue">
<div class="kpi-label">
<span>کل لیدهای شناسایی شده</span>
<span>📋</span>
</div>
<div class="kpi-number">128</div>
<div class="kpi-subtext">تارگت فاز جاری: ۱۵۰ مجموعه</div>
</div>
<div class="kpi-card cyan">
<div class="kpi-label">
<span>تماس برقرار شده</span>
<span>📞</span>
</div>
<div class="kpi-number">94</div>
<div class="kpi-subtext">۷۳.۴٪ نرخ برقراری ارتباط اولیه</div>
</div>
<div class="kpi-card amber">
<div class="kpi-label">
<span>پروپوزال و مذاکره جاری</span>
<span>📑</span>
</div>
<div class="kpi-number">102</div>
<div class="kpi-subtext">شامل بسته‌های طلایی و نقره‌ای</div>
</div>
<div class="kpi-card green">
<div class="kpi-label">
<span>جذب موفق و نهایی‌شده</span>
<span>✅</span>
</div>
<div class="kpi-number">42</div>
<div class="kpi-subtext">نرخ تبدیل نهایی: ۳۲.۸٪</div>
</div>
<div class="kpi-card purple">
<div class="kpi-label">
<span>ارزش بالقوه ناخالص (GMV)</span>
<span>💰</span>
</div>
<div class="kpi-number" style="font-size: 19px;">1,450,000,000 تومان</div>
<div class="kpi-subtext">پتانسیل درآمد ماهانه کمیسیون اکیپا</div>
</div>
</div>
<!-- Charts Row -->
<div class="charts-row">
<div class="chart-box">
<div class="chart-title">
<span>📊</span>
<span>قیف فروش و ریزش مراحل جذب (Conversion Funnel)</span>
</div>
<div id="funnelChart" style="height: 280px;"></div>
</div>
<div class="chart-box">
<div class="chart-title">
<span>🏢</span>
<span>توزیع لیدها بر اساس کانال ورودی و پکیج تجاری</span>
</div>
<div id="sourceChart" style="height: 280px;"></div>
</div>
</div>
<!-- Switcher -->
<div class="view-tabs">
<button class="view-btn active" id="btnKanban" onclick="setView('kanban')">
<span>📋</span> نمای کانبان (مراحل پیشرفت)
</button>
<button class="view-btn" id="btnTable" onclick="setView('table')">
<span>📑</span> نمای جدول داده‌ها و پیگیری
</button>
</div>
<!-- Kanban View -->
<div id="kanbanView" class="kanban-board">
<!-- Generated by JS -->
</div>
<!-- Table View -->
<div id="tableView" class="table-view-container" style="display: none;">
<div class="filter-toolbar">
<div class="filter-group">
<input type="text" id="searchInput" class="search-box" placeholder="جستجوی نام اتاق، مجموعه، مسئول یا شهر..." oninput="renderTable()">
<select id="stageFilter" class="select-filter" onchange="renderTable()">
<option value="">همه مراحل جذب</option>
<option value="new">لید جدید</option>
<option value="contacted">تماس اولیه</option>
<option value="proposal">پروپوزال ارسال شده</option>
<option value="negotiation">در حال مذاکره</option>
<option value="contract">عقد قرارداد</option>
<option value="active">فعال در سایت</option>
<option value="lost">انصراف / لغو</option>
</select>
<select id="ownerFilter" class="select-filter" onchange="renderTable()">
<option value="">همه مسئولین پیگیری</option>
<option value="الهه فلاحی">الهه فلاحی</option>
<option value="کیمیا">کیمیا</option>
<option value="غزاله">غزاله</option>
</select>
<select id="priorityFilter" class="select-filter" onchange="renderTable()">
<option value="">همه اولویت‌ها</option>
<option value="فوری">فوری</option>
<option value="بالا">بالا</option>
<option value="متوسط">متوسط</option>
<option value="کم">کم</option>
</select>
</div>
<div style="font-size: 12px; color: var(--text-muted);" id="recordCountLabel">
نمایش ۱۵ از ۱۵ مجموعه
</div>
</div>
<div style="overflow-x: auto;">
<table id="leadsDataTable">
<thead>
<tr>
<th onclick="sortTable('id')">کد پرونده</th>
<th onclick="sortTable('room_name')">نام اتاق فرار</th>
<th onclick="sortTable('complex')">مجموعه / برند</th>
<th onclick="sortTable('city')">شهر و منطقه</th>
<th onclick="sortTable('contact_person')">مدیر / مخاطب</th>
<th onclick="sortTable('owner')">مسئول پیگیری</th>
<th onclick="sortTable('status')">وضعیت مرحله</th>
<th onclick="sortTable('package')">پکیج / درصد</th>
<th onclick="sortTable('priority')">اولویت</th>
<th onclick="sortTable('last_contact')">آخرین تماس</th>
<th>اقدام بعدی</th>
</tr>
</thead>
<tbody id="tableBody">
<!-- Populated by JS -->
</tbody>
</table>
</div>
</div>
</div>
<!-- Drawer Detail Modal -->
<div class="drawer-overlay" id="drawerOverlay" onclick="closeDrawer()"></div>
<div class="drawer" id="drawer">
<button class="drawer-close" onclick="closeDrawer()">✕</button>
<div id="drawerContent">
<!-- Populated by JS -->
</div>
</div>
<script>
const LEADS = [{"id": "CRM-101", "room_name": "تارتاروس", "complex": "مجموعه هلیونز (Hellions)", "city": "تهران", "district": "سعادت‌آباد", "contact_person": "علی رضایی (مدیر مجموعه)", "phone": "09121112233", "owner": "الهه فلاحی", "status": "contract", "package": "طلایی (Gold)", "commission": "۲۵٪", "deal_value": "۴۸,۰۰۰,۰۰۰ تومان", "source": "پرسلاین / فرم داوطلب", "priority": "فوری", "last_contact": "۱۴۰۵/۰۷/۱۴", "next_action": "امضای قرارداد انحصاری و فعال‌سازی پنل سلر", "notes": "یکی از قوی‌ترین بازی‌های تهران، درخواست امکان تسویه هفتگی و تنوع درگاه‌های BNPL (اسنپ‌پی) دارند. پیش‌نویس قرارداد فرستاده شد."}, {"id": "CRM-102", "room_name": "پارکینگ", "complex": "مجموعه هلیونز (Hellions)", "city": "تهران", "district": "سعادت‌آباد", "contact_person": "علی رضایی", "phone": "09121112233", "owner": "الهه فلاحی", "status": "contract", "package": "طلایی (Gold)", "commission": "۲۵٪", "deal_value": "۴۲,۰۰۰,۰۰۰ تومان", "source": "پرسلاین", "priority": "بالا", "last_contact": "۱۴۰۵/۰۷/۱۴", "next_action": "تخصیص اکتورها و بارگذاری تایم‌اسلات‌ها در پنل", "notes": "همراه با تارتاروس به عنوان باندل ثبت‌نام شد."}, {"id": "CRM-103", "room_name": "آنخ", "complex": "مجموعه اینفرنال (Infernal)", "city": "تهران", "district": "صادقیه", "contact_person": "مهرداد کاظمی", "phone": "09123334455", "owner": "کیمیا", "status": "active", "package": "طلایی (Gold)", "commission": "۲۵٪", "deal_value": "۵۵,۰۰۰,۰۰۰ تومان", "source": "تماس مستقیم مارکتینگ", "priority": "بالا", "last_contact": "۱۴۰۵/۰۷/۱۲", "next_action": "پایش اولین رزروهای هفته", "notes": "بازی انحصاری و باکیفیت؛ روی هیچ سایت رقیبی نیست. کمپین پیامکی اختصاصی ارسال شد."}, {"id": "CRM-104", "room_name": "ابدیت", "complex": "مجموعه اینفرنال (Infernal)", "city": "تهران", "district": "صادقیه", "contact_person": "مهرداد کاظمی", "phone": "09123334455", "owner": "کیمیا", "status": "active", "package": "نقره‌ای (Silver)", "commission": "۲۰٪", "deal_value": "۳۸,۰۰۰,۰۰۰ تومان", "source": "تماس مستقیم", "priority": "متوسط", "last_contact": "۱۴۰۵/۰۷/۱۰", "next_action": "بررسی بازخورد اولین هفته فروش", "notes": "اتصال کامل به درگاه بانکی و فعال در پنل."}, {"id": "CRM-105", "room_name": "تله مرگ", "complex": "اسکیپ زوم (Escape Zoom)", "city": "مشهد", "district": "بلوار سجاد", "contact_person": "حسام نوری", "phone": "09151122334", "owner": "غزاله", "status": "negotiation", "package": "طلایی (انحصار مشهد)", "commission": "۲۵٪", "deal_value": "۳۶,۰۰۰,۰۰۰ تومان", "source": "سفر میدانی مشهد", "priority": "فوری", "last_contact": "۱۴۰۵/۰۷/۱۵", "next_action": "نهایی‌سازی مدل تضمین سانس و سقف تخفیف تبلیغاتی", "notes": "بزرگترین مجموعه شرق کشور. تقاضای تضمین کف تعداد سانس در ماه دارند."}, {"id": "CRM-106", "room_name": "شبح عمارت", "complex": "بلک لایت اسکیپ", "city": "کرج", "district": "گوهردشت", "contact_person": "فرشاد صادقی", "phone": "09359988776", "owner": "کیمیا", "status": "proposal", "package": "نقره‌ای (Silver)", "commission": "۲۰٪", "deal_value": "۲۲,۰۰۰,۰۰۰ تومان", "source": "اینستاگرام اکیپا", "priority": "متوسط", "last_contact": "۱۴۰۵/۰۷/۱۳", "next_action": "پیگیری دریافت فیدبک پروپوزال ارسالی", "notes": "پروپوزال پکیج‌های عیدانه و پیامک برایشان ارسال شده. نگران تداخل با پنل اختصاصی خود بودند."}, {"id": "CRM-107", "room_name": "سایه‌روشن", "complex": "فکرکده", "city": "تهران", "district": "انقلاب", "contact_person": "مدیریت شعب فکرکده", "phone": "02166448899", "owner": "الهه فلاحی", "status": "contacted", "package": "استاندارد (۱۳٪)", "commission": "۱۳٪", "deal_value": "۳۰,۰۰۰,۰۰۰ تومان", "source": "جلسه حضوری سازمانی", "priority": "بالا", "last_contact": "۱۴۰۵/۰۷/۱۱", "next_action": "ارسال کاتالوگ سازمانی و وبینار پرزنت", "notes": "شعبه در حال بازسازی معماها بود. قرار شد بعد از اتمام تست نهایی، قرارداد آماده شود."}, {"id": "CRM-108", "room_name": "کلبه ارواح", "complex": "مجموعه زجر (سابق)", "city": "تهران", "district": "تهرانپارس", "contact_person": "امید پیروز", "phone": "09124455667", "owner": "غزاله", "status": "lost", "package": "نامشخص", "commission": "-", "deal_value": "۰ تومان", "source": "دیتابیس اسکیپ‌های قدیمی", "priority": "کم", "last_contact": "۱۴۰۵/۰۷/۰۸", "next_action": "بستن پرونده در سیستم", "notes": "مجموعه به صورت کامل جمع‌آوری شده و دکور فروخته شده است."}, {"id": "CRM-109", "room_name": "راز گورستان", "complex": "مجموعه دایموند (Diamond)", "city": "شیراز", "district": "معالی‌آباد", "contact_person": "سینا ابراهیمی", "phone": "09172233445", "owner": "کیمیا", "status": "negotiation", "package": "طلایی (Gold)", "commission": "۲۵٪", "deal_value": "۲۸,۰۰۰,۰۰۰ تومان", "source": "پرسلاین جذبی‌ها", "priority": "بالا", "last_contact": "۱۴۰۵/۰۷/۱۵", "next_action": "تایید نهایی شماره شبا و حساب فراغت آفرینان پویا", "notes": "واریز اولیه ۴ میلیون تومان بابت ورودی پکیج طلایی هماهنگ شده است."}, {"id": "CRM-110", "room_name": "سیاهچال خونین", "complex": "رومیست (Roomist)", "city": "تهران", "district": "پاسداران", "contact_person": "کامران شمس", "phone": "09128877665", "owner": "الهه فلاحی", "status": "active", "package": "طلایی (Gold)", "commission": "۲۵٪", "deal_value": "۶۲,۰۰۰,۰۰۰ تومان", "source": "ارتباط سفیران اکیپا", "priority": "بالا", "last_contact": "۱۴۰۵/۰۷/۱۴", "next_action": "تسویه حساب دوره ۱۵ روزه اول", "notes": "یکی از پرفروش‌ترین بازی‌های ترسناک؛ رضایت بالا از درگاه تارا و اسنپ‌پی."}, {"id": "CRM-111", "room_name": "فرار از آلکاتراز", "complex": "اسکیپ ماستر (Escape Master)", "city": "اصفهان", "district": "مرداویج", "contact_person": "احسان دهقان", "phone": "09133344556", "owner": "غزاله", "status": "proposal", "package": "نقره‌ای (Silver)", "commission": "۲۰٪", "deal_value": "۲۵,۰۰۰,۰۰۰ تومان", "source": "معرفی همکاران", "priority": "متوسط", "last_contact": "۱۴۰۵/۰۷/۱۳", "next_action": "تماس پیگیری فردا ساعت ۱۱ صبح", "notes": "پیشنهاد شارژ کیف‌پول برای تست رایگان به همراه ارسال فیلم‌های معرفی داده شد."}, {"id": "CRM-112", "room_name": "انتقام زامبی‌ها", "complex": "سناتور اسکیپ", "city": "کرج", "district": "عظیمیه", "contact_person": "مجید رستگار", "phone": "09214433221", "owner": "کیمیا", "status": "active", "package": "نقره‌ای (Silver)", "commission": "۲۰٪", "deal_value": "۳۱,۰۰۰,۰۰۰ تومان", "source": "پرسلاین", "priority": "بالا", "last_contact": "۱۴۰۵/۰۷/۱۵", "next_action": "بررسی نظرات و فیدبک‌های دریافتی کاربران", "notes": "بازی با استقبال خوب روبه‌رو شده است؛ نرخ لغو زیر ۳٪ است."}, {"id": "CRM-113", "room_name": "تیمارستان شوم", "complex": "دارک روم اسکیپ", "city": "تهران", "district": "ستارخان", "contact_person": "نیما یزدانی", "phone": "09361122334", "owner": "غزاله", "status": "new", "package": "پیشنهادی نقره‌ای", "commission": "۲۰٪", "deal_value": "۲۰,۰۰۰,۰۰۰ تومان", "source": "ثبت‌نام فرم آنلاین سایت", "priority": "متوسط", "last_contact": "۱۴۰۵/۰۷/۱۵", "next_action": "تماس اولیه جهت اعتبارسنجی لوکیشن و مجوزها", "notes": "لید تازه ثبت شده؛ نیاز به تماس و پرزنت اولیه دارد."}, {"id": "CRM-114", "room_name": "نفرین مایا", "complex": "اسکیپ کلاب اندیشه", "city": "شهریار", "district": "فاز ۱ اندیشه", "contact_person": "حامد داوودی", "phone": "09127766554", "owner": "کیمیا", "status": "contacted", "package": "استاندارد (۱۳٪)", "commission": "۱۳٪", "deal_value": "۱۸,۰۰۰,۰۰۰ تومان", "source": "بازاریابی منطقه‌ای غرب تهران", "priority": "کم", "last_contact": "۱۴۰۵/۰۷/۱۴", "next_action": "ارسال لینک ثبت‌نام مستقیم", "notes": "تقاضای فیلتر منطقه اختصاصی شهریار و اندیشه در سایت برای دیده شدن داشتند."}, {"id": "CRM-115", "room_name": "معمای شرلوک", "complex": "مغز متفکر", "city": "تهران", "district": "ونک", "contact_person": "بهنام کیانی", "phone": "09121234567", "owner": "الهه فلاحی", "status": "proposal", "package": "طلایی (Gold)", "commission": "۲۵٪", "deal_value": "۴۰,۰۰۰,۰۰۰ تومان", "source": "پرسلاین داوطلبان", "priority": "بالا", "last_contact": "۱۴۰۵/۰۷/۱۵", "next_action": "جلسه آنلاین با صاحب امتیاز مجموعه", "notes": "ژانر کارآگاهی معمایی بدون ترس؛ پتانسیل بالای جذب رزروهای سازمانی و ایونت‌های شرکتی."}];
const STAGES = [{"id": "new", "title": "لید ورودی / شناسایی‌شده", "count": 22, "color": "#64748B"}, {"id": "contacted", "title": "تماس اولیه و ارزیابی", "count": 26, "color": "#0284C7"}, {"id": "proposal", "title": "ارسال پروپوزال و پکیج", "count": 34, "color": "#D97706"}, {"id": "negotiation", "title": "مذاکره کارمزد و شرایط", "count": 16, "color": "#9333EA"}, {"id": "contract", "title": "عقد قرارداد و آنبوردینگ", "count": 18, "color": "#16A34A"}, {"id": "active", "title": "فعال در پلتفرم (پایان فلو)", "count": 24, "color": "#059669"}, {"id": "lost", "title": "رد / انصراف / لغو", "count": 18, "color": "#E11D48"}];
let currentSortField = 'id';
let currentSortAsc = true;
// Render Kanban
function renderKanban() {
const board = document.getElementById('kanbanView');
board.innerHTML = '';
STAGES.forEach(stage => {
const col = document.createElement('div');
col.className = 'kanban-col';
const stageLeads = LEADS.filter(l => l.status === stage.id);
col.innerHTML = `
<div class="kanban-col-header">
<div class="kanban-col-title">
<span style="color: ${stage.color}">●</span>
<span>${stage.title}</span>
</div>
<span class="kanban-col-count">${stageLeads.length}</span>
</div>
<div class="kanban-cards-wrap" style="display: flex; flex-direction: column; gap: 10px;">
${stageLeads.map(lead => `
<div class="kanban-card" onclick="openDrawer('${lead.id}')">
<div class="card-header-flex">
<div>
<div class="card-room-name">${lead.room_name}</div>
<div class="card-complex-name">${lead.complex}</div>
</div>
<span class="priority-badge priority-${lead.priority}">${lead.priority}</span>
</div>
<div style="font-size: 11px; color: var(--text-muted); margin-top: 4px;">
📍 ${lead.city} (${lead.district})
</div>
<div style="font-size: 11px; color: var(--primary); font-weight: 700; margin-top: 4px;">
🎁 ${lead.package} (${lead.commission})
</div>
<div class="card-meta-row">
<span class="card-owner-badge">👤 ${lead.owner}</span>
<span>${lead.last_contact}</span>
</div>
</div>
`).join('')}
</div>
`;
board.appendChild(col);
});
}
// Render Table
function renderTable() {
const tbody = document.getElementById('tableBody');
const searchVal = document.getElementById('searchInput').value.trim().toLowerCase();
const stageVal = document.getElementById('stageFilter').value;
const ownerVal = document.getElementById('ownerFilter').value;
const priorityVal = document.getElementById('priorityFilter').value;
let filtered = LEADS.filter(item => {
const matchSearch = !searchVal ||
item.room_name.toLowerCase().includes(searchVal) ||
item.complex.toLowerCase().includes(searchVal) ||
item.contact_person.toLowerCase().includes(searchVal) ||
item.city.toLowerCase().includes(searchVal);
const matchStage = !stageVal || item.status === stageVal;
const matchOwner = !ownerVal || item.owner === ownerVal;
const matchPriority = !priorityVal || item.priority === priorityVal;
return matchSearch && matchStage && matchOwner && matchPriority;
});
filtered.sort((a, b) => {
let vA = a[currentSortField] || '';
let vB = b[currentSortField] || '';
if (typeof vA === 'string') {
return currentSortAsc ? vA.localeCompare(vB, 'fa') : vB.localeCompare(vA, 'fa');
}
return currentSortAsc ? vA - vB : vB - vA;
});
document.getElementById('recordCountLabel').textContent = `نمایش ${filtered.length} از ${LEADS.length} مجموعه`;
tbody.innerHTML = filtered.map(lead => {
const stageObj = STAGES.find(s => s.id === lead.status) || { title: lead.status };
return `
<tr onclick="openDrawer('${lead.id}')" style="cursor: pointer;">
<td style="font-weight: 700; color: var(--primary);">${lead.id}</td>
<td style="font-weight: 800;">${lead.room_name}</td>
<td>${lead.complex}</td>
<td>${lead.city} - ${lead.district}</td>
<td>${lead.contact_person} (${lead.phone})</td>
<td><span style="background: #F1F5F9; padding: 2px 8px; border-radius: 4px; font-weight: 600;">${lead.owner}</span></td>
<td><span class="status-pill status-${lead.status}">${stageObj.title}</span></td>
<td>${lead.package}</td>
<td><span class="priority-badge priority-${lead.priority}">${lead.priority}</span></td>
<td>${lead.last_contact}</td>
<td style="max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;" title="${lead.next_action}">${lead.next_action}</td>
</tr>
`;
}).join('');
}
function sortTable(field) {
if (currentSortField === field) {
currentSortAsc = !currentSortAsc;
} else {
currentSortField = field;
currentSortAsc = true;
}
renderTable();
}
function setView(view) {
if (view === 'kanban') {
document.getElementById('kanbanView').style.display = 'grid';
document.getElementById('tableView').style.display = 'none';
document.getElementById('btnKanban').classList.add('active');
document.getElementById('btnTable').classList.remove('active');
} else {
document.getElementById('kanbanView').style.display = 'none';
document.getElementById('tableView').style.display = 'block';
document.getElementById('btnKanban').classList.remove('active');
document.getElementById('btnTable').classList.add('active');
renderTable();
}
}
// Drawer Detail
function openDrawer(leadId) {
const lead = LEADS.find(l => l.id === leadId);
if (!lead) return;
const stageObj = STAGES.find(s => s.id === lead.status) || { title: lead.status };
const content = `
<div style="font-size: 11px; color: var(--primary); font-weight: 800;">شناسه پرونده CRM: ${lead.id}</div>
<h2 style="font-size: 20px; font-weight: 800; margin-top: 4px;">${lead.room_name}</h2>
<div style="font-size: 13px; color: var(--text-muted);">${lead.complex}</div>
<div style="margin-top: 14px;">
<span class="status-pill status-${lead.status}" style="font-size: 12px; padding: 4px 12px;">${stageObj.title}</span>
<span class="priority-badge priority-${lead.priority}" style="font-size: 12px; margin-right: 6px;">اولویت: ${lead.priority}</span>
</div>
<div class="drawer-section">
<div class="drawer-section-title">اطلاعات ارتباطی و لوکیشن</div>
<div class="drawer-field">
<span class="drawer-field-key">شخص رابط / مدیر:</span>
<span class="drawer-field-val">${lead.contact_person}</span>
</div>
<div class="drawer-field">
<span class="drawer-field-key">شماره تماس مستقیم:</span>
<span class="drawer-field-val" style="direction: ltr;">${lead.phone}</span>
</div>
<div class="drawer-field">
<span class="drawer-field-key">شهر و منطقه:</span>
<span class="drawer-field-val">${lead.city} (${lead.district})</span>
</div>
<div class="drawer-field">
<span class="drawer-field-key">کانال جذب ورودی:</span>
<span class="drawer-field-val">${lead.source}</span>
</div>
</div>
<div class="drawer-section">
<div class="drawer-section-title">جزئیات تجاری و مالی قرارداد</div>
<div class="drawer-field">
<span class="drawer-field-key">پکیج توافق‌شده:</span>
<span class="drawer-field-val" style="color: var(--primary);">${lead.package}</span>
</div>
<div class="drawer-field">
<span class="drawer-field-key">نرخ کارمزد کمیسیون:</span>
<span class="drawer-field-val">${lead.commission}</span>
</div>
<div class="drawer-field">
<span class="drawer-field-key">ارزش برآوردی ماهانه:</span>
<span class="drawer-field-val" style="color: var(--success);">${lead.deal_value}</span>
</div>
<div class="drawer-field">
<span class="drawer-field-key">مسئول پرونده در اکیپا:</span>
<span class="drawer-field-val">${lead.owner}</span>
</div>
</div>
<div class="drawer-section">
<div class="drawer-section-title">اقدام بعدی و پیگیری</div>
<div style="background: #EFF6FF; border: 1px solid #BFDBFE; border-radius: 8px; padding: 10px; font-weight: 700; color: #1E40AF; font-size: 12px;">
⚡ اقدام بعدی: ${lead.next_action}
</div>
<div style="font-size: 11px; color: var(--text-light); margin-top: 6px;">آخرین تماس ثبت‌شده: ${lead.last_contact}</div>
</div>
<div class="drawer-section">
<div class="drawer-section-title">یادداشت مذاکره و نیازمندی‌ها</div>
<div class="callout-box">
${lead.notes}
</div>
</div>
<div style="margin-top: 24px; display: flex; gap: 10px;">
<button class="btn-primary" style="flex: 1; justify-content: center;" onclick="alert('پیامک اختصاصی به شماره ' + '${lead.phone}' + ' ارسال شد.')">
💬 ارسال پیامک پنل / آفر
</button>
<button class="btn-secondary" style="flex: 1; justify-content: center;" onclick="alert('پرونده بروزرسانی شد.')">
✏️ ویرایش مرحله
</button>
</div>
`;
document.getElementById('drawerContent').innerHTML = content;
document.getElementById('drawerOverlay').style.display = 'block';
document.getElementById('drawer').classList.add('open');
}
function closeDrawer() {
document.getElementById('drawerOverlay').style.display = 'none';
document.getElementById('drawer').classList.remove('open');
}
// CSV Export
function exportLeadsCSV() {
let csv = '\uFEFF';
csv += 'کد,نام اتاق فرار,مجموعه,شهر,منطقه,مدیر,تلفن,مسئول اکیپا,مرحله,پکیج,کارمزد,ارزش قرارداد,اولویت,آخرین تماس,اقدام بعدی\n';
LEADS.forEach(l => {
csv += `"${l.id}","${l.room_name}","${l.complex}","${l.city}","${l.district}","${l.contact_person}","${l.phone}","${l.owner}","${l.status}","${l.package}","${l.commission}","${l.deal_value}","${l.priority}","${l.last_contact}","${l.next_action}"\n`;
});
const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'ekeepa_escape_rooms_crm_pipeline.csv';
a.click();
}
// Plotly Charts
window.onload = function() {
renderKanban();
// 1. Funnel Chart
const funnelData = [{
type: 'funnel',
y: ['لید ورودی', 'تماس اولیه', 'ارسال پروپوزال', 'مذاکره کارمزد', 'عقد قرارداد', 'فعال‌سازی نهایی'],
x: [128, 94, 68, 34, 42, 24],
textinfo: "value+percent initial",
marker: {
color: ["#64748B", "#0284C7", "#D97706", "#9333EA", "#16A34A", "#059669"]
}
}];
const funnelLayout = {
margin: { l: 120, r: 20, t: 10, b: 20 },
paper_bgcolor: 'rgba(0,0,0,0)',
plot_bgcolor: 'rgba(0,0,0,0)',
font: { family: 'Vazirmatn' }
};
Plotly.newPlot('funnelChart', funnelData, funnelLayout, { responsive: true, displayModeBar: false });
// 2. Source & Packages Pie/Bar
const sourceData = [{
values: [48, 32, 24, 14, 10],
labels: ['پرسلاین / فرم داوطلب', 'تماس مارکتینگ / تلفنی', 'معرفی سفیران اکیپا', 'حضوری / سفر میدانی', 'سایر'],
type: 'pie',
hole: 0.5,
marker: {
colors: ['#2563EB', '#0284C7', '#10B981', '#F59E0B', '#8B5CF6']
}
}];
const sourceLayout = {
margin: { l: 20, r: 20, t: 10, b: 20 },
paper_bgcolor: 'rgba(0,0,0,0)',
plot_bgcolor: 'rgba(0,0,0,0)',
font: { family: 'Vazirmatn' },
showlegend: true,
legend: { orientation: 'h', y: -0.1 }
};
Plotly.newPlot('sourceChart', sourceData, sourceLayout, { responsive: true, displayModeBar: false });
};
</script>
</body>
</html>