diff --git a/db/migrations/2023_08_07_000000_add_ifsg_cerificates_to_users_licenses.php b/db/migrations/2023_08_07_000000_add_ifsg_cerificates_to_users_licenses.php index 067c51c8..f3642ef3 100644 --- a/db/migrations/2023_08_07_000000_add_ifsg_cerificates_to_users_licenses.php +++ b/db/migrations/2023_08_07_000000_add_ifsg_cerificates_to_users_licenses.php @@ -17,8 +17,8 @@ class AddIfsgCerificatesToUsersLicenses extends Migration public function up(): void { $this->schema->table('users_licenses', function (Blueprint $table): void { - $table->boolean('ifsg_certificate')->default(false)->after('drive_12t'); - $table->boolean('ifsg_certificate_full')->default(false)->after('ifsg_certificate'); + $table->boolean('ifsg_certificate_light')->default(false)->after('drive_12t'); + $table->boolean('ifsg_certificate')->default(false)->after('ifsg_certificate_light'); }); } @@ -28,8 +28,8 @@ class AddIfsgCerificatesToUsersLicenses extends Migration public function down(): void { $this->schema->table('users_licenses', function (Blueprint $table): void { + $table->dropColumn('ifsg_certificate_light'); $table->dropColumn('ifsg_certificate'); - $table->dropColumn('ifsg_certificate_full'); }); } } diff --git a/includes/controller/user_driver_licenses_controller.php b/includes/controller/user_driver_licenses_controller.php index fb1357cc..07909357 100644 --- a/includes/controller/user_driver_licenses_controller.php +++ b/includes/controller/user_driver_licenses_controller.php @@ -35,7 +35,7 @@ function user_ifsg_certificate_required_hint() $user = auth()->user(); // User has already entered data, no hint needed. - if ($user->license->ifsg) { + if (!config('ifsg_enabled') || $user->license->ifsg_light || $user->license->ifsg) { return null; } diff --git a/includes/view/AngelTypes_view.php b/includes/view/AngelTypes_view.php index 044a5b93..f268f137 100644 --- a/includes/view/AngelTypes_view.php +++ b/includes/view/AngelTypes_view.php @@ -173,7 +173,7 @@ function AngelType_view_buttons( icon('person-vcard') . __('my driving license') ); } - if ($angeltype->requires_ifsg_certificate) { + if (config('isfg_enabled') && $angeltype->requires_ifsg_certificate) { $buttons[] = button( url('/settings/certificates'), icon('card-checklist') . __('angeltype.ifsg.own') @@ -191,7 +191,7 @@ function AngelType_view_buttons( error(__('This angeltype requires a driver license. Please enter your driver license information!')); } - if ($angeltype->requires_ifsg_certificate && !$user->license->ifsg_certificate) { + if (config('ifsg_enabled') && $angeltype->requires_ifsg_certificate && (!$user->license->ifsg_certificate_light || !$user->license->ifsg_certificate)) { error(__('angeltype.ifsg.required.info')); } diff --git a/includes/view/User_view.php b/includes/view/User_view.php index cdb4fa2d..8f1e8c43 100644 --- a/includes/view/User_view.php +++ b/includes/view/User_view.php @@ -565,7 +565,7 @@ function User_view( user_driver_license_edit_link($user_source), icon('person-vcard') . __('driving license') ) : '', - config('ifsg_enabled') && ($admin_user_privilege || ($its_me && $needs_drivers_license)) ? button( + config('ifsg_enabled') && ($admin_user_privilege || ($its_me && $needs_ifsg_certificate)) ? button( page_link_to('settings/certificates'), icon('card-checklist') . __('ifsg.certificate') ) : '', diff --git a/resources/lang/de_DE/default.po b/resources/lang/de_DE/default.po index b17e376a..5d501ff3 100644 --- a/resources/lang/de_DE/default.po +++ b/resources/lang/de_DE/default.po @@ -2213,10 +2213,10 @@ msgstr "Zertifikate" msgid "settings.certificates.info" msgstr "Hier kannst du deine gemachte Gesundheitsbelehrung eintragen" -msgid "settings.ifsg" +msgid "settings.ifsg_light" msgstr "Ich wurde vor Ort nach IfSG §43 (Frikadellendiplom light) belehrt." -msgid "settings.ifsg_full" +msgid "settings.ifsg" msgstr "Ich habe eine Belehrung nach §43 IfSG (Frikadellendiplom) bei meinem Gesundheitsamt " "erhalten und innerhalb von 3 Monaten die Zweitbelehrung durch uns oder meinen Arbeitgeber/Koch/Verein bekommen. " "Zusätzlich ist die Zweitbelehrung nicht älter als zwei Jahre." diff --git a/resources/lang/en_US/default.po b/resources/lang/en_US/default.po index 230154eb..4c901a2f 100644 --- a/resources/lang/en_US/default.po +++ b/resources/lang/en_US/default.po @@ -314,10 +314,10 @@ msgstr "Certificates" msgid "settings.certificates.info" msgstr "Here you can enter your health instruction" -msgid "settings.ifsg" +msgid "settings.ifsg_light" msgstr "I was instructed about IfSG §43 (aka Frikadellendiplom light) on site." -msgid "settings.ifsg_full" +msgid "settings.ifsg" msgstr "I have gotten the instruction about §43 IfSG (aka Frikadellendiplom) from my Health Department " "and a second instruction from us or my employer/chef/assosiation within 3 months. " "Additionally my second instruction is not older than 2 years." diff --git a/resources/views/pages/settings/certificates.twig b/resources/views/pages/settings/certificates.twig index 2a7535e7..cc126b96 100644 --- a/resources/views/pages/settings/certificates.twig +++ b/resources/views/pages/settings/certificates.twig @@ -11,12 +11,12 @@
{{ m.info(__('settings.certificates.info')) }} + {{ f.checkbox('ifsg_certificate_light', __('settings.ifsg_light'), { + 'checked': ifsg_certificate_light, + }) }} {{ f.checkbox('ifsg_certificate', __('settings.ifsg'), { 'checked': ifsg_certificate, }) }} - {{ f.checkbox('ifsg_certificate_full', __('settings.ifsg_full'), { - 'checked': ifsg_certificate_full, - }) }} {{ f.submit(__('form.save')) }}
diff --git a/src/Controllers/Metrics/Controller.php b/src/Controllers/Metrics/Controller.php index 4962d12f..c23bd7e4 100644 --- a/src/Controllers/Metrics/Controller.php +++ b/src/Controllers/Metrics/Controller.php @@ -83,8 +83,8 @@ class Controller extends BaseController ['labels' => ['type' => '3.5t'], 'value' => $this->stats->licenses('3.5t')], ['labels' => ['type' => '7.5t'], 'value' => $this->stats->licenses('7.5t')], ['labels' => ['type' => '12t'], 'value' => $this->stats->licenses('12t')], + ['labels' => ['type' => 'ifsg_light'], 'value' => $this->stats->licenses('ifsg_light')], ['labels' => ['type' => 'ifsg'], 'value' => $this->stats->licenses('ifsg')], - ['labels' => ['type' => 'ifsg_full'], 'value' => $this->stats->licenses('ifsg_full')], ], 'users_email' => [ 'type' => 'gauge', diff --git a/src/Controllers/Metrics/Stats.php b/src/Controllers/Metrics/Stats.php index 098d6b7a..be58c40f 100644 --- a/src/Controllers/Metrics/Stats.php +++ b/src/Controllers/Metrics/Stats.php @@ -183,8 +183,8 @@ class Stats '3.5t' => 'drive_3_5t', '7.5t' => 'drive_7_5t', '12t' => 'drive_12t', - 'ifsg' => 'ifsg_certificate', - 'ifsg_full' => 'ifsg_certificate_full', + 'ifsg_light' => 'ifsg_certificate_light', + 'ifsg' => 'ifsg_certificate', ]; $query = (new License()) diff --git a/src/Controllers/SettingsController.php b/src/Controllers/SettingsController.php index 75e5fc07..b84b0891 100644 --- a/src/Controllers/SettingsController.php +++ b/src/Controllers/SettingsController.php @@ -234,8 +234,8 @@ class SettingsController extends BaseController 'pages/settings/certificates', [ 'settings_menu' => $this->settingsMenu(), + 'ifsg_certificate_light' => $user->license->ifsg_certificate_light, 'ifsg_certificate' => $user->license->ifsg_certificate, - 'ifsg_certificate_full' => $user->license->ifsg_certificate_full, ] ); } @@ -244,16 +244,16 @@ class SettingsController extends BaseController { $user = $this->auth->user(); $data = $this->validate($request, [ + 'ifsg_certificate_light' => 'optional|checked', 'ifsg_certificate' => 'optional|checked', - 'ifsg_certificate_full' => 'optional|checked', ]); if (!config('ifsg_enabled')) { throw new HttpNotFound('ifsg.disabled'); } - $user->license->ifsg_certificate = $data['ifsg_certificate'] || $data['ifsg_certificate_full']; - $user->license->ifsg_certificate_full = (bool) $data['ifsg_certificate_full']; + $user->license->ifsg_certificate_light = !$data['ifsg_certificate'] && $data['ifsg_certificate_light']; + $user->license->ifsg_certificate = (bool) $data['ifsg_certificate']; $user->license->save(); $this->addNotification('settings.certificates.success'); @@ -292,7 +292,7 @@ class SettingsController extends BaseController $menu[url('/settings/theme')] = 'settings.theme'; } - if (config('ifsg_enable')) { + if (config('ifsg_enabled')) { $menu[url('/settings/certificates')] = 'settings.certificates'; } diff --git a/src/Models/User/License.php b/src/Models/User/License.php index e955345e..19aecbeb 100644 --- a/src/Models/User/License.php +++ b/src/Models/User/License.php @@ -31,14 +31,14 @@ class License extends HasUserModel /** @var array Default attributes */ protected $attributes = [ // phpcs:ignore - 'has_car' => false, - 'drive_forklift' => false, - 'drive_car' => false, - 'drive_3_5t' => false, - 'drive_7_5t' => false, - 'drive_12t' => false, - 'ifsg_certificate' => false, - 'ifsg_certificate_full' => false, + 'has_car' => false, + 'drive_forklift' => false, + 'drive_car' => false, + 'drive_3_5t' => false, + 'drive_7_5t' => false, + 'drive_12t' => false, + 'ifsg_certificate_light' => false, + 'ifsg_certificate' => false, ]; /** @@ -54,20 +54,20 @@ class License extends HasUserModel 'drive_3_5t', 'drive_7_5t', 'drive_12t', + 'ifsg_certificate_light', 'ifsg_certificate', - 'ifsg_certificate_full', ]; /** @var array */ protected $casts = [ // phpcs:ignore - 'has_car' => 'boolean', - 'drive_forklift' => 'boolean', - 'drive_car' => 'boolean', - 'drive_3_5t' => 'boolean', - 'drive_7_5t' => 'boolean', - 'drive_12t' => 'boolean', - 'ifsg_certificate' => 'boolean', - 'ifsg_certificate_full' => 'boolean', + 'has_car' => 'boolean', + 'drive_forklift' => 'boolean', + 'drive_car' => 'boolean', + 'drive_3_5t' => 'boolean', + 'drive_7_5t' => 'boolean', + 'drive_12t' => 'boolean', + 'ifsg_certificate_light' => 'boolean', + 'ifsg_certificate' => 'boolean', ]; /** diff --git a/tests/Unit/Controllers/Metrics/ControllerTest.php b/tests/Unit/Controllers/Metrics/ControllerTest.php index 84350e95..c9240371 100644 --- a/tests/Unit/Controllers/Metrics/ControllerTest.php +++ b/tests/Unit/Controllers/Metrics/ControllerTest.php @@ -88,7 +88,7 @@ class ControllerTest extends TestCase $stats->expects($this->exactly(8)) ->method('licenses') - ->withConsecutive(['has_car'], ['forklift'], ['car'], ['3.5t'], ['7.5t'], ['12t'], ['ifsg'], ['ifsg_full']) + ->withConsecutive(['has_car'], ['forklift'], ['car'], ['3.5t'], ['7.5t'], ['12t'], ['ifsg_light'], ['ifsg']) ->willReturnOnConsecutiveCalls(6, 3, 15, 9, 7, 1, 5, 4); $stats->expects($this->exactly(2)) ->method('arrivedUsers') diff --git a/tests/Unit/Controllers/Metrics/StatsTest.php b/tests/Unit/Controllers/Metrics/StatsTest.php index 737e265c..5d691216 100644 --- a/tests/Unit/Controllers/Metrics/StatsTest.php +++ b/tests/Unit/Controllers/Metrics/StatsTest.php @@ -142,8 +142,8 @@ class StatsTest extends TestCase $this->assertEquals(0, $stats->licenses('3.5t')); $this->assertEquals(0, $stats->licenses('7.5t')); $this->assertEquals(1, $stats->licenses('12t')); + $this->assertEquals(0, $stats->licenses('ifsg_light')); $this->assertEquals(0, $stats->licenses('ifsg')); - $this->assertEquals(0, $stats->licenses('ifsg_full')); } /**