diff --git a/tests/Feature/PdfMaker/PdfMakerDesignsTest.php b/tests/Feature/PdfMaker/PdfMakerDesignsTest.php index 3d5df2de2a70..7c8b717de6b6 100644 --- a/tests/Feature/PdfMaker/PdfMakerDesignsTest.php +++ b/tests/Feature/PdfMaker/PdfMakerDesignsTest.php @@ -909,4 +909,110 @@ class PdfMakerDesignsTest extends TestCase info($maker->getCompiledHTML(true)); } + + public function testPlayful() + { + $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']], + ]], + ], + ], + 'client-details' => [ + 'id' => 'client-details', + 'elements' => [ + ['element' => 'p', 'content' => 'Winterfield Medical Supply', 'properties' => ['class' => 'text-red-700']], + ['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'], + ], + ], + 'company-details' => [ + 'id' => 'company-details', + 'elements' => [ + ['element' => 'p', 'content' => 'Ninja Sample', 'properties' => ['class' => 'text-red-700']], + ['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'], + ], + ], + 'product-table' => [ + 'id' => 'product-table', + 'elements' => [ + ['element' => 'thead', 'content' => '', 'properties' => ['class' => 'text-left bg-teal-600'], 'elements' => [ + ['element' => 'th', 'content' => 'Item', 'properties' => ['class' => 'font-semibold text-white px-4 py-3']], + ['element' => 'th', 'content' => 'Description', 'properties' => ['class' => 'font-semibold text-white px-4 py-3']], + ['element' => 'th', 'content' => 'Unit cost', 'properties' => ['class' => 'font-semibold text-white px-4 py-3']], + ['element' => 'th', 'content' => 'Quantity', 'properties' => ['class' => 'font-semibold text-white px-4 py-3']], + ['element' => 'th', 'content' => 'Line total', 'properties' => ['class' => 'font-semibold text-white px-4 py-3']], + ]], + ['element' => 'tbody', 'content' => '', 'elements' => [ + ['element' => 'tr', 'content' => '', 'properties' => ['class' => 'border-b-2 border-teal-600 '], 'elements' => [ + ['element' => 'td', 'content' => 'Painting service', 'properties' => ['class' => 'px-4 py-4']], + ['element' => 'td', 'content' => '25 hours of painting', 'properties' => ['class' => 'px-4 py-4']], + ['element' => 'td', 'content' => '885.00', 'properties' => ['class' => 'px-4 py-4']], + ['element' => 'td', 'content' => '1', 'properties' => ['class' => 'px-4 py-4']], + ['element' => 'td', 'content' => '$885.00', 'properties' => ['class' => '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'], 'elements' => [ + ['element' => 'td', 'content' => 'Balance due', 'properties' => ['class' => 'px-4 text-right', 'colspan' => '4']], + ['element' => 'td', 'content' => '$2.00', 'properties' => ['class' => 'px-4 py-2 text-right font-semibold text-teal-600']], + ]], + ]], + ], + ], + ], + 'variables' => array_merge([], $this->state['variables']), + ]; + + $maker = new PdfMaker($state); + + $maker + ->design(Playful::class) + ->build(); + + exec('echo "" > storage/logs/laravel.log'); + + info($maker->getCompiledHTML(true)); + } } diff --git a/tests/Feature/PdfMaker/Playful.php b/tests/Feature/PdfMaker/Playful.php new file mode 100644 index 000000000000..650ddc4384c1 --- /dev/null +++ b/tests/Feature/PdfMaker/Playful.php @@ -0,0 +1,13 @@ + - diff --git a/tests/Feature/PdfMaker/designs/playful.html b/tests/Feature/PdfMaker/designs/playful.html new file mode 100644 index 000000000000..9dcf6241a1ec --- /dev/null +++ b/tests/Feature/PdfMaker/designs/playful.html @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + +
+
+ $company-name logo +
+
+
+
+
+ + +
+
+

$to:

+
+
+
+
+
+

$from:

+
+
+
+
+
+
+ + +
+ +