-- Run this once in phpMyAdmin (select the database, then SQL tab).
--
-- Root cause of the "امکان صدور اکانت تست وجود ندارد" free-trial error:
-- 'free_test_hours' was saved as "۲۴" (Persian digits, typed on a Persian
-- keyboard) instead of "24". PHP's (int) cast reads "۲۴" as 0, so the free
-- test was requested from the panel with a 0-hour duration and the panel
-- rejected it. The admin.php save-handler now converts Persian/Arabic
-- digits to ASCII before storing any numeric setting, so this can't
-- recur — this migration just repairs the value that was already saved
-- before that fix existed. Safe to run even if the value is already fine
-- (WHERE clause only touches the known-bad value).
UPDATE settings SET setting_value = '24' WHERE setting_key = 'free_test_hours' AND setting_value = '۲۴';

-- Same repair for any of the other numeric settings, in case one of them
-- was also typed in Persian digits at some point.
UPDATE settings SET setting_value = TRIM(
    REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
    setting_value,
    '۰','0'),'۱','1'),'۲','2'),'۳','3'),'۴','4'),'۵','5'),'۶','6'),'۷','7'),'۸','8'),'۹','9')
)
WHERE setting_key IN ('min_charge_amount', 'free_test_mb', 'free_test_max_count', 'referral_percent', 'monthly_cost')
  AND setting_value REGEXP '[۰-۹]';
