@model PlanTempus.Application.Features.Employees.Components.EmployeeDetailSalaryViewModel

<swp-detail-grid>
    <swp-card-column>
        <!-- Satser (Grundsatser) -->
        <swp-card>
            <swp-card-header>
                <swp-card-title>@Model.LabelRates</swp-card-title>
                <swp-section-action data-drawer-trigger="rates-drawer">@Model.LabelEdit</swp-section-action>
            </swp-card-header>
            <swp-edit-section>
                <swp-edit-row id="card-normal">
                    <swp-edit-label>@Model.LabelNormalRate</swp-edit-label>
                    <input type="text" id="value-normal" data-type="number" value="@Model.NormalRate" readonly>
                </swp-edit-row>
                <swp-edit-row id="card-overtime">
                    <swp-edit-label>@Model.LabelOvertimeRate</swp-edit-label>
                    <input type="text" id="value-overtime" data-type="number" value="@Model.OvertimeRate" readonly>
                </swp-edit-row>
                <swp-edit-row id="card-course" style="display: none;">
                    <swp-edit-label>@Model.LabelCourseRate</swp-edit-label>
                    <input type="text" id="value-course" data-type="number" value="" readonly>
                </swp-edit-row>
                <swp-edit-row id="card-timeoff" style="display: none;">
                    <swp-edit-label>@Model.LabelTimeOffRate</swp-edit-label>
                    <input type="text" id="value-timeoff" data-type="number" value="" readonly>
                </swp-edit-row>
                <swp-edit-row id="card-paidleave" style="display: none;">
                    <swp-edit-label>@Model.LabelPaidLeaveRate</swp-edit-label>
                    <input type="text" id="value-paidleave" data-type="number" value="" readonly>
                </swp-edit-row>
                <swp-edit-row id="card-vacation">
                    <swp-edit-label>@Model.LabelVacationRate</swp-edit-label>
                    <input type="text" id="value-vacation" data-type="number" value="@Model.VacationRateValue kr" readonly>
                </swp-edit-row>
                <swp-edit-row id="card-office" style="display: none;">
                    <swp-edit-label>@Model.LabelOfficeRate</swp-edit-label>
                    <input type="text" id="value-office" data-type="number" value="" readonly>
                </swp-edit-row>
                <swp-edit-row id="card-childsick" style="display: none;">
                    <swp-edit-label>@Model.LabelChildSickRate</swp-edit-label>
                    <input type="text" id="value-childsick" data-type="number" value="" readonly>
                </swp-edit-row>
                <swp-edit-row id="card-childhospital" style="display: none;">
                    <swp-edit-label>@Model.LabelChildHospitalRate</swp-edit-label>
                    <input type="text" id="value-childhospital" data-type="number" value="" readonly>
                </swp-edit-row>
                <swp-edit-row id="card-maternity" style="display: none;">
                    <swp-edit-label>@Model.LabelMaternityRate</swp-edit-label>
                    <input type="text" id="value-maternity" data-type="number" value="" readonly>
                </swp-edit-row>
            </swp-edit-section>
        </swp-card>

        <!-- Provision -->
        <swp-card>
            <swp-card-header>
                <swp-card-title>@Model.LabelCommission</swp-card-title>
            </swp-card-header>
            <swp-edit-section>
                <swp-edit-row id="card-productcommission">
                    <swp-edit-label>@Model.LabelProductCommission</swp-edit-label>
                    <input type="text" id="value-productcommission" data-type="number" value="@Model.ProductCommission" readonly>
                </swp-edit-row>
                <swp-edit-row id="card-servicecommission">
                    <swp-edit-label>@Model.LabelServiceCommission</swp-edit-label>
                    <input type="text" id="value-servicecommission" data-type="number" value="@Model.ServiceCommission" readonly>
                </swp-edit-row>
            </swp-edit-section>
        </swp-card>

        <!-- Tillaeg -->
        <swp-card>
            <swp-card-header>
                <swp-card-title>@Model.LabelSupplements</swp-card-title>
            </swp-card-header>
            <swp-edit-section>
                <swp-edit-row id="card-weekday">
                    <swp-edit-label>@Model.LabelWeekdaySupplement</swp-edit-label>
                    <input type="text" id="value-weekday" data-type="number" value="@Model.WeekdaySupplement" readonly>
                </swp-edit-row>
                <swp-edit-row id="card-saturday">
                    <swp-edit-label>@Model.LabelSaturdaySupplement</swp-edit-label>
                    <input type="text" id="value-saturday" data-type="number" value="@Model.SaturdaySupplement" readonly>
                </swp-edit-row>
                <swp-edit-row id="card-sunday">
                    <swp-edit-label>@Model.LabelSundaySupplement</swp-edit-label>
                    <input type="text" id="value-sunday" data-type="number" value="@Model.SundaySupplement" readonly>
                </swp-edit-row>
            </swp-edit-section>
        </swp-card>
    </swp-card-column>
</swp-detail-grid>

<!-- Loenspecifikationer (full width accordion) -->
<swp-card class="salary-specifications">
    <swp-card-header>
        <swp-card-title>@Model.LabelSpecifications</swp-card-title>
    </swp-card-header>
    <swp-accordion id="salary-specifications-accordion">
        @foreach (var spec in Model.Specifications)
        {
            <swp-accordion-item data-period="@spec.PeriodKey">
                <swp-accordion-header>
                    <swp-accordion-info>
                        <swp-accordion-title>@spec.Period</swp-accordion-title>
                        <swp-accordion-meta>@spec.Weeks.Sum(w => w.NormalHours + w.OvertimeHours)t</swp-accordion-meta>
                    </swp-accordion-info>
                    <swp-accordion-summary>
                        <swp-summary-item>
                            <swp-summary-value>@spec.GrossSalaryFormatted</swp-summary-value>
                            <swp-summary-label>@Model.LabelTotal</swp-summary-label>
                        </swp-summary-item>
                        <swp-accordion-toggle>
                            <i class="ph ph-caret-down"></i>
                        </swp-accordion-toggle>
                    </swp-accordion-summary>
                </swp-accordion-header>
                <swp-accordion-content>
                    <!-- Config row -->
                    <swp-config-row>
                        <swp-config-item>
                            <swp-config-label>@Model.LabelNormalRate:</swp-config-label>
                            <swp-config-value class="mono">@spec.Config.HourlyRateFormatted</swp-config-value>
                        </swp-config-item>
                        <swp-config-item>
                            <swp-config-label>@Model.LabelWeeklyNorm:</swp-config-label>
                            <swp-config-value>@spec.Config.WeeklyHoursFormatted</swp-config-value>
                        </swp-config-item>
                        <swp-config-item>
                            <swp-config-label>@Model.LabelOvertimeMultiplier:</swp-config-label>
                            <swp-config-value>@spec.Config.OvertimeFormatted</swp-config-value>
                        </swp-config-item>
                        <swp-config-item>
                            <swp-config-label>@Model.LabelMinimum:</swp-config-label>
                            <swp-config-value class="mono">@spec.Config.MinimumFormatted</swp-config-value>
                        </swp-config-item>
                        <swp-config-item>
                            <swp-config-label>@Model.LabelProvision:</swp-config-label>
                            <swp-config-value>@spec.Config.CommissionFormatted</swp-config-value>
                        </swp-config-item>
                    </swp-config-row>

                    <!-- Weeks table -->
                    <swp-accordion-table>
                        <swp-data-table class="specification-weeks">
                            <swp-data-table-header>
                                <swp-data-table-cell>@Model.LabelWeek</swp-data-table-cell>
                                <swp-data-table-cell>Timer</swp-data-table-cell>
                                <swp-data-table-cell>Overtid</swp-data-table-cell>
                                <swp-data-table-cell>Ferie</swp-data-table-cell>
                                <swp-data-table-cell>Services</swp-data-table-cell>
                                <swp-data-table-cell>Produkter</swp-data-table-cell>
                                <swp-data-table-cell>Minimum</swp-data-table-cell>
                                <swp-data-table-cell>Provision</swp-data-table-cell>
                                <swp-data-table-cell>I alt</swp-data-table-cell>
                            </swp-data-table-header>
                            @foreach (var week in spec.Weeks)
                            {
                                <swp-data-table-row>
                                    <swp-data-table-cell>Uge @week.WeekNumber</swp-data-table-cell>
                                    <swp-data-table-cell class="mono">@week.NormalHoursFormatted</swp-data-table-cell>
                                    <swp-data-table-cell class="mono @(week.HasOvertime ? "warning" : "")">@week.OvertimeHoursFormatted</swp-data-table-cell>
                                    <swp-data-table-cell class="mono">@week.VacationDaysFormatted</swp-data-table-cell>
                                    <swp-data-table-cell class="mono">@week.ServiceRevenueFormatted</swp-data-table-cell>
                                    <swp-data-table-cell class="mono">@week.ProductRevenueFormatted</swp-data-table-cell>
                                    <swp-data-table-cell class="mono">@week.MinimumThresholdFormatted</swp-data-table-cell>
                                    <swp-data-table-cell class="mono @(week.HasCommission ? "highlight" : "")">@week.CommissionFormatted</swp-data-table-cell>
                                    <swp-data-table-cell class="mono">@week.TotalPayFormatted</swp-data-table-cell>
                                </swp-data-table-row>
                            }
                            <swp-data-table-footer>
                                <swp-data-table-cell>TOTAL</swp-data-table-cell>
                                <swp-data-table-cell class="mono">@(spec.Weeks.Sum(w => w.NormalHours))t</swp-data-table-cell>
                                <swp-data-table-cell class="mono">@(spec.Weeks.Sum(w => w.OvertimeHours))t</swp-data-table-cell>
                                <swp-data-table-cell class="mono">@(spec.Weeks.Sum(w => w.VacationDays)) dg</swp-data-table-cell>
                                <swp-data-table-cell class="mono">@(spec.Weeks.Sum(w => w.ServiceRevenue).ToString("N0", System.Globalization.CultureInfo.GetCultureInfo("da-DK"))) kr</swp-data-table-cell>
                                <swp-data-table-cell class="mono">@(spec.Weeks.Sum(w => w.ProductRevenue).ToString("N0", System.Globalization.CultureInfo.GetCultureInfo("da-DK"))) kr</swp-data-table-cell>
                                <swp-data-table-cell class="mono">-</swp-data-table-cell>
                                <swp-data-table-cell class="mono">@(spec.Weeks.Sum(w => w.Commission).ToString("N2", System.Globalization.CultureInfo.GetCultureInfo("da-DK"))) kr</swp-data-table-cell>
                                <swp-data-table-cell class="mono">@(spec.Weeks.Sum(w => w.TotalPay).ToString("N2", System.Globalization.CultureInfo.GetCultureInfo("da-DK"))) kr</swp-data-table-cell>
                            </swp-data-table-footer>
                        </swp-data-table>
                    </swp-accordion-table>
                    <swp-accordion-footer>
                        <a href="/medarbejdere/loenspecifikation/@spec.PeriodKey" target="_blank" class="swp-btn secondary">
                            <i class="ph ph-file-text"></i>
                            Se lønberegning
                        </a>
                    </swp-accordion-footer>
                </swp-accordion-content>
            </swp-accordion-item>
        }
    </swp-accordion>
</swp-card>

<!-- Rates drawer -->
<div id="rates-drawer" data-drawer="lg">
    <swp-drawer-header>
        <swp-drawer-title>@Model.LabelRatesDrawerTitle</swp-drawer-title>
        <swp-drawer-close data-drawer-close>
            <i class="ph ph-x"></i>
        </swp-drawer-close>
    </swp-drawer-header>
    <swp-drawer-body class="rates-content">
        <!-- Grundsatser -->
        <swp-section-label>@Model.LabelBaseRates</swp-section-label>
        <swp-data-table>
            <swp-data-row>
                <input type="checkbox" id="rate-normal-enabled" checked>
                <swp-data-label>@Model.LabelNormalRate</swp-data-label>
                <swp-data-input><input type="text" id="rate-normal" value="@Model.NormalRateValue"> kr</swp-data-input>
            </swp-data-row>
            <swp-data-row>
                <input type="checkbox" id="rate-overtime-enabled" checked>
                <swp-data-label>@Model.LabelOvertimeRate</swp-data-label>
                <swp-data-input><input type="text" id="rate-overtime" value="@Model.OvertimeRateValue"> kr</swp-data-input>
            </swp-data-row>
            <swp-data-row>
                <input type="checkbox" id="rate-course-enabled">
                <swp-data-label class="disabled">@Model.LabelCourseRate</swp-data-label>
                <swp-data-input class="disabled"><input type="text" id="rate-course" value="@Model.CourseRateValue"> kr</swp-data-input>
            </swp-data-row>
            <swp-data-row>
                <input type="checkbox" id="rate-timeoff-enabled">
                <swp-data-label class="disabled">@Model.LabelTimeOffRate</swp-data-label>
                <swp-data-input class="disabled"><input type="text" id="rate-timeoff" value="@Model.TimeOffRateValue"> kr</swp-data-input>
            </swp-data-row>
            <swp-data-row>
                <input type="checkbox" id="rate-paidleave-enabled">
                <swp-data-label class="disabled">@Model.LabelPaidLeaveRate</swp-data-label>
                <swp-data-input class="disabled"><input type="text" id="rate-paidleave" value="@Model.PaidLeaveRateValue"> kr</swp-data-input>
            </swp-data-row>
            <swp-data-row>
                <input type="checkbox" id="rate-vacation-enabled" checked>
                <swp-data-label>@Model.LabelVacationRate</swp-data-label>
                <swp-data-input><input type="text" id="rate-vacation" value="@Model.VacationRateValue"> kr</swp-data-input>
            </swp-data-row>
            <swp-data-row>
                <input type="checkbox" id="rate-office-enabled">
                <swp-data-label class="disabled">@Model.LabelOfficeRate</swp-data-label>
                <swp-data-input class="disabled"><input type="text" id="rate-office" value="@Model.OfficeRateValue"> kr</swp-data-input>
            </swp-data-row>
            <swp-data-row>
                <input type="checkbox" id="rate-childsick-enabled">
                <swp-data-label class="disabled">@Model.LabelChildSickRate</swp-data-label>
                <swp-data-input class="disabled"><input type="text" id="rate-childsick" value="@Model.ChildSickRateValue"> kr</swp-data-input>
            </swp-data-row>
            <swp-data-row>
                <input type="checkbox" id="rate-childhospital-enabled">
                <swp-data-label class="disabled">@Model.LabelChildHospitalRate</swp-data-label>
                <swp-data-input class="disabled"><input type="text" id="rate-childhospital" value="@Model.ChildHospitalRateValue"> kr</swp-data-input>
            </swp-data-row>
            <swp-data-row>
                <input type="checkbox" id="rate-maternity-enabled">
                <swp-data-label class="disabled">@Model.LabelMaternityRate</swp-data-label>
                <swp-data-input class="disabled"><input type="text" id="rate-maternity" value="@Model.MaternityRateValue"> kr</swp-data-input>
            </swp-data-row>
        </swp-data-table>

        <!-- Tillaeg -->
        <swp-data-section>
            <swp-section-label>@Model.LabelSupplements</swp-section-label>
            <swp-data-table>
                <swp-data-row>
                    <input type="checkbox" id="rate-weekday-enabled" checked>
                    <swp-data-label>@Model.LabelWeekdaySupplementFull</swp-data-label>
                    <swp-data-input><input type="text" id="rate-weekday" value="@Model.WeekdaySupplementValue"> kr</swp-data-input>
                </swp-data-row>
                <swp-data-row>
                    <input type="checkbox" id="rate-saturday-enabled" checked>
                    <swp-data-label>@Model.LabelSaturdaySupplementFull</swp-data-label>
                    <swp-data-input><input type="text" id="rate-saturday" value="@Model.SaturdaySupplementValue"> kr</swp-data-input>
                </swp-data-row>
                <swp-data-row>
                    <input type="checkbox" id="rate-sunday-enabled" checked>
                    <swp-data-label>@Model.LabelSundaySupplement</swp-data-label>
                    <swp-data-input><input type="text" id="rate-sunday" value="@Model.SundaySupplementValue"> kr</swp-data-input>
                </swp-data-row>
            </swp-data-table>
        </swp-data-section>

        <!-- Provision -->
        <swp-data-section>
            <swp-section-label>@Model.LabelCommission</swp-section-label>
            <swp-data-table>
                <swp-data-row>
                    <input type="checkbox" id="rate-productcommission-enabled" checked>
                    <swp-data-label>@Model.LabelProductCommissionFull</swp-data-label>
                    <swp-data-input><input type="text" id="rate-productcommission" value="@Model.ProductCommissionValue"> %</swp-data-input>
                </swp-data-row>
                <swp-data-row>
                    <input type="checkbox" id="rate-servicecommission-enabled" checked>
                    <swp-data-label>@Model.LabelServiceCommissionFull</swp-data-label>
                    <swp-data-input><input type="text" id="rate-servicecommission" value="@Model.ServiceCommissionValue"> %</swp-data-input>
                </swp-data-row>
            </swp-data-table>
        </swp-data-section>
    </swp-drawer-body>
</div>
