diff --git a/app/Services/PdfMaker/Designs/Bold.php b/app/Services/PdfMaker/Designs/Bold.php index 5abe49dae4bc..ef3fd00106ad 100644 --- a/app/Services/PdfMaker/Designs/Bold.php +++ b/app/Services/PdfMaker/Designs/Bold.php @@ -48,10 +48,6 @@ class Bold extends BaseDesign $this->type = $type; - if ($type !== 'product' || $type !== 'task') { - throw new \Exception("Type '{$type}' is not allowed. Allowed values are 'product' or 'task'."); - } - $this->setup(); return [ @@ -148,7 +144,7 @@ class Bold extends BaseDesign $elements = []; - foreach ($this->context['product-table-columns'] as $column) { + foreach ($this->context["{$this->type}-table-columns"] as $column) { $elements[] = ['element' => 'th', 'content' => $column . '_label', 'properties' => ['class' => 'text-xl px-4 py-2']]; } diff --git a/app/Services/PdfMaker/Designs/Business.php b/app/Services/PdfMaker/Designs/Business.php index a5adbc706c93..7da3d7a68b52 100644 --- a/app/Services/PdfMaker/Designs/Business.php +++ b/app/Services/PdfMaker/Designs/Business.php @@ -48,10 +48,6 @@ class Business extends BaseDesign $this->type = $type; - if ($type !== 'product' || $type !== 'task') { - throw new \Exception("Type '{$type}' is not allowed. Allowed values are 'product' or 'task'."); - } - $this->setup(); return [ diff --git a/app/Services/PdfMaker/Designs/Clean.php b/app/Services/PdfMaker/Designs/Clean.php index 5949d432dac7..bf9dfaf5ec36 100644 --- a/app/Services/PdfMaker/Designs/Clean.php +++ b/app/Services/PdfMaker/Designs/Clean.php @@ -48,10 +48,6 @@ class Clean extends BaseDesign $this->type = $type; - if ($type !== 'product' || $type !== 'task') { - throw new \Exception("Type '{$type}' is not allowed. Allowed values are 'product' or 'task'."); - } - $this->setup(); return [ diff --git a/app/Services/PdfMaker/Designs/Creative.php b/app/Services/PdfMaker/Designs/Creative.php index 8b78e365276d..5eb27d9b46f1 100644 --- a/app/Services/PdfMaker/Designs/Creative.php +++ b/app/Services/PdfMaker/Designs/Creative.php @@ -48,10 +48,6 @@ class Creative extends BaseDesign $this->type = $type; - if ($type !== 'product' || $type !== 'task') { - throw new \Exception("Type '{$type}' is not allowed. Allowed values are 'product' or 'task'."); - } - $this->setup(); return [ diff --git a/app/Services/PdfMaker/Designs/Elegant.php b/app/Services/PdfMaker/Designs/Elegant.php index 752d7f1cdc3a..d1ea33c8167d 100644 --- a/app/Services/PdfMaker/Designs/Elegant.php +++ b/app/Services/PdfMaker/Designs/Elegant.php @@ -48,10 +48,6 @@ class Elegant extends BaseDesign $this->type = $type; - if ($type !== 'product' || $type !== 'task') { - throw new \Exception("Type '{$type}' is not allowed. Allowed values are 'product' or 'task'."); - } - $this->setup(); return [ diff --git a/app/Services/PdfMaker/Designs/Hipster.php b/app/Services/PdfMaker/Designs/Hipster.php index 4f08da9de847..2839dd3783a7 100644 --- a/app/Services/PdfMaker/Designs/Hipster.php +++ b/app/Services/PdfMaker/Designs/Hipster.php @@ -48,10 +48,6 @@ class Hipster extends BaseDesign $this->type = $type; - if ($type !== 'product' || $type !== 'task') { - throw new \Exception("Type '{$type}' is not allowed. Allowed values are 'product' or 'task'."); - } - $this->setup(); return [ diff --git a/app/Services/PdfMaker/Designs/Modern.php b/app/Services/PdfMaker/Designs/Modern.php index a6297e46054d..1caf7ef398ef 100644 --- a/app/Services/PdfMaker/Designs/Modern.php +++ b/app/Services/PdfMaker/Designs/Modern.php @@ -48,10 +48,6 @@ class Modern extends BaseDesign $this->type = $type; - if ($type !== 'product' || $type !== 'task') { - throw new \Exception("Type '{$type}' is not allowed. Allowed values are 'product' or 'task'."); - } - $this->setup(); return [ diff --git a/app/Services/PdfMaker/Designs/Plain.php b/app/Services/PdfMaker/Designs/Plain.php index cd7de4f96a0c..8d05119ade37 100644 --- a/app/Services/PdfMaker/Designs/Plain.php +++ b/app/Services/PdfMaker/Designs/Plain.php @@ -48,10 +48,6 @@ class Plain extends BaseDesign $this->type = $type; - if ($type !== 'product' || $type !== 'task') { - throw new \Exception("Type '{$type}' is not allowed. Allowed values are 'product' or 'task'."); - } - $this->setup(); return [ diff --git a/app/Services/PdfMaker/Designs/Playful.php b/app/Services/PdfMaker/Designs/Playful.php index a3c512b3d8bf..72dcf0840167 100644 --- a/app/Services/PdfMaker/Designs/Playful.php +++ b/app/Services/PdfMaker/Designs/Playful.php @@ -48,10 +48,6 @@ class Playful extends BaseDesign $this->type = $type; - if ($type !== 'product' || $type !== 'task') { - throw new \Exception("Type '{$type}' is not allowed. Allowed values are 'product' or 'task'."); - } - $this->setup(); return [ diff --git a/app/Utils/HtmlEngine.php b/app/Utils/HtmlEngine.php index ff05c519beb3..c37d944c5d81 100644 --- a/app/Utils/HtmlEngine.php +++ b/app/Utils/HtmlEngine.php @@ -96,6 +96,7 @@ class HtmlEngine $data = []; $data['$global-margin'] = ['value' => 'm-12', 'label' => '']; + $data['$global-padding'] = ['value' => 'p-12', 'label' => '']; $data['$tax'] = ['value' => '', 'label' => ctrans('texts.tax')]; $data['$app_url'] = ['value' => $this->generateAppUrl(), 'label' => '']; $data['$from'] = ['value' => '', 'label' => ctrans('texts.from')]; @@ -175,11 +176,11 @@ class HtmlEngine $data['$invoice.custom4'] = ['value' => $this->entity->custom_value4 ?: ' ', 'label' => $this->makeCustomField('invoice4')]; $data['$invoice.public_notes'] = ['value' => $this->entity->public_notes ?: ' ', 'label' => ctrans('texts.public_notes')]; $data['$entity.public_notes'] = &$data['$invoice.public_notes']; + + $data['$entity_issued_to'] = ['value' => '', 'label' => ctrans("texts.{$this->entity_string}_issued_to")]; - // $data['$your_invoice'] = ; - // $data['$quote'] = ; - // $data['$your_quote'] = ; - // + $data['$your_' . $this->entity_string] = ['value' => '', 'label' => ctrans("texts.your_{$this->entity_string}")]; + $data['$quote.date'] = ['value' => $this->entity->date ?: ' ', 'label' => ctrans('texts.quote_date')]; $data['$quote.number'] = ['value' => $this->entity->number ?: ' ', 'label' => ctrans('texts.quote_number')]; $data['$quote.po_number'] = &$data['$invoice.po_number']; @@ -297,6 +298,10 @@ class HtmlEngine $data['$task.line_total'] = ['value' => '', 'label' => ctrans('texts.line_total')]; $data['$contact.signature'] = ['value' => $this->invitation->signature_base64, 'label' => ctrans('texts.signature')]; + $data['$thanks'] = ['value' => '', 'label' => ctrans('texts.thanks')]; + $data['$from'] = ['value' => '', 'label' => ctrans('texts.from')]; + $data['$to'] = ['value' => '', 'label' => ctrans('texts.to')]; + // $data['custom_label1'] = ['value' => '', 'label' => ctrans('texts.')]; // $data['custom_label2'] = ['value' => '', 'label' => ctrans('texts.')]; // $data['custom_label3'] = ['value' => '', 'label' => ctrans('texts.')]; diff --git a/resources/views/pdf-designs/bold.html b/resources/views/pdf-designs/bold.html index f8ae4539a63e..025589e20ade 100644 --- a/resources/views/pdf-designs/bold.html +++ b/resources/views/pdf-designs/bold.html @@ -44,7 +44,7 @@

- $your-invoice + $your_entity_label

diff --git a/resources/views/pdf-designs/business.html b/resources/views/pdf-designs/business.html index 956e98e2bad9..768fcc56e625 100644 --- a/resources/views/pdf-designs/business.html +++ b/resources/views/pdf-designs/business.html @@ -52,7 +52,7 @@
-

$invoice-issued-to

+

$entity_issued_to_label

diff --git a/resources/views/pdf-designs/clean.html b/resources/views/pdf-designs/clean.html index 84b636873b8d..77b3847c70e2 100644 --- a/resources/views/pdf-designs/clean.html +++ b/resources/views/pdf-designs/clean.html @@ -34,7 +34,7 @@
-

$entity

+

$entity_label

diff --git a/resources/views/pdf-designs/creative.html b/resources/views/pdf-designs/creative.html index f9b247a992d1..cf29f49f8c1b 100644 --- a/resources/views/pdf-designs/creative.html +++ b/resources/views/pdf-designs/creative.html @@ -49,8 +49,8 @@
- $entity - #$entity-number + $entity_label + #$entity_number
diff --git a/resources/views/pdf-designs/elegant.html b/resources/views/pdf-designs/elegant.html index 120e9891d5a4..ad8e72c47bba 100644 --- a/resources/views/pdf-designs/elegant.html +++ b/resources/views/pdf-designs/elegant.html @@ -42,7 +42,7 @@
-

$thanks

+

$thanks_label

diff --git a/resources/views/pdf-designs/hipster.html b/resources/views/pdf-designs/hipster.html index f9e7b2b89f0f..b9db88c8619f 100644 --- a/resources/views/pdf-designs/hipster.html +++ b/resources/views/pdf-designs/hipster.html @@ -17,7 +17,7 @@

- $from: + $from_label:

@@ -26,7 +26,7 @@ class="col-span-5 pl-4 border-l border-black" id="client-details" > -

$to:

+

$to_label:

- $entity + $entity_label

-

$to:

+

$to_label:

@@ -48,7 +48,7 @@
-

$from:

+

$from_label:

diff --git a/tests/Feature/PdfMaker/ExampleIntegrationTest.php b/tests/Feature/PdfMaker/ExampleIntegrationTest.php index f2f032d480ec..98a2ca6148f8 100644 --- a/tests/Feature/PdfMaker/ExampleIntegrationTest.php +++ b/tests/Feature/PdfMaker/ExampleIntegrationTest.php @@ -3,7 +3,7 @@ namespace Tests\Feature\PdfMaker; use App\Models\Invoice; -use App\Services\PdfMaker\Designs\Plain; +use App\Services\PdfMaker\Designs\Playful; use App\Services\PdfMaker\PdfMaker; use App\Utils\HtmlEngine; use App\Utils\Traits\MakesInvoiceValues; @@ -19,7 +19,7 @@ class ExampleIntegrationTest extends TestCase $invitation = $invoice->invitations()->first(); $engine = new HtmlEngine(null, $invitation, 'invoice'); - $design = new Plain(); + $design = new Playful(); $product_table_columns = json_decode( json_encode($invoice->company->settings->pdf_variables), @@ -35,10 +35,10 @@ class ExampleIntegrationTest extends TestCase 'variables' => $engine->generateLabelsAndValues(), ]; - $maker = new PdfMaker($state, 'product'); + $maker = new PdfMaker($state); $maker - ->design(Plain::class) + ->design(Playful::class) ->build(); exec('echo "" > storage/logs/laravel.log');