initial commit
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
@using Indotalent.Features.Payroll.PayrollDetails.Cqrs
|
||||
@using Indotalent.Features.Payroll.Payrolls
|
||||
@using Indotalent.Shared.Utils
|
||||
@using Microsoft.JSInterop
|
||||
@using MudBlazor
|
||||
@inject IJSRuntime JSRuntime
|
||||
@inject ISnackbar Snackbar
|
||||
|
||||
<MudDialog>
|
||||
<TitleContent>
|
||||
<MudText Typo="Typo.h6" Style="font-weight: 900; color: #1a1a1a;">PAYROLL SLIP DETAILS</MudText>
|
||||
</TitleContent>
|
||||
<DialogContent>
|
||||
@if (Data != null)
|
||||
{
|
||||
<MudGrid Spacing="2">
|
||||
<MudItem xs="12">
|
||||
<div class="pa-4" style="background-color: #F8FAFC; border: 1px solid #E2E8F0; border-radius: 0px;">
|
||||
<MudGrid>
|
||||
<MudItem xs="6">
|
||||
<MudText Typo="Typo.caption" Style="color: #64748b; font-weight: 600;">Employee Name</MudText>
|
||||
<MudText Typo="Typo.body1" Style="font-weight: 800; color: #0D47A1;">@Data.EmployeeName</MudText>
|
||||
<div class="mt-2">
|
||||
<MudText Typo="Typo.caption" Style="color: #64748b; font-weight: 600;">Code</MudText>
|
||||
<MudText Typo="Typo.body2" Style="font-weight: 700;">@Data.EmployeeCode</MudText>
|
||||
</div>
|
||||
</MudItem>
|
||||
<MudItem xs="6" Style="text-align: right;">
|
||||
<MudText Typo="Typo.caption" Style="color: #64748b; font-weight: 600;">Payroll Period</MudText>
|
||||
<MudText Typo="Typo.body1" Style="font-weight: 800;">@PeriodName</MudText>
|
||||
<div class="mt-2">
|
||||
<MudText Typo="Typo.caption" Style="color: #64748b; font-weight: 600;">Basic Salary</MudText>
|
||||
<MudText Typo="Typo.body1" Color="Color.Primary" Style="font-weight: 800;">@Data.BasicSalary.ToString("N0")</MudText>
|
||||
</div>
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
</div>
|
||||
</MudItem>
|
||||
|
||||
<MudItem xs="6">
|
||||
<MudText Typo="Typo.subtitle2" Color="Color.Success" Style="font-weight: 900;" Class="mb-2">Incomes (+)</MudText>
|
||||
<MudDivider Class="mb-3" />
|
||||
@foreach (var inc in Data.Incomes)
|
||||
{
|
||||
<div class="d-flex justify-space-between mb-1">
|
||||
<MudText Typo="Typo.body2">@inc.ComponentName</MudText>
|
||||
<MudText Typo="Typo.body2" Style="font-weight: 700;">@inc.Amount.ToString("N0")</MudText>
|
||||
</div>
|
||||
}
|
||||
</MudItem>
|
||||
|
||||
<MudItem xs="6" Style="border-left: 1px solid #E2E8F0;">
|
||||
<MudText Typo="Typo.subtitle2" Color="Color.Error" Style="font-weight: 900;" Class="mb-2">Deductions (-)</MudText>
|
||||
<MudDivider Class="mb-3" />
|
||||
@foreach (var ded in Data.Deductions)
|
||||
{
|
||||
<div class="d-flex justify-space-between mb-1">
|
||||
<MudText Typo="Typo.body2">@ded.ComponentName</MudText>
|
||||
<MudText Typo="Typo.body2" Style="font-weight: 700; color: #C62828;">(@ded.Amount.ToString("N0"))</MudText>
|
||||
</div>
|
||||
}
|
||||
</MudItem>
|
||||
|
||||
<MudItem xs="12">
|
||||
<div class="pa-4 mt-2 d-flex justify-space-between align-center" style="background-color: #0D47A1; color: white;">
|
||||
<MudText Typo="Typo.h6" Style="font-weight: 900;">TAKE HOME PAY</MudText>
|
||||
<MudText Typo="Typo.h5" Style="font-weight: 900;">@Data.TakeHomePay.ToString("N0")</MudText>
|
||||
</div>
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton OnClick="Cancel" Variant="Variant.Outlined" Style="border: 1px solid #e0e0e0; border-radius: 4px; text-transform: none; font-weight: 700;">Close</MudButton>
|
||||
<MudButton Color="Color.Primary" Variant="Variant.Filled" StartIcon="@Icons.Material.Filled.PictureAsPdf" OnClick="PrintPdf" Style="border-radius: 4px; text-transform: none; font-weight: 700;">Print PDF Slip</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
|
||||
@code {
|
||||
[CascadingParameter] IMudDialogInstance MudDialog { get; set; } = default!;
|
||||
[Parameter] public GetPayrollSlipByIdResponse Data { get; set; } = new();
|
||||
[Parameter] public string PeriodName { get; set; } = string.Empty;
|
||||
|
||||
private void Cancel() => MudDialog.Cancel();
|
||||
|
||||
private async Task PrintPdf()
|
||||
{
|
||||
try
|
||||
{
|
||||
var pdfBytes = PayrollSlipPdfGenerator.Generate(Data, PeriodName);
|
||||
var fileName = $"Slip_{Data.EmployeeCode}_{DateTime.Now:yyyyMMdd}.pdf";
|
||||
await JSRuntime.InvokeVoidAsync("downloadFile", fileName, "application/pdf", Convert.ToBase64String(pdfBytes));
|
||||
Snackbar.Add("PDF Slip downloaded", Severity.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Snackbar.Add($"Print failed: {ex.Message}", Severity.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user