mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
Elegant
This commit is contained in:
parent
8b0cda0c6e
commit
56e11ac499
13
tests/Feature/PdfMaker/Elegant.php
Normal file
13
tests/Feature/PdfMaker/Elegant.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\PdfMaker;
|
||||
|
||||
class Elegant
|
||||
{
|
||||
public function html()
|
||||
{
|
||||
return file_get_contents(
|
||||
base_path('tests/Feature/PdfMaker/designs/elegant.html')
|
||||
);
|
||||
}
|
||||
}
|
@ -685,4 +685,117 @@ class PdfMakerDesignsTest extends TestCase
|
||||
|
||||
info($maker->getCompiledHTML(true));
|
||||
}
|
||||
|
||||
public function testElegant()
|
||||
{
|
||||
$state = [
|
||||
'template' => [
|
||||
'entity-details' => [
|
||||
'id' => 'entity-details',
|
||||
'elements' => [
|
||||
['element' => 'tr', 'content' => '', 'elements' => [
|
||||
['element' => 'th', 'content' => '$entity-number-label', 'properties' => ['class' => 'text-left pr-4 font-normal']],
|
||||
['element' => 'th', 'content' => '$entity-number', 'properties' => ['class' => 'text-left pr-4 font-medium']],
|
||||
]],
|
||||
['element' => 'tr', 'content' => '', 'elements' => [
|
||||
['element' => 'th', 'content' => '$entity-date-label', 'properties' => ['class' => 'text-left pr-4 font-normal']],
|
||||
['element' => 'th', 'content' => '$entity-date', 'properties' => ['class' => 'text-left pr-4 font-normal']],
|
||||
]],
|
||||
['element' => 'tr', 'content' => '', 'elements' => [
|
||||
['element' => 'th', 'content' => '$due-date-label', 'properties' => ['class' => 'text-left pr-4 font-normal']],
|
||||
['element' => 'th', 'content' => '$due-date', 'properties' => ['class' => 'text-left pr-4 font-normal']],
|
||||
]],
|
||||
['element' => 'tr', 'content' => '', 'elements' => [
|
||||
['element' => 'th', 'content' => '$balance-due-label', 'properties' => ['class' => 'text-left pr-4 font-normal']],
|
||||
['element' => 'th', 'content' => '$balance-due', 'properties' => ['class' => 'text-left pr-4 font-normal']],
|
||||
]],
|
||||
],
|
||||
],
|
||||
'company-details' => [
|
||||
'id' => 'company-details',
|
||||
'elements' => [
|
||||
['element' => 'p', 'content' => 'Ninja Sample'],
|
||||
['element' => 'p', 'content' => 'contact@invoiceninja.com'],
|
||||
['element' => 'p', 'content' => '1-800-555-Ninja'],
|
||||
],
|
||||
],
|
||||
'company-address' => [
|
||||
'id' => 'company-address',
|
||||
'elements' => [
|
||||
['element' => 'p', 'content' => '123 Ninja Blvd.'],
|
||||
['element' => 'p', 'content' => 'NinjaLand, 97315'],
|
||||
['element' => 'p', 'content' => 'United States'],
|
||||
],
|
||||
],
|
||||
'client-details' => [
|
||||
'id' => 'client-details',
|
||||
'elements' => [
|
||||
['element' => 'p', 'content' => 'Winterfield Medical Supply', 'properties' => ['class' => 'font-medium']],
|
||||
['element' => 'p', 'content' => '65 Medical Complex Rd., D98'],
|
||||
['element' => 'p', 'content' => 'Atlanta, GA 22546'],
|
||||
['element' => 'p', 'content' => 'United States'],
|
||||
['element' => 'p', 'content' => 'demo@invoiceninja.com'],
|
||||
],
|
||||
],
|
||||
'product-table' => [
|
||||
'id' => 'product-table',
|
||||
'elements' => [
|
||||
['element' => 'thead', 'content' => '', 'properties' => ['class' => 'text-left border-dashed border-b border-black'], 'elements' => [
|
||||
['element' => 'th', 'content' => 'Item', 'properties' => ['class' => 'font-normal text-green-700 px-4 py-2']],
|
||||
['element' => 'th', 'content' => 'Description', 'properties' => ['class' => 'font-normal text-green-700 px-4 py-2']],
|
||||
['element' => 'th', 'content' => 'Unit cost', 'properties' => ['class' => 'font-normal text-green-700 px-4 py-2']],
|
||||
['element' => 'th', 'content' => 'Quantity', 'properties' => ['class' => 'font-normal text-green-700 px-4 py-2']],
|
||||
['element' => 'th', 'content' => 'Line total', 'properties' => ['class' => 'font-normal text-green-700 px-4 py-2']],
|
||||
]],
|
||||
['element' => 'tbody', 'content' => '', 'elements' => [
|
||||
['element' => 'tr', 'content' => '', 'properties' => ['class' => 'border-dashed border-b border-black'], 'elements' => [
|
||||
['element' => 'td', 'content' => 'Painting service', 'properties' => ['class' => 'px-4 py-3']],
|
||||
['element' => 'td', 'content' => '25 hours of painting', 'properties' => ['class' => 'px-4 py-3']],
|
||||
['element' => 'td', 'content' => '885.00', 'properties' => ['class' => 'px-4 py-3']],
|
||||
['element' => 'td', 'content' => '1', 'properties' => ['class' => 'px-4 py-3']],
|
||||
['element' => 'td', 'content' => '$885.00', 'properties' => ['class' => 'px-4 py-3']],
|
||||
]],
|
||||
['element' => 'tr', 'content' => '', 'properties' => ['class' => 'border-dashed border-b border-black'], 'elements' => [
|
||||
['element' => 'td', 'content' => 'Painting service', 'properties' => ['class' => 'px-4 py-3']],
|
||||
['element' => 'td', 'content' => '25 hours of painting', 'properties' => ['class' => 'px-4 py-3']],
|
||||
['element' => 'td', 'content' => '885.00', 'properties' => ['class' => 'px-4 py-3']],
|
||||
['element' => 'td', 'content' => '1', 'properties' => ['class' => 'px-4 py-3']],
|
||||
['element' => 'td', 'content' => '$885.00', 'properties' => ['class' => 'px-4 py-3']],
|
||||
]],
|
||||
]],
|
||||
['element' => 'tfoot', 'content' => '', 'elements' => [
|
||||
['element' => 'tr', 'content' => '', 'elements' => [
|
||||
['element' => 'td', 'content' => 'Trend and SEO report has been sent via email. This is really long text just to test the width of the elements.', 'properties' => ['class' => 'border-l-4 border-white px-4 py-4', 'colspan' => '2']],
|
||||
['element' => 'td', 'content' => 'Subtotal', 'properties' => ['class' => 'px-4 py-4 text-right', 'colspan' => '2']],
|
||||
['element' => 'td', 'content' => '$0', 'properties' => ['class' => 'px-4 py-2 text-right']],
|
||||
]],
|
||||
['element' => 'tr', 'content' => '', 'elements' => [
|
||||
['element' => 'td', 'content' => 'Paid to date', 'properties' => ['class' => 'border-l-4 border-white px-4 text-right', 'colspan' => '4']],
|
||||
['element' => 'td', 'content' => '$0.00', 'properties' => ['class' => 'px-4 py-2 text-right']],
|
||||
]],
|
||||
['element' => 'tr', 'content' => '', 'elements' => [
|
||||
['element' => 'td', 'content' => 'Discount %20', 'properties' => ['class' => 'border-l-4 border-white px-4 text-right', 'colspan' => '4']],
|
||||
['element' => 'td', 'content' => '$2.00', 'properties' => ['class' => 'px-4 py-2 text-right']],
|
||||
]],
|
||||
['element' => 'tr', 'content' => '', 'properties' => ['class' => 'mt-8 px-4 py-2'], 'elements' => [
|
||||
['element' => 'td', 'content' => 'Balance due', 'properties' => ['class' => 'border-l-4 border-white px-4 text-right', 'colspan' => '4']],
|
||||
['element' => 'td', 'content' => '$2.00', 'properties' => ['class' => 'px-4 py-2 text-right']],
|
||||
]],
|
||||
]],
|
||||
],
|
||||
],
|
||||
],
|
||||
'variables' => array_merge([], $this->state['variables']),
|
||||
];
|
||||
|
||||
$maker = new PdfMaker($state);
|
||||
|
||||
$maker
|
||||
->design(Elegant::class)
|
||||
->build();
|
||||
|
||||
exec('echo "" > storage/logs/laravel.log');
|
||||
|
||||
info($maker->getCompiledHTML(true));
|
||||
}
|
||||
}
|
||||
|
52
tests/Feature/PdfMaker/designs/elegant.html
Normal file
52
tests/Feature/PdfMaker/designs/elegant.html
Normal file
@ -0,0 +1,52 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1, shrink-to-fit=no"
|
||||
/>
|
||||
<meta http-equiv="x-ua-compatible" content="ie=edge" />
|
||||
|
||||
<link rel="stylesheet" href="$css" />
|
||||
<link
|
||||
href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
</head>
|
||||
|
||||
<body class="$global-margin antialiased bg-white break-words">
|
||||
<!-- Company logo, entity details -->
|
||||
<div class="grid grid-cols-12 gap-4 pb-6 border-b-4 border-black">
|
||||
<div class="col-span-6">
|
||||
<img
|
||||
src="$company-logo"
|
||||
alt="$company-name logo"
|
||||
class="w-24 col-span-4 sm:w-32"
|
||||
/>
|
||||
</div>
|
||||
<div class="flex flex-col items-end col-span-6">
|
||||
<table id="entity-details"></table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Client details, company details -->
|
||||
<div class="grid grid-cols-12 gap-4 pt-6 mt-1 border-t border-black">
|
||||
<div
|
||||
class="col-span-5 border-r border-black border-dashed"
|
||||
id="client-details"
|
||||
></div>
|
||||
<div class="flex col-span-7 space-x-8">
|
||||
<div id="company-details"></div>
|
||||
<div id="company-address"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Product table -->
|
||||
<table id="product-table" class="w-full mt-10 table-auto"></table>
|
||||
|
||||
<!-- Thanks label -->
|
||||
<p class="w-full pb-4 mt-10 text-2xl font-semibold text-center border-b-4 border-black">$thanks</p>
|
||||
<div class="w-full border-black order-b wpy-1"></div>
|
||||
</body>
|
||||
</html>
|
@ -31,7 +31,7 @@
|
||||
<div class="col-span-3">
|
||||
<img
|
||||
src="$company-logo"
|
||||
alt="$company->name logo"
|
||||
alt="$company-name logo"
|
||||
class="w-24 col-span-4 sm:w-32"
|
||||
/>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user