%s', nexus_trans('self-enable.enable_status_normal'));
} else {
$latestBanLog = \App\Models\UserBanLog::query()
->where('uid', $CURUSER['id'])
->orderBy('id', 'desc')
->first();
if (!$latestBanLog) {
printf('
%s
', nexus_trans('self-enable.no_ban_info'));
} else {
$unit = \App\Models\Setting::getSelfEnableBonus();
$elapsedDay = ceil((time() - $latestBanLog->created_at->getTimestamp()) / 86400);
$total = $unit * $elapsedDay;
$isUserBonusEnough = $CURUSER['seedbonus'] >= $total;
$userBonusNotEnoughTip = nexus_trans('self-enable.bonus_not_enough', ['bonus' => $CURUSER['seedbonus']]);
if (!empty($_POST['submit'])) {
if (!$isUserBonusEnough) {
stdmsg('Error', $userBonusNotEnoughTip);
} else {
$userRep = new \App\Repositories\UserRepository();
$bonusRep = new \App\Repositories\BonusRepository();
$operator = \App\Models\User::query()->find($CURUSER['id']);
$bonusRep->consumeUserBonus($CURUSER['id'], $total, \App\Models\BonusLogs::BUSINESS_TYPE_SELF_ENABLE, $title);
$userRep->enableUser($operator, $CURUSER['id'], $title);
nexus_redirect('index.php');
}
} else {
printf('%s
', nexus_trans('self-enable.latest_ban_info'));
printf('');
printf('| UID: | %s |
', $latestBanLog->uid);
printf('| Username: | %s |
', $latestBanLog->username);
printf('| Reason: | %s |
', $latestBanLog->reason);
printf('| CreatedAt: | %s |
', $latestBanLog->created_at);
printf('
');
printf('%s
', nexus_trans('self-enable.deduct_bonus_per_day', ['unit' => number_format($unit)]));
printf('%s
', nexus_trans('self-enable.deduct_bonus_total', ['days' => number_format($elapsedDay), 'total' => number_format($total)]));
if ($isUserBonusEnough) {
printf('%s
', nexus_trans('self-enable.enable_desc'));
printf('', nexus_trans('self-enable.enable_button'));
} else {
printf('%s
', $userBonusNotEnoughTip);
}
}
}
}
end_frame();
end_main_frame();
stdfoot();
?>