signature du devis, dans le Pdf
This commit is contained in:
parent
e5ca14137b
commit
80fc98ee9e
3 changed files with 50 additions and 14 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)) {
|
||||
<text> @TeXHelpers.ToTeX(PostalAddress)\\</text> }
|
||||
@if (!string.IsNullOrWhiteSpace(to.PhoneNumber)) {<text>
|
||||
@TeXHelpers.ToTeX(to.PhoneNumber)<text>\\</text>
|
||||
@PostalAddress
|
||||
@if (PostalAddress!=null) {<text>@PostalAddress</text>}
|
||||
@if (!string.IsNullOrWhiteSpace(to.PhoneNumber)) {<text>@TeXHelpers.ToTeX(to.PhoneNumber)<text>\\</text>
|
||||
</text>}
|
||||
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)) { <text> - @TeXHelpers.ToTeX(proaddrm) </text> } \newline
|
||||
\cfoot{ @TeXHelpers.ToTeX(from.UserName) @if (proaddrm!=null) { <text> - @proaddrm </text> } \newline
|
||||
\small{ E-mail: @TeXHelpers.ToTeX(from.Email) @if (!string.IsNullOrWhiteSpace(from.PhoneNumber)) { <text> - Téléphone fixe: @TeXHelpers.ToTeX(from.PhoneNumber) </text> }
|
||||
}
|
||||
}
|
||||
|
|
@ -115,7 +114,7 @@
|
|||
|
||||
% Logo de la société
|
||||
@if (from.Avatar != null) {
|
||||
<text>\includegraphics{@from.Avatar}
|
||||
<text>\includegraphics[height=60pt]{@(ViewBag.AvatarsDir)/@(from.UserName).png}
|
||||
</text>
|
||||
} else {
|
||||
<text>%\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)) {
|
||||
<text>
|
||||
\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}
|
||||
|
||||
</text>
|
||||
}
|
||||
\end{document}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue