mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
Modern
This commit is contained in:
parent
1f8ddc0642
commit
15d8877d48
13
tests/Feature/PdfMaker/Modern.php
Normal file
13
tests/Feature/PdfMaker/Modern.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\PdfMaker;
|
||||
|
||||
class Modern
|
||||
{
|
||||
public function html()
|
||||
{
|
||||
return file_get_contents(
|
||||
base_path('tests/Feature/PdfMaker/designs/modern.html')
|
||||
);
|
||||
}
|
||||
}
|
@ -18,8 +18,10 @@ class PdfMakerDesignsTest extends TestCase
|
||||
'variables' => [
|
||||
'$css' => asset('css/tailwindcss@1.4.6.css'),
|
||||
'$global-margin' => 'm-12',
|
||||
'$global-padding' => 'p-12',
|
||||
|
||||
'$company-logo' => 'https://invoiceninja-invoice-templates.netlify.app/assets/images/invoiceninja-logo.png',
|
||||
'$company-name' => 'Invoice Ninja',
|
||||
'$entity-number-label' => 'Invoice number',
|
||||
'$entity-number' => '10000',
|
||||
'$entity-date-label' => 'Invoice date',
|
||||
@ -243,4 +245,117 @@ class PdfMakerDesignsTest extends TestCase
|
||||
|
||||
info($maker->getCompiledHTML(true));
|
||||
}
|
||||
|
||||
public function testModern()
|
||||
{
|
||||
$state = [
|
||||
'template' => [
|
||||
'entity-details' => [
|
||||
'id' => 'entity-details',
|
||||
'elements' => [
|
||||
['element' => 'tr', 'content' => '', 'elements' => [
|
||||
['element' => 'th', 'content' => '$entity-number-label', 'properties' => ['class' => 'text-left pr-16 lg:pr-24 font-normal']],
|
||||
['element' => 'th', 'content' => '$entity-number', 'properties' => ['class' => 'text-left pr-16 lg:pr-24 font-medium']],
|
||||
]],
|
||||
['element' => 'tr', 'content' => '', 'elements' => [
|
||||
['element' => 'th', 'content' => '$entity-date-label', 'properties' => ['class' => 'text-left pr-16 lg:pr-24 font-normal']],
|
||||
['element' => 'th', 'content' => '$entity-date', 'properties' => ['class' => 'text-left pr-16 lg:pr-24 font-normal']],
|
||||
]],
|
||||
['element' => 'tr', 'content' => '', 'elements' => [
|
||||
['element' => 'th', 'content' => '$due-date-label', 'properties' => ['class' => 'text-left pr-16 lg:pr-24 font-normal']],
|
||||
['element' => 'th', 'content' => '$due-date', 'properties' => ['class' => 'text-left pr-16 lg:pr-24 font-normal']],
|
||||
]],
|
||||
['element' => 'tr', 'content' => '', 'elements' => [
|
||||
['element' => 'th', 'content' => '$balance-due-label', 'properties' => ['class' => 'text-left pr-16 lg:pr-24 font-normal']],
|
||||
['element' => 'th', 'content' => '$balance-due', 'properties' => ['class' => 'text-left pr-16 lg:pr-24 font-normal']],
|
||||
]],
|
||||
],
|
||||
],
|
||||
'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 text-white bg-gray-900'], 'elements' => [
|
||||
['element' => 'th', 'content' => 'Item', 'properties' => ['class' => 'px-4 py-2']],
|
||||
['element' => 'th', 'content' => 'Description', 'properties' => ['class' => 'px-4 py-2']],
|
||||
['element' => 'th', 'content' => 'Unit cost', 'properties' => ['class' => 'px-4 py-2']],
|
||||
['element' => 'th', 'content' => 'Quantity', 'properties' => ['class' => 'px-4 py-2']],
|
||||
['element' => 'th', 'content' => 'Line total', 'properties' => ['class' => 'px-4 py-2']],
|
||||
]],
|
||||
['element' => 'tbody', 'content' => '', 'elements' => [
|
||||
['element' => 'tr', 'content' => '', 'elements' => [
|
||||
['element' => 'td', 'content' => 'Painting service', 'properties' => ['class' => 'font-bold border-t border-b border-gray-900 px-4 py-4']],
|
||||
['element' => 'td', 'content' => '25 hours of painting', 'properties' => ['class' => 'border-t border-b border-gray-900 px-4 py-4']],
|
||||
['element' => 'td', 'content' => '885.00', 'properties' => ['class' => 'border-t border-b border-gray-900 px-4 py-4']],
|
||||
['element' => 'td', 'content' => '1', 'properties' => ['class' => 'border-t border-b border-gray-900 px-4 py-4']],
|
||||
['element' => 'td', 'content' => '$885.00', 'properties' => ['class' => 'border-t border-b border-gray-900 px-4 py-4']],
|
||||
]],
|
||||
['element' => 'tr', 'content' => '', 'elements' => [
|
||||
['element' => 'td', 'content' => 'Painting service', 'properties' => ['class' => 'font-bold border-t border-b border-gray-900 px-4 py-4']],
|
||||
['element' => 'td', 'content' => '25 hours of painting', 'properties' => ['class' => 'border-t border-b border-gray-900 px-4 py-4']],
|
||||
['element' => 'td', 'content' => '885.00', 'properties' => ['class' => 'border-t border-b border-gray-900 px-4 py-4']],
|
||||
['element' => 'td', 'content' => '1', 'properties' => ['class' => 'border-t border-b border-gray-900 px-4 py-4']],
|
||||
['element' => 'td', 'content' => '$885.00', 'properties' => ['class' => 'border-t border-b border-gray-900 px-4 py-4']],
|
||||
]],
|
||||
]],
|
||||
['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 bg-gray-900 text-white'], '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']],
|
||||
]],
|
||||
]],
|
||||
],
|
||||
],
|
||||
'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'],
|
||||
],
|
||||
],
|
||||
],
|
||||
'variables' => array_merge([], $this->state['variables']),
|
||||
];
|
||||
|
||||
$maker = new PdfMaker($state);
|
||||
|
||||
$maker
|
||||
->design(Modern::class)
|
||||
->build();
|
||||
|
||||
exec('echo "" > storage/logs/laravel.log');
|
||||
|
||||
info($maker->getCompiledHTML(true));
|
||||
}
|
||||
}
|
||||
|
49
tests/Feature/PdfMaker/designs/modern.html
Normal file
49
tests/Feature/PdfMaker/designs/modern.html
Normal file
@ -0,0 +1,49 @@
|
||||
<!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">
|
||||
</head>
|
||||
|
||||
<body class="antialiased break-words bg-white">
|
||||
<!-- Company name, entity details -->
|
||||
<div class="bg-orange-600">
|
||||
<div class="$global-padding">
|
||||
<div class="grid grid-cols-12">
|
||||
<div class="col-span-4">
|
||||
<h1 class="text-3xl font-bold text-white lg:text-4xl">$company-name</h1>
|
||||
</div>
|
||||
<div class="col-span-7 col-start-6 lg:col-start-7">
|
||||
<table id="entity-details" class="text-white"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="$global-margin">
|
||||
<!-- Company logo, client details -->
|
||||
<div class="grid grid-cols-12">
|
||||
<img src="$company-logo" alt="$company-name logo" class="grid w-24 col-span-4 sm:w-32">
|
||||
<div id="client-details" class="col-span-8 col-start-6"></div>
|
||||
</div>
|
||||
|
||||
<!-- Product table -->
|
||||
<table id="product-table" class="mt-8 table-auto"></table>
|
||||
</div>
|
||||
|
||||
<!-- Company details -->
|
||||
<div class="bg-orange-600">
|
||||
<div class="$global-padding">
|
||||
<div class="grid grid-cols-12">
|
||||
<div class="flex justify-between col-span-8 col-start-6 lg:col-span-6 lg:col-start-8">
|
||||
<div id="company-details" class="text-white"></div>
|
||||
<div id="company-address" class="text-white"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
Loading…
Reference in New Issue
Block a user