diff --git a/app/Designs/Business.php b/app/Designs/Business.php index 3a8086cc1a1d..acbda2aa4f5c 100644 --- a/app/Designs/Business.php +++ b/app/Designs/Business.php @@ -52,10 +52,10 @@ $custom_css
$company_logo
-
+
$company_details
-
+
$company_address
'; @@ -64,46 +64,46 @@ $custom_css public function body() { return '
-
+
$client_details
-
-
+
+
$entity_details
- +
$product_table_header - + $product_table_body
- +
$task_table_header - + $task_table_body
-
+

$entity.public_notes

-
+
-
+
$discount_label $total_tax_labels $line_tax_labels
-
+
$discount $total_tax_values $line_tax_values @@ -111,17 +111,17 @@ $custom_css
-
+

$terms_label

$terms

-
-
+
+

$balance_due_label

-

$balance_due

+

$balance_due

@@ -142,7 +142,7 @@ $custom_css { return '
-
'; } diff --git a/tests/Feature/PdfMaker/Business.php b/tests/Feature/PdfMaker/Business.php index 6429bb9468f1..1509f69fecc0 100644 --- a/tests/Feature/PdfMaker/Business.php +++ b/tests/Feature/PdfMaker/Business.php @@ -7,7 +7,7 @@ class Business public function html() { return file_get_contents( - base_path('tests/Feature/PdfMaker/business.html') + base_path('tests/Feature/PdfMaker/designs/business.html') ); } } diff --git a/tests/Feature/PdfMaker/PdfMakerDesignsTest.php b/tests/Feature/PdfMaker/PdfMakerDesignsTest.php index aaecaf675711..bde0bbb558f1 100644 --- a/tests/Feature/PdfMaker/PdfMakerDesignsTest.php +++ b/tests/Feature/PdfMaker/PdfMakerDesignsTest.php @@ -16,7 +16,21 @@ class PdfMakerDesignsTest extends TestCase $this->state = [ 'variables' => [ - '$css' => asset('css/tailwindcss@1.4.6.css'), + '#css' => asset('css/tailwindcss@1.4.6.css'), + '#global-margin' => 'm-12', + + '#company-logo' => 'https://invoiceninja-invoice-templates.netlify.app/assets/images/invoiceninja-logo.png', + '#entity-number-label' => 'Invoice number', + '#entity-number' => '10000', + '#entity-date-label' => 'Invoice date', + '#entity-date' => '3th of June, 2025.', + '#due-date-label' => 'Due date', + '#due-date' => '5th of June, 2025.', + '#balance-due-label' => 'Balance due', + '#balance-due' => '$800.50', + + '#terms-label' => 'Terms', + '#terms' => 'Trend and SEO report has been sent via email. This is really long text just to test the width of the elements.', ], ]; } @@ -24,8 +38,96 @@ class PdfMakerDesignsTest extends TestCase public function testBusiness() { $state = [ - 'template' => [], - 'variables' => $this->state['variables'], + '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 '], + ['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' => 'div', 'content' => '', 'elements' => [ + ['element' => 'p', 'content' => '#entity-number-label'], + ['element' => 'p', 'content' => '#entity-date-label'], + ['element' => 'p', 'content' => '#due-date-label'], + ['element' => 'p', 'content' => '#balance-due-label'], + ]], + ['element' => 'div', 'content' => '', 'elements' => [ + ['element' => 'p', 'content' => '#entity-number'], + ['element' => 'p', 'content' => '#entity-date'], + ['element' => 'p', 'content' => '#due-date'], + ['element' => 'p', 'content' => '#balance-due'], + ]], + ], + ], + 'product-table' => [ + 'id' => 'product-table', + 'elements' => [ + ['element' => 'thead', 'content' => '', 'properties' => ['class' => 'text-left rounded-t-lg'], 'elements' => [ + ['element' => 'th', 'content' => 'Item', 'properties' => ['class' => 'font-semibold text-white px-4 bg-blue-900 py-5']], + ['element' => 'th', 'content' => 'Description', 'properties' => ['class' => 'font-semibold text-white px-4 bg-blue-900 py-5']], + ['element' => 'th', 'content' => 'Unit cost', 'properties' => ['class' => 'font-semibold text-white px-4 bg-blue-900 py-5']], + ['element' => 'th', 'content' => 'Quantity', 'properties' => ['class' => 'font-semibold text-white px-4 bg-blue-900 py-5']], + ['element' => 'th', 'content' => 'Line total', 'properties' => ['class' => 'font-semibold text-white px-4 bg-blue-900 py-5']], + ]], + ['element' => 'tbody', 'content' => '', 'elements' => [ + ['element' => 'tr', 'content' => '', 'elements' => [ + ['element' => 'td', 'content' => 'Painting service', 'properties' => ['class' => 'border-4 border-white text-orange-700 px-4 py-4 bg-gray-200']], + ['element' => 'td', 'content' => '25 hours of painting', 'properties' => ['class' => 'border-4 border-white text-orange-700 px-4 py-4 bg-gray-200']], + ['element' => 'td', 'content' => '885.00', 'properties' => ['class' => 'border-4 border-white text-orange-700 px-4 py-4 bg-gray-200']], + ['element' => 'td', 'content' => '1', 'properties' => ['class' => 'border-4 border-white text-orange-700 px-4 py-4 bg-gray-200']], + ['element' => 'td', 'content' => '$885.00', 'properties' => ['class' => 'border-4 border-white text-orange-700 px-4 py-4 bg-gray-200']], + ]], + ]], + ['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 bg-gray-200', 'colspan' => '2']], + ['element' => 'td', 'content' => 'Subtotal', 'properties' => ['class' => 'px-4 py-4 bg-gray-200 text-right', 'colspan' => '2']], + ['element' => 'td', 'content' => '$0', 'properties' => ['class' => 'px-4 py-4 bg-gray-200 text-right']], + ]], + ['element' => 'tr', 'content' => '', 'elements' => [ + ['element' => 'td', 'content' => 'Paid to date', 'properties' => ['class' => 'border-l-4 border-white px-4 bg-gray-200 text-right', 'colspan' => '4']], + ['element' => 'td', 'content' => '$0.00', 'properties' => ['class' => 'px-4 py-4 bg-gray-200 text-right']], + ]], + ]], + ], + ], + ], + 'variables' => array_merge([ + '#invoice-issued-to' => 'Invoice issued to', + ], $this->state['variables']), ]; + + $maker = new PdfMaker($state); + + $maker + ->design(Business::class) + ->build(); + + exec('echo "" > storage/logs/laravel.log'); + + info($maker->getCompiledHTML()); } } diff --git a/tests/Feature/PdfMaker/designs/business.html b/tests/Feature/PdfMaker/designs/business.html index bc1d98603a52..e0169ecd5040 100644 --- a/tests/Feature/PdfMaker/designs/business.html +++ b/tests/Feature/PdfMaker/designs/business.html @@ -1 +1,67 @@ -php a \ No newline at end of file + + + + + + + + + + + + + + + +
+ #company-name +
+
+
+
+
+ + +
+
+

#invoice-issued-to

+
+
+
+
+
+
+
+
+ + +
+ + +
+
+

#terms-label

+

#terms

+
+
+
+
+

#balance-due-label

+

#balance-due

+
+
+
+
+ + + \ No newline at end of file