From 3d5ce35f5e2e4654ed2f1fe984b1105fac9b9e44 Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Sun, 18 Oct 2020 00:52:27 +0200 Subject: [PATCH] Show available vouchers in user view --- includes/model/User_model.php | 1 + includes/view/User_view.php | 11 ++++++++--- resources/lang/de_DE/default.po | 11 ++++++----- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/includes/model/User_model.php b/includes/model/User_model.php index 968dfa21..18febf73 100644 --- a/includes/model/User_model.php +++ b/includes/model/User_model.php @@ -254,6 +254,7 @@ function User_get_eligable_voucher_count($user) } $vouchers -= $user->state->got_voucher; + $vouchers = floor($vouchers); if ($vouchers < 0) { return 0; } diff --git a/includes/view/User_view.php b/includes/view/User_view.php index ab6e5b12..4810f2fd 100644 --- a/includes/view/User_view.php +++ b/includes/view/User_view.php @@ -766,14 +766,19 @@ function User_view_state_admin($freeloader, $user_source) . ''; } + $voucherCount = $user_source->state->got_voucher; + $availableCount = $voucherCount + User_get_eligable_voucher_count($user_source); + $availableCount = max($voucherCount, $availableCount); if ($user_source->state->got_voucher > 0) { - $voucherCount = $user_source->state->got_voucher; $state[] = '' . glyph('cutlery') - . _e('Got %s voucher', 'Got %s vouchers', $voucherCount, [$voucherCount]) + . __('Got %s of %s vouchers', [$voucherCount, $availableCount]) . ''; } else { - $state[] = '' . __('Got no vouchers') . ''; + $state[] = '' + . __('Got no vouchers') + . ($availableCount ? ' (' . __('out of %s', [$availableCount]) . ')' : '') + . ''; } return $state; diff --git a/resources/lang/de_DE/default.po b/resources/lang/de_DE/default.po index 55c0ad5b..6b0461e7 100644 --- a/resources/lang/de_DE/default.po +++ b/resources/lang/de_DE/default.po @@ -2703,14 +2703,15 @@ msgstr "Nicht angekommen (Geplant: %s)" #: includes/view/User_view.php:753 #, php-format -msgid "Got %s voucher" -msgid_plural "Got %s vouchers" -msgstr[0] "Einen Gutschein bekommen" -msgstr[1] "%s Gutscheine bekommen" +msgid "Got %s of %s vouchers" +msgstr "%s von %s Gutscheinen bekommen" #: includes/view/User_view.php:756 msgid "Got no vouchers" -msgstr "Gutschein nicht bekommen" +msgstr "Keine Gutscheine bekommen" + +msgid "out of %s" +msgstr "von %s" #: includes/view/User_view.php:797 msgid "Rights"