diff --git a/HerramientaCASA/Components/Pages/HerramientaCASAS.razor b/HerramientaCASA/Components/Pages/HerramientaCASAS.razor index 08c6873..d235547 100644 --- a/HerramientaCASA/Components/Pages/HerramientaCASAS.razor +++ b/HerramientaCASA/Components/Pages/HerramientaCASAS.razor @@ -5,8 +5,10 @@ @using System.Text @using bdHerramientaCACOA.db @using Newtonsoft.Json +@using PuppeteerSharp @using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage @inject ProtectedLocalStorage ProtectedLocalStore +@inject IJSRuntime JS @rendermode InteractiveServer @inject NavigationManager Navigation @@ -47,6 +49,10 @@ Nombre de la simulación: + + + + @@ -64,7 +70,7 @@ -
+
@@ -72,7 +78,9 @@
- +
+ +
@code { [Parameter] public string? idSimulador { get; set; } = ""; @@ -83,6 +91,7 @@ public bool actualizado = true; string nombreOriginal = ""; + private string pdfUrl; public tsHerramientasCACOA bd; public bdHerramientaCACOA.CASA casa = new CASA(); @@ -103,7 +112,7 @@ idSimulador = clValue; } - + if (string.IsNullOrEmpty(idSimulador)) { @@ -267,4 +276,89 @@ { await popupGuardar.HideAsync(); } + + + + + private async Task imprimir() + { + var cssPath = Path.Combine(Environment.CurrentDirectory, "wwwroot", "Content", "Site.css"); + var cssContent = await File.ReadAllTextAsync(cssPath); + + var contenidoHtml = await JS.InvokeAsync("obtenerContenidoHtml"); + var fullHtml = $@" + + + + + + + {contenidoHtml} + + "; + + var fileName = $"factura_{DateTime.Now:yyyyMMddHHmmss}.pdf"; + var filePath = Path.Combine("wwwroot", fileName); + + var browserFetcher = new BrowserFetcher(); + await browserFetcher.DownloadAsync(); + + using var browser = await Puppeteer.LaunchAsync(new LaunchOptions + { + Headless = true, + Args = new[] { "--ignore-certificate-errors" } + }); + + using var page = await browser.NewPageAsync(); + + await page.SetViewportAsync(new ViewPortOptions { Width = 1200, Height = 800 }); + + await page.SetContentAsync(fullHtml); + + await page.PdfAsync(filePath, new PdfOptions + { + PrintBackground = true, + Format = PuppeteerSharp.Media.PaperFormat.A4, + MarginOptions = new PuppeteerSharp.Media.MarginOptions + { + Top = "20mm", + Bottom = "20mm" + } + }); + + pdfUrl = "/" + fileName; + + Navigation.NavigateTo(pdfUrl, true); + } + } + + + + \ No newline at end of file diff --git a/HerramientaCASA/Components/Pages/HerramientaCASATabs/CostesProduccionComponents/CostesVariables.razor b/HerramientaCASA/Components/Pages/HerramientaCASATabs/CostesProduccionComponents/CostesVariables.razor index 8bc61b9..dd6a4e1 100644 --- a/HerramientaCASA/Components/Pages/HerramientaCASATabs/CostesProduccionComponents/CostesVariables.razor +++ b/HerramientaCASA/Components/Pages/HerramientaCASATabs/CostesProduccionComponents/CostesVariables.razor @@ -127,7 +127,7 @@ } -
+
Coste hora Despacho Profesional
@@ -170,7 +170,7 @@
-
+
Coste hora Externalización @@ -187,7 +187,7 @@ Incremento por externalización -
+
%
diff --git a/HerramientaCASA/Components/Pages/HerramientaCASATabs/DespachoProfesional.razor b/HerramientaCASA/Components/Pages/HerramientaCASATabs/DespachoProfesional.razor index 6102bf9..79f9a04 100644 --- a/HerramientaCASA/Components/Pages/HerramientaCASATabs/DespachoProfesional.razor +++ b/HerramientaCASA/Components/Pages/HerramientaCASATabs/DespachoProfesional.razor @@ -8,7 +8,6 @@ @using bdHerramientaCACOA.db @inject NavigationManager Navigation @inject UserState UserState -@inject IJSRuntime JS
@@ -17,9 +16,8 @@
-@* *@ -
+
@@ -68,6 +66,7 @@ [Parameter] public string? idSimulador { get; set; } = ""; + private int idFicheroObtenido = 0; public tsHerramientasCACOA bd; @@ -110,6 +109,10 @@ } + + + + // private void clonarDespacho() // { // var byteFichero = bd.ficheros.First(x=> x.idFichero == idFicheroObtenido).Fichero; @@ -127,10 +130,3 @@ // } } - -@* *@ \ No newline at end of file diff --git a/HerramientaCASA/Components/Pages/Imprimir/HerramientaCASAImprimir.razor b/HerramientaCASA/Components/Pages/Imprimir/HerramientaCASAImprimir.razor new file mode 100644 index 0000000..48676d9 --- /dev/null +++ b/HerramientaCASA/Components/Pages/Imprimir/HerramientaCASAImprimir.razor @@ -0,0 +1,314 @@ +
+
+
+ +
+
+
+ Coste hora Despacho Profesional +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Tipo de costesCoste/hora
Costes directos@objetoCASA.DespachoProfesional.CostesDirectos.MilesYDecimales() €/hora
Costes indirectos@objetoCASA.DespachoProfesional.TasaCostesIndirectos.MilesYDecimales() €/hora
Costes variables@objetoCASA.CostesProduccion.CostesVariables.MilesYDecimales() €/hora
+
+ Total Coste hora Despacho Profesional: @objetoCASA.CostesProduccion.TotalCostes.MilesYDecimales() €/hora +
+
+
+ +
+
+ +
+ Coste hora Externalización +
+
+ + + + + + + + + + + + + + + + + + +
ExternalizaciónPorcentaje
Incremento por externalización + + @objetoCASA.CostesProduccion.CoeficienteCostesExternalizacion + +
+ Coste hora Externalización: @objetoCASA.CostesProduccion.CosteHoraExternalizacion.MilesYDecimales() €/hora +
+
+ +
+
+
+
+ +
+ + @if (objetoCASA.TrabajoProfesional.Usos.Count != 0) + { +
+
+ Usos/Tipologías +
+ +
+ + + + + + + + + + + + + @foreach(var uso in objetoCASA.TrabajoProfesional.Usos){ + + + + + + + } + + + + + + +
SuperficieUsosTipologíaIntervención
@uso.superficie.MilesYDecimales()@objetoCASA.Enumerados.GruposTipologias?.FirstOrDefault(x => x.idEnumeracion == uso.idGrupoTipologia)?.ValorAlfabetico1@objetoCASA.Enumerados.Tipologias?.FirstOrDefault(x => x.idTipologia == uso.idTipologia)?.Descripcion@objetoCASA.Enumerados.Intervenciones?.FirstOrDefault(x => x.idEnumeracion == uso.idTipoIntervencion)?.ValorAlfabetico1
+
+ Total superficie: @objetoCASA.TrabajoProfesional.Usos.Sum(x=>x.superficie).MilesYDecimales() +
+
+
+ +
+ + } + +
+
+
+ + + + + +
Plazo de presentación de la documentación: + @objetoCASA.CostesProduccion.PlazoPresentacionDocumentos +
+
+ @if (objetoCASA.CostesProduccion.IncrementoUrgencia > 0) + { + + } +
+
+
+ +
+
+
+
+ Trabajo profesional +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TrabajosHoras
Horas elaboración documentación@objetoCASA.TrabajoProfesional.HorasTPEDocumentacion.MilesYDecimales() h
Horas de documentación en Despacho Profesional@objetoCASA.CostesProduccion.HorasProduccionDespachoElabDocumentacion.MilesYDecimales() h
Horas de documentación mediante externalización@objetoCASA.CostesProduccion.NumHorasMinimoExt.MilesYDecimales() h
Horas de dirección de obra@objetoCASA.TrabajoProfesional.HorasTPEDireccion.MilesYDecimales() h
HORAS TRABAJO PROFESIONAL@objetoCASA.TrabajoProfesional.HorasTPE.MilesYDecimales() h
+
+ +
+ +
+
+
+ +
+ +
+ +
+ Costes Asociados a los Servicios de Arquitectura +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Concepto
COSTES DE PRODUCCIÓN DEL TRABAJO PROFESIONAL @objetoCASA.CostesProduccion.CostesProduccionTrabProf.MilesYDecimales() €
Beneficio (antes de impuestos) + @objetoCASA.CostesProduccion.Beneficio +
+ Precio del trabajo profesional: @objetoCASA.CostesProduccion.PrecioTrabProf.MilesYDecimales() € +
+ +
+ + @if (objetoCASA.CostesProduccion.OtrosTrabajos.Count != 0) + { +
+ +
+ Otros trabajos incluidos en el Encargo +
+
+ + + + + + + + + + + @foreach (var otroTrabajo in objetoCASA.CostesProduccion.OtrosTrabajos) + { + + + + + } + + + + + + + + + + + +
EncargoPrecio
@otroTrabajo.Denominacion@otroTrabajo.Coste.MilesYDecimales()
+
+
+ Total Otros trabajos: + @objetoCASA.CostesProduccion.TotalOtrosTrabajos.MilesYDecimales() € +
+
+ +
+ Precio del encargo: @objetoCASA.CostesProduccion.PrecioDelEncargo.MilesYDecimales() € +
+
+ +
+ } +
+
+ + + +@code { + + [Parameter] + public bdHerramientaCACOA.CASA objetoCASA { get; set; } = new bdHerramientaCACOA.CASA(); + + public tsHerramientasCACOA bd; + + protected override async Task OnInitializedAsync() + { + bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false); + } + public void RefreshState() + { + this.StateHasChanged(); + } + +} diff --git a/HerramientaCASA/Components/Pages/Imprimir/LicitacionesCASAImprimir.razor b/HerramientaCASA/Components/Pages/Imprimir/LicitacionesCASAImprimir.razor new file mode 100644 index 0000000..8c01fb3 --- /dev/null +++ b/HerramientaCASA/Components/Pages/Imprimir/LicitacionesCASAImprimir.razor @@ -0,0 +1,133 @@ +
+
+
+ +
+
+
+ Usos/Tipologías +
+ +
+ + + + + + + + + + + + + @foreach (var uso in objetoLicitaciones.Usos) + { + + + + + + + } + + + + + + +
SuperficieUsosTipologíaIntervención
@uso.superficie.MilesYDecimales()@objetoLicitaciones.Enumerados.GruposTipologias?.FirstOrDefault(x => x.idEnumeracion == uso.idGrupoTipologia)?.ValorAlfabetico1@objetoLicitaciones.Enumerados.Tipologias?.FirstOrDefault(x => x.idTipologia == uso.idTipologia)?.Descripcion@objetoLicitaciones.Enumerados.Intervenciones?.FirstOrDefault(x => x.idEnumeracion == uso.idTipoIntervencion)?.ValorAlfabetico1
+
+ Total superficie: @objetoLicitaciones.Usos.Sum(x => x.superficie).MilesYDecimales() +
+
+
+ +
+
+
+ Fases +
+ +
+ + + + + + + + + + + @foreach (var fase in objetoLicitaciones.FasesTrabajo) + { + + + + + } + + + + + + +
Fases
@fase.Denominacion +
+ @fase.Porcentaje + @if (fase.Seleccionado) + { + poner tick + } +
+
+
+
+ @if (objetoLicitaciones.FasesTrabajo + .Where(f => f.Seleccionado) + .Sum(f => f.Porcentaje) != 100) + { +
+ Trabajo en misión parcial: + @objetoLicitaciones.FasesTrabajo.Where(f => f.Seleccionado).Sum(f => f.Porcentaje) % + +
+ } + else + { +
+ Total: + @objetoLicitaciones.FasesTrabajo.Where(f => f.Seleccionado).Sum(f => f.Porcentaje) % + +
+ } +
+
+
+
+ +
+ +
+
+ + + +@code { + + [Parameter] + public LICITACIONES objetoLicitaciones { get; set; } = new LICITACIONES(); + + public tsHerramientasCACOA bd; + + protected override async Task OnInitializedAsync() + { + bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false); + } + public void RefreshState() + { + this.StateHasChanged(); + } + +} diff --git a/HerramientaCASA/Components/Pages/Licitaciones.razor b/HerramientaCASA/Components/Pages/Licitaciones.razor index fd432c8..1d6dabe 100644 --- a/HerramientaCASA/Components/Pages/Licitaciones.razor +++ b/HerramientaCASA/Components/Pages/Licitaciones.razor @@ -4,8 +4,10 @@ @using Microsoft.EntityFrameworkCore @using bdHerramientaCACOA.db @using HerramientaCASA.Components.Pages.LicitacionesGrids +@using PuppeteerSharp @using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage @inject ProtectedLocalStorage ProtectedLocalStore +@inject IJSRuntime JS @page "/LicitacionCASA" @page "/LicitacionCASA/{idSimulador}" @@ -51,6 +53,8 @@
+ +
Convenio Colectivo:
@@ -111,6 +115,9 @@
+
+ +
@*
@@ -205,6 +212,8 @@ private bdHerramientaCACOA.LICITACIONES objetoLicitaciones; + private string pdfUrl; + private int idUser = 0; public bool modificarTabla = true; @@ -384,6 +393,57 @@ { await popupGuardar.HideAsync(); } + private async Task imprimir() + { + var cssPath = Path.Combine(Environment.CurrentDirectory, "wwwroot", "Content", "Site.css"); + var cssContent = await File.ReadAllTextAsync(cssPath); + + var contenidoHtml = await JS.InvokeAsync("obtenerContenidoHtml"); + var fullHtml = $@" + + + + + + + {contenidoHtml} + + "; + + var fileName = $"factura_{DateTime.Now:yyyyMMddHHmmss}.pdf"; + var filePath = Path.Combine("wwwroot", fileName); + + var browserFetcher = new BrowserFetcher(); + await browserFetcher.DownloadAsync(); + + using var browser = await Puppeteer.LaunchAsync(new LaunchOptions + { + Headless = true, + Args = new[] { "--ignore-certificate-errors" } + }); + + using var page = await browser.NewPageAsync(); + + await page.SetViewportAsync(new ViewPortOptions { Width = 1200, Height = 800 }); + + await page.SetContentAsync(fullHtml); + + await page.PdfAsync(filePath, new PdfOptions + { + PrintBackground = true, + Format = PuppeteerSharp.Media.PaperFormat.A4, + MarginOptions = new PuppeteerSharp.Media.MarginOptions + { + Top = "20mm", + Bottom = "20mm" + } + }); + + pdfUrl = "/" + fileName; + + Navigation.NavigateTo(pdfUrl, true); + } + private async void modificarTablaChanged(bool res) @@ -419,3 +479,15 @@ } } + + + + \ No newline at end of file diff --git a/HerramientaCASA/HerramientaCASA.csproj b/HerramientaCASA/HerramientaCASA.csproj index 5403cd4..cef15e6 100644 --- a/HerramientaCASA/HerramientaCASA.csproj +++ b/HerramientaCASA/HerramientaCASA.csproj @@ -15,6 +15,7 @@ + diff --git a/HerramientaCASA/wwwroot/factura_20250729144732.pdf b/HerramientaCASA/wwwroot/factura_20250729144732.pdf new file mode 100644 index 0000000..bd4952a Binary files /dev/null and b/HerramientaCASA/wwwroot/factura_20250729144732.pdf differ