{# Live region for the Insight page. Rendered inside insight.html.twig on first load AND standalone by AgentController::insightData(), re-fetched by the agent-insight Stimulus controller every ~15s. Keep markup identical between the two so the innerHTML swap is diff-free where data is unchanged. Every table is `data-insight-paginate` + carries an `.insight-pager` footer; the Stimulus controller slices each to 10 rows/page (state survives the swap). #} {% import _self as insight %} {# ── Headline tiles ── #}
{% set p = periodLabel %} {% set tiles = [ {key: 'online', label: 'Online · ' ~ p, value: onlineCount, sub: 'seen on the site'}, {key: 'played', label: 'Played · ' ~ p, value: playedCount, sub: 'placed at least one bet'}, {key: 'bets', label: 'Total Bets · ' ~ p, value: '₱' ~ betTotals.betAmount|number_format(2), sub: betTotals.betCount ~ ' bet' ~ (betTotals.betCount == 1 ? '' : 's')}, {key: 'wins', label: 'Total Wins · ' ~ p, value: '₱' ~ betTotals.winAmount|number_format(2), sub: 'paid out to your downline'}, {key: 'winrate', label: 'Players Win Rate · ' ~ p, value: playersWinRate|number_format(2) ~ '%', sub: 'wins ÷ bets across your downline'}, {key: 'commission', label: 'Commission Earned · ' ~ p, value: '₱' ~ commissionToday|number_format(2), sub: 'your share'}, {key: 'deposits', label: 'Deposit Requests · ' ~ p, value: '₱' ~ depositsToday|number_format(2), sub: 'requested by your downline'}, {key: 'withdrawals', label: 'Withdrawal Requests · ' ~ p, value: '₱' ~ withdrawalsToday|number_format(2), sub: 'requested by your downline'}, ] %} {% for tile in tiles %}

{{ tile.label }}

{{ tile.value }}

{{ tile.sub }}

{% endfor %}
{# ── Deposit & withdrawal requests ── #}

Deposit & Withdrawal Requests

{% for req in requests %} {% else %} {% endfor %}
Time Player Kind Amount Status
{{ req.createdAt|date('M d, H:i') }} {{ req.entity.user.firstName }} {{ req.entity.user.lastName }} {% if req.kind == 'deposit' %} Deposit {% else %} Withdrawal {% endif %} ₱{{ req.entity.amount|number_format(2) }} {% if req.entity.status == 'approved' %} Approved {% elseif req.entity.status == 'rejected' %} Rejected {% else %} Pending {% endif %}
No deposit or withdrawal requests from your downline.
{{ insight.insight_pager('agent-insight-requests-table') }}
{# ── Players seen on-site ── #}

Players Online · {{ periodLabel }}

{% for row in onlineUsers %} {% else %} {% endfor %}
Name Mobile Last Seen
{{ row.firstName }} {{ row.lastName }} {{ row.mobileNumber }} {% if isToday %}{{ row.minutesAgo == 0 ? 'just now' : row.minutesAgo ~ ' min ago' }} {% else %}{{ row.lastSeenAt|date('M j, H:i') }}{% endif %}
No one in your downline was seen on {{ periodLabel }}.
{{ insight.insight_pager('agent-insight-online-table') }}
{# ── Players who placed a bet ── #}

Players Who Played · {{ periodLabel }}

{% for row in playedPlayers %} {% else %} {% endfor %}
Name Mobile Bets Staked
{{ row.firstName }} {{ row.lastName }} {{ row.mobileNumber }} {{ row.betCount }} ₱{{ row.betAmount|number_format(2) }}
No one in your downline placed a bet on {{ periodLabel }}.
{{ insight.insight_pager('agent-insight-played-table') }}
{# ── Player activity: last deposit request + last bet per player ── #}

Player Activity — Last Deposit & Last Bet

{% for row in playerActivity %} {% else %} {% endfor %}
Player Mobile Last Deposit Request Last Bet Game
{{ row.firstName }} {{ row.lastName }} {{ row.mobileNumber }} {% if row.lastDeposit %} ₱{{ row.lastDeposit.amount|number_format(2) }} · {{ row.lastDeposit.createdAt|date('M d, H:i') }} {% if row.lastDeposit.status == 'approved' %} Approved {% elseif row.lastDeposit.status == 'rejected' %} Rejected {% else %} Pending {% endif %} {% else %} — {% endif %} {% if row.lastBet %} ₱{{ row.lastBet.amount|number_format(2) }} · {{ row.lastBet.placedAt|date('M d, H:i') }} {% else %} — {% endif %} {{ row.lastBet ? row.lastBet.game : '—' }}
No deposit or bet activity from your {{ scope == 'all' ? 'downline' : 'direct players' }} yet.
{{ insight.insight_pager('agent-insight-player-activity-table') }}
{# ── Recent transactions: direct players / sub-agent players ── #} {% macro tx_type_badge(type) %} {% if type == 'deposit' %} Deposit {% elseif type == 'withdrawal' %} Withdrawal {% elseif type == 'win' %} Win {% elseif type == 'bet' %} Bet {% elseif type == 'commission' %} Commission {% else %} {{ type|capitalize }} {% endif %} {% endmacro %} {% macro insight_pager(testid) %} {% endmacro %} {% macro tx_table(rows, testid, emptyText) %} {% import _self as helper %}
{% for tx in rows %} {% else %} {% endfor %}
Time Player Type Amount Balance After
{{ tx.createdAt|date('M d, H:i') }} {{ tx.user.firstName }} {{ tx.user.lastName }} {{ helper.tx_type_badge(tx.type) }} ₱{{ tx.amount|number_format(2) }} ₱{{ tx.balanceAfter|number_format(2) }}
{{ emptyText }}
{{ helper.insight_pager(testid) }}
{% endmacro %}

Direct Players — Recent Transactions

{{ insight.tx_table(directTx, 'agent-insight-direct-tx-table', 'No recent transactions from your direct players.') }}
{% if scope == 'all' %}

Sub-Agents' Players — Recent Transactions

{{ insight.tx_table(subAgentTx, 'agent-insight-subagent-tx-table', 'No recent transactions from your sub-agents\' players.') }}
{% endif %}