where('display_on_medal_page', 1); $q = htmlspecialchars($_REQUEST['q'] ?? ''); if (!empty($q)) { $query->where('username', 'name', "%{$q}%"); } $total = (clone $query)->count(); $perPage = 20; list($paginationTop, $paginationBottom, $limit, $offset) = pager($perPage, $total, "?"); $rows = (clone $query)->offset($offset)->take($perPage)->orderBy('id', 'desc')->get(); $q = htmlspecialchars($q); $title = nexus_trans('medal.label'); $columnNameLabel = nexus_trans('label.name'); $columnImageLargeLabel = nexus_trans('medal.fields.image_large'); $columnPriceLabel = nexus_trans('medal.fields.price'); $columnDurationLabel = nexus_trans('medal.fields.duration'); $columnDescriptionLabel = nexus_trans('medal.fields.description'); $columnBuyLabel = nexus_trans('medal.buy_btn'); $columnSaleBeginEndTimeLabel = nexus_trans('medal.fields.sale_begin_end_time'); $columnInventoryLabel = nexus_trans('medal.fields.inventory'); $columnBonusAdditionLabel = nexus_trans('medal.fields.bonus_addition'); $columnGiftLabel = nexus_trans('medal.gift_btn'); $columnGiftFeeLabel = nexus_trans('medal.fields.gift_fee'); $header = '

'.$title.'

'; $filterForm = <<
FORM; stdhead($title); begin_main_frame(); $table = << TABLE; $now = now(); $table .= ''; $userMedals = \App\Models\UserMedal::query()->where('uid', $CURUSER['id']) ->orderBy('id', 'desc') ->get() ->keyBy('medal_id') ; foreach ($rows as $row) { $buyDisabled = $giftDisabled = ' disabled'; $buyClass = $giftClass = ''; try { $row->checkCanBeBuy(); if ($userMedals->has($row->id)) { $buyBtnText = nexus_trans('medal.buy_already'); } elseif ($CURUSER['seedbonus'] < $row->price) { $buyBtnText = nexus_trans('medal.require_more_bonus'); } else { $buyBtnText = nexus_trans('medal.buy_btn'); $buyDisabled = ''; $buyClass = 'buy'; } if ($CURUSER['seedbonus'] < $row->price * (1 + ($row->gift_fee_factor ?? 0))) { $giftBtnText = nexus_trans('medal.require_more_bonus'); } else { $giftBtnText = nexus_trans('medal.gift_btn'); $giftDisabled = ''; $giftClass = 'gift'; } } catch (\Exception $exception) { $buyBtnText = $giftBtnText = $exception->getMessage(); } $buyAction = sprintf( '', $buyClass, $row->id, $buyBtnText, $buyDisabled ); $giftAction = sprintf( '%s: %s', $giftDisabled, $giftClass, $row->id, $giftBtnText, $giftDisabled, $columnGiftFeeLabel, (($row->gift_fee_factor ?? 0) * 100).'%' ); $table .= sprintf( '', $row->image_large, $row->name, $row->description, $row->sale_begin_time ?? nexus_trans('nexus.no_limit'), $row->sale_end_time ?? nexus_trans('nexus.no_limit'), $row->durationText, (($row->bonus_addition_factor ?? 0) * 100).'%', number_format($row->price), $row->inventory ?? nexus_trans('label.infinite'), $buyAction, $giftAction ); } $table .= '
$columnImageLargeLabel $columnDescriptionLabel $columnSaleBeginEndTimeLabel $columnDurationLabel $columnBonusAdditionLabel $columnPriceLabel $columnInventoryLabel $columnBuyLabel $columnGiftLabel

%s

%s
%s ~
%s
%s%s%s%s%s%s
'; echo $header . $table . $paginationBottom; end_main_frame(); $confirmBuyMsg = nexus_trans('medal.confirm_to_buy'); $confirmGiftMsg = nexus_trans('medal.confirm_to_gift'); $js = <<