where('get_type', \App\Models\Medal::GET_TYPE_EXCHANGE); $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'); $columnActionLabel = nexus_trans('nexus.action'); $header = '

'.$title.'

'; $filterForm = <<
FORM; stdhead($title); begin_main_frame(); $table = << TABLE; $table .= ''; $userMedals = \App\Models\UserMedal::query()->where('uid', $CURUSER['id']) ->orderBy('id', 'desc') ->get() ->keyBy('medal_id') ; foreach ($rows as $row) { if ($userMedals->has($row->id) || $CURUSER['seedbonus'] < $row->price) { if ($userMedals->has($row->id)) { $btnText = nexus_trans('medal.buy_already'); } else { $btnText = nexus_trans('medal.require_more_bonus'); } $disabled = ' disabled'; $class = ''; } else { $btnText = nexus_trans('medal.buy_btn'); $disabled = ''; $class = 'buy'; } $action = sprintf( '', $class, $row->id, $btnText, $disabled ); $table .= sprintf( '', $row->id, $row->name, $row->image_large, number_format($row->price), $row->duration, $row->description, $action ); } $table .= '
ID $columnNameLabel $columnImageLargeLabel $columnPriceLabel $columnDurationLabel $columnDescriptionLabel $columnActionLabel
%s%s%s%s%s%s
'; echo $header . $table . $paginationBottom; $confirmMsg = nexus_trans('medal.confirm_to_buy'); $js = <<