From 01e4cc60fd250b67e4514ed26a1e1edc72115109 Mon Sep 17 00:00:00 2001 From: Frede Hundewadt Date: Sat, 25 Mar 2023 15:59:34 +0100 Subject: [PATCH] WIP: supervisor --- .../ReportActivityListComponent.razor | 74 +++++++ .../ReportActivityListComponent.razor.cs | 31 +++ ...Page.razor => OfficeAdvisorListPage.razor} | 0 ...azor.cs => OfficeAdvisorListPage.razor.cs} | 2 +- ...azor => OfficeAdvisorReportListPage.razor} | 0 ...s => OfficeAdvisorReportListPage.razor.cs} | 2 +- .../SupervisorAdvisorReportViewPage.razor | 71 +++++++ .../SupervisorAdvisorReportViewPage.razor.cs | 181 ++++++++++++++++++ .../Pages/SupervisorAdvisorViewPage.razor | 5 + .../Pages/SupervisorAdvisorViewPage.razor.cs | 6 + Wonky.Client/Pages/SupervisorHomePage.razor | 5 + .../Pages/SupervisorHomePage.razor.cs | 6 + ...age.razor => SupervisorUserListPage.razor} | 4 +- ...zor.cs => SupervisorUserListPage.razor.cs} | 11 +- .../Pages/SupervisorVisitViewPage.razor | 158 +++++++++++++++ .../Pages/SupervisorVisitViewPage.razor.cs | 140 ++++++++++++++ .../Pages/SupervisorVisitViewPage.razor.css | 21 ++ Wonky.Client/Shared/NavMenu-backup.razor | 146 ++++++++++++++ Wonky.Client/Shared/NavMenu-backup.razor.css | 81 ++++++++ 19 files changed, 937 insertions(+), 7 deletions(-) create mode 100644 Wonky.Client/Components/ReportActivityListComponent.razor create mode 100644 Wonky.Client/Components/ReportActivityListComponent.razor.cs rename Wonky.Client/Pages/{OfficeUserAdvisorListPage.razor => OfficeAdvisorListPage.razor} (100%) rename Wonky.Client/Pages/{OfficeUserAdvisorListPage.razor.cs => OfficeAdvisorListPage.razor.cs} (97%) rename Wonky.Client/Pages/{OfficeUserAdvisorReportListPage.razor => OfficeAdvisorReportListPage.razor} (100%) rename Wonky.Client/Pages/{OfficeUserAdvisorReportListPage.razor.cs => OfficeAdvisorReportListPage.razor.cs} (97%) create mode 100644 Wonky.Client/Pages/SupervisorAdvisorReportViewPage.razor create mode 100644 Wonky.Client/Pages/SupervisorAdvisorReportViewPage.razor.cs create mode 100644 Wonky.Client/Pages/SupervisorAdvisorViewPage.razor create mode 100644 Wonky.Client/Pages/SupervisorAdvisorViewPage.razor.cs create mode 100644 Wonky.Client/Pages/SupervisorHomePage.razor create mode 100644 Wonky.Client/Pages/SupervisorHomePage.razor.cs rename Wonky.Client/Pages/{SupervisorAdvisorListPage.razor => SupervisorUserListPage.razor} (97%) rename Wonky.Client/Pages/{SupervisorAdvisorListPage.razor.cs => SupervisorUserListPage.razor.cs} (79%) create mode 100644 Wonky.Client/Pages/SupervisorVisitViewPage.razor create mode 100644 Wonky.Client/Pages/SupervisorVisitViewPage.razor.cs create mode 100644 Wonky.Client/Pages/SupervisorVisitViewPage.razor.css create mode 100644 Wonky.Client/Shared/NavMenu-backup.razor create mode 100644 Wonky.Client/Shared/NavMenu-backup.razor.css diff --git a/Wonky.Client/Components/ReportActivityListComponent.razor b/Wonky.Client/Components/ReportActivityListComponent.razor new file mode 100644 index 00000000..35abbaed --- /dev/null +++ b/Wonky.Client/Components/ReportActivityListComponent.razor @@ -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()) +{ + + + + + + + + + + + + + + + + + + @foreach (var activity in ActivityList) + { + + + + + + + + + + + + + + } + +
KundeBynavnDemoSalgNotesasBeløb
@activity.Company.Name@activity.Company.City@activity.Demo@activity.Sales@activity.OfficeNote@($"{activity.SasAmount:N2}")@(activity.StatusTypeEnum == "Quote" ? $"{0:N2}" : $"{activity.OrderAmount:N2}") + @if (activity.OurRef.Contains("T:")) + {} + + @if (activity.Express) + {} + + @if (activity.StatusTypeEnum == "Quote") + {} + + @if (activity.Lines.Any() && activity.StatusTypeEnum == "Order") + { + + } +
+} +else +{ +
Ingen data
+} \ No newline at end of file diff --git a/Wonky.Client/Components/ReportActivityListComponent.razor.cs b/Wonky.Client/Components/ReportActivityListComponent.razor.cs new file mode 100644 index 00000000..2aadc4a2 --- /dev/null +++ b/Wonky.Client/Components/ReportActivityListComponent.razor.cs @@ -0,0 +1,31 @@ +// 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 OfficeReportActivityListComponent +{ + [Parameter] public List ActivityList { get; set; } = new(); + [Inject] public NavigationManager Navigator { get; set; } + + private void ShowOrder(string companyId, string orderId) + { + Navigator.NavigateTo($"/office/customers/{companyId}/orders/{orderId}"); + } +} \ No newline at end of file diff --git a/Wonky.Client/Pages/OfficeUserAdvisorListPage.razor b/Wonky.Client/Pages/OfficeAdvisorListPage.razor similarity index 100% rename from Wonky.Client/Pages/OfficeUserAdvisorListPage.razor rename to Wonky.Client/Pages/OfficeAdvisorListPage.razor diff --git a/Wonky.Client/Pages/OfficeUserAdvisorListPage.razor.cs b/Wonky.Client/Pages/OfficeAdvisorListPage.razor.cs similarity index 97% rename from Wonky.Client/Pages/OfficeUserAdvisorListPage.razor.cs rename to Wonky.Client/Pages/OfficeAdvisorListPage.razor.cs index 01874e90..1cecfd56 100644 --- a/Wonky.Client/Pages/OfficeUserAdvisorListPage.razor.cs +++ b/Wonky.Client/Pages/OfficeAdvisorListPage.razor.cs @@ -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; } diff --git a/Wonky.Client/Pages/OfficeUserAdvisorReportListPage.razor b/Wonky.Client/Pages/OfficeAdvisorReportListPage.razor similarity index 100% rename from Wonky.Client/Pages/OfficeUserAdvisorReportListPage.razor rename to Wonky.Client/Pages/OfficeAdvisorReportListPage.razor diff --git a/Wonky.Client/Pages/OfficeUserAdvisorReportListPage.razor.cs b/Wonky.Client/Pages/OfficeAdvisorReportListPage.razor.cs similarity index 97% rename from Wonky.Client/Pages/OfficeUserAdvisorReportListPage.razor.cs rename to Wonky.Client/Pages/OfficeAdvisorReportListPage.razor.cs index a0c6d8f5..627fae57 100644 --- a/Wonky.Client/Pages/OfficeUserAdvisorReportListPage.razor.cs +++ b/Wonky.Client/Pages/OfficeAdvisorReportListPage.razor.cs @@ -23,7 +23,7 @@ using Wonky.Entity.Views; namespace Wonky.Client.Pages; -public partial class OfficeUserAdvisorReportListPage : IDisposable +public partial class OfficeAdvisorReportListPage : IDisposable { // ############################################################# [Inject] public ICountryReportRepository ReportRepo { get; set; } diff --git a/Wonky.Client/Pages/SupervisorAdvisorReportViewPage.razor b/Wonky.Client/Pages/SupervisorAdvisorReportViewPage.razor new file mode 100644 index 00000000..2c800c51 --- /dev/null +++ b/Wonky.Client/Pages/SupervisorAdvisorReportViewPage.razor @@ -0,0 +1,71 @@ +@* 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 +@using Wonky.Client.Models +@attribute [Authorize(Roles = "Admin,Office,Supervisor")] +@page "/office/users/advisors/{CountryCode}/{UserId}/reports/{ReportDate}" + +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ @if (!string.IsNullOrWhiteSpace(Report.ReportData.DayTypeEnum)) + { + @Report.ReportData.Name +
+
+

@Report.ReportData.Name

+
+
+
+
+ +
+
+ +
+
+ + + } + else + { +
+
Ingen rapport data
+
+ } +
+ +@if (Activities.Any()) +{ + foreach (var item in Activities.Where(item => item.StatusTypeEnum.ToLower() == "order" && item.ProcessStatusEnum.ToLower() == "none")) + { + + } +} diff --git a/Wonky.Client/Pages/SupervisorAdvisorReportViewPage.razor.cs b/Wonky.Client/Pages/SupervisorAdvisorReportViewPage.razor.cs new file mode 100644 index 00000000..9cdb7904 --- /dev/null +++ b/Wonky.Client/Pages/SupervisorAdvisorReportViewPage.razor.cs @@ -0,0 +1,181 @@ +// 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 OfficeAdvisorReportViewPage : IDisposable +{ + // ############################################################# + [Inject] public HttpInterceptorService Interceptor { get; set; } + [Inject] public ICountryReportRepository ReportRepo { get; set; } + [Inject] public NavigationManager Navigator { get; set; } + [Inject] public ILogger 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 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("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"); + } + + /// + /// Work date component event handler + /// + /// + 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($"/office/users/advisors/{CountryCode}/{UserId}/reports/{workDate}", false, true); + + // return if we are already at it + if (Working) + { + return; + } + + // reset variables + Report = new ReportView(); + Activities = new List(); + + // 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; + } +} \ No newline at end of file diff --git a/Wonky.Client/Pages/SupervisorAdvisorViewPage.razor b/Wonky.Client/Pages/SupervisorAdvisorViewPage.razor new file mode 100644 index 00000000..608b31b0 --- /dev/null +++ b/Wonky.Client/Pages/SupervisorAdvisorViewPage.razor @@ -0,0 +1,5 @@ +

SupervisorAdvisorVewPage

+ +@code { + +} \ No newline at end of file diff --git a/Wonky.Client/Pages/SupervisorAdvisorViewPage.razor.cs b/Wonky.Client/Pages/SupervisorAdvisorViewPage.razor.cs new file mode 100644 index 00000000..03de56b0 --- /dev/null +++ b/Wonky.Client/Pages/SupervisorAdvisorViewPage.razor.cs @@ -0,0 +1,6 @@ +namespace Wonky.Client.Pages; + +public class SupervisorAdvisorViewPage_razor +{ + +} \ No newline at end of file diff --git a/Wonky.Client/Pages/SupervisorHomePage.razor b/Wonky.Client/Pages/SupervisorHomePage.razor new file mode 100644 index 00000000..74e18076 --- /dev/null +++ b/Wonky.Client/Pages/SupervisorHomePage.razor @@ -0,0 +1,5 @@ +

SupervisorHomePage

+ +@code { + +} \ No newline at end of file diff --git a/Wonky.Client/Pages/SupervisorHomePage.razor.cs b/Wonky.Client/Pages/SupervisorHomePage.razor.cs new file mode 100644 index 00000000..f9891d6a --- /dev/null +++ b/Wonky.Client/Pages/SupervisorHomePage.razor.cs @@ -0,0 +1,6 @@ +namespace Wonky.Client.Pages; + +public class SupervisorHomePage_razor +{ + +} \ No newline at end of file diff --git a/Wonky.Client/Pages/SupervisorAdvisorListPage.razor b/Wonky.Client/Pages/SupervisorUserListPage.razor similarity index 97% rename from Wonky.Client/Pages/SupervisorAdvisorListPage.razor rename to Wonky.Client/Pages/SupervisorUserListPage.razor index 7115a6c2..9d90fe46 100644 --- a/Wonky.Client/Pages/SupervisorAdvisorListPage.razor +++ b/Wonky.Client/Pages/SupervisorUserListPage.razor @@ -15,7 +15,7 @@ @using Microsoft.AspNetCore.Authorization @attribute [Authorize(Roles = "Supervisor")] -@page "/supervisor/salesReps" +@page "/supervisor/advisors" Supervisor Sælger Oversigt
@@ -58,7 +58,7 @@ { foreach (var user in Users) { - +
@user.CountryCode @user.SalesRep diff --git a/Wonky.Client/Pages/SupervisorAdvisorListPage.razor.cs b/Wonky.Client/Pages/SupervisorUserListPage.razor.cs similarity index 79% rename from Wonky.Client/Pages/SupervisorAdvisorListPage.razor.cs rename to Wonky.Client/Pages/SupervisorUserListPage.razor.cs index a242f8d0..4379d9b5 100644 --- a/Wonky.Client/Pages/SupervisorAdvisorListPage.razor.cs +++ b/Wonky.Client/Pages/SupervisorUserListPage.razor.cs @@ -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() diff --git a/Wonky.Client/Pages/SupervisorVisitViewPage.razor b/Wonky.Client/Pages/SupervisorVisitViewPage.razor new file mode 100644 index 00000000..ebebe2ec --- /dev/null +++ b/Wonky.Client/Pages/SupervisorVisitViewPage.razor @@ -0,0 +1,158 @@ +@* 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 "/office/customers/{CompanyId}/orders/{OrderId}" +@ReportItem.ESalesNumber - @ReportItem.Company.Name + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+ +
+ @if (ReportItem is { Express: true, ProcessStatusEnum: "None" }) + { + + +
+ +
+
+
+ } +
+
+
+

@ReportItem.Company.Name

+ @if (ReportItem.Express) + { +

HASTER

+ } + @if (ReportItem.VisitTypeEnum.ToLower() == "phone" || ReportItem.OurRef.Contains("T:")) + { +
TELEFONORDRE
+ } + @if (ReportItem.StatusTypeEnum is "Quote") + { +
TILBUD
+ } +
+
Dato@ReportItem.OrderDateKonto@ReportItem.Company.Account
Telefon@ReportItem.Company.PhoneKøber@ReportItem.YourRef
CVR/VAT@ReportItem.Company.VatNumberRekvisition@ReportItem.ReferenceNumber
Navn@ReportItem.Company.NameLev.Navn@ReportItem.DlvName
Adresse@ReportItem.Company.Address1Lev.Adresse@ReportItem.DlvAddress1
Adresse@ReportItem.Company.Address2Lev.Adresse@ReportItem.DlvAddress2
Postnr By@ReportItem.Company.ZipCode @ReportItem.Company.CityLev.Postnr By@ReportItem.DlvZipCity
Email@ReportItem.Company.Email
+ + + + + + + + + + + + + @foreach (var line in ReportItem.Lines) + { + + + + + + + + + } + + + + + + @if (ReportItem.Express) + { + + + } + +
AntalVarnrBeskrivelsePrisR%Beløb
@line.Quantity@line.Sku@line.Description@($"{line.Price:N2}")@($"{line.Discount:N2}")@($"{line.LineSum:N2}")
Ordresum@ReportItem.OrderAmount
+
HASTER
+
+@if (!string.IsNullOrWhiteSpace(ReportItem.OfficeNote)) +{ +
+

@ReportItem.OfficeNote

+
+} + + +@if (Working) +{ + +} \ No newline at end of file diff --git a/Wonky.Client/Pages/SupervisorVisitViewPage.razor.cs b/Wonky.Client/Pages/SupervisorVisitViewPage.razor.cs new file mode 100644 index 00000000..d2c4716f --- /dev/null +++ b/Wonky.Client/Pages/SupervisorVisitViewPage.razor.cs @@ -0,0 +1,140 @@ +// 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 OfficeOrderViewPage : 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 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; + } + + /// + /// Set activity process state to express. Send confirmation notification to salesRep + /// + private async Task SetExpressState() + { + // disable doubled actions + if (Working) + return; + Working = true; + Logger.LogDebug("GetExpressState => {}", JsonSerializer.Serialize(ReportItem, _options)); + // send request to backend + var responseView = await AdvisorActivityRepo.GetExpressState(ReportItem.ActivityId); + Logger.LogDebug("SetExpressState => responseView <= {} ", JsonSerializer.Serialize(responseView)); + // get user info from storage + var user = await UserInfoService.GetUserInfo(); + // fetch sales rep from response + var salesRep = await UserRepo.GetUserInfo(responseView.Id); + Logger.LogDebug("SetExpressState => salesRep => {}", JsonSerializer.Serialize(salesRep)); + // create email notification body + var body = new StringBuilder(); + body.AppendLine($"Kvittering for modtagelse af hasteordre {ReportItem.ESalesNumber}"); + body.AppendLine($"Konto : {ReportItem.Company.Account}"); + body.AppendLine($"Navn : {ReportItem.Company.Name}"); + body.AppendLine( + $"Post By : {salesRep.CountryCode.ToUpper()}-{ReportItem.Company.ZipCode} {ReportItem.Company.City}"); + body.AppendLine(); + body.AppendLine("Med venlig hilsen"); + body.AppendLine($"{user.FirstName} {user.LastName}"); + body.AppendLine($"{user.PhoneNumber}"); + // create a list of mail addresses + var sendTo = new List + { + new() + { + Email = salesRep.Email, + Name = $"{salesRep.FirstName} {salesRep.LastName}" + } + }; + // create an email + var msg = new EmailMessage + { + Body = body.ToString(), + Subject = $"Haste ordre til {ReportItem.Company.Name} er modtaget.", + To = sendTo, + IsBodyHtml = false + }; + Logger.LogDebug("SetExpressState Notification => \n {}", JsonSerializer.Serialize(msg)); + // send a system generated email + var sendMail = await MailService.SendMail("System", msg); + + // result notification + if (sendMail.IsSuccess) + { + Toast + .ShowSuccess( + $"Status er opdateret og notifikation sendt til {salesRep.FirstName}.", "OK"); + } + else + { + Toast + .ShowWarning( + $"Notifikation til {salesRep.FirstName} kunne ikke sendes. {sendMail.Message}", "ADVARSEL"); + } + Logger.LogDebug("SendMail Result => \n {}", JsonSerializer.Serialize(sendMail)); + // disable further notifications + IsNotified = true; + Working = false; + } + + public void Dispose() + { + Interceptor.DisposeEvent(); + } +} \ No newline at end of file diff --git a/Wonky.Client/Pages/SupervisorVisitViewPage.razor.css b/Wonky.Client/Pages/SupervisorVisitViewPage.razor.css new file mode 100644 index 00000000..182f9027 --- /dev/null +++ b/Wonky.Client/Pages/SupervisorVisitViewPage.razor.css @@ -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; +} \ No newline at end of file diff --git a/Wonky.Client/Shared/NavMenu-backup.razor b/Wonky.Client/Shared/NavMenu-backup.razor new file mode 100644 index 00000000..4770cef0 --- /dev/null +++ b/Wonky.Client/Shared/NavMenu-backup.razor @@ -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 + +
+ +
+ +
+ +@code { + + private bool collapseNavMenu = true; + + private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null; + + private void ToggleNavMenu() + { + collapseNavMenu = !collapseNavMenu; + } + + +} \ No newline at end of file diff --git a/Wonky.Client/Shared/NavMenu-backup.razor.css b/Wonky.Client/Shared/NavMenu-backup.razor.css new file mode 100644 index 00000000..dfecd000 --- /dev/null +++ b/Wonky.Client/Shared/NavMenu-backup.razor.css @@ -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; + } +}