{# templates/dashboard.html #} {% extends "base.html" %} {% block content %} {# =========================================================== BRAND DASHBOARD (brand-side users) =========================================================== #} {% if current_user.brand_id %}

Brand Dashboard

Welcome, {{ current_user.full_name or current_user.username }} · Brand: {{ current_user.brand.name if current_user.brand else 'My Brand' }}

{# My Pending Approvals #}
My Pending Approvals
One-click jump to the first pending item in each queue.
{% if first_pending_brand %} Brand Approval {{ pending_brand_count or 0 }} {% else %} {% endif %} {% if first_pending_script %} Script Approval {{ pending_script_count or 0 }} {% else %} {% endif %} {% if first_pending_content %} Content Approval {{ pending_content_count or 0 }} {% else %} {% endif %}
{# Top summary cards #}
Total Campaigns
{{ total_campaigns or 0 }}
{% set live_count = status_counts.get('GO_LIVE', 0) if status_counts else 0 %}
Live Campaigns
{{ live_count }}
{% set pipeline = 0 %} {% if status_counts %} {% set pipeline = status_counts.get('SCRIPTING', 0) + status_counts.get('CONTENT', 0) %} {% endif %}
In Pipeline
{{ pipeline }}
Scripting + Content phases
Creators Engaged
{{ total_creators|default(0) }}
Across all your campaigns
Overall Revenue Generated
₹ {{ "{:,.2f}".format((overall_revenue or 0)|float) }}
Received: ₹ {{ "{:,.2f}".format((total_received or 0)|float) }}
Outstanding: ₹ {{ "{:,.2f}".format((total_outstanding or 0)|float) }}
{# Campaign Dashboard list #}
My Campaigns
View full list
Clear
{% if brand_campaigns %}
{% for c in brand_campaigns %} {% endfor %}
ID Title Status Created Action
#{{ c.id }} {{ c.title }} {% set st = c.status %} {% if st == 'CREATE' %}{{ st }} {% elif st == 'SHORTLIST' %}{{ st }} {% elif st == 'APPROVED' %}{{ st }} {% elif st == 'SCRIPTING' %}{{ st }} {% elif st == 'CONTENT' %}{{ st }} {% elif st == 'GO_LIVE' %}{{ st }} {% elif st == 'REPORT' %}{{ st }} {% else %}{{ st }} {% endif %} {{ c.created_at }} {# FIXED: Proper routing per status #} {% if c.status == 'SHORTLIST' %} Brand Approval {% elif c.status == 'SCRIPTING' %} Script Approval {% elif c.status in ['CONTENT','GO_LIVE','REPORT'] %} Content Approval {% else %} Open {% endif %}
{% else %}

No campaigns found for your filters.

{% endif %}
{# Recent + upcoming #}
Recent Campaigns
View all
{% if recent_campaigns %}
{% for c in recent_campaigns %} {% endfor %}
Title Status Created Actions
{{ c.title }} {{ c.status }} {{ c.created_at }} Open
{% else %}

No campaigns yet for this brand.

{% endif %}
Upcoming Go-Live
{% if not upcoming_go_live %}

No scheduled go-live posts yet.

{% else %}
{% for c in upcoming_go_live %} {% endfor %}
Date Creator Deliverable
{{ c.go_live_date }} {{ c.creator.name }}
@{{ c.creator.handle }}
{{ c.campaign_deliverable.platform.name }} – {{ c.campaign_deliverable.deliverable_type.name }} (Unit {{ c.unit_index }})
{% endif %}
{# =========================================================== CREATOR DASHBOARD (creator-side users) =========================================================== #} {% elif current_user.creator_id %}

Creator Dashboard

Welcome, {{ current_user.full_name or current_user.username }}.

My Campaigns My Payouts
My Campaigns
{{ total_campaigns or 0 }}
Brands Worked With
{{ total_brands or 0 }}
Upcoming Go-Live
{{ (upcoming_go_live|length) if upcoming_go_live else 0 }}
By Status
{% for s, label in { 'CREATE':'Create', 'SHORTLIST':'Shortlist', 'APPROVED':'Approved', 'SCRIPTING':'Scripting', 'CONTENT':'Content', 'GO_LIVE':'Go Live', 'REPORT':'Report' }.items() %}
{{ label }} {{ status_counts.get(s, 0) if status_counts else 0 }}
{% endfor %}
Recent Campaigns
View all
{% if recent_campaigns %}
{% for c in recent_campaigns %} {% endfor %}
Brand Title Status Action
{{ c.brand.name if c.brand else '-' }} {{ c.title }} {{ c.status }} Open Work
{% else %}

No campaigns assigned yet.

{% endif %}
Upcoming Go-Live
{% if not upcoming_go_live %}

No scheduled go-live items yet.

{% else %}
{% for row in upcoming_go_live %} {% endfor %}
Date Campaign Deliverable
{{ row.go_live_date }} {{ row.campaign.title if row.campaign else '-' }} {{ row.campaign_deliverable.platform.name }} – {{ row.campaign_deliverable.deliverable_type.name }} (Unit {{ row.unit_index }})
{% endif %}
{# =========================================================== ADMIN / INTERNAL DASHBOARD (no brand_id and no creator_id) =========================================================== #} {% else %}
{# =========================================================== TAB 1: CURRENT (MONTH-WISE ONLY) =========================================================== #}

Admin Dashboard

Welcome, {{ current_user.full_name or current_user.username }}.

Clear
{# =========================== TOP METRIC CARDS (MONTH) =========================== #}
Month Campaigns Created
{{ month_campaigns_created or 0 }}
Month: {{ month }}
Month Campaigns Go Live
{{ month_campaigns_completed or 0 }}
Completed = Go Live
Backlog
{{ backlog_campaigns or 0 }}
Created before month, not Go Live
By Status
{% for s, label in { 'CREATE':'Create', 'SHORTLIST':'Shortlist', 'APPROVED':'Approved', 'SCRIPTING':'Scripting', 'CONTENT':'Content', 'GO_LIVE':'Go Live', 'REPORT':'Report' }.items() %}
{{ label }} {{ status_counts.get(s, 0) if status_counts else 0 }}
{% endfor %}
Month Revenue (Invoices)
₹ {{ "{:,.2f}".format((month_revenue or 0)|float) }}
Non-draft invoices
Month Creator Cost
₹ {{ "{:,.2f}".format((month_creator_cost or 0)|float) }}
Approved quotes only
Month Margin
₹ {{ "{:,.2f}".format((month_margin or 0)|float) }}
From quotes margin_amount
Invoices (Month)
TI
{{ month_ti or 0 }}
PI
{{ month_pi or 0 }}
{# IMPORTANT: "Invoices (Overall)" removed from current tab as requested #}
{# =========================== REST OF CURRENT DASHBOARD =========================== #}
{# Payment pendings #}
Pending Payments (7+ days)
{{ payment_pendings|length }}
{% if not payment_pendings %}

No pending invoices older than 7 days.

{% else %}
{% for inv in payment_pendings %} {% endfor %}
Invoice Brand Total Paid Balance Status Created
{{ inv.invoice_number }} {{ inv.brand.name if inv.brand else '-' }} ₹ {{ "{:,.2f}".format((inv.total_amount or 0)|float) }} ₹ {{ "{:,.2f}".format((inv.amount_paid or 0)|float) }} ₹ {{ "{:,.2f}".format((inv.balance_amount or 0)|float) }} {% set ps = inv.payment_status %} {% if ps == 'UNPAID' %} UNPAID {% elif ps == 'PARTIAL' %} PARTIAL {% else %} {{ ps }} {% endif %} {{ inv.created_at }}
{% endif %}
{# Ops bandwidth #}
Ops Bandwidth
{% if not ops_bandwidth %}

No data.

{% else %}
{% for row in ops_bandwidth %} {% endfor %}
Ops Campaigns Value (Budget)
{{ row.full_name or ('User #' ~ row.user_id) }}
OpsID: {{ row.user_id }}
{{ row.campaigns or 0 }} ₹ {{ "{:,.2f}".format((row.value_sum or 0)|float) }}
{% endif %}
{# Recent campaigns #}
Recent Campaigns
{% if recent_campaigns %}
{% for c in recent_campaigns %} {% endfor %}
Brand Title Status Created
{{ c.brand.name if c.brand else '-' }} {{ c.title }} {{ c.status }} {{ c.created_at }}
{% else %}

No campaigns found for filters.

{% endif %}
{# Brand performance #}
Top Brands (Revenue)
{% if not brand_perf %}

No invoice data.

{% else %}
{% for b in brand_perf %} {% endfor %}
Brand Invoices Revenue
{{ b.name }} {{ b.invoices or 0 }} ₹ {{ "{:,.2f}".format((b.revenue or 0)|float) }}
{% endif %}
{# Upcoming go-live #}
Upcoming Go-Live
{% if not upcoming_go_live %}

No scheduled go-live yet.

{% else %}
{% for c in upcoming_go_live %} {% endfor %}
Date Campaign Creator Deliverable
{{ c.go_live_date }} {{ c.campaign.title }} {{ c.creator.name }} {{ c.campaign_deliverable.platform.name }} – {{ c.campaign_deliverable.deliverable_type.name }} (Unit {{ c.unit_index }})
{% endif %}
{# =========================================================== TAB 2: CONSOLIDATED (FROM / TO) =========================================================== #}
Consolidated Dashboard
Across selected date range
{% if admin_status %}{% endif %} {% if ops_id %}{% endif %}
Creators
{{ cons_creators }}
Brands
{{ cons_brands }}
Campaigns
{{ cons_campaigns }}
Margin
₹ {{ cons_margin }}
Revenue
₹ {{ cons_revenue }}
Received
₹ {{ cons_received }}
Outstanding
₹ {{ cons_outstanding }}
Invoices (Overall)
TI: {{ cons_ti }}   PI: {{ cons_pi }}
Creator Cost
₹ {{ cons_creator_cost }}
{% endif %} {% endblock %}