{% extends "base.html" %} {% block content %}

{{ tr("Admin") }}

{{ tr("Business Control Center") }}

{{ tr("One TTC account is shared for all customer orders. Configure TTC + MBank + pricing here.") }}

{{ tr("TTC Shared Account") }}

{{ tr("Current TTC API Key") }}: {{ ttc_api_key_mask }}

{{ tr("Current TTC Access Token") }}: {{ ttc_access_token_mask }}

{{ tr("Cached TTC balance") }}: {{ payment_config['provider_balance_cache'] or tr('Not synced') }}

{{ tr("Payment Configuration (MBank + Web2M)") }}

{{ tr("Current History Token") }}: {{ history_token_mask }}

{{ tr("Current Webhook Bearer Token") }}: {{ webhook_token_mask }}

{{ tr("Webhook URL to set on Web2M") }}: {{ request.url_root.rstrip('/') }}{{ url_for('webhook_web2m') }}

{{ tr("Top-up Requests") }}

{% if not topups %}

{{ tr("No top-up records yet.") }}

{% else %}
{% for item in topups %} {% endfor %}
{{ tr("ID") }} Username {{ tr("Amount") }} {{ tr("Code") }} {{ tr("Status") }} {{ tr("Transaction Ref") }} {{ tr("Created") }} {{ tr("Paid") }} {{ tr("Action") }}
#{{ item['id'] }} {{ item['username'] }} {{ item['amount_tic']|ticfmt }} TIC {{ item['deposit_code'] }} {{ item['status'] }} {{ item['matched_transaction_ref'] or '-' }} {{ item['created_at']|dtfmt }} {{ (item['paid_at']|dtfmt) if item['paid_at'] else '-' }} {% if item['status']|lower in ['pending', 'canceled', 'cancelled', 'expired'] %}
{% else %} - {% endif %}
{% endif %}

{{ tr("Received Bank Transactions") }}

{% if not transactions %}

{{ tr("No bank transaction logs yet.") }}

{% else %}
{% for tx in transactions %} {% endfor %}
{{ tr("Ref") }} {{ tr("Amount") }} {{ tr("Description") }} {{ tr("Type") }} {{ tr("Source") }} {{ tr("Matched Topup") }} {{ tr("Time") }}
{{ tx['external_ref'] }} {{ tx['amount_tic']|ticfmt }} TIC {{ tx['description'] }} {{ tx['tx_type'] }} {{ tx['source'] }} {{ tx['matched_topup_id'] or '-' }} {{ tx['created_at']|dtfmt }}
{% endif %}

{{ tr("Website Settings") }}

{{ tr("Image shown when sharing links on social networks.") }} {{ tr("Recommended size: 1200x630 for social sharing.") }} {% if payment_config['web_share_image_path'] %} {{ tr("View current image") }} Share image preview {% endif %}
{{ tr("Icon shown in browser tabs.") }} {% if payment_config['web_favicon_path'] %} {{ tr("View current favicon") }} Favicon preview {% endif %}
{{ tr("Notice text shown on dashboard hero section.") }}

{{ tr("Members") }}

{% for member in members %} {% endfor %}
Username {{ tr("Balance") }} {{ tr("Role") }} {{ tr("Status") }} {{ tr("Actions") }}
{{ member['username'] }}
{{ member['email'] }}
{{ member['wallet_balance']|ticfmt }} TIC {{ tr('Admin') if member['is_admin'] == 1 else tr('Member') }} {{ tr('Active') if member['is_active'] == 1 else tr('Disabled') }}

{{ tr("Running Member Orders") }}

{% if not running_orders %}

{{ tr("No running member orders right now.") }}

{% else %} {% if running_order_categories %}
{% for category in running_order_categories %} {% endfor %}
{% endif %}
{% for item in running_orders %} {% endfor %}
{{ tr("Order Code") }} {{ tr("Member") }} {{ tr("Service") }} {{ tr("Username") }} Trạng Thái {{ tr("Start Count") }} {{ tr("Purchased Quantity") }} {{ tr("Increased") }} {{ tr("Remains") }} {{ tr("Price") }} {{ tr("Purchase Date") }}
{{ item['provider_order_id'] or '-' }} {{ item['username'] }}
{{ item['email'] }}
{{ item['service_name'] or ('Service ' ~ item['service_id']) }} {{ item['provider_user'] or '-' }} {{ item['provider_status_raw'] or '-' }} {{ item['start_count'] or '-' }} {{ item['quantity'] or '0' }} {% if item['remains'] %} {% set increased_preview = (item['quantity'] or 0) - (item['remains']|int) %} {{ 0 if increased_preview < 0 else increased_preview }} {% else %} 0 {% endif %} {{ item['remains'] or '-' }} {{ item['local_charge_tic']|ticfmt }} TIC {{ item['created_at']|dtfmt }}
{% endif %}

{{ tr("Services + Selling Price") }}

{{ tr("Price / 1 formula: ((Provider Rate * TTC Coin Price) / 1,000,000) then + Profit Margin%.") }}

{% if service_categories %}
{% for category in service_categories %} {% endfor %}
{% endif %} {% if services %}
{% for item in services %} {% endfor %}
{{ tr("Service ID") }} {{ tr("Name") }} {{ tr("Provider Rate") }} {{ tr("Price / 1") }} {{ tr("Min") }} {{ tr("Max") }} {{ tr("Sell") }} {{ tr("Action") }}
{{ item['service_id'] }} {{ item['service_name_display'] }} {{ item['provider_rate'] or '-' }} {{ item['price_per_1000_tic']|ticfmt if item['price_per_1000_tic'] is not none else '-' }} TIC {{ item['min_qty'] or '-' }} {{ item['max_qty'] or '-' }} {{ tr('ON') if item['pricing_active'] == 1 else tr('OFF') }}
{{ tr("Service Note") }}

{{ tr("Service note (shown below service selector on Create Order form).") }}

{{ tr("Use toolbar to format note text and add image.") }}
{% else %}

{{ tr('No services synced yet. Use "Sync Services from TTC" first.') }}

{% endif %}

{{ tr("Top-up Overview") }}

{{ tr("Today") }}

{{ topup_summary['today_tic']|ticfmt }} TIC

{{ tr("This Week") }}

{{ topup_summary['week_tic']|ticfmt }} TIC

{{ tr("This Month") }}

{{ topup_summary['month_tic']|ticfmt }} TIC

{{ tr("Service Revenue Statistics") }}

{% if not service_statistics %}

{{ tr("No service revenue data yet.") }}

{% else %}
{% for item in service_statistics %} {% endfor %}
{{ tr("Service ID") }} {{ tr("Name") }} {{ tr("Total Revenue (All-time)") }} {{ tr("Avg Completion Time (7d)") }} {{ tr("Completed Orders (7d)") }} {{ tr("Total Orders") }}
{{ item['service_id'] }} {{ item['service_name_display'] }} {{ item['total_revenue_tic']|ticfmt }} TIC {% if item['avg_completion_hours_7d'] is not none %}{{ "%.2f"|format(item['avg_completion_hours_7d']) }} h{% else %}-{% endif %} {{ item['completed_orders_7d'] }} {{ item['total_orders'] }}
{% endif %}

{{ tr("Monthly Top-up Log") }}

{% if not monthly_topup_logs %}

{{ tr("No monthly top-up logs yet.") }}

{% else %}
{% for item in monthly_topup_logs %} {% endfor %}
{{ tr("Month") }} {{ tr("Total Top-up") }} {{ tr("Top-up Count") }} {{ tr("Last Top-up Time") }}
{{ item['month_label'] }} {{ item['total_tic']|ticfmt }} TIC {{ item['topup_count'] }} {{ item['last_paid_at']|dtfmt if item['last_paid_at'] else '-' }}
{% endif %}

{{ tr("Login IP Logs") }}

{% if not login_ip_logs %}

{{ tr("No login IP logs yet.") }}

{% else %}
{% for item in login_ip_logs %} {% endfor %}
{{ tr("User") }} {{ tr("Previous IP") }} {{ tr("Current IP") }} {{ tr("User Agent") }} {{ tr("Login Time") }}
{{ item['username'] }} {{ item['previous_ip'] }} {{ item['current_ip'] }} {{ item['user_agent'] }} {{ item['created_at']|dtfmt }}
{% endif %}
{% endblock %}