<script setup>
const props = defineProps({
    event: Object
})
</script>

<template>
    <h2>Übersicht</h2>
    <div class="participant-flexbox">
        <div class="participant-flexbox-row top">
            <div class="left">
                <h3>Teilnehmende</h3>
                <table class="participant-income-table" style="margin-bottom: 40px; font-size: 11pt;">
                    <tr>
                        <th>Teili</th>
                        <td><strong>{{props.event.participants.participant.count}} Personen:</strong></td>
                        <td>
                            {{props.event.participants.participant.amount.paid.readable}} /
                        </td>
                        <td>
                            {{props.event.participants.participant.amount.expected.readable}}
                        </td>
                    </tr>

                    <tr>
                        <th>Team</th>
                        <td><strong>{{props.event.participants.team.count}} Personen:</strong></td>
                        <td>
                            {{props.event.participants.team.amount.paid.readable}} /
                        </td>
                        <td>
                            {{props.event.participants.team.amount.expected.readable}}
                        </td>
                    </tr>

                    <tr>
                        <th>Unterstützende</th>
                        <td><strong>{{props.event.participants.volunteer.count}} Personen:</strong></td>
                        <td>
                            {{props.event.participants.volunteer.amount.paid.readable}} /
                        </td>
                        <td>
                            {{props.event.participants.volunteer.amount.expected.readable}}
                        </td>
                    </tr>

                    <tr>
                        <th>Sonstige</th>
                        <td><strong>{{props.event.participants.other.count}} Personen:</strong></td>
                        <td>
                            {{props.event.participants.other.amount.paid.readable}} /
                        </td>
                        <td>
                            {{props.event.participants.other.amount.expected.readable}}
                        </td>
                    </tr>

                    <tr>
                        <th colspan="2">Sonstige Einnahmen</th>
                        <td colspan="2">{{ props.event.flatSupport }}</td>
                    </tr>

                    <tr>
                        <th style="padding-bottom: 20px" colspan="2">Förderung</th>
                        <td style="padding-bottom: 20px" colspan="2">
                            {{ props.event.supportPerson.readable }}<br />
                            <label style="font-size: 9pt;">({{ props.event.supportPersonValue }} / Tag p.P.)</label>
                        </td>
                    </tr>

                    <tr>
                        <th colspan="2" style="border-width: 1px; border-top-style: solid">Gesamt</th>
                        <td style="font-weight: bold; border-width: 1px; border-top-style: solid">
                            {{ props.event.income.real.readable }} /
                        </td>

                        <td style="font-weight: bold; border-width: 1px; border-top-style: solid">
                            {{ props.event.income.expected.readable }}
                        </td>
                    </tr>

                    <tr>
                        <th style="padding-top: 20px; font-size: 12pt !important;" colspan="2">Bilanz</th>
                        <td v-if="props.event.totalBalance.real.value >= 0" style="color: #4caf50;font-weight: bold; padding-top: 20px; font-size: 12pt !important;">
                            {{ props.event.totalBalance.real.readable }} /
                        </td>
                        <td v-else style="color: #f44336; font-weight: bold; padding-top: 20px; font-size: 12pt !important;">
                            {{props.event.totalBalance.real.readable}}
                        </td>

                        <td v-if="props.event.totalBalance.expected.value >= 0" style="color: #4caf50; font-weight: bold; padding-top: 20px; font-size: 12pt !important;">
                            {{ props.event.totalBalance.expected.readable }}
                        </td>
                        <td v-else style="color: #f44336; font-weight: bold; padding-top: 20px; font-size: 12pt !important;">
                            {{props.event.totalBalance.expected.readable}}
                        </td>
                    </tr>

                    <tr>
                        <th style="padding-top: 20px; font-size: 12pt !important;" colspan="2">Budget</th>
                        <td v-if="props.event.totalBalance.estimated.value >= 0" style="color: #4caf50; font-weight: bold; padding-top: 20px; font-size: 12pt !important;">
                            {{ props.event.totalBalance.estimated.readable }}
                        </td>
                        <td v-else style="color: #f44336; font-weight: bold; padding-top: 20px; font-size: 12pt !important;">
                            {{props.event.totalBalance.estimated.readable}}
                        </td>
                    </tr>

                </table>
            </div>

            <div class="right">
                <h3>Ausgaben</h3>
                <table class="event-payment-table" style="font-size: 10pt; width:100%">
                    <tr v-for="amount in props.event.costUnit.amounts">
                        <th>{{amount.name}}</th>
                        <td>{{amount.string}}</td>
                        <td>({{ amount.estimatedString }}) </td>
                    </tr>
                    <tr>
                        <th style="color:#f44336; border-width: 1px; border-top-style: solid; ">Gesamt</th>
                        <td style="color:#f44336; border-width: 1px; border-top-style: solid; font-weight: bold; padding-right: 20px;">{{props.event.costUnit.overAllAmount.text}}</td>
                        <td style="color:#f44336; border-width: 1px; border-top-style: solid; font-weight: bold">({{props.event.costUnit.overAllEstimatedAmount.text}}))</td>
                    </tr>
                </table>
            </div>
        </div>

    </div>
</template>

<style scoped>
.participant-flexbox {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 95%;
    margin: 20px auto 0;
}

.participant-flexbox-row {
    display: flex;
    flex: 1 1;
    flex-wrap: wrap;
}

.participant-flexbox-row.top .left,
.participant-flexbox-row.top .right {

    padding: 20px;
    min-width: 0;
}

.participant-income-table,
.event-payment-table {
    width: 100%;
    max-width: 475px;
    table-layout: auto;
}

.participant-income-table th {
    width: 20px;
    font-size: 11pt !important;
}

.participant-income-table tr td:first-child {
    width: 50px;
}

.participant-income-table tr td:first-child {
    width: 25px !important;
    font-size: 10pt;
}

.event-payment-table th {
    width: 50px;
}

</style>
