<?php

namespace App\Installer;

use App\Enumerations\CostUnitType;
use App\Enumerations\CronTaskType;
use App\Enumerations\EatingHabit;
use App\Enumerations\EfzStatus;
use App\Enumerations\FirstAidPermission;
use App\Enumerations\InvoiceStatus;
use App\Enumerations\InvoiceType;
use App\Enumerations\ParticipationFeeType;
use App\Enumerations\ParticipationType;
use App\Enumerations\PaymentStatus;
use App\Enumerations\SwimmingPermission;
use App\Enumerations\UserRole;
use App\EventPaymentModules\EventPaymentModuleRegistry;
use App\Models\CronTask;
use App\Models\PaymentMethod;
use App\Models\Tenant;

class ProductionDataSeeder {
    public function execute() {
        $this->installCronTypes();
        $this->installUserRoles();
        $this->installCostUnitTypes();
        $this->installSwimmingPermissions();
        $this->installEatingHabits();
        $this->installFirstAidPermissions();
        $this->installInvoiceMetaData();
        $this->installParticipationFeeTypes();
        $this->installParticipationTypes();
        $this->installEfzStatus();
        $this->installPaymentMethods();
        $this->installPaymentStatus();
    }

    private function installPaymentStatus() {
        PaymentStatus::create(['slug' => PaymentStatus::PAYMENT_STATUS_PENDING]);
        PaymentStatus::create(['slug' => PaymentStatus::PAYMENT_STATUS_SCHEDULED]);
        PaymentStatus::create(['slug' => PaymentStatus::PAYMENT_STATUS_PAID]);
        PaymentStatus::create(['slug' => PaymentStatus::PAYMENT_STATUS_FAILED]);
    }

    private function installPaymentMethods() {
        foreach (EventPaymentModuleRegistry::slugs() as $slug) {
            PaymentMethod::create(['slug' => $slug]);
        }
    }

    private function installEfzStatus() {
        EfzStatus::create(['slug' => EfzStatus::EFZ_STATUS_NOT_CHECKED, 'name' => 'Nicht geprüft']);
        EfzStatus::create(['slug' => EfzStatus::EFZ_STATUS_NOT_REQUIRED, 'name' => 'Nicht erforderlich']);
        EfzStatus::create(['slug' => EfzStatus::EFZ_STATUS_CHECKED_VALID, 'name' => 'Gültig']);
        EfzStatus::create(['slug' => EfzStatus::EFZ_STATUS_CHECKED_INVALID, 'name' => 'Nicht eingereicht']);
    }

    private function installParticipationTypes() {
        ParticipationType::create([
            'slug' => ParticipationType::PARTICIPATION_TYPE_PARTICIPANT,
            'name' => 'Teilnehmende'
        ]);

        ParticipationType::create([
            'slug' => ParticipationType::PARTICIPATION_TYPE_TEAM,
            'name' => 'Kernteam'
        ]);

        ParticipationType::create([
            'slug' => ParticipationType::PARTICIPATION_TYPE_VOLUNTEER,
            'name' => 'Unterstützende'
        ]);

        ParticipationType::create([
            'slug' => ParticipationType::PARTICIPATION_TYPE_OTHER,
            'name' => 'Sonstige'
        ]);
    }

    private function installParticipationFeeTypes() {
        ParticipationFeeType::create(['slug' => ParticipationFeeType::PARTICIPATION_FEE_TYPE_SOLIDARITY, 'name' => 'Solidaritätsprinzip']);
        ParticipationFeeType::create(['slug' => ParticipationFeeType::PARTICIPATION_FEE_TYPE_FIXED, 'name' => 'Festpreis']);
    }

    private function installUserRoles() {
        UserRole::create(['name' => 'Administrator*in', 'slug' => UserRole::USER_ROLE_ADMIN]);
        UserRole::create(['name' => 'Vorstandsmitglied', 'slug' => UserRole::USER_ROLE_GROUP_LEADER]);
        UserRole::create(['name' => 'Benutzer*in', 'slug' => UserRole::USER_ROLE_USER]);
    }

    private function installSwimmingPermissions() {
        SwimmingPermission::create(['name' => 'Mein Kind darf baden und kann schwimmen', 'slug' => SwimmingPermission::SWIMMING_PERMISSION_ALLOWED, 'short' => 'Erteilt']);
        SwimmingPermission::create(['name' => 'Mein Kind darf baden und kann NICHT schwimmen', 'slug' => SwimmingPermission::SWIMMING_PERMISSION_LIMITED, 'short' => 'Nur Flachwasser']);
        SwimmingPermission::create(['name' => 'Mein Kind darf nicht baden', 'slug' => SwimmingPermission::SWIMMING_PERMISSION_DENIED, 'short' => 'Verweiger']);
    }

    private function installEatingHabits() {
        EatingHabit::create(['name' => 'Vegan', 'slug' => EatingHabit::EATING_HABIT_VEGAN]);
        EatingHabit::create(['name' => 'Vegetarisch', 'slug' => EatingHabit::EATING_HABIT_VEGETARIAN]);
        EatingHabit::create(['name' => 'Omnivor', 'slug' => EatingHabit::EATING_HABIT_OMNIVOR]);

    }
    private function installFirstAidPermissions() {
        FirstAidPermission::create([
            'name' => 'Zugestimmt',
            'description' => 'Ich STIMME der Anwendung von erweiteren Erste-Hilfe-Maßnahmen an meinem Kind explizit ZU.',
            'slug' => FirstAidPermission::FIRST_AID_PERMISSION_ALLOWED]);

        FirstAidPermission::create([
            'name' => 'Verweigert',
            'description' => 'Ich LEHNE die Anwendung von erweiteren Erste-Hilfe-Maßnahmen an meinem Kind explizit AB.',
            'slug' => FirstAidPermission::FIRST_AID_PERMISSION_DENIED]);
    }

    private function installCostUnitTypes() {
        CostUnitType::create(['slug' => CostUnitType::COST_UNIT_TYPE_EVENT, 'name' => 'Veranstaltung']);
        CostUnitType::create(['slug' => CostUnitType::COST_UNIT_TYPE_RUNNING_JOB, 'name' => 'Laufende Tätigkeit']);

    }



    private function installInvoiceMetaData() {
        InvoiceType::create([
            'slug' => InvoiceType::INVOICE_TYPE_TRAVELLING,
            'name' => 'Reisekosten'
        ]);

        InvoiceType::create([
            'slug' => InvoiceType::INVOICE_TYPE_PROGRAM,
            'name' => 'Programmkosten'
        ]);

        InvoiceType::create([
            'slug' => InvoiceType::INVOICE_TYPE_ACCOMMODATION,
            'name' => 'Unterkunftskosten'
        ]);

        InvoiceType::create([
            'slug' => InvoiceType::INVOICE_TYPE_CATERING,
            'name' => 'Verpflegungskosten',
        ]);

        InvoiceType::create([
            'slug' => InvoiceType::INVOICE_TYPE_OTHER,
            'name' => 'Sonstige Kosten'
        ]);

        InvoiceStatus::create(['slug' => InvoiceStatus::INVOICE_STATUS_NEW]);
        InvoiceStatus::create(['slug' => InvoiceStatus::INVOICE_STATUS_APPROVED]);
        InvoiceStatus::create(['slug' => InvoiceStatus::INVOICE_STATUS_EXPORTED]);
        InvoiceStatus::create(['slug' => InvoiceStatus::INVOICE_STATUS_DENIED]);
        InvoiceStatus::create(['slug' => InvoiceStatus::INVOICE_STATUS_DELETED]);
    }

    private function installCronTypes() {
        CronTaskType::create(['slug' => CronTaskType::CRON_TASK_TYPE_REALTIME]);
        CronTaskType::create(['slug' => CronTaskType::CRON_TASK_TYPE_DAILY]);
    }
}

