1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 08:21:34 +02:00
This commit is contained in:
Benjamin Beganović 2021-04-13 16:43:35 +02:00
parent ed83f27537
commit dba330bcb3
5 changed files with 291 additions and 250 deletions

View File

@ -16,6 +16,7 @@ use App\Utils\Traits\MakesHash;
use DOMDocument;
use DOMXPath;
use Exception;
use League\CommonMark\CommonMarkConverter;
trait DesignHelpers
{
@ -308,4 +309,13 @@ trait DesignHelpers
$this->client
);
}
public static function parseMarkdownToHtml(string $markdown): ?string
{
$converter = new CommonMarkConverter([
'allow_unsafe_links' => false,
]);
return $converter->convertToHtml($markdown);
}
}

View File

@ -16,11 +16,13 @@ use App\Models\Client;
use App\Models\ClientContact;
use App\Models\Invoice;
use App\Models\InvoiceInvitation;
use App\Services\PdfMaker\Designs\Utilities\DesignHelpers;
use App\Utils\Traits\MakesHash;
use App\Utils\Traits\MakesInvoiceHtml;
use App\Utils\Traits\MakesTemplateData;
use DB;
use League\CommonMark\CommonMarkConverter;
use TijsVerkoyen\CssToInlineStyles\CssToInlineStyles;
class TemplateEngine
{
@ -162,17 +164,12 @@ class TemplateEngine
$this->body = strtr($this->body, $data['labels']);
$this->body = strtr($this->body, $data['values']);
$this->body = str_replace("\n", "<br>", $this->body);
// $this->body = str_replace("\n", "<br>", $this->body);
$this->subject = strtr($this->subject, $data['labels']);
$this->subject = strtr($this->subject, $data['values']);
$converter = new CommonMarkConverter([
'allow_unsafe_links' => false,
]);
$this->body = $converter->convertToHtml($this->body);
$this->body = DesignHelpers::parseMarkdownToHtml($this->body);
}
private function renderTemplate()
@ -256,4 +253,11 @@ class TemplateEngine
{
DB::rollBack();
}
private static function inlineMarkupCss(string $css, string $html): ?string
{
$inliner = new CssToInlineStyles();
return $inliner->convert($html, $css);
}
}

View File

@ -65,6 +65,7 @@
"sentry/sentry-laravel": "^2",
"stripe/stripe-php": "^7.50",
"symfony/http-client": "^5.2",
"tijsverkoyen/css-to-inline-styles": "^2.2",
"turbo124/beacon": "^1.0",
"turbo124/laravel-gmail": "^5",
"webpatser/laravel-countries": "dev-master#75992ad",

159
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "7ccb8d2434343dfb0ba62866f0ee919a",
"content-hash": "f01381d3d00f0bd84acbda078ad1b99e",
"packages": [
{
"name": "authorizenet/authorizenet",
@ -11718,103 +11718,6 @@
],
"time": "2021-01-25T15:34:13+00:00"
},
{
"name": "nunomaduro/larastan",
"version": "v0.7.3",
"source": {
"type": "git",
"url": "https://github.com/nunomaduro/larastan.git",
"reference": "9c515d46851dca5a99fc82c0a69392c362b7affd"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nunomaduro/larastan/zipball/9c515d46851dca5a99fc82c0a69392c362b7affd",
"reference": "9c515d46851dca5a99fc82c0a69392c362b7affd",
"shasum": ""
},
"require": {
"composer/composer": "^1.0 || ^2.0",
"ext-json": "*",
"illuminate/console": "^6.0 || ^7.0 || ^8.0 || ^9.0",
"illuminate/container": "^6.0 || ^7.0 || ^8.0 || ^9.0",
"illuminate/contracts": "^6.0 || ^7.0 || ^8.0 || ^9.0",
"illuminate/database": "^6.0 || ^7.0 || ^8.0 || ^9.0",
"illuminate/http": "^6.0 || ^7.0 || ^8.0 || ^9.0",
"illuminate/pipeline": "^6.0 || ^7.0 || ^8.0 || ^9.0",
"illuminate/support": "^6.0 || ^7.0 || ^8.0 || ^9.0",
"mockery/mockery": "^0.9 || ^1.0",
"php": "^7.2 || ^8.0",
"phpstan/phpstan": "^0.12.83",
"symfony/process": "^4.3 || ^5.0"
},
"require-dev": {
"orchestra/testbench": "^4.0 || ^5.0 || ^6.0 || ^7.0",
"phpunit/phpunit": "^7.3 || ^8.2 || ^9.3"
},
"suggest": {
"orchestra/testbench": "^4.0 || ^5.0"
},
"type": "phpstan-extension",
"extra": {
"branch-alias": {
"dev-master": "0.6-dev"
},
"phpstan": {
"includes": [
"extension.neon"
]
}
},
"autoload": {
"psr-4": {
"NunoMaduro\\Larastan\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nuno Maduro",
"email": "enunomaduro@gmail.com"
}
],
"description": "Larastan - Discover bugs in your code without running it. A phpstan/phpstan wrapper for Laravel",
"keywords": [
"PHPStan",
"code analyse",
"code analysis",
"larastan",
"laravel",
"package",
"php",
"static analysis"
],
"support": {
"issues": "https://github.com/nunomaduro/larastan/issues",
"source": "https://github.com/nunomaduro/larastan/tree/v0.7.3"
},
"funding": [
{
"url": "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=66BYDWAT92N6L",
"type": "custom"
},
{
"url": "https://github.com/canvural",
"type": "github"
},
{
"url": "https://github.com/nunomaduro",
"type": "github"
},
{
"url": "https://www.patreon.com/nunomaduro",
"type": "patreon"
}
],
"time": "2021-04-12T11:01:46+00:00"
},
{
"name": "openlss/lib-array2xml",
"version": "1.0.0",
@ -12259,66 +12162,6 @@
},
"time": "2021-03-17T13:42:18+00:00"
},
{
"name": "phpstan/phpstan",
"version": "0.12.83",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "4a967cec6efb46b500dd6d768657336a3ffe699f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/4a967cec6efb46b500dd6d768657336a3ffe699f",
"reference": "4a967cec6efb46b500dd6d768657336a3ffe699f",
"shasum": ""
},
"require": {
"php": "^7.1|^8.0"
},
"conflict": {
"phpstan/phpstan-shim": "*"
},
"bin": [
"phpstan",
"phpstan.phar"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "0.12-dev"
}
},
"autoload": {
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "PHPStan - PHP Static Analysis Tool",
"support": {
"issues": "https://github.com/phpstan/phpstan/issues",
"source": "https://github.com/phpstan/phpstan/tree/0.12.83"
},
"funding": [
{
"url": "https://github.com/ondrejmirtes",
"type": "github"
},
{
"url": "https://www.patreon.com/phpstan",
"type": "patreon"
},
{
"url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan",
"type": "tidelift"
}
],
"time": "2021-04-03T15:35:45+00:00"
},
{
"name": "phpunit/php-code-coverage",
"version": "9.2.6",

View File

@ -2,113 +2,296 @@
if(!isset($design)) {
$design = 'light';
}
$primary_color = isset($settings) ? $settings->primary_color : '#4caf50';
@endphp
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<!--[if gte mso 9]>
<xml>
<o:OfficeDocumentSettings>
<o:AllowPNG/>
<o:PixelsPerInch>96</o:PixelsPerInch>
</o:OfficeDocumentSettings>
</xml>
<![endif]-->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="x-apple-disable-message-reformatting">
<!--[if !mso]><!--><meta http-equiv="X-UA-Compatible" content="IE=edge"><!--<![endif]-->
<title></title>
<style type="text/css">
a {
color: #0000ee;
text-decoration: underline;
}
@media only screen and (min-width: 520px) {
.u-row {
width: 500px !important;
}
.u-row .u-col {
vertical-align: top;
}
.u-row .u-col-100 {
width: 500px !important;
}
}
@media (max-width: 520px) {
.u-row-container {
max-width: 100% !important;
padding-left: 0px !important;
padding-right: 0px !important;
}
.u-row .u-col {
min-width: 320px !important;
max-width: 100% !important;
display: block !important;
}
.u-row {
width: calc(100% - 40px) !important;
}
.u-col {
width: 100% !important;
}
.u-col>div {
margin: 0 auto;
}
}
body {
margin: 0;
padding: 0;
}
table,
tr,
td {
vertical-align: top;
border-collapse: collapse;
}
p {
margin: 0;
}
.ie-container table,
.mso-container table {
table-layout: fixed;
}
* {
line-height: inherit;
}
a[x-apple-data-detectors='true'] {
color: inherit !important;
text-decoration: none !important;
}
.header-logo {
outline: none;
text-decoration: none;
-ms-interpolation-mode: bicubic;
clear: both;
display: inline-block !important;
border: none;
height: auto;
float: none;
width: 60%;
max-width: 288px;
}
h1 {
margin: 0px; color: #000000; line-height: 140%; text-align: left; word-wrap: break-word; font-weight: normal; font-family: arial,helvetica,sans-serif; font-size: 22px;
}
p {
font-size: 14px; line-height: 140%
}
.button {
padding: 12px; box-sizing: border-box;display: inline-block;font-family:arial,helvetica,sans-serif;text-decoration: none;-webkit-text-size-adjust: none;text-align: center;color: #FFFFFF; background-color: #142cb5; border-radius: 4px; -webkit-border-radius: 4px; -moz-border-radius: 4px; width:auto; max-width:100%; overflow-wrap: break-word; word-break: break-word; word-wrap:break-word; mso-border-alt: none;
}
</style>
</head>
<style type="text/css">
:root {
--primary-color: {{ $primary_color }};
}
<body class="clean-body" style="margin: 0;padding: 0;-webkit-text-size-adjust: 100%;background-color: #ffffff">
<!--[if IE]><div class="ie-container"><![endif]-->
<!--[if mso]><div class="mso-container"><![endif]-->
<table style="border-collapse: collapse;table-layout: fixed;border-spacing: 0;mso-table-lspace: 0pt;mso-table-rspace: 0pt;vertical-align: top;min-width: 320px;Margin: 0 auto;background-color: #ffffff;width:100%" cellpadding="0" cellspacing="0">
<tbody>
<tr style="vertical-align: top">
<td style="word-break: break-word;border-collapse: collapse !important;vertical-align: top">
<!--[if (mso)|(IE)]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td align="center" style="background-color: #ffffff;"><![endif]-->
.primary-color-bg {
background-color: {{ $primary_color }};
}
#email-content h1, h2, h3, h4 {
display: block;
color: {{ $design == 'light' ? 'black' : 'white' }};
padding-bottom: 20px;
padding-top: 20px;
}
<div class="u-row-container" style="padding: 0px;background-color: transparent">
<div class="u-row" style="Margin: 0 auto;min-width: 320px;max-width: 500px;overflow-wrap: break-word;word-wrap: break-word;word-break: break-word;background-color: transparent;">
<div style="border-collapse: collapse;display: table;width: 100%;background-color: transparent;">
<!--[if (mso)|(IE)]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="padding: 0px;background-color: transparent;" align="center"><table cellpadding="0" cellspacing="0" border="0" style="width:500px;"><tr style="background-color: transparent;"><![endif]-->
#email-content p {
display: block;
color: {{ $design == 'light' ? 'black' : 'white' }};
padding-bottom: 20px;
/*padding-top: 20px;*/
}
<!--[if (mso)|(IE)]><td align="center" width="500" style="width: 500px;padding: 0px;border-top: 0px solid transparent;border-left: 0px solid transparent;border-right: 0px solid transparent;border-bottom: 0px solid transparent;" valign="top"><![endif]-->
<div class="u-col u-col-100" style="max-width: 320px;min-width: 500px;display: table-cell;vertical-align: top;">
<div style="width: 100% !important;">
<!--[if (!mso)&(!IE)]><!--><div style="padding: 0px;border-top: 0px solid transparent;border-left: 0px solid transparent;border-right: 0px solid transparent;border-bottom: 0px solid transparent;"><!--<![endif]-->
.button {
background-color: {{ $primary_color }};
color: white;
padding: 10px 16px;
text-decoration: none;
}
<table style="font-family:arial,helvetica,sans-serif;" role="presentation" cellpadding="0" cellspacing="0" width="100%" border="0">
<tbody>
<tr>
<td style="overflow-wrap:break-word;word-break:break-word;padding:0px 0px 20px;font-family:arial,helvetica,sans-serif;" align="left">
#email-content a, .link {
word-break: break-all;
}
<table height="0px" align="center" border="0" cellpadding="0" cellspacing="0" width="100%" style="border-collapse: collapse;table-layout: fixed;border-spacing: 0;mso-table-lspace: 0pt;mso-table-rspace: 0pt;vertical-align: top;border-top: 6px solid #142cb5;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%">
<tbody>
<tr style="vertical-align: top">
<td style="word-break: break-word;border-collapse: collapse !important;vertical-align: top;font-size: 0px;line-height: 0px;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%">
<span>&#160;</span>
</td>
</tr>
</tbody>
</table>
#email-content .button {
position: center;
}
</td>
</tr>
</tbody>
</table>
.center {
text-align: center;
}
<table style="font-family:arial,helvetica,sans-serif;" role="presentation" cellpadding="0" cellspacing="0" width="100%" border="0">
<tbody>
<tr>
<td style="overflow-wrap:break-word;word-break:break-word;padding:10px 10px 15px;font-family:arial,helvetica,sans-serif;" align="left">
p {
padding-bottom: 5px;
}
</style>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td style="padding-right: 0px;padding-left: 0px;" align="center">
{{ $header }}
</td>
</tr>
</table>
<body style="margin: 0; padding: 0; background-color: {{ $design == 'light' ? '#F9FAFB' : '#111827' }};">
<table role="presentation" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td style="padding: 20px; font-family: Arial, sans-serif, 'Open Sans'">
<table align="center" cellpadding="0" cellspacing="0" width="600"
style="box-shadow: 0 1px 3px 0 rgba(0,0,0,.1), 0 1px 2px 0 rgba(0,0,0,.06)">
<tr>
<td align="center" bgcolor="{{ $primary_color }}" class="primary-color-bg" style="padding: 40px 0 30px 0;">
{{ $header }}
</td>
</tr>
<tr>
<td bgcolor="{{ $design == 'light' ? '#ffffff' : '#1F2937'}}" style="padding: 40px 30px 40px 30px;">
<table cellpadding="0" cellspacing="0" width="100%" style="border-collapse: collapse;">
<tr>
<td id="email-content">
@yield('greeting')
</td>
</tr>
</tbody>
</table>
<!--[if (!mso)&(!IE)]><!--></div><!--<![endif]-->
</div>
</div>
<!--[if (mso)|(IE)]></td><![endif]-->
<!--[if (mso)|(IE)]></tr></table></td></tr></table><![endif]-->
</div>
</div>
</div>
<div class="u-row-container" style="padding: 0px;background-color: transparent">
<div class="u-row" style="Margin: 0 auto;min-width: 320px;max-width: 500px;overflow-wrap: break-word;word-wrap: break-word;word-break: break-word;background-color: transparent;">
<div style="border-collapse: collapse;display: table;width: 100%;background-color: transparent;">
<!--[if (mso)|(IE)]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="padding: 0px;background-color: transparent;" align="center"><table cellpadding="0" cellspacing="0" border="0" style="width:500px;"><tr style="background-color: transparent;"><![endif]-->
<!--[if (mso)|(IE)]><td align="center" width="500" style="width: 500px;padding: 11px;border-top: 0px solid transparent;border-left: 0px solid transparent;border-right: 0px solid transparent;border-bottom: 0px solid transparent;" valign="top"><![endif]-->
<div class="u-col u-col-100" style="max-width: 320px;min-width: 500px;display: table-cell;vertical-align: top;">
<div style="width: 100% !important;">
<!--[if (!mso)&(!IE)]><!--><div style="padding: 11px;border-top: 0px solid transparent;border-left: 0px solid transparent;border-right: 0px solid transparent;border-bottom: 0px solid transparent;"><!--<![endif]-->
{{ $slot }}
@yield('signature')
@yield('footer')
</td>
</tr>
</table>
</td>
</tr>
<tr>
@isset($whitelabel)
@if(!$whitelabel)
<td bgcolor="{{ $design == 'light' ? '#ffffff' : '#1F2937'}}" style="padding-top: 20px; padding-bottom: 20px;" align="center">
<p style="margin: 0; border-top: 1px solid {{ $design == 'light' ? '#F3F4F6' : '#374151' }}; padding-top: 20px;">
<a href="https://invoiceninja.com" target="_blank">
<img
style="height: 4rem; {{ $design == 'dark' ? 'filter: invert(100%);' : '' }}"
src="{{ asset('images/created-by-invoiceninja-new.png') }}"
alt="Invoice Ninja">
</a>
</p>
</td>
@endif
@endif
</tr>
</table>
{{-- <table style="font-family:arial,helvetica,sans-serif;" role="presentation" cellpadding="0" cellspacing="0" width="100%" border="0">--}}
{{-- <tbody>--}}
{{-- <tr>--}}
{{-- <td style="overflow-wrap:break-word;word-break:break-word;padding:10px;font-family:arial,helvetica,sans-serif;" align="left">--}}
{{-- <div align="center">--}}
{{-- <!--[if mso]><table width="100%" cellpadding="0" cellspacing="0" border="0" style="border-spacing: 0; border-collapse: collapse; mso-table-lspace:0pt; mso-table-rspace:0pt;font-family:arial,helvetica,sans-serif;"><tr><td style="font-family:arial,helvetica,sans-serif;" align="center"><v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="" style="height:36px; v-text-anchor:middle; width:106px;" arcsize="11%" stroke="f" fillcolor="#142cb5"><w:anchorlock/><center style="color:#FFFFFF;font-family:arial,helvetica,sans-serif;"><![endif]-->--}}
{{-- <a href="" target="_blank" class="button">--}}
{{-- Visit portal--}}
{{-- </a>--}}
{{-- <!--[if mso]></center></v:roundrect></td></tr></table><![endif]-->--}}
{{-- </div>--}}
{{-- </td>--}}
{{-- </tr>--}}
{{-- </tbody>--}}
{{-- </table>--}}
{{-- <table style="font-family:arial,helvetica,sans-serif;" role="presentation" cellpadding="0" cellspacing="0" width="100%" border="0">--}}
{{-- <tbody>--}}
{{-- <tr>--}}
{{-- <td style="overflow-wrap:break-word;word-break:break-word;padding:10px;font-family:arial,helvetica,sans-serif;" align="left">--}}
{{-- <div style="color: #000000; line-height: 140%; text-align: left; word-wrap: break-word;">--}}
{{-- <p style="font-size: 14px; line-height: 140%;">If you can't click on button copy following link: <a href="https://invoiceninja.com/example-url-to-copy" target="_blank" rel="noopener">https://invoiceninja.com/example-url-to-copy</a></p>--}}
{{-- </div>--}}
{{-- </td>--}}
{{-- </tr>--}}
{{-- </tbody>--}}
{{-- </table>--}}
<!-- Bottom border (gray) -->
<table style="font-family:arial,helvetica,sans-serif;" role="presentation" cellpadding="0" cellspacing="0" width="100%" border="0">
<tbody>
<tr>
<td style="overflow-wrap:break-word;word-break:break-word;padding:10px 0px;font-family:arial,helvetica,sans-serif;" align="left">
<table height="0px" align="center" border="0" cellpadding="0" cellspacing="0" width="100%" style="border-collapse: collapse;table-layout: fixed;border-spacing: 0;mso-table-lspace: 0pt;mso-table-rspace: 0pt;vertical-align: top;border-top: 2px solid #f3f4f6;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%">
<tbody>
<tr style="vertical-align: top">
<td style="word-break: break-word;border-collapse: collapse !important;vertical-align: top;font-size: 0px;line-height: 0px;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%">
<span>&#160;</span>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<!-- Whitelabel logo -->
<table style="font-family:arial,helvetica,sans-serif;" role="presentation" cellpadding="0" cellspacing="0" width="100%" border="0">
<tbody>
<tr>
<td style="overflow-wrap:break-word;word-break:break-word;padding:10px;font-family:arial,helvetica,sans-serif;" align="left">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td style="padding-right: 0px;padding-left: 0px;" align="center">
<img align="center" border="0" src="images/image-2.png" alt="Image" title="Image" style="outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;clear: both;display: inline-block !important;border: none;height: auto;float: none;width: 34%;max-width: 163.2px;" width="163.2"/>
</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
<!--[if (!mso)&(!IE)]><!--></div><!--<![endif]-->
</div>
</div>
<!--[if (mso)|(IE)]></td><![endif]-->
<!--[if (mso)|(IE)]></tr></table></td></tr></table><![endif]-->
</div>
</div>
</div>
<!--[if (mso)|(IE)]></td></tr></table><![endif]-->
</td>
</tr>
</tbody>
</table>
<!--[if mso]></div><![endif]-->
<!--[if IE]></div><![endif]-->
</body>
</html>