mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 03:57:22 +08:00
bonus logs
This commit is contained in:
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
require "../include/bittorrent.php";
|
||||
dbconn();
|
||||
loggedinorreturn();
|
||||
$uid = $_REQUEST['uid'] ?? $CURUSER['id'] ?? 0;
|
||||
int_check($uid,true);
|
||||
$user = \App\Models\User::query()->where('id', $uid)->first(\App\Models\User::$commonFields);
|
||||
if (!$user) {
|
||||
stderr("Error", "Invalid uid: $uid");
|
||||
}
|
||||
if ($uid != $CURUSER['id']) {
|
||||
user_can(\App\Enums\Permission\PermissionEnum::VIEW_USER_HISTORY->value, true, $CURUSER['id']);
|
||||
}
|
||||
$isRecordSeedingBonusLog = \App\Models\Setting::getIsRecordSeedingBonusLog();
|
||||
$defaultCategory = \App\Models\BonusLogs::CATEGORY_COMMON;
|
||||
$category = $_REQUEST['category'] ?? $defaultCategory;
|
||||
$categoryOptions = \App\Models\BonusLogs::listCategoryOptions($isRecordSeedingBonusLog);
|
||||
if (!isset($categoryOptions[$category])) {
|
||||
stderr("Error", "Invalid category: $category");
|
||||
}
|
||||
$businessType = $_REQUEST['business_type'] ?? 0;
|
||||
$businessTypeOptions = \App\Models\BonusLogs::listBusinessTypeOptions($isRecordSeedingBonusLog ? '' : $defaultCategory);
|
||||
if ($businessType && !isset($businessTypeOptions[$businessType])) {
|
||||
stderr("Error", "Invalid business_type: $businessType");
|
||||
}
|
||||
|
||||
stdhead(nexus_trans('bonus-log.title_for_user'));
|
||||
$pagerParam = "?uid=$uid&category=$category&business_type=$businessType";
|
||||
print("<h1 align=center>".nexus_trans('bonus-log.title_for_user') . "<a href=userdetails.php?id=" . htmlspecialchars($uid) . "><b> ".htmlspecialchars($user->username)."</b></a></h1>");
|
||||
|
||||
$textSelectOnePlease = nexus_trans('nexus.select_one_please');
|
||||
$categoryOptionsText = $businessTypeOptionsText = '';
|
||||
foreach ($categoryOptions as $name => $text) {
|
||||
$categoryOptionsText .= sprintf(
|
||||
'<option value="%s"%s>%s</option>',
|
||||
$name, isset($_REQUEST['category']) && $_REQUEST['category'] == $name ? ' selected' : '', $text
|
||||
);
|
||||
}
|
||||
foreach ($businessTypeOptions as $name => $text) {
|
||||
$businessTypeOptionsText .= sprintf(
|
||||
'<option value="%s"%s>%s</option>',
|
||||
$name, isset($_REQUEST['business_type']) && $_REQUEST['business_type'] == $name ? ' selected' : '', $text
|
||||
);
|
||||
}
|
||||
|
||||
$resetText = nexus_trans('label.reset');
|
||||
$submitText = nexus_trans('label.submit');
|
||||
$categoryText = nexus_trans('bonus-log.category');
|
||||
$businessTypeText = nexus_trans('bonus-log.fields.business_type');
|
||||
$filterForm = <<<FORM
|
||||
<div>
|
||||
<form id="filterForm" action="{$_SERVER['REQUEST_URI']}" method="get">
|
||||
<input type="hidden" name="uid" value="{$uid}" />
|
||||
<span>{$categoryText}:</span>
|
||||
<select name="category">
|
||||
{$categoryOptionsText}
|
||||
</select>
|
||||
|
||||
<span>{$businessTypeText}:</span>
|
||||
<select name="business_type">
|
||||
<option value="0">-{$textSelectOnePlease}-</option>
|
||||
{$businessTypeOptionsText}
|
||||
</select>
|
||||
|
||||
<input type="submit" value="{$submitText}">
|
||||
<input type="button" id="reset" value="{$resetText}">
|
||||
</form>
|
||||
</div>
|
||||
FORM;
|
||||
$resetJs = <<<JS
|
||||
jQuery("#reset").on('click', function () {
|
||||
jQuery("select[name=category]").val('')
|
||||
jQuery("select[name=business_type]").val('')
|
||||
})
|
||||
JS;
|
||||
\Nexus\Nexus::js($resetJs, 'footer', false);
|
||||
|
||||
$rep = new \App\Repositories\BonusRepository();
|
||||
$total = $rep->getCount($uid, $category, $businessType);
|
||||
list($pagertop, $pagerbottom, $limit, $offset, $pageSize, $page) = pager(50, $total, "$pagerParam&");
|
||||
$list = $rep->getList($uid, $category, $businessType, $page + 1, $pageSize);
|
||||
begin_main_frame();
|
||||
print($filterForm);
|
||||
print("<table id='bonus-log-table' width='100%' cellpadding='5'>");
|
||||
print("<tr>
|
||||
<td class='colhead' align='left'>".nexus_trans('bonus-log.fields.business_type')."</td>
|
||||
<td class='colhead' align='left'>".nexus_trans('bonus-log.fields.old_total_value')."</td>
|
||||
<td class='colhead' align='left'>".nexus_trans('bonus-log.fields.value')."</td>
|
||||
<td class='colhead' align='left'>".nexus_trans('bonus-log.fields.new_total_value')."</td>
|
||||
<td class='colhead' align='left'>".nexus_trans('label.comment')."</td>
|
||||
<td class='colhead' align='left'>".nexus_trans('label.created_at')."</td>
|
||||
</tr>");
|
||||
foreach ($list as $row) {
|
||||
print("<tr>
|
||||
<td class='rowfollow nowrap' align='left'>" . $row->businessTypeText . "</td>
|
||||
<td class='rowfollow nowrap' align='left'>" . ($row->old_total_value > 0 ? number_format($row->old_total_value, 1) : '-') . "</td>
|
||||
<td class='rowfollow nowrap' align='left'>" . ($row->old_total_value < $row->new_total_value ? "+" . number_format($row->value, 1) : "-" . number_format($row->value, 1)) . "</td>
|
||||
<td class='rowfollow nowrap' align='left'>" . ($row->new_total_value > 0 ? number_format($row->new_total_value, 1) : '-') . "</td>
|
||||
<td class='rowfollow nowrap' align='left'>" . $row->comment . "</td>
|
||||
<td class='rowfollow nowrap' align='left'>" . $row->created_at . "</td>
|
||||
</tr>");
|
||||
}
|
||||
|
||||
print("</table>");
|
||||
print($pagerbottom);
|
||||
end_main_frame();
|
||||
stdfoot();
|
||||
|
||||
|
||||
+1
-1
@@ -115,7 +115,7 @@ if ($sort == 'seed_time') {
|
||||
}
|
||||
$list = $query->selectRaw("claims.*")->get();
|
||||
print($filterForm);
|
||||
print("<table id='claim-table' width='100%'>");
|
||||
print("<table id='claim-table' width='100%' cellpadding='5'>");
|
||||
print("<tr>
|
||||
<td class='colhead' align='center'>".nexus_trans('claim.th_id')."</td>
|
||||
<td class='colhead' align='center'>".nexus_trans('claim.th_username')."</td>
|
||||
|
||||
@@ -400,7 +400,8 @@ if ($user["id"] == $CURUSER["id"] || user_can('viewhistory')) {
|
||||
$states = (new \App\Repositories\ClaimRepository())->getStats($user['id']);
|
||||
tr_small($lang_functions['menu_claim'], sprintf('<a href="claim.php?uid=%s" target="_blank">%s</a>', $user['id'], $states), 1);
|
||||
}
|
||||
tr_small($lang_userdetails['row_karma_points'], number_format($user['seedbonus'], 1), 1);
|
||||
$bonusLogText = sprintf(' <a href="bonus-log.php?uid=%s" target="_blank" class="altlink">[%s]</a>', $user['id'], nexus_trans("bonus-log.view_detail"));
|
||||
tr_small($lang_userdetails['row_karma_points'], number_format($user['seedbonus'], 1) . $bonusLogText, 1);
|
||||
tr_small($lang_functions['text_seed_points'], number_format($user['seed_points'], 1) . " <span class='text-muted'>(" . nexus_trans('label.updated_at') . ": " . $user['seed_points_updated_at'] . ")</span>", 1);
|
||||
}
|
||||
|
||||
@@ -511,7 +512,7 @@ if (user_can('prfmanage') && $user["class"] < get_user_class())
|
||||
tr($lang_userdetails['row_comment'], "<textarea cols=\"60\" rows=\"6\" name=\"modcomment\">".$modcomment."</textarea>", 1);
|
||||
$bonuscomment = \App\Models\BonusLogs::query()
|
||||
->where("uid", $user["id"])
|
||||
->whereNotIn("business_type", \App\Models\BonusLogs::$businessTypeBonus)
|
||||
->whereNotIn("business_type", \App\Models\BonusLogs::$businessTypeSeeding)
|
||||
->orderBy("id", "desc")
|
||||
->limit(20)
|
||||
->get()
|
||||
|
||||
Reference in New Issue
Block a user