536 lines
46 KiB
Python
536 lines
46 KiB
Python
import re
|
||
import os
|
||
import shutil
|
||
|
||
src_file = '/workspace/personal/dashboards/marketing/index.html'
|
||
bak_file = '/workspace/personal/dashboards/marketing/index.html.bak'
|
||
|
||
if not os.path.exists(bak_file):
|
||
shutil.copyfile(src_file, bak_file)
|
||
print("Backup created at", bak_file)
|
||
|
||
with open(src_file, 'r', encoding='utf-8') as f:
|
||
html = f.read()
|
||
|
||
# 1. Update navbar-nav-list
|
||
nav_item_html = ''' <li class="navbar-nav-item active" id="navItemMarketingOps">
|
||
<a onclick="switchMainTab('marketing_ops', this)">
|
||
<svg style="width: 17px; height: 17px;" viewBox="0 0 24 24"><path fill="currentColor" d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-7 14l-5-5 1.41-1.41L12 14.17l7.59-7.59L21 8l-9 9z"/></svg>
|
||
<span style="font-weight: 800;">تسکهای مارکتینگ</span>
|
||
<span id="badgeTaskCount" style="background: var(--primary); color: #fff; font-size: 0.65rem; padding: 1px 6px; border-radius: 10px; margin-right: 4px; font-weight: 800;">۲۷ تسک</span>
|
||
</a>
|
||
</li>
|
||
'''
|
||
|
||
if 'id="navItemMarketingOps"' not in html:
|
||
# replace navItemChannels active state
|
||
html = html.replace('<li class="navbar-nav-item active" id="navItemChannels">', '<li class="navbar-nav-item" id="navItemChannels">')
|
||
# insert before navItemChannels
|
||
html = html.replace('<li class="navbar-nav-item" id="navItemChannels">', nav_item_html + ' <li class="navbar-nav-item" id="navItemChannels">')
|
||
print("Nav item inserted")
|
||
|
||
# 2. Update top-mode-switcher
|
||
top_btn_html = ''' <button id="topModeBtnMarketingOps" onclick="switchMainTab('marketing_ops', this)" class="date-btn active" style="display: flex; align-items: center; gap: 6px; padding: 6px 14px; font-weight: 800; background: var(--primary); color: #fff;">
|
||
<svg style="width: 14px; height: 14px;" viewBox="0 0 24 24"><path fill="currentColor" d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-7 14l-5-5 1.41-1.41L12 14.17l7.59-7.59L21 8l-9 9z"/></svg>
|
||
<span>تسکها و عملیات مارکتینگ</span>
|
||
</button>
|
||
'''
|
||
|
||
if 'id="topModeBtnMarketingOps"' not in html:
|
||
html = html.replace('id="topModeBtnChannels" onclick="switchMainTab(\'channels\', this)" class="date-btn active"', 'id="topModeBtnChannels" onclick="switchMainTab(\'channels\', this)" class="date-btn"')
|
||
html = html.replace('<button id="topModeBtnChannels"', top_btn_html + ' <button id="topModeBtnChannels"')
|
||
print("Top mode button inserted")
|
||
|
||
# 3. Add tabPaneMarketingOps HTML content
|
||
marketing_ops_section = ''' <!-- ================= TAB 0: اتاق فرمان تسکهای مارکتینگ ================= -->
|
||
<section id="tabPaneMarketingOps" class="main-tab-pane" style="display: block;">
|
||
<!-- Executive Header Bar -->
|
||
<div style="background: linear-gradient(135deg, #0F172A 0%, #1E1B4B 50%, #4C1D95 100%); color: #fff; border-radius: 16px; padding: 24px; margin-bottom: 24px; box-shadow: 0 10px 25px -5px rgba(76, 29, 149, 0.25); position: relative; overflow: hidden;">
|
||
<div style="position: absolute; left: -40px; top: -40px; width: 180px; height: 180px; background: radial-gradient(circle, rgba(124, 58, 237, 0.3) 0%, transparent 70%); pointer-events: none;"></div>
|
||
<div style="display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px; position: relative; z-index: 2;">
|
||
<div>
|
||
<div style="display: flex; align-items: center; gap: 10px; margin-bottom: 6px;">
|
||
<span style="background: rgba(124, 58, 237, 0.4); border: 1px solid rgba(167, 139, 250, 0.4); color: #E9D5FF; font-size: 0.75rem; font-weight: 800; padding: 3px 10px; border-radius: 20px;">پایپلاین اجرایی مارکتینگ</span>
|
||
<span style="background: rgba(16, 185, 129, 0.2); border: 1px solid rgba(16, 185, 129, 0.4); color: #6EE7B7; font-size: 0.72rem; font-weight: 700; padding: 3px 8px; border-radius: 20px; display: inline-flex; align-items: center; gap: 4px;">
|
||
<span style="width: 6px; height: 6px; border-radius: 50%; background: #10B981;"></span>
|
||
همگامسازی زنده
|
||
</span>
|
||
</div>
|
||
<h1 style="font-size: 1.5rem; font-weight: 900; margin: 0 0 6px 0; color: #FFFFFF;">اتاق فرمان و تسکهای عملیاتی مارکتینگ اکیپا</h1>
|
||
<div style="font-size: 0.85rem; color: #CBD5E1; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;">
|
||
<span style="color: #F8FAFC; font-weight: 700; background: rgba(255,255,255,0.08); padding: 2px 8px; border-radius: 6px;">امضای مدیریت: الهه فلاحی (Marketing & Operations Lead)</span>
|
||
<span>•</span>
|
||
<span>تمرکز: گوگلادز، سئو، پیامک و CRM، پارتنرشیپ اسنپپی، بستههای B2B</span>
|
||
</div>
|
||
</div>
|
||
<div style="display: flex; align-items: center; gap: 10px;">
|
||
<button onclick="openAddTaskModal()" style="background: #7C3AED; hover: background: #6D28D9; color: #fff; border: none; padding: 10px 18px; border-radius: 10px; font-weight: 800; font-size: 0.85rem; cursor: pointer; display: flex; align-items: center; gap: 6px; box-shadow: 0 4px 12px rgba(124, 58, 237, 0.4); transition: all 0.2s;">
|
||
<svg style="width: 16px; height: 16px;" viewBox="0 0 24 24"><path fill="currentColor" d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/></svg>
|
||
<span>افزودن تسک جدید</span>
|
||
</button>
|
||
<button onclick="resetMarketingTasksToDefault()" title="بازگردانی تسکهای پیشفرض" style="background: rgba(255,255,255,0.1); color: #E2E8F0; border: 1px solid rgba(255,255,255,0.2); padding: 10px 12px; border-radius: 10px; font-weight: 700; font-size: 0.85rem; cursor: pointer;">
|
||
<svg style="width: 16px; height: 16px;" viewBox="0 0 24 24"><path fill="currentColor" d="M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"/></svg>
|
||
</button>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Marketing Key Metrics Ribbon -->
|
||
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-top: 20px; padding-top: 18px; border-top: 1px solid rgba(255,255,255,0.12);">
|
||
<div style="background: rgba(255,255,255,0.06); padding: 12px 14px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.08);">
|
||
<div style="font-size: 0.72rem; color: #94A3B8; margin-bottom: 4px;">گوگل ادز (Google Ads)</div>
|
||
<div style="font-size: 1.15rem; font-weight: 900; color: #FFFFFF;">۱۰ کمپین فعال <span style="font-size: 0.8rem; color: #38BDF8;">(۳۹ اد)</span></div>
|
||
<div style="font-size: 0.7rem; color: #CBD5E1; margin-top: 2px;">تارگت CPA: <b style="color: #6EE7B7;">۳.۸۸ AED</b> (~۶۶هزار ت)</div>
|
||
</div>
|
||
<div style="background: rgba(255,255,255,0.06); padding: 12px 14px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.08);">
|
||
<div style="font-size: 0.72rem; color: #94A3B8; margin-bottom: 4px;">سئو و لندینگها (SEO)</div>
|
||
<div style="font-size: 1.15rem; font-weight: 900; color: #FFFFFF;">۱۹۶ سئوباکس ادمین</div>
|
||
<div style="font-size: 0.7rem; color: #CBD5E1; margin-top: 2px;">اتوماسیون متادیتا PDP با <b style="color: #FBBF24;">n8n</b></div>
|
||
</div>
|
||
<div style="background: rgba(255,255,255,0.06); padding: 12px 14px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.08);">
|
||
<div style="font-size: 0.72rem; color: #94A3B8; margin-bottom: 4px;">ریتنشن و پیامک (CRM)</div>
|
||
<div style="font-size: 1.15rem; font-weight: 900; color: #FFFFFF;">پلتفرم دوباره + کاوهنگار</div>
|
||
<div style="font-size: 0.7rem; color: #CBD5E1; margin-top: 2px;">کمپین فیلیمو + ترکینگ تمیز <b style="color: #A78BFA;">Shlink</b></div>
|
||
</div>
|
||
<div style="background: rgba(255,255,255,0.06); padding: 12px 14px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.08);">
|
||
<div style="font-size: 0.72rem; color: #94A3B8; margin-bottom: 4px;">پارتنرشیپ و اسنپپی (BNPL)</div>
|
||
<div style="font-size: 1.15rem; font-weight: 900; color: #FFFFFF;">اقساط ۴ ماهه اسنپپی</div>
|
||
<div style="font-size: 0.7rem; color: #CBD5E1; margin-top: 2px;">کیدزی، اوانو + کارمزد بستهها <b style="color: #34D399;">۲۵٪</b></div>
|
||
</div>
|
||
<div style="background: rgba(255,255,255,0.06); padding: 12px 14px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.08);">
|
||
<div style="font-size: 0.72rem; color: #94A3B8; margin-bottom: 4px;">پیشرفت تسکهای مهر</div>
|
||
<div style="font-size: 1.15rem; font-weight: 900; color: #FFFFFF;" id="statProgressText">۰٪ تکمیل</div>
|
||
<div style="width: 100%; height: 5px; background: rgba(255,255,255,0.15); border-radius: 10px; margin-top: 6px; overflow: hidden;">
|
||
<div id="statProgressBar" style="width: 0%; height: 100%; background: #10B981; transition: width 0.3s;"></div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Task Filters and Navigation -->
|
||
<div style="background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 14px; padding: 16px; margin-bottom: 20px; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 14px;">
|
||
<!-- Category Pills -->
|
||
<div style="display: flex; flex-wrap: wrap; gap: 8px;" id="taskCategoryFilters">
|
||
<button class="task-cat-filter active" onclick="setTaskCategoryFilter('all', this)" style="padding: 7px 14px; border-radius: 8px; border: 1px solid var(--primary); background: var(--primary); color: #fff; font-size: 0.8rem; font-weight: 800; cursor: pointer;">
|
||
🎯 همه تسکها (<span id="catCountAll">۲۷</span>)
|
||
</button>
|
||
<button class="task-cat-filter" onclick="setTaskCategoryFilter('gads', this)" style="padding: 7px 14px; border-radius: 8px; border: 1px solid var(--border-color); background: var(--bg-card); color: var(--text-main); font-size: 0.8rem; font-weight: 700; cursor: pointer;">
|
||
🚀 گوگل ادز (<span id="catCountGads">۶</span>)
|
||
</button>
|
||
<button class="task-cat-filter" onclick="setTaskCategoryFilter('seo', this)" style="padding: 7px 14px; border-radius: 8px; border: 1px solid var(--border-color); background: var(--bg-card); color: var(--text-main); font-size: 0.8rem; font-weight: 700; cursor: pointer;">
|
||
🔍 سئو و لندینگها (<span id="catCountSeo">۵</span>)
|
||
</button>
|
||
<button class="task-cat-filter" onclick="setTaskCategoryFilter('crm', this)" style="padding: 7px 14px; border-radius: 8px; border: 1px solid var(--border-color); background: var(--bg-card); color: var(--text-main); font-size: 0.8rem; font-weight: 700; cursor: pointer;">
|
||
💬 ریتنشن و پیامک (<span id="catCountCrm">۵</span>)
|
||
</button>
|
||
<button class="task-cat-filter" onclick="setTaskCategoryFilter('partners', this)" style="padding: 7px 14px; border-radius: 8px; border: 1px solid var(--border-color); background: var(--bg-card); color: var(--text-main); font-size: 0.8rem; font-weight: 700; cursor: pointer;">
|
||
🤝 پارتنرشیپ و اسنپپی (<span id="catCountPartners">۴</span>)
|
||
</button>
|
||
<button class="task-cat-filter" onclick="setTaskCategoryFilter('b2b', this)" style="padding: 7px 14px; border-radius: 8px; border: 1px solid var(--border-color); background: var(--bg-card); color: var(--text-main); font-size: 0.8rem; font-weight: 700; cursor: pointer;">
|
||
🏢 بستههای مجموعهداران (<span id="catCountB2b">۳</span>)
|
||
</button>
|
||
<button class="task-cat-filter" onclick="setTaskCategoryFilter('bi', this)" style="padding: 7px 14px; border-radius: 8px; border: 1px solid var(--border-color); background: var(--bg-card); color: var(--text-main); font-size: 0.8rem; font-weight: 700; cursor: pointer;">
|
||
📊 هوش تجاری و بودجه (<span id="catCountBi">۴</span>)
|
||
</button>
|
||
</div>
|
||
|
||
<!-- Status Filter Pills -->
|
||
<div style="display: flex; align-items: center; gap: 8px;">
|
||
<span style="font-size: 0.75rem; color: var(--text-muted); font-weight: 700;">وضعیت:</span>
|
||
<select id="taskStatusSelect" onchange="filterMarketingTasks()" style="padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border-color); background: var(--bg-card); color: var(--text-main); font-size: 0.8rem; font-weight: 700; font-family: inherit;">
|
||
<option value="all">همه وضعیتها</option>
|
||
<option value="in_progress">در حال انجام (In Progress)</option>
|
||
<option value="done">انجام شده (Done)</option>
|
||
<option value="urgent">نیازمند اقدام فوری</option>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Task Cards Grid/List Container -->
|
||
<div id="marketingTasksContainer" style="display: flex; flex-direction: column; gap: 12px; margin-bottom: 40px;">
|
||
<!-- Tasks will be dynamically rendered here -->
|
||
</div>
|
||
</section>
|
||
|
||
<!-- Task Add Modal -->
|
||
<div id="addTaskModal" style="display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, 0.6); backdrop-filter: blur(4px); z-index: 9999; align-items: center; justify-content: center; padding: 20px;">
|
||
<div style="background: #fff; border-radius: 16px; width: 100%; max-width: 520px; box-shadow: 0 20px 25px -5px rgba(0,0,0,0.2); overflow: hidden; font-family: inherit;">
|
||
<div style="background: #1E1B4B; color: #fff; padding: 18px 24px; display: flex; justify-content: space-between; align-items: center;">
|
||
<div style="font-weight: 900; font-size: 1.1rem;">افزودن تسک جدید مارکتینگ</div>
|
||
<button onclick="closeAddTaskModal()" style="background: transparent; border: none; color: #CBD5E1; font-size: 1.3rem; cursor: pointer;">✕</button>
|
||
</div>
|
||
<div style="padding: 24px; display: flex; flex-direction: column; gap: 16px;">
|
||
<div>
|
||
<label style="display: block; font-size: 0.8rem; font-weight: 800; color: #334155; margin-bottom: 6px;">عنوان و شرح تسک *</label>
|
||
<input type="text" id="modalTaskTitle" placeholder="مثال: بهینهسازی کلمات منفی کمپین شیراز" style="width: 100%; box-sizing: border-box; padding: 10px 12px; border-radius: 8px; border: 1px solid #CBD5E1; font-family: inherit; font-size: 0.85rem;" />
|
||
</div>
|
||
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 12px;">
|
||
<div>
|
||
<label style="display: block; font-size: 0.8rem; font-weight: 800; color: #334155; margin-bottom: 6px;">دستهبندی مارکتینگ</label>
|
||
<select id="modalTaskCat" style="width: 100%; box-sizing: border-box; padding: 10px 12px; border-radius: 8px; border: 1px solid #CBD5E1; font-family: inherit; font-size: 0.85rem;">
|
||
<option value="gads">گوگل ادز (Google Ads)</option>
|
||
<option value="seo">سئو و لندینگها (SEO)</option>
|
||
<option value="crm">ریتنشن و پیامک (CRM)</option>
|
||
<option value="partners">پارتنرشیپ و اسنپپی</option>
|
||
<option value="b2b">بستههای مجموعهداران B2B</option>
|
||
<option value="bi">هوش تجاری و بودجه</option>
|
||
</select>
|
||
</div>
|
||
<div>
|
||
<label style="display: block; font-size: 0.8rem; font-weight: 800; color: #334155; margin-bottom: 6px;">اولویت</label>
|
||
<select id="modalTaskPriority" style="width: 100%; box-sizing: border-box; padding: 10px 12px; border-radius: 8px; border: 1px solid #CBD5E1; font-family: inherit; font-size: 0.85rem;">
|
||
<option value="high">حیاتی و فوری (High)</option>
|
||
<option value="medium">متوسط (Medium)</option>
|
||
<option value="routine">دورهای / روتین</option>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 12px;">
|
||
<div>
|
||
<label style="display: block; font-size: 0.8rem; font-weight: 800; color: #334155; margin-bottom: 6px;">شاخص کلیدی متصل (KPI)</label>
|
||
<input type="text" id="modalTaskMetric" placeholder="مثال: تارگت CPA یا نرخ تبدیل" style="width: 100%; box-sizing: border-box; padding: 10px 12px; border-radius: 8px; border: 1px solid #CBD5E1; font-family: inherit; font-size: 0.85rem;" />
|
||
</div>
|
||
<div>
|
||
<label style="display: block; font-size: 0.8rem; font-weight: 800; color: #334155; margin-bottom: 6px;">موعد اجرا</label>
|
||
<input type="text" id="modalTaskDeadline" placeholder="مثال: مهر ۱۴۰۵ / روزانه" style="width: 100%; box-sizing: border-box; padding: 10px 12px; border-radius: 8px; border: 1px solid #CBD5E1; font-family: inherit; font-size: 0.85rem;" />
|
||
</div>
|
||
</div>
|
||
<div style="display: flex; justify-content: flex-end; gap: 10px; margin-top: 10px;">
|
||
<button onclick="closeAddTaskModal()" style="padding: 10px 18px; border-radius: 8px; border: 1px solid #CBD5E1; background: #F1F5F9; color: #475569; font-weight: 700; cursor: pointer; font-family: inherit;">انصراف</button>
|
||
<button onclick="saveNewMarketingTask()" style="padding: 10px 20px; border-radius: 8px; border: none; background: #7C3AED; color: #fff; font-weight: 800; cursor: pointer; font-family: inherit;">ثبت تسک</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
'''
|
||
|
||
if 'id="tabPaneMarketingOps"' not in html:
|
||
# Hide tabPaneChannels by default so marketing_ops is shown
|
||
html = html.replace('<section id="tabPaneChannels" class="main-tab-pane">', '<section id="tabPaneChannels" class="main-tab-pane" style="display: none;">')
|
||
# Insert marketing_ops_section before tabPaneChannels
|
||
html = html.replace('<section id="tabPaneChannels"', marketing_ops_section + '\n <section id="tabPaneChannels"')
|
||
print("tabPaneMarketingOps section inserted")
|
||
|
||
# 4. JavaScript implementation for Marketing Tasks
|
||
js_code = '''
|
||
/* ================= MARKETING TASKS OPERATIONS LOGIC ================= */
|
||
const DEFAULT_MARKETING_TASKS = [
|
||
// گوگل ادز
|
||
{ id: 'task-gads-1', title: 'پایش و کالیبراسیون تارگت CPA ده کمپین فعال سرچ (تهران، کرج، مشهد، اصفهان، شیراز و...)', cat: 'gads', catName: 'گوگل ادز', priority: 'high', priorityName: 'حیاتی', metric: 'سقف تارگت CPA: ۳.۸۸ درهم (۶۶هزار ت)', deadline: 'روزانه / مهر ۱۴۰۵', status: 'in_progress', assignee: 'الهه فلاحی' },
|
||
{ id: 'task-gads-2', title: 'کنترل هزینهکرد روزانه اکانت و مانیتورینگ عدم جهش ناگهانی هزینه هر تبدیل', cat: 'gads', catName: 'گوگل ادز', priority: 'high', priorityName: 'حیاتی', metric: 'میانگین هزینه تبدیل پایدار', deadline: 'روزانه', status: 'done', assignee: 'الهه فلاحی' },
|
||
{ id: 'task-gads-3', title: 'پاز نگهداشتن کلمات کلیدی Broad پرهزینه و نامرتبط (بهویژه عبارات EscapeZoom)', cat: 'gads', catName: 'گوگل ادز', priority: 'high', priorityName: 'حیاتی', metric: 'کاهش نرخ پرش کلیکها', deadline: 'هفتگی', status: 'done', assignee: 'الهه فلاحی' },
|
||
{ id: 'task-gads-4', title: 'پایش و بهروزرسانی لیست Negative Keywords (فیلتر کلمات انجیل، دانلود و بازیهای ناموجود)', cat: 'gads', catName: 'گوگل ادز', priority: 'medium', priorityName: 'مهم', metric: 'صرفهجویی بودجه کلیکی', deadline: 'هفتگی', status: 'done', assignee: 'الهه فلاحی' },
|
||
{ id: 'task-gads-5', title: 'هماهنگی شارژ ارزی درهمی و تسویهحساب با آژانس همکار (آفراک / راتین)', cat: 'gads', catName: 'گوگل ادز', priority: 'high', priorityName: 'حیاتی', metric: 'مانده مثبت شارژ تبلیغات', deadline: 'دورهای / هفتگی', status: 'in_progress', assignee: 'الهه فلاحی' },
|
||
{ id: 'task-gads-6', title: 'تنظیم و تست ۴ سایتلینک اختصاصی به ازای هر لندینگ شهری (تخفیف، رزرو، نظرات، قوانین)', cat: 'gads', catName: 'گوگل ادز', priority: 'medium', priorityName: 'مهم', metric: 'افزایش CTR ادز', deadline: 'مهر ۱۴۰۵', status: 'done', assignee: 'الهه فلاحی' },
|
||
|
||
// سئو و لندینگها
|
||
{ id: 'task-seo-1', title: 'ممیزی و تکمیل ۱۹۶ سئوباکس در پنل ادمین اکیپا برای تمام لندینگهای شهری و ژانرها', cat: 'seo', catName: 'سئو و لندینگ', priority: 'high', priorityName: 'حیاتی', metric: 'پوشش ۱۰۰٪ اسکیما و سئوباکسها', deadline: 'مهر ۱۴۰۵', status: 'in_progress', assignee: 'الهه فلاحی' },
|
||
{ id: 'task-seo-2', title: 'نظارت بر وبهوک و پایپلاین اتوماسیون متاتایتل و توضیحات صفحات بازیها (PDP) با n8n', cat: 'seo', catName: 'سئو و لندینگ', priority: 'medium', priorityName: 'مهم', metric: 'تولید خودکار متادیتا', deadline: 'مداوم', status: 'done', assignee: 'الهه فلاحی' },
|
||
{ id: 'task-seo-3', title: 'مانیتورینگ رتبه کلمات کلیدی کلان در سرچ کنسول («اتاق فرار»، «اسکیپ روم»، «سینما ترس»)', cat: 'seo', catName: 'سئو و لندینگ', priority: 'high', priorityName: 'حیاتی', metric: 'حفظ رتبه ۱ تا ۳ گوگل', deadline: 'روزانه', status: 'in_progress', assignee: 'الهه فلاحی' },
|
||
{ id: 'task-seo-4', title: 'اجرای پلن انتشار رپورتاژهای فصلی طبق برنامه و تست اعتبار بکلینکها (آژانس راتین)', cat: 'seo', catName: 'سئو و لندینگ', priority: 'medium', priorityName: 'مهم', metric: 'افزایش دامین اتوریتی', deadline: 'پاییز ۱۴۰۵', status: 'in_progress', assignee: 'الهه فلاحی' },
|
||
{ id: 'task-seo-5', title: 'بهینهسازی لندینگ کمپین رویدادها (/campaign/event) و لندینگهای مناسبتی مدارس', cat: 'seo', catName: 'سئو و لندینگ', priority: 'medium', priorityName: 'مهم', metric: 'نرخ تبدیل لندینگ > ۴.۵٪', deadline: 'مهر ۱۴۰۵', status: 'done', assignee: 'الهه فلاحی' },
|
||
|
||
// ریتنشن، پیامک و CRM
|
||
{ id: 'task-crm-1', title: 'طراحی، سگمنتیشن و ارسال کمپینهای پیامک از پنل کاوهنگار (فاز ۱ و ۲ فیلیمو مدرسه و زوم)', cat: 'crm', catName: 'ریتنشن و CRM', priority: 'high', priorityName: 'حیاتی', metric: 'نرخ بازگشایی و خرید پیامکی', deadline: 'مهر ۱۴۰۵', status: 'done', assignee: 'الهه فلاحی' },
|
||
{ id: 'task-crm-2', title: 'طراحی و فعالسازی سناریوهای بازگشت خودکار مشتریان بر اساس سبدهای رهاشده در پلتفرم دوباره', cat: 'crm', catName: 'ریتنشن و CRM', priority: 'high', priorityName: 'حیاتی', metric: 'بازیابی ۱۵٪ سبدهای خرید رهاشده', deadline: 'پاییز ۱۴۰۵', status: 'in_progress', assignee: 'الهه فلاحی' },
|
||
{ id: 'task-crm-3', title: 'ردیابی کلیکهای تمیز و فیلتر کردن هیتهای بات با شورتلینک اختصاصی Shlink (l.ekpa.ir)', cat: 'crm', catName: 'ریتنشن و CRM', priority: 'medium', priorityName: 'مهم', metric: 'دقت ۱۰۰٪ آنالیتیکس کلیک', deadline: 'مداوم', status: 'done', assignee: 'الهه فلاحی' },
|
||
{ id: 'task-crm-4', title: 'تعریف کوپنهای تخفیف مناسبتی و پایش روزانه نرخ بازخرید (Redemption Rate)', cat: 'crm', catName: 'ریتنشن و CRM', priority: 'medium', priorityName: 'مهم', metric: 'کنترل مارجین سود تخفیفها', deadline: 'هفتگی', status: 'in_progress', assignee: 'الهه فلاحی' },
|
||
{ id: 'task-crm-5', title: 'بررسی اعتبار باقیمانده پنل کاوهنگار و ثبت درخواست شارژ به موقع قبل از اتمام سقف', cat: 'crm', catName: 'ریتنشن و CRM', priority: 'high', priorityName: 'حیاتی', metric: 'مانده اعتبار همیشه > ۵ میلیون ت', deadline: 'هفتگی', status: 'done', assignee: 'الهه فلاحی' },
|
||
|
||
// پارتنرشیپها و اسنپپی
|
||
{ id: 'task-partners-1', title: 'هماهنگی و مانیتورینگ بنرها و اسلایدرهای اختصاصی خرید اقساطی ۴ ماهه اسنپپی (SnappPay)', cat: 'partners', catName: 'پارتنرشیپ و فینتک', priority: 'high', priorityName: 'حیاتی', metric: 'سهم بلیتهای BNPL از کل رزروها', deadline: 'روزانه / مهر ۱۴۰۵', status: 'in_progress', assignee: 'الهه فلاحی' },
|
||
{ id: 'task-partners-2', title: 'پیگیری تعامل و کمپینهای مشترک تخفیفی با پلتفرمهای کیدزی (Kidzy) و اوانو (Evano)', cat: 'partners', catName: 'پارتنرشیپ و فینتک', priority: 'medium', priorityName: 'مهم', metric: 'جذب کاربران تفریحات خانوادگی', deadline: 'پاییز ۱۴۰۵', status: 'in_progress', assignee: 'الهه فلاحی' },
|
||
{ id: 'task-partners-3', title: 'پایش و بهروزرسانی کدهای تخفیف باشگاه مشتریان تپسی کلاب و فیلیمو', cat: 'partners', catName: 'پارتنرشیپ و فینتک', priority: 'medium', priorityName: 'مهم', metric: 'افزایش سهم ورودی باشگاه مشتریان', deadline: 'هفتگی', status: 'done', assignee: 'الهه فلاحی' },
|
||
{ id: 'task-partners-4', title: 'آنالیز هفتگی ترافیک ورودی، نرخ تبدیل و سهم فروش هر پارتنر افیلیت', cat: 'partners', catName: 'پارتنرشیپ و فینتک', priority: 'medium', priorityName: 'مهم', metric: 'محاسبه سهم سودآوری پارتنرها', deadline: 'هفتگی', status: 'in_progress', assignee: 'الهه فلاحی' },
|
||
|
||
// بستههای مجموعهداران B2B
|
||
{ id: 'task-b2b-1', title: 'پروموشن و فروش بستههای ارتقای فروش با کارمزد ویژه ۲۵٪ در کانال تلگرام مجموعهداران', cat: 'b2b', catName: 'بستههای B2B', priority: 'high', priorityName: 'حیاتی', metric: 'فروش بستههای تقویت رزرو B2B', deadline: 'مهر ۱۴۰۵', status: 'in_progress', assignee: 'الهه فلاحی' },
|
||
{ id: 'task-b2b-2', title: 'اختصاص تگ و اسلایدر ویژه سایت برای بازیهای شاخص پارتنر (آبادی، دارک وب، پازوزو، ایکس)', cat: 'b2b', catName: 'بستههای B2B', priority: 'medium', priorityName: 'مهم', metric: 'افزایش ۳۰٪ رزرو بازیهای منتخب', deadline: 'مهر ۱۴۰۵', status: 'done', assignee: 'الهه فلاحی' },
|
||
{ id: 'task-b2b-3', title: 'ارزیابی اثربخشی تبلیغات بستهها و تهیه گزارش بازدهی برای مالکان مجموعههای برتر', cat: 'b2b', catName: 'بستههای B2B', priority: 'medium', priorityName: 'مهم', metric: 'ریتنشن مجموعهداران پارتنر', deadline: 'پایان هر ماه', status: 'in_progress', assignee: 'الهه فلاحی' },
|
||
|
||
// هوش تجاری و بودجه
|
||
{ id: 'task-bi-1', title: 'پایش روزانه تلهمتری مایکروسافت کلاریتی (Dead clicks، اسکرول و ریزشهای فانل رزرو)', cat: 'bi', catName: 'هوش تجاری و بودجه', priority: 'high', priorityName: 'حیاتی', metric: 'شناسایی و رفع نقاط اصطکاک خرید', deadline: 'روزانه', status: 'in_progress', assignee: 'الهه فلاحی' },
|
||
{ id: 'task-bi-2', title: 'محاسبه و تطبیق Blended CAC ماهانه، Blended ROAS و نسبت LTV به CAC', cat: 'bi', catName: 'هوش تجاری و بودجه', priority: 'high', priorityName: 'حیاتی', metric: 'حفظ سلامت اقتصادی کانالها', deadline: 'هفتگی', status: 'in_progress', assignee: 'الهه فلاحی' },
|
||
{ id: 'task-bi-3', title: 'تطبیق روزانه گزارشهای فروش متابیس با درگاهها و ردیابی کنسلیهای رزرو', cat: 'bi', catName: 'هوش تجاری و بودجه', priority: 'medium', priorityName: 'مهم', metric: 'دقت مالی گزارشهای اجرایی', deadline: 'روزانه', status: 'done', assignee: 'الهه فلاحی' },
|
||
{ id: 'task-bi-4', title: 'ثبت و مانیتورینگ موجودی شارژ حسابهای تبلیغاتی (درهمی و ریالی) در دفتر کل', cat: 'bi', catName: 'هوش تجاری و بودجه', priority: 'high', priorityName: 'حیاتی', metric: 'جلوگیری از توقف تبلیغات', deadline: 'روزانه', status: 'done', assignee: 'الهه فلاحی' }
|
||
];
|
||
|
||
let currentTaskCategory = 'all';
|
||
let currentTaskStatus = 'all';
|
||
|
||
function getStoredMarketingTasks() {
|
||
try {
|
||
const stored = localStorage.getItem('ekeepa_marketing_tasks_v1');
|
||
if (stored) {
|
||
const parsed = JSON.parse(stored);
|
||
if (Array.isArray(parsed) && parsed.length > 0) return parsed;
|
||
}
|
||
} catch(e) {}
|
||
return DEFAULT_MARKETING_TASKS;
|
||
}
|
||
|
||
function saveMarketingTasksToStorage(tasks) {
|
||
try {
|
||
localStorage.setItem('ekeepa_marketing_tasks_v1', JSON.stringify(tasks));
|
||
} catch(e) {}
|
||
}
|
||
|
||
function setTaskCategoryFilter(cat, btn) {
|
||
currentTaskCategory = cat;
|
||
document.querySelectorAll('#taskCategoryFilters button').forEach(b => {
|
||
b.style.background = 'var(--bg-card)';
|
||
b.style.color = 'var(--text-main)';
|
||
b.style.borderColor = 'var(--border-color)';
|
||
b.classList.remove('active');
|
||
});
|
||
if (btn) {
|
||
btn.style.background = 'var(--primary)';
|
||
btn.style.color = '#fff';
|
||
btn.style.borderColor = 'var(--primary)';
|
||
btn.classList.add('active');
|
||
}
|
||
renderMarketingTasks();
|
||
}
|
||
|
||
function filterMarketingTasks() {
|
||
const select = document.getElementById('taskStatusSelect');
|
||
if (select) currentTaskStatus = select.value;
|
||
renderMarketingTasks();
|
||
}
|
||
|
||
function toggleTaskStatus(taskId) {
|
||
const tasks = getStoredMarketingTasks();
|
||
const task = tasks.find(t => t.id === taskId);
|
||
if (task) {
|
||
task.status = (task.status === 'done') ? 'in_progress' : 'done';
|
||
saveMarketingTasksToStorage(tasks);
|
||
renderMarketingTasks();
|
||
}
|
||
}
|
||
|
||
function openAddTaskModal() {
|
||
const m = document.getElementById('addTaskModal');
|
||
if (m) m.style.display = 'flex';
|
||
}
|
||
|
||
function closeAddTaskModal() {
|
||
const m = document.getElementById('addTaskModal');
|
||
if (m) m.style.display = 'none';
|
||
}
|
||
|
||
function saveNewMarketingTask() {
|
||
const titleInput = document.getElementById('modalTaskTitle');
|
||
const catSelect = document.getElementById('modalTaskCat');
|
||
const prioSelect = document.getElementById('modalTaskPriority');
|
||
const metricInput = document.getElementById('modalTaskMetric');
|
||
const deadlineInput = document.getElementById('modalTaskDeadline');
|
||
|
||
if (!titleInput || !titleInput.value.trim()) {
|
||
alert('لطفاً عنوان تسک را وارد نمایید.');
|
||
return;
|
||
}
|
||
|
||
const catMap = {
|
||
gads: 'گوگل ادز',
|
||
seo: 'سئو و لندینگ',
|
||
crm: 'ریتنشن و CRM',
|
||
partners: 'پارتنرشیپ و فینتک',
|
||
b2b: 'بستههای B2B',
|
||
bi: 'هوش تجاری و بودجه'
|
||
};
|
||
|
||
const prioMap = {
|
||
high: 'حیاتی',
|
||
medium: 'مهم',
|
||
routine: 'دورهای'
|
||
};
|
||
|
||
const newTask = {
|
||
id: 'task-custom-' + Date.now(),
|
||
title: titleInput.value.trim(),
|
||
cat: catSelect.value,
|
||
catName: catMap[catSelect.value] || 'مارکتینگ',
|
||
priority: prioSelect.value,
|
||
priorityName: prioMap[prioSelect.value] || 'مهم',
|
||
metric: metricInput.value.trim() || 'شاخص تعریفشده مارکتینگ',
|
||
deadline: deadlineInput.value.trim() || 'پاییز ۱۴۰۵',
|
||
status: 'in_progress',
|
||
assignee: 'الهه فلاحی'
|
||
};
|
||
|
||
const tasks = getStoredMarketingTasks();
|
||
tasks.unshift(newTask);
|
||
saveMarketingTasksToStorage(tasks);
|
||
|
||
titleInput.value = '';
|
||
metricInput.value = '';
|
||
deadlineInput.value = '';
|
||
closeAddTaskModal();
|
||
renderMarketingTasks();
|
||
}
|
||
|
||
function resetMarketingTasksToDefault() {
|
||
if (confirm('آیا مایل به بازگردانی فهرست پیشفرض ۲۷ تسک مارکتینگ هستید؟')) {
|
||
localStorage.removeItem('ekeepa_marketing_tasks_v1');
|
||
renderMarketingTasks();
|
||
}
|
||
}
|
||
|
||
function renderMarketingTasks() {
|
||
const container = document.getElementById('marketingTasksContainer');
|
||
if (!container) return;
|
||
|
||
const tasks = getStoredMarketingTasks();
|
||
|
||
// Counts update
|
||
const totalCount = tasks.length;
|
||
const doneCount = tasks.filter(t => t.status === 'done').length;
|
||
const percent = totalCount > 0 ? Math.round((doneCount / totalCount) * 100) : 0;
|
||
|
||
const badge = document.getElementById('badgeTaskCount');
|
||
if (badge) badge.innerText = totalCount + ' تسک';
|
||
|
||
const statProgressText = document.getElementById('statProgressText');
|
||
if (statProgressText) statProgressText.innerText = percent + '٪ تکمیل (' + doneCount + ' از ' + totalCount + ')';
|
||
|
||
const statProgressBar = document.getElementById('statProgressBar');
|
||
if (statProgressBar) statProgressBar.style.width = percent + '%';
|
||
|
||
// Category counts
|
||
const updateCount = (id, cat) => {
|
||
const el = document.getElementById(id);
|
||
if (el) el.innerText = tasks.filter(t => t.cat === cat).length;
|
||
};
|
||
const catAll = document.getElementById('catCountAll');
|
||
if (catAll) catAll.innerText = totalCount;
|
||
updateCount('catCountGads', 'gads');
|
||
updateCount('catCountSeo', 'seo');
|
||
updateCount('catCountCrm', 'crm');
|
||
updateCount('catCountPartners', 'partners');
|
||
updateCount('catCountB2b', 'b2b');
|
||
updateCount('catCountBi', 'bi');
|
||
|
||
// Filter tasks
|
||
let filtered = tasks.filter(t => {
|
||
if (currentTaskCategory !== 'all' && t.cat !== currentTaskCategory) return false;
|
||
if (currentTaskStatus === 'done' && t.status !== 'done') return false;
|
||
if (currentTaskStatus === 'in_progress' && t.status !== 'in_progress') return false;
|
||
if (currentTaskStatus === 'urgent' && t.priority !== 'high') return false;
|
||
return true;
|
||
});
|
||
|
||
if (filtered.length === 0) {
|
||
container.innerHTML = `
|
||
<div style="background: var(--bg-card); border: 1px dashed var(--border-color); border-radius: 12px; padding: 40px; text-align: center; color: var(--text-muted);">
|
||
<div style="font-size: 2rem; margin-bottom: 8px;">📋</div>
|
||
<div style="font-weight: 700; font-size: 1rem;">تسکی با این فیلتر یافت نشد.</div>
|
||
<div style="font-size: 0.8rem; margin-top: 4px;">میتوانید فیلترها را تغییر داده یا تسک جدیدی اضافه فرمایید.</div>
|
||
</div>
|
||
`;
|
||
return;
|
||
}
|
||
|
||
let html = '';
|
||
filtered.forEach(task => {
|
||
const isDone = task.status === 'done';
|
||
const prioColor = task.priority === 'high' ? '#DC2626' : (task.priority === 'medium' ? '#D97706' : '#64748B');
|
||
const prioBg = task.priority === 'high' ? '#FEF2F2' : (task.priority === 'medium' ? '#FFFBEB' : '#F1F5F9');
|
||
|
||
const catColors = {
|
||
gads: { bg: '#EFF6FF', text: '#1D4ED8', border: '#BFDBFE' },
|
||
seo: { bg: '#F5F3FF', text: '#6D28D9', border: '#DDD6FE' },
|
||
crm: { bg: '#ECFDF5', text: '#047857', border: '#A7F3D0' },
|
||
partners: { bg: '#FFF7ED', text: '#C2410C', border: '#FFEDD5' },
|
||
b2b: { bg: '#FAF5FF', text: '#7E22CE', border: '#F3E8FF' },
|
||
bi: { bg: '#F0FDF4', text: '#15803D', border: '#BBF7D0' }
|
||
};
|
||
const catStyle = catColors[task.cat] || { bg: '#F1F5F9', text: '#334155', border: '#E2E8F0' };
|
||
|
||
html += `
|
||
<div style="background: var(--bg-card); border: 1px solid ${isDone ? 'var(--border-color)' : 'var(--border-hover)'}; border-radius: 12px; padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.03); opacity: ${isDone ? '0.75' : '1'}; transition: all 0.2s;">
|
||
<div style="display: flex; align-items: flex-start; gap: 14px; flex: 1;">
|
||
<input type="checkbox" ${isDone ? 'checked' : ''} onchange="toggleTaskStatus('${task.id}')" style="width: 20px; height: 20px; margin-top: 3px; cursor: pointer; accent-color: var(--primary);" />
|
||
<div style="flex: 1;">
|
||
<div style="display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px;">
|
||
<span style="background: ${catStyle.bg}; color: ${catStyle.text}; border: 1px solid ${catStyle.border}; font-size: 0.72rem; font-weight: 800; padding: 2px 8px; border-radius: 6px;">${task.catName}</span>
|
||
<span style="background: ${prioBg}; color: ${prioColor}; font-size: 0.7rem; font-weight: 700; padding: 2px 8px; border-radius: 6px;">${task.priorityName}</span>
|
||
<span style="font-size: 0.72rem; color: var(--text-muted);">${task.deadline}</span>
|
||
${isDone ? '<span style="background: #D1FAE5; color: #065F46; font-size: 0.68rem; font-weight: 800; padding: 1px 6px; border-radius: 4px;">✓ انجام شد</span>' : '<span style="background: #EDE9FE; color: #5B21B6; font-size: 0.68rem; font-weight: 800; padding: 1px 6px; border-radius: 4px;">در حال اجرا</span>'}
|
||
</div>
|
||
<div style="font-size: 0.95rem; font-weight: 800; color: ${isDone ? 'var(--text-muted)' : 'var(--text-main)'}; text-decoration: ${isDone ? 'line-through' : 'none'}; line-height: 1.5;">
|
||
${task.title}
|
||
</div>
|
||
<div style="font-size: 0.75rem; color: var(--text-muted); margin-top: 6px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap;">
|
||
<span>🎯 متریک هدف: <b style="color: var(--text-body);">${task.metric}</b></span>
|
||
<span>👤 مسئول: <b style="color: var(--primary);">${task.assignee}</b></span>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
`;
|
||
});
|
||
|
||
container.innerHTML = html;
|
||
}
|
||
'''
|
||
|
||
# Check if JS already injected
|
||
if '/* ================= MARKETING TASKS OPERATIONS LOGIC ================= */' not in html:
|
||
# Inject JS right before function switchMainTab
|
||
html = html.replace('function switchMainTab', js_code + '\n function switchMainTab')
|
||
print("JS logic injected")
|
||
|
||
# 5. Update switchMainTab to support 'marketing_ops' or 'tasks'
|
||
switch_tab_branch = ''' if (tabId === 'marketing_ops' || tabId === 'tasks') {
|
||
const el = document.getElementById('tabPaneMarketingOps');
|
||
if (el) el.style.display = 'block';
|
||
if (document.getElementById('navItemMarketingOps')) document.getElementById('navItemMarketingOps').classList.add('active');
|
||
if (document.getElementById('topModeBtnMarketingOps')) document.getElementById('topModeBtnMarketingOps').classList.add('active');
|
||
if (history.replaceState) history.replaceState(null, null, '#tasks');
|
||
if (typeof renderMarketingTasks === 'function') renderMarketingTasks();
|
||
return;
|
||
}
|
||
'''
|
||
|
||
if "tabId === 'marketing_ops'" not in html:
|
||
html = re.sub(r'(function\s+switchMainTab\s*\([^\)]*\)\s*\{[\s\S]*?document\.querySelectorAll\(\'\.top-mode-switcher \.date-btn\'\)\.forEach\(b => b\.classList\.remove\(\'active\'\)\);)',
|
||
r'\1\n' + switch_tab_branch,
|
||
html, count=1)
|
||
print("switchMainTab updated")
|
||
|
||
# 6. Update checkHashAndSwitch to default to marketing_ops or handle #tasks
|
||
check_hash_updated = ''' function checkHashAndSwitch() {
|
||
const h = window.location.hash || '';
|
||
const s = window.location.search || '';
|
||
if (h.includes('analytics') || s.includes('analytics')) {
|
||
switchMainTab('analytics');
|
||
} else if (h.includes('b2b') || s.includes('b2b') || h.includes('gads') || s.includes('gads')) {
|
||
switchMainTab('google_ads_b2b');
|
||
} else if (h.includes('planning') || s.includes('planning')) {
|
||
switchMainTab('planning');
|
||
} else if (h.includes('channels') || s.includes('channels') || h.includes('social') || s.includes('social')) {
|
||
switchMainTab('channels');
|
||
} else {
|
||
switchMainTab('marketing_ops');
|
||
}
|
||
}'''
|
||
|
||
if 'switchMainTab(\'marketing_ops\');' not in html:
|
||
html = re.sub(r'function\s+checkHashAndSwitch\s*\(\)\s*\{[\s\S]*?\}\s*window\.addEventListener',
|
||
check_hash_updated + '\n\n window.addEventListener',
|
||
html, count=1)
|
||
print("checkHashAndSwitch updated")
|
||
|
||
# Write to src_file
|
||
with open(src_file, 'w', encoding='utf-8') as f:
|
||
f.write(html)
|
||
|
||
print("Updated", src_file, "size:", len(html))
|
||
|
||
# Also sync to new/index.html, v2/index.html, v3/index.html
|
||
for mirror in ['/workspace/personal/dashboards/marketing/new/index.html',
|
||
'/workspace/personal/dashboards/marketing/v2/index.html',
|
||
'/workspace/personal/dashboards/marketing/v3/index.html']:
|
||
if os.path.exists(os.path.dirname(mirror)):
|
||
shutil.copyfile(src_file, mirror)
|
||
print("Mirrored to", mirror)
|
||
|