fix hr pager & format uploaded/downloaded change value

This commit is contained in:
xiaomlove
2022-05-12 01:35:01 +08:00
parent c5ace7df67
commit cd7de04e6c
2 changed files with 8 additions and 6 deletions
+7 -5
View File
@@ -224,9 +224,11 @@ class UserRepository extends BaseRepository
$targetUser = User::query()->findOrFail($uid, User::$commonFields); $targetUser = User::query()->findOrFail($uid, User::$commonFields);
$old = $targetUser->{$sourceField}; $old = $targetUser->{$sourceField};
$valueAtomic = $value; $valueAtomic = $value;
$formatSize = false;
if (in_array($field, ['uploaded', 'downloaded'])) { if (in_array($field, ['uploaded', 'downloaded'])) {
//Frontend unit: GB //Frontend unit: GB
$valueAtomic = $value * 1024 * 1024 * 1024; $valueAtomic = $value * 1024 * 1024 * 1024;
$formatSize = true;
} }
if ($action == 'Increment') { if ($action == 'Increment') {
$new = $old + abs($valueAtomic); $new = $old + abs($valueAtomic);
@@ -239,12 +241,12 @@ class UserRepository extends BaseRepository
$modCommentText = nexus_trans('message.field_value_change_message_body', [ $modCommentText = nexus_trans('message.field_value_change_message_body', [
'field' => nexus_trans("user.labels.$sourceField", [], 'en'), 'field' => nexus_trans("user.labels.$sourceField", [], 'en'),
'operator' => $operator->username, 'operator' => $operator->username,
'old' => $old, 'old' => $formatSize ? mksize($old) : $old,
'new' => $new, 'new' => $formatSize ? mksize($new) : $new,
'reason' => $reason, 'reason' => $reason,
], 'en'); ], 'en');
$modCommentText = date('Y-m-d') . " - $modCommentText"; $modCommentText = date('Y-m-d') . " - $modCommentText";
do_log("user: $uid, $modCommentText"); do_log("user: $uid, $modCommentText", 'alert');
$update = [ $update = [
$sourceField => $new, $sourceField => $new,
'modcomment' => NexusDB::raw("if(modcomment = '', '$modCommentText', concat_ws('\n', '$modCommentText', modcomment))"), 'modcomment' => NexusDB::raw("if(modcomment = '', '$modCommentText', concat_ws('\n', '$modCommentText', modcomment))"),
@@ -255,8 +257,8 @@ class UserRepository extends BaseRepository
$msg = nexus_trans('message.field_value_change_message_body', [ $msg = nexus_trans('message.field_value_change_message_body', [
'field' => $fieldLabel, 'field' => $fieldLabel,
'operator' => $operator->username, 'operator' => $operator->username,
'old' => $old, 'old' => $formatSize ? mksize($old) : $old,
'new' => $new, 'new' => $formatSize ? mksize($new) : $new,
'reason' => $reason, 'reason' => $reason,
], $locale); ], $locale);
$message = [ $message = [
+1 -1
View File
@@ -40,7 +40,7 @@ print $filterForm;
$baseQuery = \App\Models\HitAndRun::query()->where('uid', $userid)->where('status', $status); $baseQuery = \App\Models\HitAndRun::query()->where('uid', $userid)->where('status', $status);
$rescount = (clone $baseQuery)->count(); $rescount = (clone $baseQuery)->count();
list($pagertop, $pagerbottom, $limit, $offset, $pageSize) = pager(50, $rescount, "?status=$status"); list($pagertop, $pagerbottom, $limit, $offset, $pageSize) = pager(50, $rescount, "?status=$status&");
print("<table width='100%'>"); print("<table width='100%'>");
print("<tr> print("<tr>
<td class='colhead' align='center'>{$lang_myhr['th_hr_id']}</td> <td class='colhead' align='center'>{$lang_myhr['th_hr_id']}</td>