WIP: supervisor

This commit is contained in:
Frede Hundewadt 2023-03-25 15:59:34 +01:00
parent 65556383fd
commit ce7ec0646f
38 changed files with 1040 additions and 45 deletions

View file

@ -40,7 +40,7 @@
{
@foreach (var report in ReportList)
{
<ReportListItemComponent OnShowReport="ShowThisReport" Report="report" />
<ReportListItemComponent OnShowReport="ShowThisReport" Report="@report" />
}
}
else

View file

@ -20,10 +20,20 @@ namespace Wonky.Client.Components;
public partial class OfficeReportListComponent
{
// ##################################################################
[Parameter] public List<SalesReportListView> ReportList { get; set; } = new();
[Parameter] public string UserId { get; set; } = "";
[Parameter] public string CountryCode { get; set; } = "";
[Parameter] public EventCallback<string> OnShowReport { get; set; }
protected override void OnParametersSet()
{
if (ReportList.Any())
ReportList = ReportList.OrderByDescending(x => x.ReportDate).ToList();
}
private void ShowThisReport(string reportDate)
{
OnShowReport.InvokeAsync(reportDate);

View file

@ -30,7 +30,7 @@ public partial class ProcessStateComponent
"the-bad" => "file-earmark-check",
"the-ugly" => "box2-fill",
"the-dead" => "truck",
"accepted" => "printer",
"printed" => "printer",
_ => "question-square"
};
}

View file

@ -0,0 +1,74 @@
@* Copyright (C) 2022 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
*@
@using Wonky.Client.Helpers
@if (ActivityList.Any())
{
<table class="table table-sm table-bordered d-print-table table-striped">
<thead>
<tr class="bg-dark text-white opacity-75 border-bottom">
<th scope="col">Kunde</th>
<th scope="col">Bynavn</th>
<th scope="col">Demo</th>
<th scope="col">Salg</th>
<th scope="col">Note</th>
<th class="text-end" scope="col">sas</th>
<th class="text-end" scope="col">Beløb</th>
<th class="text-center" scope="col"><i class="bi-phone"></i></th>
<th class="text-center" scope="col"><i class="bi-lightning"></i></th>
<th class="text-center" scope="col"><i class="bi-calculator"></i></th>
<th class="text-center" scope="col"><i class="bi-truck"></i></th>
</tr>
</thead>
<tbody>
@foreach (var activity in ActivityList)
{
<tr class="border-bottom">
<td class="align-middle"><a class="link-info" href="#" @onclick="() => ShowDocument(activity.ActivityId)">@activity.Company.Name</a></td>
<td class="align-middle">@activity.Company.City</td>
<td class="align-middle">@activity.Demo</td>
<td class="align-middle">@activity.Sales</td>
<td class="align-middle fw-bold">@activity.OfficeNote</td>
<td class="align-middle text-end">@($"{activity.SasAmount:N2}")</td>
<td class="align-middle text-end">@(activity.StatusTypeEnum == "Quote" ? $"{0:N2}" : $"{activity.OrderAmount:N2}")</td>
<td class="align-middle text-center">
@if (activity.OurRef.Contains("T:"))
{<i style="font-size:1.3em;" class="bi-phone"></i>}
</td>
<td class="align-middle text-center">
@if (activity.Express)
{<i style="font-size:1.3em;" class="bi-lightning"></i>}
</td>
<td class="align-middle text-end">
@if (activity.StatusTypeEnum == "Quote")
{<i style="font-size:1.3em;" class="bi-calculator"></i>}
</td>
<td class="align-middle state">
@if (activity.Lines.Any() && activity.StatusTypeEnum == "Order")
{
<ProcessStateComponent StateClass="@Utils.GetProcessStatus(activity.ProcessStatusEnum)"/>
}
</td>
</tr>
}
</tbody>
</table>
}
else
{
<div>Ingen data</div>
}

View file

@ -0,0 +1,33 @@
// Copyright (C) 2022 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
//
using Microsoft.AspNetCore.Components;
using Wonky.Entity.Views;
#pragma warning disable CS8618
namespace Wonky.Client.Components;
public partial class ReportActivityListComponent
{
// ##############################################################################
[Parameter] public List<ReportItemView> ActivityList { get; set; } = new();
[Parameter] public EventCallback<string> OnShowDocument { get; set; }
private void ShowDocument(string documentId)
{
OnShowDocument.InvokeAsync(documentId);
}
}

View file

@ -20,9 +20,10 @@ namespace Wonky.Client.Components;
public partial class ReportItemComponent
{
[Parameter]
public ReportItemView ReportItem { get; set; } = new();
// ##############################################################################
[Parameter] public ReportItemView ReportItem { get; set; } = new();
protected override void OnParametersSet()
{
var lines = ReportItem.Lines.OrderBy(x => x.Location).ToList();

View file

@ -38,7 +38,7 @@
{
@foreach (var report in ReportList)
{
<ReportListItemComponent Report="report" OnShowReport="ShowThisReport" />
<ReportListItemComponent Report="@report" OnShowReport="ShowThisReport" />
}
}
else

View file

@ -21,16 +21,22 @@ namespace Wonky.Client.Components;
public partial class ReportListComponent
{
// ###########################################################################
[Parameter] public List<SalesReportListView> ReportList { get; set; } = new();
[Parameter] public EventCallback<string> OnShowReport { get; set; }
// ###########################################################################
private List<SalesReportListView> Reports { get; set; } = new();
protected override void OnParametersSet()
{
Reports = ReportList;
Reports = ReportList.OrderByDescending(x => x.ReportDate).ToList();
}
private void ShowThisReport(string reportDate)
{
OnShowReport.InvokeAsync(reportDate);

View file

@ -15,8 +15,8 @@
@using Wonky.Entity.Views
<button type="button" aria-role="navigation" class="list-group-item list-group-item-action"
style="cursor: pointer" @onclick="ShowThisReport">
<button type="button" aria-role="navigation" class="list-group-item list-group-item-action" style="cursor: pointer"
@onclick="ShowThisReport">
<div class="row">
<div class="col">
@Report.ReportDate
@ -56,4 +56,4 @@
@Report.Turnover
</div>
</div>
</button>
</button>

View file

@ -20,9 +20,11 @@ namespace Wonky.Client.Components;
public partial class ReportListItemComponent
{
// #############################################################
[Parameter] public SalesReportListView Report { get; set; } = new();
[Parameter] public EventCallback<string> OnShowReport { get; set; }
private void ShowThisReport()
{
OnShowReport.InvokeAsync(Report.ReportDate);

View file

@ -217,7 +217,7 @@ public static class Utils
"picked" => "the-bad",
"packed" => "the-ugly",
"shipped" => "the-dead",
"accepted" => "accepted",
"printed" => "printed",
_ => "question"
};
}

View file

@ -22,6 +22,7 @@ public interface IUserInfoService
{
Task<UserManagerEditView> GetUserInfo();
Task SetUserInfo(UserManagerEditView userInfo);
Task<bool> IsSupervisor();
Task<string> GetRefreshToken();
Task SetRefreshToken(string token);
Task<string> GetAccessToken();

View file

@ -16,6 +16,8 @@
using System.Text.Json;
using Blazored.LocalStorage;
using Microsoft.AspNetCore.DataProtection.KeyManagement;
using Wonky.Client.Models;
using Wonky.Entity.DTO;
namespace Wonky.Client.Local.Services;
@ -26,50 +28,65 @@ public class UserInfoService : IUserInfoService
private const string _refreshKey = "_xr";
private const string _accessKey = "_xa";
private const string _expiryKey = "_xe";
private readonly ILocalStorageService _localStorageService;
private readonly JsonSerializerOptions _options = new() { PropertyNameCaseInsensitive = true };
public UserInfoService(ILocalStorageService localStorageService)
{
_localStorageService = localStorageService;
}
public async Task<bool> IsSupervisor()
{
var x = await GetUserInfo();
return x.AssignedRoles.Any(x => x is { Name: "Supervisor", Assigned: true });
}
public async Task<UserManagerEditView> GetUserInfo()
{
return await _localStorageService.GetItemAsync<UserManagerEditView>(_infoKey);
}
public async Task SetUserInfo(UserManagerEditView userInfo)
{
await _localStorageService.SetItemAsync(_infoKey, userInfo);
}
public async Task<string> GetRefreshToken()
{
return await _localStorageService.GetItemAsStringAsync(_refreshKey);
}
public async Task SetRefreshToken(string token)
{
await _localStorageService.SetItemAsStringAsync(_refreshKey, token);
}
public async Task<string> GetAccessToken()
{
return await _localStorageService.GetItemAsStringAsync(_accessKey);
}
public async Task SetAccessToken(string token)
{
await _localStorageService.SetItemAsStringAsync(_accessKey, token);
}
public async Task<long> GetExpiration()
{
return await _localStorageService.GetItemAsync<long>(_expiryKey);
}
public async Task SetExpiration(long expiration)
{
await _localStorageService.SetItemAsync(_expiryKey, expiration);

View file

@ -144,7 +144,7 @@ public partial class AdvisorCustomerCreatePage : IDisposable
// validate vat number according to country
if (!VatUtils.ValidateFormat(Company.CountryCode, Company.VatNumber))
{
Toaster.ShowError("Momsnummber er ikke korrekt.");
Toaster.ShowError("Momsnummer er ikke korrekt.");
FormInvalid = true;
Company.ValidVat = 0;
RegState = "the-ugly";

View file

@ -16,7 +16,7 @@
@using Microsoft.AspNetCore.Authorization
@using Wonky.Client.Components
@attribute [Authorize(Roles = "Advisor")]
@attribute [Authorize(Roles = "Advisor,Supervisor")]
@page "/advisor/reports/new"
<PageTitle>Opret Dagsrapport for @ThisWorkDate</PageTitle>
@ -27,7 +27,7 @@
<WorkDateComponent OnChangedCallback="SetWorkDateCallback"/>
</div>
<div class="col-sm-4 text-end">
<AdvisorActivityKmStartComponent />
<AdvisorActivityKmStartComponent/>
</div>
</div>
@ -54,11 +54,15 @@
<option value="sales">Salgsdag</option>
<option value="meeting">Salgsmøde</option>
<option value="office">Kontordag</option>
<option value="supervisor">Medkørende Supervisor</option>
@if (IsSupervisor)
{
<option value="supervisor">Medkørende Supervisor</option>
}
<option value="sickLeave">Sygdom</option>
<option value="leave">Ferie</option>
</select>
<ValidationMessage For="@(() => Report.DayTypeEnum)"/>
</td>
@if (Report.DayTypeEnum.ToLower().Contains("leave"))
{
@ -148,12 +152,12 @@
disabled="@(NoFigures)" readonly/>
</td>
<td>
<InputNumber class="form-control" @bind-Value="@Report.Figures.Distance"
disabled />
<InputNumber class="form-control" @bind-Value="@Report.Figures.Distance"
disabled/>
</td>
<td>
<InputNumber class="form-control" @bind-Value="@Report.Figures.DistanceMonth"
disabled />
<InputNumber class="form-control" @bind-Value="@Report.Figures.DistanceMonth"
disabled/>
</td>
</tr>
</tbody>
@ -172,8 +176,8 @@
disabled="@(NoFigures)"/>
</td>
<td>
<InputNumber class="form-control" @bind-Value="@Report.Figures.DistancePrivateMonth"
disabled />
<InputNumber class="form-control" @bind-Value="@Report.Figures.DistancePrivateMonth"
disabled/>
</td>
</tr>
</tbody>
@ -182,19 +186,19 @@
@if (Activities.Any())
{
<div class="row">
<AdvisorActivityListComponent ActivityList="Activities" />
<AdvisorActivityListComponent ActivityList="Activities"/>
</div>
}
}
<div class="row">
@* ledger summaries calculated *@
<AdvisorReportActivityLedgerComponent ReportData="Report.Figures" />
<AdvisorReportActivityLedgerComponent ReportData="Report.Figures"/>
</div>
</EditForm>
@if (Working)
{
<WorkingThreeDots />
<WorkingThreeDots/>
}
<ConfirmationModal BodyMessage="@Prompt" OnOkClicked="ConfirmReportCallback" OnCancelClicked="OnCancelCallback" @ref="ConfirmReportModal"/>
<ConfirmationModal BodyMessage="@Prompt" OnOkClicked="ConfirmReportCallback" OnCancelClicked="OnCancelCallback" @ref="ConfirmReportModal"/>

View file

@ -31,6 +31,7 @@ namespace Wonky.Client.Pages;
public partial class AdvisorReportCreatePage : IDisposable
{
// ##########################################################################
[Inject] public HttpInterceptorService Interceptor { get; set; }
[Inject] public UserPreferenceService PreferenceService { get; set; }
[Inject] public IAdvisorActivityRepository AdvisorActivityRepo { get; set; }
@ -38,6 +39,10 @@ public partial class AdvisorReportCreatePage : IDisposable
[Inject] public NavigationManager Navigator { get; set; }
[Inject] public ILogger<AdvisorReportCreatePage> Logger { get; set; }
[Inject] public IToastService Toaster { get; set; }
[Inject] public IUserInfoService UserInfo { get; set; }
// ##########################################################################
private EditContext ReportContext { get; set; }
private ReportDto Report { get; set; } = new();
private List<ReportItemView> Activities { get; set; } = new();
@ -56,6 +61,8 @@ public partial class AdvisorReportCreatePage : IDisposable
private string WorkDate { get; set; } = "";
private int CurrKmMonth { get; set; }
private int CurrKmPrivate { get; set; }
private bool IsSupervisor { get; set; }
/// <summary>
/// OnInitialized
@ -64,6 +71,8 @@ public partial class AdvisorReportCreatePage : IDisposable
{
Interceptor.RegisterEvent();
Interceptor.RegisterBeforeSendEvent();
IsSupervisor = await UserInfo.IsSupervisor();
ReportContext = new EditContext(Report);
ReportContext.OnFieldChanged += HandleFieldChanged;

View file

@ -16,7 +16,7 @@
@using Wonky.Client.Components;
@using Microsoft.AspNetCore.Authorization
@attribute [Authorize(Roles = "Admin,Advisor,Office,Supervisor,Warehouse")]
@attribute [Authorize(Roles = "Admin,Advisor,Management,Office,Supervisor,Warehouse")]
@page "/"
@page "/index"
@page "/home"
@ -25,7 +25,7 @@
<AdvisorLandingComponent />
</AuthorizeView>
<AuthorizeView Roles="Admin,Office,Warehouse">
<AuthorizeView Roles="Admin,Management,Office,Warehouse">
<OfficeLandingComponent />
</AuthorizeView>

View file

@ -24,7 +24,7 @@ using Wonky.Entity.Views;
namespace Wonky.Client.Pages;
public partial class OfficeUserAdvisorListPage :IDisposable
public partial class OfficeAdvisorListPage :IDisposable
{
// #############################################################
[Inject] public HttpInterceptorService Interceptor { get; set; }

View file

@ -23,11 +23,11 @@ using Wonky.Entity.Views;
namespace Wonky.Client.Pages;
public partial class OfficeUserAdvisorReportListPage : IDisposable
public partial class OfficeAdvisorReportListPage : IDisposable
{
// #############################################################
[Inject] public ICountryReportRepository ReportRepo { get; set; }
[Inject] public HttpInterceptorService Interceptor { get; set; }
[Inject] public ICountryReportRepository ReportRepo { get; set; }
[Inject] public IOfficeUserInfoRepository UserRepo { get; set; }
[Inject] public NavigationManager Navigator { get; set; }

View file

@ -0,0 +1,47 @@
@* Copyright (C) 2022 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
*@
@using Wonky.Client.Components
@using Microsoft.AspNetCore.Authorization
@attribute [Authorize(Roles = "Admin,Management,Supervisor")]
@page "/supervisor/advisors/{UserId}/reports/{ReportDate}"
<div class="report-main d-print-print">
@if (!string.IsNullOrWhiteSpace(Report.ReportData.DayTypeEnum))
{
<PageTitle>@Report.ReportData.Name</PageTitle>
<div class="row">
<div class="alert border border-1 border-dark text-center align-content-center">
<h3>@Report.ReportData.Name</h3>
</div>
</div>
<div class="row">
<div class="w-75">
<ReportSummaryComponent ReportData="Report.ReportData"/>
</div>
<div class="w-25">
<ReportDistanceLedgerComponent ReportData="Report.ReportData"/>
</div>
</div>
<OfficeReportActivityListComponent ActivityList="Report.ReportItems"/>
<ReportActivityLedgerComponent ReportData="Report.ReportData"/>
}
else
{
<div class="row">
<div class="col">Ingen rapport data</div>
</div>
}
</div>

View file

@ -0,0 +1,188 @@
// Copyright (C) 2022 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
//
using System.Text.Json;
using Blazored.LocalStorage;
using Blazored.Toast.Services;
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using Wonky.Client.Helpers;
using Wonky.Client.HttpInterceptors;
using Wonky.Client.HttpRepository;
using Wonky.Client.Local.Services;
using Wonky.Client.Models;
using Wonky.Entity.DTO;
using Wonky.Entity.Views;
#pragma warning disable CS8618
namespace Wonky.Client.Pages;
public partial class SupervisorAdvisorReportViewPage : IDisposable
{
// #############################################################
[Inject] public HttpInterceptorService Interceptor { get; set; }
[Inject] public ICountryReportRepository ReportRepo { get; set; }
[Inject] public NavigationManager Navigator { get; set; }
[Inject] public ILogger<SupervisorAdvisorReportViewPage> Logger { get; set; }
[Inject] public ILocalStorageService Storage { get; set; }
[Inject] public UserPreferenceService PreferenceService { get; set; }
[Inject] public IJSRuntime JsRuntime { get; set; }
[Inject] public IToastService Toaster { get; set; }
[Inject] public IOrderProcessRepository ProcessRepo { get; set; }
// #############################################################
[Parameter] public string CountryCode { get; set; } = "";
[Parameter] public string UserId { get; set; } = "";
[Parameter] public string ReportDate { get; set; } = "";
// #############################################################
private IJSObjectReference JsModule { get; set; }
private ReportView Report { get; set; } = new();
private List<ReportItemView> Activities { get; set; } = new();
private bool Working { get; set; } = true;
private UserPreference Profile { get; set; } = new();
private string _returnUrl = "";
protected override async Task OnParametersSetAsync()
{
Interceptor.RegisterEvent();
Interceptor.RegisterBeforeSendEvent();
PreferenceService.OnChange += ProfileServiceOnOnChange;
await PreferenceService.SetWorkDate(DateTime.Parse(ReportDate));
await FetchUserReport(ReportDate);
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
JsModule = await JsRuntime
.InvokeAsync<IJSObjectReference>("import", "/scripts/print-invoke.js");
}
}
// private void Print(PrintTarget target)
// {
// _returnUrl = new Uri(Navigator.Uri).AbsolutePath;
// switch (target)
// {
// case PrintTarget.OrderPage:
// Navigator.NavigateTo($"/report/print/orders/{CountryCode}/{UserId}/{ReportDate}?returnUrl={_returnUrl}");
// break;
// case PrintTarget.FrontPage:
// Navigator.NavigateTo($"/report/print/summary/{CountryCode}/{UserId}/{ReportDate}?returnUrl={_returnUrl}");
// break;
// case PrintTarget.None:
// break;
// case PrintTarget.All:
// break;
// default:
// throw new ArgumentOutOfRangeException(nameof(target), target, null);
// }
// }
//
//
// private async Task Print()
// {
// var current = 0;
// var orders = Report.ReportItems
// .Where(x => x is { StatusTypeEnum: "Order", ProcessStatusEnum: "None" } );
// var count = orders.Count();
// foreach (var item in orders)
// {
// Toaster.ShowInfo($"Behandler {current++} af {count} ordrer. Vent venligst");
// await ProcessRepo.UpdateWarehouseOrderStatus(new OrderProcessState
// {
// OrderId = item.ActivityId,
// ProcessStatusEnum = Utils.EnumToString(ProcessStatus.Printed)
// });
// }
// Toaster.ClearAll();
// await JsModule.InvokeVoidAsync("printInvoke");
// }
/// <summary>
/// Work date component event handler
/// </summary>
/// <param name="workDate"></param>
private async Task FetchUserReport(string workDate)
{
// remove busy signal if report is empty
if (string.IsNullOrWhiteSpace(Report.ReportData.ReportDate))
{
Working = false;
}
ReportDate = workDate;
// ensure the browser address bar contains the correct link
Navigator.NavigateTo($"/supervisor/advisors/{UserId}/reports/{workDate}", false, true);
// return if we are already at it
if (Working)
{
return;
}
// reset variables
Report = new ReportView();
Activities = new List<ReportItemView>();
// set busy signal
Working = true;
Logger.LogDebug("UserId => {}", UserId);
// fetch report
Report = await ReportRepo.GetCountryReport(UserId, workDate);
Logger.LogDebug("Report => {}", JsonSerializer.Serialize(Report, new JsonSerializerOptions(JsonSerializerDefaults.Web)));
// extract activities
Activities = Report.ReportItems.Where(x => x.Lines.Any()).ToList();
// store locally
if (!string.IsNullOrWhiteSpace(Report.ReportData.ReportDate))
{
await Storage.SetItemAsync($"{UserId}-{workDate}", Report);
}
// remove busy signal
Working = false;
}
private void ProfileServiceOnOnChange(UserPreference userPreference)
{
Logger.LogDebug("OfficeReportViewPage => ProfileServiceOnOnChange");
Profile = userPreference;
Logger.LogDebug("OfficeReportViewPage => ProfileServiceOnOnChange => Prefs.WorkDate <= {}", Profile.WorkDate);
ReportDate = Profile.WorkDate;
StateHasChanged();
}
public void Dispose()
{
Interceptor.DisposeEvent();
PreferenceService.OnChange -= ProfileServiceOnOnChange;
}
}

View file

@ -0,0 +1,34 @@
@* Copyright (C) 2022 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
*@
@using Microsoft.AspNetCore.Authorization
@using Wonky.Client.Components
@attribute [Authorize(Roles = "Admin,Management,Supervisor")]
@page "/supervisor/advisors/{UserId}"
<PageTitle>Rapport Arkiv @AdvisorInfo.FirstName @AdvisorInfo.LastName</PageTitle>
<div class="card">
<div class="card-header">
<div class="mt-3 h3 card-title">
Rapport Arkiv - @AdvisorInfo.FirstName @AdvisorInfo.LastName
</div>
</div>
<OfficeReportListComponent OnShowReport="ShowThisReport" CountryCode="@AdvisorInfo.CountryCode" UserId="@UserId" ReportList="@ActivityReports" />
</div>
@if (Working)
{
<WorkingThreeDots/>
}

View file

@ -0,0 +1,64 @@
using Microsoft.AspNetCore.Components;
using Wonky.Client.HttpInterceptors;
using Wonky.Client.HttpRepository;
using Wonky.Entity.Views;
#pragma warning disable CS8618
namespace Wonky.Client.Pages;
public partial class SupervisorAdvisorViewPage : IDisposable
{
// #############################################################
[Inject] public HttpInterceptorService Interceptor { get; set; }
[Inject] public IOfficeUserInfoRepository UserRepo { get; set; }
[Inject] public ICountryReportRepository ReportRepo { get; set; }
[Inject] public NavigationManager Navigator { get; set; }
[Inject] public ILogger<SupervisorAdvisorViewPage> Logger { get; set; }
// #############################################################
[Parameter] public string UserId { get; set; } = "";
// #############################################################
private UserAdvisorInfoView AdvisorInfo { get; set; } = new();
private List<SalesReportListView> ActivityReports { get; set; } = new();
private bool Working { get; set; } = true;
protected override async Task OnParametersSetAsync()
{
Interceptor.RegisterEvent();
Interceptor.RegisterBeforeSendEvent();
AdvisorInfo = await UserRepo.GetUserInfo(UserId);
while (string.IsNullOrWhiteSpace(AdvisorInfo.UserId))
{
await Task.Delay(500);
}
var reports = await ReportRepo.GetCountryReports(UserId);
if (reports.Any())
ActivityReports = reports.OrderByDescending(x => x.ReportDate).ToList();
}
protected override void OnInitialized()
{
Working = false;
}
private void ShowThisReport(string reportDate)
{
var uri = new Uri(Navigator.Uri);
var url = uri.AbsoluteUri;
Logger.LogDebug("ShowThisReport\n => {}\n =>{}", reportDate, url);
Logger.LogDebug("ShowThisReport => NavigateTo => {}",$"{url}/report/{reportDate}");
Navigator.NavigateTo($"{url}/reports/{reportDate}");
}
public void Dispose()
{
Interceptor.DisposeEvent();
}
}

View file

@ -0,0 +1,11 @@
@using Microsoft.AspNetCore.Authorization
@attribute [Authorize(Roles = "Admin,Management,Supervisor")]
@page "/supervisor"
<PageTitle>Supervisor</PageTitle>
<div class="h3">Supervisor</div>
<div class="list-group">
<a class="list-group-item list-group-item-action" href="/supervisor/advisors">Sælgere</a>
</div>

View file

@ -0,0 +1,6 @@
namespace Wonky.Client.Pages;
public partial class SupervisorHomePage
{
}

View file

@ -14,8 +14,8 @@
*@
@using Microsoft.AspNetCore.Authorization
@attribute [Authorize(Roles = "Supervisor")]
@page "/supervisor/salesReps"
@attribute [Authorize(Roles = "Admin,Management,Supervisor")]
@page "/supervisor/advisors"
<PageTitle>Supervisor Sælger Oversigt</PageTitle>
<div class="row">
@ -33,7 +33,6 @@
</div>
</div>
<div class="list-group">
<div class="list-group-item">
<div class="row">
@ -58,7 +57,7 @@
{
foreach (var user in Users)
{
<a class="list-group-item list-group-item-action" href="/supervisor/salesReps/@user.UserId">
<a class="list-group-item list-group-item-action" href="/supervisor/advisors/@user.UserId">
<div class="row">
<div class="col-sm-1">
@user.CountryCode @user.SalesRep

View file

@ -8,7 +8,7 @@ namespace Wonky.Client.Pages;
#pragma warning disable CS8618
public partial class SupervisorAdvisorListPage : IDisposable
public partial class SupervisorUserListPage : IDisposable
{
// #############################################################
[Inject] public HttpInterceptorService Interceptor { get; set; }
@ -24,9 +24,14 @@ public partial class SupervisorAdvisorListPage : IDisposable
Interceptor.RegisterBeforeSendEvent();
Users = await UserRepo.GetSupervisorUsers();
if (Users.Any())
{
Users = Users
.OrderBy(x => x.FullName)
.ThenBy(x => x.CountryCode)
.ToList();
}
Working = false;
}
public void Dispose()

View file

@ -0,0 +1,155 @@
@* Copyright (C) 2022 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
*@
@using Microsoft.AspNetCore.Authorization
@using Wonky.Client.Components
@attribute [Authorize(Roles = "Admin,Office,Warehouse")]
@page "/supervisor/advisors/{UserId}/reports/{ReportDate}/{ActivityId}"
<PageTitle>@ReportItem.ESalesNumber - @ReportItem.Company.Name</PageTitle>
<table class="table table-sm table-striped d-print-table">
<thead>
<tr>
<th class="p-0" colspan="4">
<div class="bg-light text-dark border border-1 rounded-3 pt-3 mb-2">
<h2 class="fw-bold text-center">@ReportItem.Company.Name</h2>
@if (ReportItem.Express)
{
<h2 class="fw-bold text-center"><i class="bi-lightning-charge text-dark" style="font-size: 2rem;"></i> HASTER</h2>
}
@if (ReportItem.VisitTypeEnum.ToLower() == "phone" || ReportItem.OurRef.Contains("T:"))
{
<h5 class="text-center">TELEFONORDRE</h5>
}
@if (ReportItem.StatusTypeEnum is "Quote")
{
<h5 class="text-center">TILBUD</h5>
}
</div>
</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">Dato</th>
<td>@ReportItem.OrderDate</td>
<th scope="row">Konto</th>
<td>@ReportItem.Company.Account</td>
</tr>
<tr>
<th scope="col">Telefon</th>
<td>@ReportItem.Company.Phone</td>
<th scope="col">Køber</th>
<td>@ReportItem.YourRef</td>
</tr>
<tr>
<th scope="col">CVR/VAT</th>
<td>@ReportItem.Company.VatNumber</td>
<th scope="col">Rekvisition</th>
<td>@ReportItem.ReferenceNumber</td>
</tr>
<tr>
<th scope="col">Navn</th>
<td>@ReportItem.Company.Name</td>
<th scope="col">Lev.Navn</th>
<td>@ReportItem.DlvName</td>
</tr>
<tr>
<th scope="col">Adresse</th>
<td>@ReportItem.Company.Address1</td>
<th scope="col">Lev.Adresse</th>
<td>@ReportItem.DlvAddress1</td>
</tr>
<tr>
<th scope="col">Adresse</th>
<td>@ReportItem.Company.Address2</td>
<th scope="col">Lev.Adresse</th>
<td>@ReportItem.DlvAddress2</td>
</tr>
<tr>
<th scope="col">Postnr By</th>
<td>@ReportItem.Company.ZipCode @ReportItem.Company.City</td>
<th scope="col">Lev.Postnr By</th>
<td>@ReportItem.DlvZipCity</td>
</tr>
<tr>
<th scope="col">Email</th>
<td colspan="3">@ReportItem.Company.Email</td>
</tr>
</tbody>
</table>
<table class="table table-sm table-striped table-bordered">
<thead>
<tr class="bg-light text-black">
<th scope="col">Antal</th>
<th scope="col">Varnr</th>
<th scope="col">Beskrivelse</th>
<th class="text-end" scope="col">Pris</th>
<th class="text-end" scope="col">R%</th>
<th class="text-end" scope="col">Beløb</th>
</tr>
</thead>
<tbody>
@foreach (var line in ReportItem.Lines)
{
<tr>
<td>@line.Quantity</td>
<td>@line.Sku</td>
<td>@line.Description</td>
<td class="text-end">@($"{line.Price:N2}")</td>
<td class="text-end">@($"{line.Discount:N2}")</td>
<td class="text-end">@($"{line.LineSum:N2}")</td>
</tr>
}
<tr>
<td colspan="4"></td>
<td>Ordresum</td>
<td class="text-end">@ReportItem.OrderAmount</td>
</tr>
@if (ReportItem.Express)
{
<td colspan="4"></td>
<td class="text-end" colspan="2">
<h5 class="fw-bold"><i class="bi-lightning-charge the-fast" style="font-size: 2rem;"></i> HASTER</h5>
</td>
}
</tbody>
</table>
<div class="card">
<div class="card-header">
<div class="card-title">
<div class="h3 pt-3">
Noter
</div>
</div>
</div>
<div class="card-body">
<div class="card-title">
Kontor
</div>
@ReportItem.OfficeNote
</div>
<div class="card-body">
<div class="card-title">
Kundekort
</div>
@ReportItem.CrmNote
</div>
</div>
@if (Working)
{
<WorkingThreeDots/>
}

View file

@ -0,0 +1,76 @@
// Copyright (C) 2022 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
//
using System.Text;
using System.Text.Json;
using Blazored.LocalStorage;
using Blazored.Toast.Services;
using Microsoft.AspNetCore.Components;
using Wonky.Client.HttpInterceptors;
using Wonky.Client.HttpRepository;
using Wonky.Client.Local.Services;
using Wonky.Entity.DTO;
using Wonky.Entity.Views;
#pragma warning disable CS8618
namespace Wonky.Client.Pages;
public partial class SupervisorVisitViewPage : IDisposable
{
// #############################################################
[Inject] public HttpInterceptorService Interceptor { get; set; }
[Inject] public IAdvisorActivityRepository AdvisorActivityRepo { get; set; }
[Inject] public ISystemSendMailService MailService { get; set; }
[Inject] public ILocalStorageService Storage { get; set; }
[Inject] public IOfficeUserInfoRepository UserRepo { get; set; }
[Inject] public ILogger<OfficeOrderViewPage> Logger { get; set; }
[Inject] public IToastService Toast { get; set; }
[Inject] public IUserInfoService UserInfoService { get; set; }
// #############################################################
[Parameter] public string CompanyId { get; set; } = "";
[Parameter] public string OrderId { get; set; } = "";
// #############################################################
private ReportItemView ReportItem { get; set; } = new();
private bool IsNotified { get; set; }
private bool Working { get; set; } = true;
private readonly JsonSerializerOptions _options = new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true
};
protected override async Task OnInitializedAsync()
{
Interceptor.RegisterEvent();
Interceptor.RegisterBeforeSendEvent();
// fetch order from backend
ReportItem = await AdvisorActivityRepo.GetReportItem(OrderId);
Logger.LogDebug("ReportItem => \n {}", JsonSerializer.Serialize(ReportItem, _options));
Working = false;
}
public void Dispose()
{
Interceptor.DisposeEvent();
}
}

View file

@ -0,0 +1,21 @@
/* Copyright (C) 2022 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
*/
#watermark {
position: absolute;
z-index: -999;
top: 10px;
right: 0;
}

View file

@ -105,7 +105,7 @@
<div class="col-md-3">
</div>
<div class="col-md-4">
@if (Order.ProcessStatusEnum.ToLower() is "none" or "accepted")
@if (Order.ProcessStatusEnum.ToLower() is "none" or "printed")
{
<button class="btn btn-lg btn-warning text-nowrap" type="button" @onclick="SetProcessStatusPicked" disabled="@Working">Sæt status plukket</button>
}

View file

@ -0,0 +1,146 @@
@* Copyright (C) 2022 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
*@
@inject IWebAssemblyHostEnvironment HostEnvironment
@using Wonky.Client.Components;
@using Wonky.Entity.Views
@using Blazored.LocalStorage
<div class="top-row ps-3 navbar navbar-dark">
<div class="container-fluid">
<a class="navbar-brand" href="/"><TopbarDisplayUser /></a>
<button title="Navigation menu" class="navbar-toggler" @onclick="ToggleNavMenu">
<span class="navbar-toggler-icon"></span>
</button>
</div>
</div>
<div class="@NavMenuCssClass" @onclick="ToggleNavMenu">
<nav class="flex-column">
<AuthorizeView>
<NotAuthorized>
<div class="nav-item px-3">
<NavLink class="nav-link ps-2" href="/" Match="NavLinkMatch.All">
<i class="bi-person-workspace pe-2" style="font-size:1.3em;" aria-hidden="true"></i> Start
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link ps-2" href="/login">
<i class="bi-lock pe-2" style="font-size:1.3em;" aria-hidden="true"></i> Log ind
</NavLink>
</div>
</NotAuthorized>
</AuthorizeView>
<AuthorizeView Roles="Admin,Office,Warehouse">
<div class="nav-item px-3">
<NavLink class="nav-link ps-2" href="/office/country">
<i class="bi-people pe-2" style="font-size:1.3em;" aria-hidden="true"></i> Sælgere
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link ps-2" href="/office/customers/dk">
<i class="bi-building pe-2" style="font-size:1.3em;" aria-hidden="true"></i> Kunder DK
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link ps-2" href="/office/customers/no">
<i class="bi-building pe-2" style="font-size:1.3em;" aria-hidden="true"></i> Kunder NO
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link ps-2" href="/office/customers/se">
<i class="bi-building pe-2" style="font-size:1.3em;" aria-hidden="true"></i> Kunder SE
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link ps-2" href="/warehouse/orders/none">
<i class="bi-box pe-2" style="font-size:1.3em;" aria-hidden="true"></i> Forsendelse
</NavLink>
</div>
</AuthorizeView>
<AuthorizeView Roles="Advisor">
<Authorized>
<div class="nav-item px-3">
<NavLink class="nav-link ps-2" href="/home">
<i class="bi-calendar pe-2" style="font-size:1.3em;" aria-hidden="true"></i> ToDo
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link ps-2" href="/catalog">
<i class="bi-file-spreadsheet pe-2" style="font-size:1.3em;" aria-hidden="true"></i> Priskatalog
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link ps-2" href="/advisor/customers">
<i class="bi-building pe-2" style="font-size:1.3em;" aria-hidden="true"></i> Firmaer
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link ps-2" href="/advisor/agreements">
<i class="bi-calculator pe-2" style="font-size:1.3em;" aria-hidden="true"></i> Aftaler/Tilbud
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link ps-2" href="/advisor/activity-today">
<i class="bi-activity pe-2" style="font-size:1.3em;" aria-hidden="true"></i> Aktivitet
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link ps-2" href="/advisor/reports">
<i class="bi-file-earmark-spreadsheet pe-2" style="font-size:1.3em;" aria-hidden="true"></i> Dagsrapporter
</NavLink>
</div>
</Authorized>
</AuthorizeView>
<AuthorizeView Roles="Admin">
<div class="nav-item px-3">
<NavLink class="nav-link ps-2" href="/system">
<i class="bi-gear-wide-connected pe-2" style="font-size:1.3em;" aria-hidden="true"></i> System
</NavLink>
</div>
</AuthorizeView>
<AuthorizeView Roles="Admin,Advisor,Office,Supervisor,Warehouse">
<div class="nav-item px-3">
<NavLink class="nav-link ps-2" href="/info">
<i class="bi-question pe-2" style="font-size:1.3em;" aria-hidden="true"></i> Hjælp
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link ps-2" href="/logout">
<i class="bi-lock pe-2" style="font-size:1.3em;" aria-hidden="true"></i> Log af
</NavLink>
</div>
</AuthorizeView>
</nav>
</div>
@code {
private bool collapseNavMenu = true;
private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null;
private void ToggleNavMenu()
{
collapseNavMenu = !collapseNavMenu;
}
}

View file

@ -0,0 +1,81 @@
/* Copyright (C) 2022 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
*/
.navbar-toggler {
background-color: rgba(255, 255, 255, 0.1);
}
.top-row {
height: 3.5rem;
background-color: rgba(0,0,0,0.4);
}
.navbar-brand {
font-size: 1.1rem;
}
.oi {
width: 2rem;
font-size: 1.1rem;
vertical-align: text-top;
top: -2px;
}
.nav-item {
font-size: 0.9rem;
padding-bottom: 0.5rem;
}
.nav-item:first-of-type {
padding-top: 1rem;
}
.nav-item:last-of-type {
padding-bottom: 1rem;
}
.nav-item ::deep a {
color: #d7d7d7;
border-radius: 4px;
height: 3rem;
display: flex;
align-items: center;
line-height: 3rem;
}
.nav-item ::deep a.active {
background-color: rgba(255,255,255,0.25);
color: white;
}
.nav-item ::deep a:hover {
background-color: rgba(255,255,255,0.1);
color: white;
}
.list-group.panel > .list-group-item {
border-bottom-right-radius: 4px;
border-bottom-left-radius: 4px;
}
@media (min-width: 1025px) {
.navbar-toggler {
display: none;
}
.collapse {
/* Never collapse the sidebar for wide screens */
display: block;
}
}

View file

@ -72,6 +72,15 @@
</NavLink>
</div>
</AuthorizeView>
<AuthorizeView Roles="Supervisor">
<Authorized>
<div class="nav-item px-3">
<NavLink class="nav-link ps-2" href="/supervisor">
<i class="bi-people pe-2" style="font-size:1.3em;" aria-hidden="true"></i> Supervisor
</NavLink>
</div>
</Authorized>
</AuthorizeView>
<AuthorizeView Roles="Advisor">
<Authorized>

View file

@ -3797,8 +3797,4 @@
<None Remove="wwwroot\icons\**" />
</ItemGroup>
<ItemGroup>
<Folder Include="Services" />
</ItemGroup>
</Project>

View file

@ -1,7 +1,7 @@
{
"appInfo": {
"name": "Wonky Online",
"version": "0.124.0",
"version": "0.126.0",
"rc": true,
"sandBox": false,
"image": "grumpy-coder.png"