<?php
/**
 * نصب جداول ABC انتخابات
 * C:\xampp\php\php.exe run-election-abc-install.php
 */
declare(strict_types=1);

if ( ! defined( 'ACC_BASE_PATH' ) ) {
    define( 'ACC_BASE_PATH', __DIR__ );
    require __DIR__ . '/standalone/bootstrap.php';
}

header( 'Content-Type: application/json; charset=utf-8' );

require_once ACC_PATH . 'includes/helpers/election-activity-cost.php';
Election_Activity_Cost::ensure_tables();

$acts = Election_Activity_Cost::list_activities( false );
$camps = Election_Activity_Cost::list_campaigns();
echo wp_json_encode( [
    'success' => true,
    'message' => 'جداول ABC انتخابات آماده شد',
    'activities' => count( $acts ),
    'campaigns' => count( $camps ),
    'sample' => array_slice( $acts, 0, 3 ),
    'campaign' => $camps[0] ?? null,
], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT );
