where('type', \App\Models\Exam::TYPE_TASK)->where("status", \App\Models\Exam::STATUS_ENABLED); $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(); $title = nexus_trans('exam.type_task'); $columnNameLabel = nexus_trans('label.name'); $columnIndexLabel = nexus_trans('exam.index'); $columnBeginTimeLabel = nexus_trans('label.begin'); $columnEndTimeLabel = nexus_trans('label.end'); $columnDurationLabel = nexus_trans('label.duration'); $columnRecurringLabel = nexus_trans('exam.recurring'); $columnTargetUserLabel = nexus_trans('label.exam.filter_formatted'); $columnDescLabel = nexus_trans('label.description'); $columnSuccessRewardLabel = nexus_trans('exam.success_reward_bonus'); $columnFailDeductLabel = nexus_trans('exam.fail_deduct_bonus'); $columnDescriptionDeductLabel = nexus_trans('label.description'); $columnClaimLabel = nexus_trans('exam.action_claim_task'); $header = '

'.$title.'

'; stdhead($title); begin_main_frame(); $table = << TABLE; $now = now(); $table .= ''; $userInfo = \App\Models\User::query()->findOrFail($CURUSER['id'], \App\Models\User::$commonFields); $userTasks = $userInfo->examAndTasks()->where("type", \App\Models\Exam::TYPE_TASK) ->orderBy('id', 'desc') ->get() ->keyBy('id') ; //dd($userTasks); foreach ($rows as $row) { $claimDisabled = $claimClass = ''; $claimBtnText = "认领"; if ($userTasks->has($row->id)) { $claimDisabled = " disabled"; $claimBtnText = "已认领"; } $claimAction = sprintf( '', $claimClass, $row->id, $claimBtnText, $claimDisabled ); $columns = []; $columns[] = sprintf('', $row->name); $columns[] = sprintf('', $row->indexFormatted); $columns[] = sprintf('', $row->getBeginForUser()); $columns[] = sprintf('', $row->getEndForUser()); $columns[] = sprintf('', $row->filterFormatted); $columns[] = sprintf('', number_format($row->success_reward_bonus)); $columns[] = sprintf('', number_format($row->fail_deduct_bonus)); $columns[] = sprintf('', $row->description); $columns[] = sprintf('', $claimAction); $table .= sprintf('%s', implode("", $columns)); } $table .= '
$columnNameLabel $columnIndexLabel $columnBeginTimeLabel $columnEndTimeLabel $columnTargetUserLabel $columnSuccessRewardLabel $columnFailDeductLabel $columnDescriptionDeductLabel $columnClaimLabel
%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 = <<