diff --git a/Yavsc/Helpers/TeXHelpers.cs b/Yavsc/Helpers/TeXHelpers.cs
index 6c2ef6c2..7bbe434a 100644
--- a/Yavsc/Helpers/TeXHelpers.cs
+++ b/Yavsc/Helpers/TeXHelpers.cs
@@ -2,6 +2,7 @@ using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
+using System.Text;
using Microsoft.AspNet.Http;
using Microsoft.AspNet.Mvc;
using Microsoft.AspNet.Mvc.Rendering;
@@ -67,6 +68,13 @@ namespace Yavsc.Helpers
{
return data;
}
+ public HtmlString ToHtmlString()
+ {
+ return new HtmlString(ToString());
+ }
+
+
+
}
public static class TeXHelpers
{
@@ -78,11 +86,24 @@ namespace Yavsc.Helpers
return string.Join(separator, items);
}
- public static TeXString ToTeX(string target, string lineSeparator = "\n\\\\")
+ public static TeXString ToTeX(this string target, string lineSeparator = "\n\\\\")
{
if (target == null) return null;
return new TeXString(target.NewLinesWith(lineSeparator));
}
+
+ public static HtmlString SplitAddressToTeX (this string target)
+ {
+ var alines = target.Split(',');
+ var texlines = alines.Select(l=>new TeXString(l));
+ StringBuilder sb = new StringBuilder();
+ foreach (var l in texlines)
+ {
+ sb.AppendFormat("{0}\\\\\n",l.ToString());
+ }
+ return new HtmlString(sb.ToString());
+ }
+
public static bool GenerateEstimatePdf(this PdfGenerationViewModel Model)
{
string errorMsg = null;
diff --git a/Yavsc/ViewComponents/EstimateViewComponent.cs b/Yavsc/ViewComponents/EstimateViewComponent.cs
index fe549b60..9c11a3a4 100644
--- a/Yavsc/ViewComponents/EstimateViewComponent.cs
+++ b/Yavsc/ViewComponents/EstimateViewComponent.cs
@@ -34,7 +34,10 @@ namespace Yavsc.ViewComponents
.Include(e => e.Bill).FirstOrDefault(x => x.Id == id);
if (estimate == null)
throw new Exception("No data");
-
+ var di = new DirectoryInfo(Startup.SiteSetup.UserFiles.Bills);
+ var dia = new DirectoryInfo(Startup.SiteSetup.UserFiles.Avatars);
+ ViewBag.BillsDir = di.FullName;
+ ViewBag.AvatarsDir = dia.FullName;
if (outputFormat == "LaTeX") {
return this.View("Estimate_tex", estimate);
}
diff --git a/Yavsc/Views/Shared/Components/Estimate/Estimate_tex.cshtml b/Yavsc/Views/Shared/Components/Estimate/Estimate_tex.cshtml
index 5f8c9d89..71eaf329 100644
--- a/Yavsc/Views/Shared/Components/Estimate/Estimate_tex.cshtml
+++ b/Yavsc/Views/Shared/Components/Estimate/Estimate_tex.cshtml
@@ -6,10 +6,10 @@
var pro = Model.Query.PerformerProfile;
var from = Model.Query.PerformerProfile.Performer;
var to = Model.Query.Client;
- var PostalAddress = (to.PostalAddress!=null) ? to.PostalAddress.Address.Replace("\n","\\\\\n") : null ;
- var proaddr = Model.Query?.PerformerProfile.OrganizationAddress.Address;
- var proaddrn = (proaddr!=null) ? proaddr.NewLinesWith("\\\\\n") : null ;
- var proaddrm = (proaddr!=null) ? proaddr.NewLinesWith(" - ") : null ;
+ var PostalAddress = to.PostalAddress?.Address.SplitAddressToTeX();
+ var proaddr = Model.Query.PerformerProfile.OrganizationAddress.Address.SplitAddressToTeX();
+ var proaddrm = new HtmlString(Model.Query.PerformerProfile.OrganizationAddress.Address);
+
}\documentclass[french,11pt]{article}
\usepackage{eurosym}
\usepackage{babel}
@@ -68,7 +68,7 @@
\def\FactureNum {@Model.Id.ToString()} % Numéro de facture
\def\FactureAcquittee {non} % Facture acquittée : oui/non
-\def\FactureLieu {@proaddrn} % Lieu de l'édition de la facture
+\def\FactureLieu {@proaddrm} % Lieu de l'édition de la facture
\def\FactureObjet {Facture : @TeXHelpers.ToTeX(Model.Title)} % Objet du document
% Description de la facture
\def\FactureDescr {
@@ -80,10 +80,9 @@
\def\ClientAdresse{
% Adresse du client
-@if (!string.IsNullOrWhiteSpace(PostalAddress)) {
- @TeXHelpers.ToTeX(PostalAddress)\\ }
- @if (!string.IsNullOrWhiteSpace(to.PhoneNumber)) {
- @TeXHelpers.ToTeX(to.PhoneNumber)\\
+@PostalAddress
+@if (PostalAddress!=null) {@PostalAddress}
+@if (!string.IsNullOrWhiteSpace(to.PhoneNumber)) {@TeXHelpers.ToTeX(to.PhoneNumber)\\
}
E-mail: @TeXHelpers.ToTeX(to.Email)
}
@@ -106,7 +105,7 @@
\setlength{\parindent}{0pt}
\renewcommand{\headrulewidth}{0pt}
-\cfoot{ @TeXHelpers.ToTeX(from.UserName) @if (!string.IsNullOrWhiteSpace(proaddrm)) { - @TeXHelpers.ToTeX(proaddrm) } \newline
+\cfoot{ @TeXHelpers.ToTeX(from.UserName) @if (proaddrm!=null) { - @proaddrm } \newline
\small{ E-mail: @TeXHelpers.ToTeX(from.Email) @if (!string.IsNullOrWhiteSpace(from.PhoneNumber)) { - Téléphone fixe: @TeXHelpers.ToTeX(from.PhoneNumber) }
}
}
@@ -115,7 +114,7 @@
% Logo de la société
@if (from.Avatar != null) {
-\includegraphics{@from.Avatar}
+\includegraphics[height=60pt]{@(ViewBag.AvatarsDir)/@(from.UserName).png}
} else {
%\includegraphics{logo.png}
@@ -123,7 +122,7 @@
}
% Nom et adresse de la société
@TeXHelpers.ToTeX(from.UserName) \\
- @TeXHelpers.ToTeX(proaddrn)
+ @proaddr
Facture n°\FactureNum
@@ -188,5 +187,18 @@ Facture n°\FactureNum
}
}
+}
+@if (!(Model.ProviderValidationDate==null)) {
+
+\begin{flushright}
+ Facture validée le @TeXHelpers.ToTeX(Model.ProviderValidationDate.ToString("dddd dd MMMM yyyy",
+ CultureInfo.CreateSpecificCulture("fr-FR"))).ToHtmlString()
+\end{flushright}
+\begin{center}
+ \hspace{263pt}
+ \includegraphics[height=60pt]{@(ViewBag.BillsDir)/estimate-prosign-@(Model.Id).png}
+\end{center}
+
+
}
\end{document}