diff --git a/tests/Feature/PdfMaker/Creative.php b/tests/Feature/PdfMaker/Creative.php new file mode 100644 index 0000000000..d3a7f654c5 --- /dev/null +++ b/tests/Feature/PdfMaker/Creative.php @@ -0,0 +1,13 @@ +getCompiledHTML(true)); } + + public function testCreative() + { + $state = [ + 'template' => [ + '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'], + ], + ], + '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']], + ]], + ], + ], + 'product-table' => [ + 'id' => 'product-table', + 'elements' => [ + ['element' => 'thead', 'content' => '', 'properties' => ['class' => 'text-left'], 'elements' => [ + ['element' => 'th', 'content' => 'Item', 'properties' => ['class' => 'font-medium uppercase text-pink-700 text-xl px-4 py-5']], + ['element' => 'th', 'content' => 'Description', 'properties' => ['class' => 'font-medium uppercase text-pink-700 text-xl px-4 py-5']], + ['element' => 'th', 'content' => 'Unit cost', 'properties' => ['class' => 'font-medium uppercase text-pink-700 text-xl px-4 py-5']], + ['element' => 'th', 'content' => 'Quantity', 'properties' => ['class' => 'font-medium uppercase text-pink-700 text-xl px-4 py-5']], + ['element' => 'th', 'content' => 'Line total', 'properties' => ['class' => 'font-medium uppercase text-pink-700 text-xl px-4 py-5']], + ]], + ['element' => 'tbody', 'content' => '', 'elements' => [ + ['element' => 'tr', 'content' => '', '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' => 'tr', 'content' => '', '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 border-t-4 border-pink-700'], '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 font-semibold text-pink-700']], + ]], + ]], + ], + ], + ], + 'variables' => array_merge([], $this->state['variables']), + ]; + + $maker = new PdfMaker($state); + + $maker + ->design(Creative::class) + ->build(); + + exec('echo "" > storage/logs/laravel.log'); + + info($maker->getCompiledHTML(true)); + } } diff --git a/tests/Feature/PdfMaker/designs/creative.html b/tests/Feature/PdfMaker/designs/creative.html new file mode 100644 index 0000000000..12cb6e1960 --- /dev/null +++ b/tests/Feature/PdfMaker/designs/creative.html @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + +
+ +
+
+
+ + +
+
+
+
+ + +
+ $company-name logo +
+
+ + +
+ +
+ $entity + #$entity-number +
+ + +
+
+
+
+ +
+ +