From 6a246b1dc56f25258a3f04bab7cb62893d7c2e52 Mon Sep 17 00:00:00 2001 From: Frede Hundewadt Date: Thu, 22 Dec 2022 15:00:07 +0100 Subject: [PATCH] built v.0.87.1 --- .../OfficeReportTableComponent.razor.cs | 2 +- .../Components/ReportTableComponent.razor.cs | 4 +- .../Components/WorkDateComponent.razor | 4 +- .../ICrmReportHttpRepository.cs | 2 +- .../IOfficeReportHttpRepository.cs | 2 +- .../HttpRepository/CrmReportHttpRepository.cs | 4 +- .../OfficeReportHttpRepository.cs | 4 +- Wonky.Client/Models/PTarget.cs | 9 ++ Wonky.Client/Pages/ActivityCreatePage.razor | 17 ---- Wonky.Client/Pages/CatalogPage.razor | 2 +- Wonky.Client/Pages/CrmReportListPage.razor.cs | 2 +- Wonky.Client/Pages/CrmReportViewPage.razor | 43 +++++---- Wonky.Client/Pages/CrmReportViewPage.razor.cs | 32 +++++-- Wonky.Client/Pages/OfficeReportListPage.razor | 2 +- .../Pages/OfficeReportListPage.razor.cs | 23 +++-- Wonky.Client/Pages/OfficeReportViewPage.razor | 96 ++++++++++--------- .../Pages/OfficeReportViewPage.razor.cs | 77 ++++++++++----- ...PrintPage.razor => PrintCatalogPage.razor} | 2 +- ...age.razor.cs => PrintCatalogPage.razor.cs} | 2 +- Wonky.Client/Pages/PrintOrdersPage.razor | 32 +++++++ Wonky.Client/Pages/PrintOrdersPage.razor.cs | 64 +++++++++++++ Wonky.Client/Pages/PrintReportPage.razor | 46 +++++++++ Wonky.Client/Pages/PrintReportPage.razor.cs | 63 ++++++++++++ Wonky.Client/Shared/MainLayout.razor | 2 +- Wonky.Client/wwwroot/appsettings.json | 2 +- .../wwwroot/css/{app-v0.38.css => app.css} | 52 ---------- Wonky.Client/wwwroot/css/print.css | 53 ++++++++++ Wonky.Client/wwwroot/index.html | 17 ++-- Wonky.Client/wwwroot/scripts/bsTooltip.js | 4 - Wonky.Client/wwwroot/scripts/print-invoke.js | 7 ++ Wonky.Client/wwwroot/scripts/scripts.js | 16 ---- ...portListView.cs => SalesReportListView.cs} | 2 +- 32 files changed, 466 insertions(+), 223 deletions(-) create mode 100644 Wonky.Client/Models/PTarget.cs rename Wonky.Client/Pages/{CatalogPrintPage.razor => PrintCatalogPage.razor} (97%) rename Wonky.Client/Pages/{CatalogPrintPage.razor.cs => PrintCatalogPage.razor.cs} (97%) create mode 100644 Wonky.Client/Pages/PrintOrdersPage.razor create mode 100644 Wonky.Client/Pages/PrintOrdersPage.razor.cs create mode 100644 Wonky.Client/Pages/PrintReportPage.razor create mode 100644 Wonky.Client/Pages/PrintReportPage.razor.cs rename Wonky.Client/wwwroot/css/{app-v0.38.css => app.css} (73%) create mode 100644 Wonky.Client/wwwroot/css/print.css delete mode 100644 Wonky.Client/wwwroot/scripts/bsTooltip.js create mode 100644 Wonky.Client/wwwroot/scripts/print-invoke.js delete mode 100644 Wonky.Client/wwwroot/scripts/scripts.js rename Wonky.Entity/Views/{NgSalesReportListView.cs => SalesReportListView.cs} (97%) diff --git a/Wonky.Client/Components/OfficeReportTableComponent.razor.cs b/Wonky.Client/Components/OfficeReportTableComponent.razor.cs index 9e0f86e9..5f21c66e 100644 --- a/Wonky.Client/Components/OfficeReportTableComponent.razor.cs +++ b/Wonky.Client/Components/OfficeReportTableComponent.razor.cs @@ -20,7 +20,7 @@ namespace Wonky.Client.Components; public partial class OfficeReportTableComponent { - [Parameter] public List ReportList { get; set; } = new(); + [Parameter] public List ReportList { get; set; } = new(); [Parameter] public string UserId { get; set; } = ""; [Parameter] public string CountryCode { get; set; } = ""; } \ No newline at end of file diff --git a/Wonky.Client/Components/ReportTableComponent.razor.cs b/Wonky.Client/Components/ReportTableComponent.razor.cs index 4da8d7c1..f7646d44 100644 --- a/Wonky.Client/Components/ReportTableComponent.razor.cs +++ b/Wonky.Client/Components/ReportTableComponent.razor.cs @@ -21,8 +21,8 @@ namespace Wonky.Client.Components; public partial class ReportTableComponent { - [Parameter] public List ReportList { get; set; } = new(); - private List _reports { get; set; } = new(); + [Parameter] public List ReportList { get; set; } = new(); + private List _reports { get; set; } = new(); protected override void OnParametersSet() { _reports = ReportList; diff --git a/Wonky.Client/Components/WorkDateComponent.razor b/Wonky.Client/Components/WorkDateComponent.razor index 6dbc50a3..e9e1d862 100644 --- a/Wonky.Client/Components/WorkDateComponent.razor +++ b/Wonky.Client/Components/WorkDateComponent.razor @@ -21,10 +21,10 @@
-
+
@SelectedDate.ToLongDateString()
-
+
diff --git a/Wonky.Client/HttpInterfaces/ICrmReportHttpRepository.cs b/Wonky.Client/HttpInterfaces/ICrmReportHttpRepository.cs index 2ab9f1ef..d6211053 100644 --- a/Wonky.Client/HttpInterfaces/ICrmReportHttpRepository.cs +++ b/Wonky.Client/HttpInterfaces/ICrmReportHttpRepository.cs @@ -21,7 +21,7 @@ namespace Wonky.Client.HttpInterfaces; public interface ICrmReportHttpRepository { Task ReportExist(string workDate); - Task> GetReports(); + Task> GetReports(); Task GetReport(string workDate); Task InitializeReportData(string workDate); Task PostReport(string workDate, ReportDto reportDto); diff --git a/Wonky.Client/HttpInterfaces/IOfficeReportHttpRepository.cs b/Wonky.Client/HttpInterfaces/IOfficeReportHttpRepository.cs index 8c989461..bcb6bf69 100644 --- a/Wonky.Client/HttpInterfaces/IOfficeReportHttpRepository.cs +++ b/Wonky.Client/HttpInterfaces/IOfficeReportHttpRepository.cs @@ -20,6 +20,6 @@ namespace Wonky.Client.HttpInterfaces; public interface IOfficeReportHttpRepository { - Task> GetReports(string userId); + Task> GetReports(string userId); Task GetReport(string userId, string workDate); } \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/CrmReportHttpRepository.cs b/Wonky.Client/HttpRepository/CrmReportHttpRepository.cs index 84d5c462..71074793 100644 --- a/Wonky.Client/HttpRepository/CrmReportHttpRepository.cs +++ b/Wonky.Client/HttpRepository/CrmReportHttpRepository.cs @@ -47,9 +47,9 @@ public class CrmReportHttpRepository :ICrmReportHttpRepository _apiConfig = configuration.Value; } - public async Task> GetReports() + public async Task> GetReports() { - return await _client.GetFromJsonAsync>($"{_apiConfig.CrmReports}"); + return await _client.GetFromJsonAsync>($"{_apiConfig.CrmReports}"); } public async Task ReportExist(string workDate) { diff --git a/Wonky.Client/HttpRepository/OfficeReportHttpRepository.cs b/Wonky.Client/HttpRepository/OfficeReportHttpRepository.cs index e5814c79..42319199 100644 --- a/Wonky.Client/HttpRepository/OfficeReportHttpRepository.cs +++ b/Wonky.Client/HttpRepository/OfficeReportHttpRepository.cs @@ -46,9 +46,9 @@ public class OfficeReportHttpRepository : IOfficeReportHttpRepository _apiConfig = configuration.Value; } - public async Task> GetReports(string userId) + public async Task> GetReports(string userId) { - return await _client.GetFromJsonAsync>($"{_apiConfig.OfficeReports}/{userId}"); + return await _client.GetFromJsonAsync>($"{_apiConfig.OfficeReports}/{userId}"); } public async Task GetReport(string userId, string workDate) diff --git a/Wonky.Client/Models/PTarget.cs b/Wonky.Client/Models/PTarget.cs new file mode 100644 index 00000000..122d24d5 --- /dev/null +++ b/Wonky.Client/Models/PTarget.cs @@ -0,0 +1,9 @@ +namespace Wonky.Client.Models; + +public enum PTarget +{ + None, + All, + Report, + Order +} \ No newline at end of file diff --git a/Wonky.Client/Pages/ActivityCreatePage.razor b/Wonky.Client/Pages/ActivityCreatePage.razor index e240c5af..7c5d3665 100644 --- a/Wonky.Client/Pages/ActivityCreatePage.razor +++ b/Wonky.Client/Pages/ActivityCreatePage.razor @@ -262,23 +262,6 @@ else @* end draft line ------------------------------------------------- *@
- @* - $1$ Order lines #1# -
-

- -

-
-
- -
-
-
- *@ @* Delivery address *@

diff --git a/Wonky.Client/Pages/CatalogPage.razor b/Wonky.Client/Pages/CatalogPage.razor index 9bd50259..6f941ed9 100644 --- a/Wonky.Client/Pages/CatalogPage.razor +++ b/Wonky.Client/Pages/CatalogPage.razor @@ -42,7 +42,7 @@

diff --git a/Wonky.Client/Pages/CrmReportListPage.razor.cs b/Wonky.Client/Pages/CrmReportListPage.razor.cs index 4fed94f5..73926284 100644 --- a/Wonky.Client/Pages/CrmReportListPage.razor.cs +++ b/Wonky.Client/Pages/CrmReportListPage.razor.cs @@ -27,7 +27,7 @@ public partial class CrmReportListPage : IDisposable [Inject] public ICrmReportHttpRepository CrmReportRepo { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; } - private List ReportList { get; set; } = new(); + private List ReportList { get; set; } = new(); private bool Working { get; set; } = true; protected override async Task OnInitializedAsync() diff --git a/Wonky.Client/Pages/CrmReportViewPage.razor b/Wonky.Client/Pages/CrmReportViewPage.razor index a4926e4a..fa04ef17 100644 --- a/Wonky.Client/Pages/CrmReportViewPage.razor +++ b/Wonky.Client/Pages/CrmReportViewPage.razor @@ -17,36 +17,43 @@ @using Wonky.Client.Components @using Microsoft.AspNetCore.Authorization +@using Wonky.Client.Models @page "/sales-reports/view/{ReportDate}" @attribute [Authorize(Roles = "Advisor,Admin,Supervisor")]
-
- +
+
-
- +
+
-
+
+ +
+
+ +
+
- @if (!string.IsNullOrWhiteSpace(_report.ReportData.DayTypeEnum)) + @if (!string.IsNullOrWhiteSpace(Report.ReportData.DayTypeEnum)) { - @_report.ReportData.Name + @Report.ReportData.Name
-

@_report.ReportData.Name

+

@Report.ReportData.Name

- +
- +
- - + + } else { @@ -56,13 +63,9 @@ }
-
-   -
- -@if (_items.Any()) +@if (Items.Any()) { - @foreach (var item in _items) + @foreach (var item in Items) { } @@ -71,5 +74,5 @@ @if (Working) { - -} + +} \ No newline at end of file diff --git a/Wonky.Client/Pages/CrmReportViewPage.razor.cs b/Wonky.Client/Pages/CrmReportViewPage.razor.cs index 8b0f29d9..44d46280 100644 --- a/Wonky.Client/Pages/CrmReportViewPage.razor.cs +++ b/Wonky.Client/Pages/CrmReportViewPage.razor.cs @@ -13,9 +13,11 @@ // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // +using Blazored.LocalStorage; using Microsoft.AspNetCore.Components; using Wonky.Client.HttpInterfaces; using Wonky.Client.HttpRepository; +using Wonky.Client.Models; using Wonky.Entity.DTO; using Wonky.Entity.Views; @@ -24,10 +26,12 @@ namespace Wonky.Client.Pages; public partial class CrmReportViewPage { [Parameter] public string ReportDate { get; set; } - [Inject] public ICrmReportHttpRepository CrmReportRepo { get; set; } - [Inject] public NavigationManager _navigator { get; set; } - private ReportView _report { get; set; } = new(); - private List _items { get; set; } = new (); + [Inject] public ICrmReportHttpRepository ReportRepo { get; set; } + [Inject] public NavigationManager Navigator { get; set; } + [Inject] public ILocalStorageService Storage { get; set; } + private ReportView Report { get; set; } = new(); + private List Items { get; set; } = new (); + private bool Working { get; set; } = true; protected override async Task OnInitializedAsync() @@ -40,17 +44,27 @@ public partial class CrmReportViewPage Working = false; } + private async Task Print(PTarget target) + { + var ux = await Storage.GetItemAsync("_ux"); + if (target == PTarget.Order) + { + Navigator.NavigateTo($"/print/orders/{ux.CountryCode}/{ux.Id}/{ReportDate}"); + return; + } + Navigator.NavigateTo($"/print/report/{ux.CountryCode}/{ux.Id}/{ReportDate}"); + } private async Task GetReport(string workDate) { Working = true; - _report = new ReportView(); - _items = new List(); + Report = new ReportView(); + Items = new List(); if(workDate != ReportDate) - _navigator.NavigateTo($"/sales-reports/view/{workDate}"); - _report = await CrmReportRepo.GetReport(workDate); + Navigator.NavigateTo($"/sales-reports/view/{workDate}"); + Report = await ReportRepo.GetReport(workDate); - _items = _report.ReportItems.Where(x => x.Lines.Any()).ToList(); + Items = Report.ReportItems.Where(x => x.Lines.Any()).ToList(); Working = false; } } \ No newline at end of file diff --git a/Wonky.Client/Pages/OfficeReportListPage.razor b/Wonky.Client/Pages/OfficeReportListPage.razor index 7caa6c9d..e9fddd8c 100644 --- a/Wonky.Client/Pages/OfficeReportListPage.razor +++ b/Wonky.Client/Pages/OfficeReportListPage.razor @@ -29,7 +29,7 @@
- +
diff --git a/Wonky.Client/Pages/OfficeReportListPage.razor.cs b/Wonky.Client/Pages/OfficeReportListPage.razor.cs index 9106d49e..b859771d 100644 --- a/Wonky.Client/Pages/OfficeReportListPage.razor.cs +++ b/Wonky.Client/Pages/OfficeReportListPage.razor.cs @@ -26,22 +26,31 @@ public partial class OfficeReportListPage : IDisposable { [Parameter] public string UserId { get; set; } = ""; [Parameter] public string CountryCode { get; set; } = ""; - [Inject] public IOfficeReportHttpRepository _reportRepo { get; set; } - [Inject] public HttpInterceptorService _interceptor { get; set; } - private List _reports { get; set; } + [Inject] public IOfficeReportHttpRepository ReportRepo { get; set; } + [Inject] public HttpInterceptorService Interceptor { get; set; } + private List ActivityReports { get; set; } = new(); private bool Working { get; set; } = true; + protected override async Task OnInitializedAsync() { - _interceptor.RegisterEvent(); - _interceptor.RegisterBeforeSendEvent(); + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); - _reports = await _reportRepo.GetReports(UserId); + await FetchReports(); Working = false; } + private async Task FetchReports() + { + var reports = await ReportRepo.GetReports(UserId); + if (reports.Any()) + ActivityReports = reports.OrderByDescending(x => x.ReportDate).ToList(); + } + + /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. public void Dispose() { - _interceptor.DisposeEvent(); + Interceptor.DisposeEvent(); } } \ No newline at end of file diff --git a/Wonky.Client/Pages/OfficeReportViewPage.razor b/Wonky.Client/Pages/OfficeReportViewPage.razor index 588e745e..55494943 100644 --- a/Wonky.Client/Pages/OfficeReportViewPage.razor +++ b/Wonky.Client/Pages/OfficeReportViewPage.razor @@ -17,60 +17,66 @@ @using Wonky.Client.Components @using Microsoft.AspNetCore.Authorization +@using Wonky.Client.Models @page "/office/users/advisors/{CountryCode}/{UserId}/reports/{ReportDate}" @attribute [Authorize(Roles = "Admin")] -
-
- @*
*@ - @*

@DateTime.Parse(ReportDate).ToLongDateString()

*@ - @*
*@ -
- -
-
- -
- @* todo - option wo print only report - *@ +
+
+ +
+
+ +
+
+ +
+
+
- @if (!string.IsNullOrWhiteSpace(Report.ReportData.DayTypeEnum)) - { - @Report.ReportData.Name -
-
-

@Report.ReportData.Name

-
-
-
-
- -
-
- -
-
- - - } - else - { -
-
Ingen data
-
- }
-@* todo - add flag for printing only report *@ -@if (_items.Any()) +@if (ThisTarget is PTarget.Report or PTarget.All) { - @foreach (var item in _items.Where(item => item.StatusTypeEnum.ToLower() == "order" && item.ProcessStatusEnum.ToLower() == "none")) - { - - } +
+ @if (!string.IsNullOrWhiteSpace(Report.ReportData.DayTypeEnum)) + { + @Report.ReportData.Name +
+
+

@Report.ReportData.Name

+
+
+
+
+ +
+
+ +
+
+ + + } + else + { +
+
Ingen data
+
+ } +
} +@if (ThisTarget is PTarget.Order or PTarget.All) +{ + if (Activities.Any()) + { + foreach (var item in Activities.Where(item => item.StatusTypeEnum.ToLower() == "order" && item.ProcessStatusEnum.ToLower() == "none")) + { + + } + } +} @if (Working) { diff --git a/Wonky.Client/Pages/OfficeReportViewPage.razor.cs b/Wonky.Client/Pages/OfficeReportViewPage.razor.cs index 4cd69f6c..2e15f94b 100644 --- a/Wonky.Client/Pages/OfficeReportViewPage.razor.cs +++ b/Wonky.Client/Pages/OfficeReportViewPage.razor.cs @@ -13,11 +13,11 @@ // 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 Microsoft.AspNetCore.Components; using Wonky.Client.HttpInterceptors; using Wonky.Client.HttpInterfaces; -using Wonky.Client.HttpRepository; +using Wonky.Client.Models; using Wonky.Entity.Views; namespace Wonky.Client.Pages; @@ -27,46 +27,71 @@ public partial class OfficeReportViewPage : IDisposable /// /// Country code from url parameter /// - [Parameter] public string CountryCode { get; set; } = ""; + [Parameter] + public string CountryCode { get; set; } = ""; + /// /// Report date from url parameter /// - [Parameter] public string ReportDate { get; set; } = ""; + [Parameter] + public string ReportDate { get; set; } = ""; + /// /// User entity Id from url parameter /// - [Parameter] public string UserId { get; set; } = ""; + [Parameter] + public string UserId { get; set; } = ""; + /// /// Injected interceptor service /// - [Inject] public HttpInterceptorService _interceptor { get; set; } + [Inject] + public HttpInterceptorService Interceptor { get; set; } + /// /// Injected administrative report http repo /// - [Inject] public IOfficeReportHttpRepository _reportRepo { get; set; } + [Inject] + public IOfficeReportHttpRepository ReportRepo { get; set; } + /// /// Navigation Manager /// - [Inject] public NavigationManager _navigator { get; set; } + [Inject] + public NavigationManager Navigator { get; set; } + + [Inject] public ILogger Logger { get; set; } + [Inject] public ILocalStorageService Storage { get; set; } /// /// Report to render /// private ReportView Report { get; set; } = new(); - private List _items { get; set; } = new(); - private string _workDate { get; set; } = ""; + private PTarget ThisTarget { get; set; } = PTarget.All; + private List Activities { get; set; } = new(); private bool Working { get; set; } = true; - + protected override async Task OnParametersSetAsync() { - _interceptor.RegisterEvent(); - _interceptor.RegisterBeforeSendEvent(); - + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); + await Task.Delay(100); await FetchReport(ReportDate); Working = false; } - + + private void Print(PTarget target) + { + if (target == PTarget.Order) + { + Navigator.NavigateTo($"/print/orders/{CountryCode}/{UserId}/{ReportDate}"); + return; + } + Navigator.NavigateTo($"/print/report/{CountryCode}/{UserId}/{ReportDate}"); + + } + /// /// Work date component event handler /// @@ -75,20 +100,20 @@ public partial class OfficeReportViewPage : IDisposable { if (workDate != ReportDate) { - _navigator.NavigateTo($"/office/users/advisors/{CountryCode}/{UserId}/reports/{workDate}"); + Navigator.NavigateTo($"/office/users/advisors/{CountryCode}/{UserId}/reports/{workDate}"); return; } Working = true; Report = new ReportView(); - _items = new List(); - - Report = await FetchUserReport(UserId, workDate); - //_items = Report.ReportItems.Where(x => x.OrderAmount > 0).ToList(); - _items = Report.ReportItems.Where(x => x.Lines.Any()).ToList(); - Working = false; + Activities = new List(); + Report = await FetchUserReport(UserId, workDate); + Activities = Report.ReportItems.Where(x => x.Lines.Any()).ToList(); + await Storage.SetItemAsync($"{UserId}-{ReportDate}", Report); + Working = false; } + /// /// Get report for user with entity Id for work date /// @@ -98,13 +123,13 @@ public partial class OfficeReportViewPage : IDisposable private async Task FetchUserReport(string userId, string workDate) { Working = true; - var x =Report = await _reportRepo.GetReport(userId, workDate); + var x = Report = await ReportRepo.GetReport(userId, workDate); Working = false; - return x; + return x; } public void Dispose() { - _interceptor.DisposeEvent(); + Interceptor.DisposeEvent(); } -} +} \ No newline at end of file diff --git a/Wonky.Client/Pages/CatalogPrintPage.razor b/Wonky.Client/Pages/PrintCatalogPage.razor similarity index 97% rename from Wonky.Client/Pages/CatalogPrintPage.razor rename to Wonky.Client/Pages/PrintCatalogPage.razor index ea83190b..ccced787 100644 --- a/Wonky.Client/Pages/CatalogPrintPage.razor +++ b/Wonky.Client/Pages/PrintCatalogPage.razor @@ -15,7 +15,7 @@ // *@ -@page "/price-catalog/print" +@page "/print/catalog" @using Wonky.Client.Components @using Microsoft.AspNetCore.Authorization diff --git a/Wonky.Client/Pages/CatalogPrintPage.razor.cs b/Wonky.Client/Pages/PrintCatalogPage.razor.cs similarity index 97% rename from Wonky.Client/Pages/CatalogPrintPage.razor.cs rename to Wonky.Client/Pages/PrintCatalogPage.razor.cs index 3b6cad5d..a7246b2b 100644 --- a/Wonky.Client/Pages/CatalogPrintPage.razor.cs +++ b/Wonky.Client/Pages/PrintCatalogPage.razor.cs @@ -29,7 +29,7 @@ using Wonky.Entity.Views; namespace Wonky.Client.Pages; -public partial class CatalogPrintPage : IDisposable +public partial class PrintCatalogPage : IDisposable { [Inject] public ILocalStorageService Storage { get; set; } [Inject] public ICatalogHttpRepository ItemRepo { get; set; } diff --git a/Wonky.Client/Pages/PrintOrdersPage.razor b/Wonky.Client/Pages/PrintOrdersPage.razor new file mode 100644 index 00000000..2ea578f5 --- /dev/null +++ b/Wonky.Client/Pages/PrintOrdersPage.razor @@ -0,0 +1,32 @@ +@* +// 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 +@page "/print/orders/{CountryCode}/{UserId}/{ReportDate}" +@attribute [Authorize(Roles = "Admin,Advisor")] + +
+
+ +
+
+ +@foreach (var item in Items.Where(item => item.StatusTypeEnum.ToLower() == "order" && item.ProcessStatusEnum.ToLower() == "none")) +{ + +} diff --git a/Wonky.Client/Pages/PrintOrdersPage.razor.cs b/Wonky.Client/Pages/PrintOrdersPage.razor.cs new file mode 100644 index 00000000..d7e46dd1 --- /dev/null +++ b/Wonky.Client/Pages/PrintOrdersPage.razor.cs @@ -0,0 +1,64 @@ +// 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 Blazored.LocalStorage; +using Microsoft.AspNetCore.Components; +using Microsoft.JSInterop; +using Wonky.Entity.Views; + +namespace Wonky.Client.Pages; + +public partial class PrintOrdersPage +{ + [Parameter] public string CountryCode { get; set; } = ""; + [Parameter] public string UserId { get; set; } = ""; + [Parameter] public string ReportDate { get; set; } = ""; + [Inject] public ILocalStorageService Storage { get; set; } + [Inject] public NavigationManager Navigator { get; set; } + [Inject] private IJSRuntime JSRuntime { get; set; } + [Inject] public ILogger Logger { get; set; } + private ReportView Report { get; set; } = new(); + private List Items { get; set; } = new(); + private IJSObjectReference JsModule { get; set; } + + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + JsModule = await JSRuntime + .InvokeAsync("import", "/scripts/print-invoke.js"); + } + } + + protected override async Task OnInitializedAsync() + { + Report = await Storage.GetItemAsync($"{UserId}-{ReportDate}"); + Items = Report.ReportItems; + } + + private async Task Print() + { + await JsModule.InvokeVoidAsync("printInvoke"); + + Navigator.NavigateTo($"/office/users/advisors/{CountryCode}/{UserId}/reports/{ReportDate}"); + } + + /* + * await Task.Delay(1000); + * JS.InvokeVoidAsync("invokePrint"); + * InvokeAsync(() => StateHasChanged()); + */ +} diff --git a/Wonky.Client/Pages/PrintReportPage.razor b/Wonky.Client/Pages/PrintReportPage.razor new file mode 100644 index 00000000..e50aca41 --- /dev/null +++ b/Wonky.Client/Pages/PrintReportPage.razor @@ -0,0 +1,46 @@ +@* +// 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 +@page "/print/report/{CountryCode}/{UserId}/{ReportDate}" +@attribute [Authorize(Roles = "Admin,Advisor")] + +
+
+ +
+
+ +
+ @Report.ReportData.Name +
+
+

@Report.ReportData.Name

+
+
+
+
+ +
+
+ +
+
+ + +
\ No newline at end of file diff --git a/Wonky.Client/Pages/PrintReportPage.razor.cs b/Wonky.Client/Pages/PrintReportPage.razor.cs new file mode 100644 index 00000000..6f504d86 --- /dev/null +++ b/Wonky.Client/Pages/PrintReportPage.razor.cs @@ -0,0 +1,63 @@ +// 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 Blazored.LocalStorage; +using Microsoft.AspNetCore.Components; +using Microsoft.JSInterop; +using Wonky.Entity.Views; + +namespace Wonky.Client.Pages; + +public partial class PrintReportPage +{ + [Parameter] public string CountryCode { get; set; } = ""; + [Parameter] public string UserId { get; set; } = ""; + [Parameter] public string ReportDate { get; set; } = ""; + [Inject] public ILocalStorageService Storage { get; set; } + [Inject] public NavigationManager Navigator { get; set; } + [Inject] private IJSRuntime JSRuntime { get; set; } + [Inject] public ILogger Logger { get; set; } + private ReportView Report { get; set; } = new(); + private IJSObjectReference JsModule { get; set; } + private bool Printed { get; set; } + + protected override async Task OnInitializedAsync() + { + Report = await Storage.GetItemAsync($"{UserId}-{ReportDate}"); + } + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + JsModule = await JSRuntime + .InvokeAsync("import", "/scripts/print-invoke.js"); + } + } + + private async Task Print() + { + if(!Printed) + Printed = true; + await JsModule.InvokeVoidAsync("printInvoke"); + Navigator.NavigateTo($"/office/users/advisors/{CountryCode}/{UserId}/reports/{ReportDate}"); + } + + /* + * await Task.Delay(1000); + * JS.InvokeVoidAsync("invokePrint"); + * InvokeAsync(() => StateHasChanged()); + */ +} diff --git a/Wonky.Client/Shared/MainLayout.razor b/Wonky.Client/Shared/MainLayout.razor index bb572576..c64c9a6b 100644 --- a/Wonky.Client/Shared/MainLayout.razor +++ b/Wonky.Client/Shared/MainLayout.razor @@ -32,6 +32,6 @@
@Body
- +
diff --git a/Wonky.Client/wwwroot/appsettings.json b/Wonky.Client/wwwroot/appsettings.json index 6aee5bcf..a0421445 100644 --- a/Wonky.Client/wwwroot/appsettings.json +++ b/Wonky.Client/wwwroot/appsettings.json @@ -1,7 +1,7 @@ { "appInfo": { "name": "Wonky Client", - "version": "0.86.1", + "version": "0.87.1", "rc": true, "sandBox": false, "image": "grumpy-coder.png" diff --git a/Wonky.Client/wwwroot/css/app-v0.38.css b/Wonky.Client/wwwroot/css/app.css similarity index 73% rename from Wonky.Client/wwwroot/css/app-v0.38.css rename to Wonky.Client/wwwroot/css/app.css index d04a5d2e..2cb2a5d5 100644 --- a/Wonky.Client/wwwroot/css/app-v0.38.css +++ b/Wonky.Client/wwwroot/css/app.css @@ -152,55 +152,3 @@ footer.version { right: 25px; display: none; } - -/* printer classes */ -@media print { - @page { - size: a4; - } - @font-face { - font-family: 'Montserrat'; - src: url('https://fonts.googleapis.com/css2?family=Montserrat&display=swap'); - } - html, body { - height: 290mm; - width: 210mm; - -webkit-print-color-adjust: exact; - color-adjust: exact; - } - .report-main { - font-size: 10px; - break-before: page; - break-after: page; - page-break-after: always; - height: initial; - border: initial; - border-radius: initial; - box-shadow: initial; - margin: 0; - width: initial; - -webkit-print-color-adjust: exact; - color-adjust: exact; - } - .report-visit { - page-break-before: always; - break-after: page; - break-before: page; - break-inside: avoid-page; - height: initial; - border: initial; - border-radius: initial; - box-shadow: initial; - margin: 0; - width: initial; - -webkit-print-color-adjust: exact; - color-adjust: exact; - } - .distance-ledger {} - .report-ledger { - page-break-inside: avoid; - page-break-after: always; - break-after: recto; - min-height: 300px; - } -} \ No newline at end of file diff --git a/Wonky.Client/wwwroot/css/print.css b/Wonky.Client/wwwroot/css/print.css new file mode 100644 index 00000000..775f3c3e --- /dev/null +++ b/Wonky.Client/wwwroot/css/print.css @@ -0,0 +1,53 @@ +/* printer classes */ +@media print { + @page { + size: a4; + } + @font-face { + font-family: 'Montserrat'; + src: url('https://fonts.googleapis.com/css2?family=Montserrat&display=swap'); + } + html, body { + height: 290mm; + width: 210mm; + -webkit-print-color-adjust: exact; + color-adjust: exact; + } + .report-main { + font-size: 10px; + break-before: page; + break-after: page; + page-break-after: always; + height: initial; + border: initial; + border-radius: initial; + box-shadow: initial; + margin: 0; + width: initial; + -webkit-print-color-adjust: exact; + color-adjust: exact; + } + .report-visit { + page-break-before: always; + page-break-after: always; + break-after: page; + break-before: page; + break-inside: avoid-page; + height: initial; + border: initial; + border-radius: initial; + box-shadow: initial; + min-height: 250mm; + margin: 0; + width: initial; + -webkit-print-color-adjust: exact; + color-adjust: exact; + } + .distance-ledger {} + .report-ledger { + page-break-inside: avoid; + page-break-after: always; + break-after: recto; + min-height: 300px; + } +} \ No newline at end of file diff --git a/Wonky.Client/wwwroot/index.html b/Wonky.Client/wwwroot/index.html index db9415af..9374b8fd 100644 --- a/Wonky.Client/wwwroot/index.html +++ b/Wonky.Client/wwwroot/index.html @@ -14,12 +14,13 @@ - - - - - - + + + + + + +
@@ -29,7 +30,7 @@
- - + + diff --git a/Wonky.Client/wwwroot/scripts/bsTooltip.js b/Wonky.Client/wwwroot/scripts/bsTooltip.js deleted file mode 100644 index 9bb45d48..00000000 --- a/Wonky.Client/wwwroot/scripts/bsTooltip.js +++ /dev/null @@ -1,4 +0,0 @@ -var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]')) -var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) { - return new bootstrap.Tooltip(tooltipTriggerEl) -}) diff --git a/Wonky.Client/wwwroot/scripts/print-invoke.js b/Wonky.Client/wwwroot/scripts/print-invoke.js new file mode 100644 index 00000000..7623b1e3 --- /dev/null +++ b/Wonky.Client/wwwroot/scripts/print-invoke.js @@ -0,0 +1,7 @@ +export function printInvoke() { + window.print(); +} + +document.addEventListener("load", function() { + window.print(); +}); diff --git a/Wonky.Client/wwwroot/scripts/scripts.js b/Wonky.Client/wwwroot/scripts/scripts.js deleted file mode 100644 index 9444efad..00000000 --- a/Wonky.Client/wwwroot/scripts/scripts.js +++ /dev/null @@ -1,16 +0,0 @@ -(document).ready(function(){ - $(window).scroll(function () { - if ($(this).scrollTop() > 50) { - $('#back-to-top').fadeIn(); - } else { - $('#back-to-top').fadeOut(); - } - }); - // scroll body to 0px on click - $('#back-to-top').click(function () { - $('body,html').animate({ - scrollTop: 0 - }, 400); - return false; - }); -}); \ No newline at end of file diff --git a/Wonky.Entity/Views/NgSalesReportListView.cs b/Wonky.Entity/Views/SalesReportListView.cs similarity index 97% rename from Wonky.Entity/Views/NgSalesReportListView.cs rename to Wonky.Entity/Views/SalesReportListView.cs index 4cf5fbd2..f7c360c9 100644 --- a/Wonky.Entity/Views/NgSalesReportListView.cs +++ b/Wonky.Entity/Views/SalesReportListView.cs @@ -15,7 +15,7 @@ namespace Wonky.Entity.Views; -public class NgSalesReportListView +public class SalesReportListView { public string ReportId { get; set; } = ""; public string UserId { get; set; } = "";