From 3c23cf02867362bde9a270c72502a618f50a7db0 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Tue, 6 Dec 2016 23:39:29 +0100 Subject: [PATCH] devis sans signature, en Pdf --- Yavsc/Startup/Startup.DataProtection.cs | 1 - Yavsc/Startup/Startup.FileServer.cs | 1 - Yavsc/Startup/Startup.OAuth.cs | 1 - Yavsc/Startup/Startup.cs | 6 ++++-- Yavsc/ViewComponents/EstimateViewComponent.cs | 12 +++++++++--- Yavsc/ViewModels/Gen/PdfGenerationViewModel.cs | 1 + .../Views/Shared/Components/Estimate/Default.cshtml | 2 ++ .../Shared/Components/Estimate/Estimate_tex.cshtml | 12 ++++++++---- 8 files changed, 24 insertions(+), 12 deletions(-) diff --git a/Yavsc/Startup/Startup.DataProtection.cs b/Yavsc/Startup/Startup.DataProtection.cs index ac588904..d11790d6 100644 --- a/Yavsc/Startup/Startup.DataProtection.cs +++ b/Yavsc/Startup/Startup.DataProtection.cs @@ -7,7 +7,6 @@ using Microsoft.Extensions.DependencyInjection; namespace Yavsc { - public partial class Startup { public void ConfigureProtectionServices(IServiceCollection services) diff --git a/Yavsc/Startup/Startup.FileServer.cs b/Yavsc/Startup/Startup.FileServer.cs index 5cfda1f9..d9f39f04 100644 --- a/Yavsc/Startup/Startup.FileServer.cs +++ b/Yavsc/Startup/Startup.FileServer.cs @@ -7,7 +7,6 @@ using Microsoft.AspNet.StaticFiles; namespace Yavsc { - public partial class Startup { public static string UserFilesDirName { get; private set; } diff --git a/Yavsc/Startup/Startup.OAuth.cs b/Yavsc/Startup/Startup.OAuth.cs index 63a3042c..affea7d3 100644 --- a/Yavsc/Startup/Startup.OAuth.cs +++ b/Yavsc/Startup/Startup.OAuth.cs @@ -20,7 +20,6 @@ using Yavsc.Models; namespace Yavsc { - public partial class Startup { public static CookieAuthenticationOptions ExternalCookieAppOptions { get; private set; } diff --git a/Yavsc/Startup/Startup.cs b/Yavsc/Startup/Startup.cs index e5be5a7c..ee70c789 100755 --- a/Yavsc/Startup/Startup.cs +++ b/Yavsc/Startup/Startup.cs @@ -37,6 +37,7 @@ namespace Yavsc public static string AvatarsDirName { private set; get; } public static string Authority { get; private set; } public static string Audience { get; private set; } + public static string Temp { get; set; } public static SiteSettings SiteSetup { get; private set; } private static ILogger logger; @@ -234,6 +235,7 @@ namespace Yavsc SiteSetup = siteSettings.Value; Startup.UserFilesDirName = new DirectoryInfo(siteSettings.Value.UserFiles.Blog).FullName; Startup.UserBillsDirName = new DirectoryInfo(siteSettings.Value.UserFiles.Bills).FullName; + Startup.Temp = siteSettings.Value.TempDir; // TODO implement an installation & upgrade procedure // Create required directories @@ -285,7 +287,7 @@ namespace Yavsc if (ex.InnerException is InvalidOperationException) // nothing to do ? { - // TODO Send an email to the Admin + // TODO (or not) Hit the developper } else throw ex; } @@ -346,4 +348,4 @@ namespace Yavsc } } -// \ No newline at end of file +// diff --git a/Yavsc/ViewComponents/EstimateViewComponent.cs b/Yavsc/ViewComponents/EstimateViewComponent.cs index 9c11a3a4..60ad611a 100644 --- a/Yavsc/ViewComponents/EstimateViewComponent.cs +++ b/Yavsc/ViewComponents/EstimateViewComponent.cs @@ -21,8 +21,11 @@ namespace Yavsc.ViewComponents { return await InvokeAsync(id,"Html"); } - - public async Task InvokeAsync(long id, string outputFormat ="Html") + public async Task InvokeAsync(long id, string outputFormat ="Html") + { + return await InvokeAsync(id,outputFormat,false,false); + } + public async Task InvokeAsync(long id, string outputFormat ="Html", bool asBill = false, bool acquitted = false) { return await Task.Run( ()=> { Estimate estimate = @@ -38,6 +41,8 @@ namespace Yavsc.ViewComponents var dia = new DirectoryInfo(Startup.SiteSetup.UserFiles.Avatars); ViewBag.BillsDir = di.FullName; ViewBag.AvatarsDir = dia.FullName; + ViewBag.AsBill = asBill; + ViewBag.Acquitted = acquitted; if (outputFormat == "LaTeX") { return this.View("Estimate_tex", estimate); } @@ -59,6 +64,7 @@ namespace Yavsc.ViewComponents return this.View("Estimate_pdf", new PdfGenerationViewModel{ + Temp = Startup.Temp, TeXSource = tex, DestDir = Startup.UserBillsDirName, BaseFileName = $"estimate-{id}" @@ -70,4 +76,4 @@ namespace Yavsc.ViewComponents } } -} \ No newline at end of file +} diff --git a/Yavsc/ViewModels/Gen/PdfGenerationViewModel.cs b/Yavsc/ViewModels/Gen/PdfGenerationViewModel.cs index 8253ade5..53808880 100644 --- a/Yavsc/ViewModels/Gen/PdfGenerationViewModel.cs +++ b/Yavsc/ViewModels/Gen/PdfGenerationViewModel.cs @@ -14,5 +14,6 @@ namespace Yavsc.ViewModels.Gen public string DestDir { get; set; } public bool Generated { get; set; } public HtmlString GenerationErrorMessage { get; set; } + public string Temp { get; set; } } } \ No newline at end of file diff --git a/Yavsc/Views/Shared/Components/Estimate/Default.cshtml b/Yavsc/Views/Shared/Components/Estimate/Default.cshtml index 9c695bd6..5992dc4e 100644 --- a/Yavsc/Views/Shared/Components/Estimate/Default.cshtml +++ b/Yavsc/Views/Shared/Components/Estimate/Default.cshtml @@ -1,5 +1,6 @@ @model Estimate + diff --git a/Yavsc/Views/Shared/Components/Estimate/Estimate_tex.cshtml b/Yavsc/Views/Shared/Components/Estimate/Estimate_tex.cshtml index 812c655e..297f516f 100644 --- a/Yavsc/Views/Shared/Components/Estimate/Estimate_tex.cshtml +++ b/Yavsc/Views/Shared/Components/Estimate/Estimate_tex.cshtml @@ -1,4 +1,5 @@ @using Yavsc.Helpers +@using System.IO @using System.Globalization @model Estimate @{ @@ -9,8 +10,8 @@ var PostalAddress = to.PostalAddress?.Address.SplitAddressToTeX(); var proaddr = Model.Query.PerformerProfile.OrganizationAddress.Address.SplitAddressToTeX(); var proaddrm = new HtmlString(Model.Query.PerformerProfile.OrganizationAddress.Address); - var isestimate = true; - var ack = false; + var isestimate = !ViewBag.AsBill; + var prosign = new FileInfo($"{ViewBag.BillsDir}/estimate-prosign-{Model.Id}.png"); } \documentclass[french,11pt]{article} @@ -65,7 +66,7 @@ %%%%%%%%%%%%%%%%%%%%% A MODIFIER DANS LA FACTURE %%%%%%%%%%%%%%%%%%%%% \def\FactureNum {@Model.Id.ToString()} % Numéro de facture -\def\FactureAcquittee {non} % Facture acquittée : oui/non +\def\FactureAcquittee {@ViewBag.Acquitted?"oui":"non"} % Facture acquittée : oui/non \def\FactureLieu {@proaddrm} % Lieu de l'édition de la facture \def\FactureObjet {@(new HtmlString(isestimate?"Devis":"Facture")) @TeXHelpers.ToTeX(Model.Title)} % Objet du document % Description de la facture @@ -193,11 +194,14 @@ @(new HtmlString(isestimate?"Devis validé":"Facture validée")) le @TeXHelpers.ToTeX(Model.ProviderValidationDate.ToString("dddd dd MMMM yyyy", CultureInfo.CreateSpecificCulture("fr-FR"))).ToHtmlString() \end{flushright} +@if (prosign.Exists) { + \begin{center} \hspace{263pt} \includegraphics[height=60pt]{@(ViewBag.BillsDir)/estimate-prosign-@(Model.Id).png} \end{center} - + +} } \end{document}