diff --git a/app/Services/PdfMaker/Designs/Bold.php b/app/Services/PdfMaker/Designs/Bold.php deleted file mode 100644 index fe7541440a..0000000000 --- a/app/Services/PdfMaker/Designs/Bold.php +++ /dev/null @@ -1,200 +0,0 @@ - product||task */ - public $type; - - public function html() - { - return file_get_contents( - base_path('resources/views/pdf-designs/bold.html') - ); - } - - public function elements(array $context, string $type = 'product'): array - { - $this->context = $context; - - $this->type = $type; - - $this->setup(); - - return [ - 'company-details' => [ - 'id' => 'company-details', - 'elements' => $this->companyDetails(), - ], - 'company-address' => [ - 'id' => 'company-address', - 'elements' => $this->companyAddress(), - ], - 'client-details' => [ - 'id' => 'client-details', - 'elements' => $this->clientDetails(), - ], - 'entity-details' => [ - 'id' => 'entity-details', - 'elements' => $this->entityDetails(), - ], - 'product-table' => [ - 'id' => 'product-table', - 'elements' => $this->productTable(), - ], - 'footer-elements' => [ - 'id' => 'footer', - 'elements' => [ - $this->sharedFooterElements(), - ], - ], - ]; - } - - public function companyDetails() - { - $variables = $this->context['pdf_variables']['company_details']; - - $elements = []; - - foreach ($variables as $variable) { - $elements[] = ['element' => 'p', 'content' => $variable]; - } - - return $elements; - } - - public function companyAddress(): array - { - $variables = $this->context['pdf_variables']['company_address']; - - $elements = []; - - foreach ($variables as $variable) { - $elements[] = ['element' => 'p', 'content' => $variable]; - } - - return $elements; - } - - public function clientDetails(): array - { - $variables = $this->context['pdf_variables']['client_details']; - - $elements = []; - - foreach ($variables as $variable) { - $elements[] = ['element' => 'p', 'content' => $variable]; - } - - return $elements; - } - - public function entityDetails(): array - { - $variables = $this->context['pdf_variables']['invoice_details']; - - if ($this->entity instanceof \App\Models\Quote) { - $variables = $this->context['pdf_variables']['quote_details']; - } - - $elements = []; - - foreach ($variables as $variable) { - $elements[] = ['element' => 'tr', 'properties' => ['hidden' => $this->entityVariableCheck($variable)], 'content' => '', 'elements' => [ - ['element' => 'th', 'content' => $variable . '_label', 'properties' => ['class' => 'text-left pr-4 font-normal']], - ['element' => 'th', 'content' => $variable, 'properties' => ['class' => 'text-left pr-4 font-normal']], - ]]; - } - - return $elements; - } - - public function productTable(): array - { - return [ - ['element' => 'thead', 'content' => '', 'properties' => ['class' => 'text-left rounded-t-lg'], 'elements' => $this->buildTableHeader()], - ['element' => 'tbody', 'content' => '', 'elements' => $this->buildTableBody()], - ['element' => 'tfoot', 'content' => '', 'elements' => $this->tableFooter()], - ]; - } - - public function buildTableHeader(): array - { - $this->processTaxColumns(); - - $elements = []; - - foreach ($this->context["{$this->type}-table-columns"] as $column) { - $elements[] = ['element' => 'th', 'content' => $column . '_label', 'properties' => ['class' => 'text-xl px-4 py-2']]; - } - - return $elements; - } - - public function buildTableBody(): array - { - $elements = []; - - $items = $this->transformLineItems($this->entity->line_items); - - if (count($items) == 0) { - return []; - } - - foreach ($items as $row) { - $element = ['element' => 'tr', 'content' => '', 'elements' => []]; - - foreach ($this->context['pdf_variables']['product_columns'] as $key => $cell) { - $element['elements'][] = ['element' => 'td', 'content' => $row[$cell], 'properties' => ['class' => 'px-4 py-4']]; - } - - $elements[] = $element; - } - - return $elements; - } - - public function tableFooter() - { - $variables = $this->entity->company->settings->pdf_variables->total_columns; - - $elements = [ - ['element' => 'tr', 'content' => '', 'elements' => [ - ['element' => 'td', 'content' => '$entity.public_notes', 'properties' => ['class' => 'border-l-4 border-white px-4 text-right', 'colspan' => '100%']], - ]], - ]; - - foreach ($variables as $variable) { - ['element' => 'tr', 'properties' => ['hidden' => 'false'], 'content' => '', 'elements' => [ - ['element' => 'td', 'content' => $variable . '_label', 'properties' => ['class' => 'border-l-4 border-white px-4 text-right', 'colspan' => $this->calculateColspan(1)]], - ['element' => 'td', 'content' => $variable, 'properties' => ['class' => 'px-4 py-2 text-right']], - ]]; - } - - return $elements; - } -} diff --git a/app/Services/PdfMaker/Designs/Business.php b/app/Services/PdfMaker/Designs/Business.php deleted file mode 100644 index 71c4c8ff63..0000000000 --- a/app/Services/PdfMaker/Designs/Business.php +++ /dev/null @@ -1,206 +0,0 @@ - product||task */ - public $type; - - public function html() - { - return file_get_contents( - base_path('resources/views/pdf-designs/business.html') - ); - } - - public function elements(array $context, string $type = 'product'): array - { - $this->context = $context; - - $this->type = $type; - - $this->setup(); - - return [ - 'company-details' => [ - 'id' => 'company-details', - 'elements' => $this->companyDetails(), - ], - 'company-address' => [ - 'id' => 'company-address', - 'elements' => $this->companyAddress(), - ], - 'client-details' => [ - 'id' => 'client-details', - 'elements' => $this->clientDetails(), - ], - 'entity-details' => [ - 'id' => 'entity-details', - 'elements' => $this->entityDetails(), - ], - 'product-table' => [ - 'id' => 'product-table', - 'elements' => $this->productTable(), - ], - 'footer-elements' => [ - 'id' => 'footer', - 'elements' => [ - $this->sharedFooterElements(), - ], - ], - ]; - } - - public function companyDetails() - { - $variables = $this->context['pdf_variables']['company_details']; - - $elements = []; - - foreach ($variables as $variable) { - $elements[] = ['element' => 'p', 'content' => $variable]; - } - - return $elements; - } - - public function companyAddress(): array - { - $variables = $this->context['pdf_variables']['company_address']; - - $elements = []; - - foreach ($variables as $variable) { - $elements[] = ['element' => 'p', 'content' => $variable]; - } - - return $elements; - } - - public function clientDetails(): array - { - $variables = $this->context['pdf_variables']['client_details']; - - $elements = []; - - foreach ($variables as $variable) { - $elements[] = ['element' => 'p', 'content' => $variable]; - } - - return $elements; - } - - public function entityDetails(): array - { - $variables = $this->context['pdf_variables']['invoice_details']; - - if ($this->entity instanceof \App\Models\Quote) { - $variables = $this->context['pdf_variables']['quote_details']; - } - - $elements = []; - - foreach ($variables as $variable) { - $elements[] = ['element' => 'tr', 'properties' => ['hidden' => $this->entityVariableCheck($variable)], 'content' => '', 'elements' => [ - ['element' => 'th', 'content' => $variable . '_label', 'properties' => ['class' => 'text-left pr-4 font-normal']], - ['element' => 'th', 'content' => $variable, 'properties' => ['class' => 'text-left pr-4 font-normal']], - ]]; - } - - return $elements; - } - - public function productTable(): array - { - return [ - ['element' => 'thead', 'content' => '', 'properties' => ['class' => 'text-left rounded-t-lg'], 'elements' => $this->buildTableHeader()], - ['element' => 'tbody', 'content' => '', 'elements' => $this->buildTableBody()], - ['element' => 'tfoot', 'content' => '', 'elements' => $this->tableFooter()], - ]; - } - - public function buildTableHeader(): array - { - $this->processTaxColumns(); - - $elements = []; - - foreach ($this->context['pdf_variables']['product_columns'] as $column) { - $elements[] = ['element' => 'th', 'content' => $column . '_label', 'properties' => ['class' => 'font-semibold text-white px-4 bg-blue-900 py-5']]; - } - - return $elements; - } - - public function buildTableBody(): array - { - $elements = []; - - $items = $this->transformLineItems($this->entity->line_items); - - if (count($items) == 0) { - return []; - } - - foreach ($items as $row) { - $element = ['element' => 'tr', 'content' => '', 'elements' => []]; - - foreach ($this->context['pdf_variables']['product_columns'] as $key => $cell) { - $element['elements'][] = ['element' => 'td', 'content' => $row[$cell], 'properties' => ['class' => 'border-4 border-white px-4 py-4 bg-gray-200']]; - } - - $elements[] = $element; - } - - return $elements; - } - - public function tableFooter() - { - $variables = $this->entity->company->settings->pdf_variables->total_columns; - - $elements = [ - ['element' => 'tr', 'content' => '', 'elements' => [ - ['element' => 'td', 'content' => '$entity.public_notes', 'properties' => ['class' => 'border-l-4 border-white px-4 text-right', 'colspan' => '100%']], - ]], - ]; - - foreach ($variables as $variable) { - ['element' => 'tr', 'properties' => ['hidden' => 'false'], 'content' => '', 'elements' => [ - ['element' => 'td', 'content' => $variable . '_label', 'properties' => ['class' => 'border-l-4 border-white px-4 text-right', 'colspan' => $this->calculateColspan(1)]], - ['element' => 'td', 'content' => $variable, 'properties' => ['class' => 'px-4 py-2 text-right']], - ]]; - } - - return $elements; - } -} diff --git a/app/Services/PdfMaker/Designs/Clean.php b/app/Services/PdfMaker/Designs/Clean.php deleted file mode 100644 index 6855d93029..0000000000 --- a/app/Services/PdfMaker/Designs/Clean.php +++ /dev/null @@ -1,206 +0,0 @@ - product||task */ - public $type; - - public function html() - { - return file_get_contents( - base_path('resources/views/pdf-designs/clean.html') - ); - } - - public function elements(array $context, string $type = 'product'): array - { - $this->context = $context; - - $this->type = $type; - - $this->setup(); - - return [ - 'company-details' => [ - 'id' => 'company-details', - 'elements' => $this->companyDetails(), - ], - 'company-address' => [ - 'id' => 'company-address', - 'elements' => $this->companyAddress(), - ], - 'entity-details' => [ - 'id' => 'entity-details', - 'elements' => $this->entityDetails(), - ], - 'client-details' => [ - 'id' => 'client-details', - 'elements' => $this->clientDetails(), - ], - 'product-table' => [ - 'id' => 'product-table', - 'elements' => $this->productTable(), - ], - 'footer-elements' => [ - 'id' => 'footer', - 'elements' => [ - $this->sharedFooterElements(), - ], - ], - ]; - } - - public function companyDetails() - { - $variables = $this->context['pdf_variables']['company_details']; - - $elements = []; - - foreach ($variables as $variable) { - $elements[] = ['element' => 'p', 'content' => $variable]; - } - - return $elements; - } - - public function companyAddress(): array - { - $variables = $this->context['pdf_variables']['company_address']; - - $elements = []; - - foreach ($variables as $variable) { - $elements[] = ['element' => 'p', 'content' => $variable]; - } - - return $elements; - } - - public function entityDetails(): array - { - $variables = $this->context['pdf_variables']['invoice_details']; - - if ($this->entity instanceof \App\Models\Quote) { - $variables = $this->context['pdf_variables']['quote_details']; - } - - $elements = []; - - foreach ($variables as $variable) { - $elements[] = ['element' => 'tr', 'properties' => ['hidden' => $this->entityVariableCheck($variable)], 'content' => '', 'elements' => [ - ['element' => 'th', 'content' => $variable . '_label', 'properties' => ['class' => 'text-left pr-4 font-normal']], - ['element' => 'th', 'content' => $variable, 'properties' => ['class' => 'text-left pr-4 font-normal']], - ]]; - } - - return $elements; - } - - public function clientDetails(): array - { - $variables = $this->context['pdf_variables']['client_details']; - - $elements = []; - - foreach ($variables as $variable) { - $elements[] = ['element' => 'p', 'content' => $variable]; - } - - return $elements; - } - - public function productTable(): array - { - return [ - ['element' => 'thead', 'content' => '', 'properties' => ['class' => 'text-left rounded-t-lg'], 'elements' => $this->buildTableHeader()], - ['element' => 'tbody', 'content' => '', 'elements' => $this->buildTableBody()], - ['element' => 'tfoot', 'content' => '', 'elements' => $this->tableFooter()], - ]; - } - - public function buildTableHeader(): array - { - $this->processTaxColumns(); - - $elements = []; - - foreach ($this->context['pdf_variables']['product_columns'] as $column) { - $elements[] = ['element' => 'th', 'content' => $column . '_label', 'properties' => ['class' => 'font-semibold px-4 py-5']]; - } - - return $elements; - } - - public function buildTableBody(): array - { - $elements = []; - - $items = $this->transformLineItems($this->entity->line_items); - - if (count($items) == 0) { - return []; - } - - foreach ($items as $row) { - $element = ['element' => 'tr', 'content' => '', 'elements' => []]; - - foreach ($this->context['pdf_variables']['product_columns'] as $key => $cell) { - $element['elements'][] = ['element' => 'td', 'content' => $row[$cell], 'properties' => ['class' => 'border-t border-b px-4 py-4']]; - } - - $elements[] = $element; - } - - return $elements; - } - - public function tableFooter() - { - $variables = $this->entity->company->settings->pdf_variables->total_columns; - - $elements = [ - ['element' => 'tr', 'content' => '', 'elements' => [ - ['element' => 'td', 'content' => '$entity.public_notes', 'properties' => ['class' => 'border-l-4 border-white px-4 text-right', 'colspan' => '100%']], - ]], - ]; - - foreach ($variables as $variable) { - ['element' => 'tr', 'properties' => ['hidden' => 'false'], 'content' => '', 'elements' => [ - ['element' => 'td', 'content' => $variable . '_label', 'properties' => ['class' => 'border-l-4 border-white px-4 text-right', 'colspan' => $this->calculateColspan(1)]], - ['element' => 'td', 'content' => $variable, 'properties' => ['class' => 'px-4 py-2 text-right']], - ]]; - } - - return $elements; - } -} diff --git a/app/Services/PdfMaker/Designs/Creative.php b/app/Services/PdfMaker/Designs/Creative.php deleted file mode 100644 index fc731add27..0000000000 --- a/app/Services/PdfMaker/Designs/Creative.php +++ /dev/null @@ -1,206 +0,0 @@ - product||task */ - public $type; - - public function html() - { - return file_get_contents( - base_path('resources/views/pdf-designs/creative.html') - ); - } - - public function elements(array $context, string $type = 'product'): array - { - $this->context = $context; - - $this->type = $type; - - $this->setup(); - - return [ - 'company-details' => [ - 'id' => 'company-details', - 'elements' => $this->companyDetails(), - ], - 'company-address' => [ - 'id' => 'company-address', - 'elements' => $this->companyAddress(), - ], - 'client-details' => [ - 'id' => 'client-details', - 'elements' => $this->clientDetails(), - ], - 'entity-details' => [ - 'id' => 'entity-details', - 'elements' => $this->entityDetails(), - ], - 'product-table' => [ - 'id' => 'product-table', - 'elements' => $this->productTable(), - ], - 'footer-elements' => [ - 'id' => 'footer', - 'elements' => [ - $this->sharedFooterElements(), - ], - ], - ]; - } - - public function companyDetails() - { - $variables = $this->context['pdf_variables']['company_details']; - - $elements = []; - - foreach ($variables as $variable) { - $elements[] = ['element' => 'p', 'content' => $variable]; - } - - return $elements; - } - - public function companyAddress(): array - { - $variables = $this->context['pdf_variables']['company_address']; - - $elements = []; - - foreach ($variables as $variable) { - $elements[] = ['element' => 'p', 'content' => $variable]; - } - - return $elements; - } - - public function clientDetails(): array - { - $variables = $this->context['pdf_variables']['client_details']; - - $elements = []; - - foreach ($variables as $variable) { - $elements[] = ['element' => 'p', 'content' => $variable]; - } - - return $elements; - } - - public function entityDetails(): array - { - $variables = $this->context['pdf_variables']['invoice_details']; - - if ($this->entity instanceof \App\Models\Quote) { - $variables = $this->context['pdf_variables']['quote_details']; - } - - $elements = []; - - foreach ($variables as $variable) { - $elements[] = ['element' => 'tr', 'properties' => ['hidden' => $this->entityVariableCheck($variable)], 'content' => '', 'elements' => [ - ['element' => 'th', 'content' => $variable . '_label', 'properties' => ['class' => 'text-left pr-4 font-normal']], - ['element' => 'th', 'content' => $variable, 'properties' => ['class' => 'text-left pr-4 font-normal']], - ]]; - } - - return $elements; - } - - public function productTable(): array - { - return [ - ['element' => 'thead', 'content' => '', 'properties' => ['class' => 'text-left'], 'elements' => $this->buildTableHeader()], - ['element' => 'tbody', 'content' => '', 'elements' => $this->buildTableBody()], - ['element' => 'tfoot', 'content' => '', 'elements' => $this->tableFooter()], - ]; - } - - public function buildTableHeader(): array - { - $this->processTaxColumns(); - - $elements = []; - - foreach ($this->context['pdf_variables']['product_columns'] as $column) { - $elements[] = ['element' => 'th', 'content' => $column . '_label', 'properties' => ['class' => 'font-medium uppercase text-pink-700 text-xl px-4 py-5']]; - } - - return $elements; - } - - public function buildTableBody(): array - { - $elements = []; - - $items = $this->transformLineItems($this->entity->line_items); - - if (count($items) == 0) { - return []; - } - - foreach ($items as $row) { - $element = ['element' => 'tr', 'content' => '', 'elements' => []]; - - foreach ($this->context['pdf_variables']['product_columns'] as $key => $cell) { - $element['elements'][] = ['element' => 'td', 'content' => $row[$cell], 'properties' => ['class' => 'px-4 py-4']]; - } - - $elements[] = $element; - } - - return $elements; - } - - public function tableFooter() - { - $variables = $this->entity->company->settings->pdf_variables->total_columns; - - $elements = [ - ['element' => 'tr', 'content' => '', 'elements' => [ - ['element' => 'td', 'content' => '$entity.public_notes', 'properties' => ['class' => 'border-l-4 border-white px-4 text-right', 'colspan' => '100%']], - ]], - ]; - - foreach ($variables as $variable) { - ['element' => 'tr', 'properties' => ['hidden' => 'false'], 'content' => '', 'elements' => [ - ['element' => 'td', 'content' => $variable . '_label', 'properties' => ['class' => 'border-l-4 border-white px-4 text-right', 'colspan' => $this->calculateColspan(1)]], - ['element' => 'td', 'content' => $variable, 'properties' => ['class' => 'px-4 py-2 text-right']], - ]]; - } - - return $elements; - } -} diff --git a/app/Services/PdfMaker/Designs/Elegant.php b/app/Services/PdfMaker/Designs/Elegant.php deleted file mode 100644 index 0fb5f3a6aa..0000000000 --- a/app/Services/PdfMaker/Designs/Elegant.php +++ /dev/null @@ -1,207 +0,0 @@ - product||task */ - public $type; - - public function html() - { - return file_get_contents( - base_path('resources/views/pdf-designs/elegant.html') - ); - } - - public function elements(array $context, string $type = 'product'): array - { - $this->context = $context; - - $this->type = $type; - - $this->setup(); - - return [ - 'entity-details' => [ - 'id' => 'entity-details', - 'elements' => $this->entityDetails(), - ], - 'company-details' => [ - 'id' => 'company-details', - 'elements' => $this->companyDetails(), - ], - 'company-address' => [ - 'id' => 'company-address', - 'elements' => $this->companyAddress(), - ], - 'client-details' => [ - 'id' => 'client-details', - 'elements' => $this->clientDetails(), - ], - 'product-table' => [ - 'id' => 'product-table', - 'elements' => $this->productTable(), - ], - 'footer-elements' => [ - 'id' => 'footer', - 'elements' => [ - $this->sharedFooterElements(), - ], - ], - ]; - } - - public function entityDetails(): array - { - $variables = $this->context['pdf_variables']['invoice_details']; - - if ($this->entity instanceof \App\Models\Quote) { - $variables = $this->context['pdf_variables']['quote_details']; - } - - $elements = []; - - foreach ($variables as $variable) { - $elements[] = ['element' => 'tr', 'properties' => ['hidden' => $this->entityVariableCheck($variable)], 'content' => '', 'elements' => [ - ['element' => 'th', 'content' => $variable . '_label', 'properties' => ['class' => 'text-left pr-4 font-normal']], - ['element' => 'th', 'content' => $variable, 'properties' => ['class' => 'text-left pr-4 font-normal']], - ]]; - } - - return $elements; - } - - - public function companyDetails() - { - $variables = $this->context['pdf_variables']['company_details']; - - $elements = []; - - foreach ($variables as $variable) { - $elements[] = ['element' => 'p', 'content' => $variable]; - } - - return $elements; - } - - public function companyAddress(): array - { - $variables = $this->context['pdf_variables']['company_address']; - - $elements = []; - - foreach ($variables as $variable) { - $elements[] = ['element' => 'p', 'content' => $variable]; - } - - return $elements; - } - - public function clientDetails(): array - { - $variables = $this->context['pdf_variables']['client_details']; - - $elements = []; - - foreach ($variables as $variable) { - $elements[] = ['element' => 'p', 'content' => $variable]; - } - - return $elements; - } - - public function productTable(): array - { - return [ - ['element' => 'thead', 'content' => '', 'properties' => ['class' => 'text-left border-dashed border-b border-black'], 'elements' => $this->buildTableHeader()], - ['element' => 'tbody', 'content' => '', 'elements' => $this->buildTableBody()], - ['element' => 'tfoot', 'content' => '', 'elements' => $this->tableFooter()], - ]; - } - - public function buildTableHeader(): array - { - $this->processTaxColumns(); - - $elements = []; - - foreach ($this->context['pdf_variables']['product_columns'] as $column) { - $elements[] = ['element' => 'th', 'content' => $column . '_label', 'properties' => ['class' => 'font-normal text-green-700 px-4 py-2']]; - } - - return $elements; - } - - public function buildTableBody(): array - { - $elements = []; - - $items = $this->transformLineItems($this->entity->line_items); - - if (count($items) == 0) { - return []; - } - - foreach ($items as $row) { - $element = ['element' => 'tr', 'properties' => ['class' => 'border-dashed border-b border-black'], 'content' => '', 'elements' => []]; - - foreach ($this->context['pdf_variables']['product_columns'] as $key => $cell) { - $element['elements'][] = ['element' => 'td', 'content' => $row[$cell], 'properties' => ['class' => 'px-4 py-3']]; - } - - $elements[] = $element; - } - - return $elements; - } - - public function tableFooter() - { - $variables = $this->entity->company->settings->pdf_variables->total_columns; - - $elements = [ - ['element' => 'tr', 'content' => '', 'elements' => [ - ['element' => 'td', 'content' => '$entity.public_notes', 'properties' => ['class' => 'border-l-4 border-white px-4 text-right', 'colspan' => '100%']], - ]], - ]; - - foreach ($variables as $variable) { - ['element' => 'tr', 'properties' => ['hidden' => 'false'], 'content' => '', 'elements' => [ - ['element' => 'td', 'content' => $variable . '_label', 'properties' => ['class' => 'border-l-4 border-white px-4 text-right', 'colspan' => $this->calculateColspan(1)]], - ['element' => 'td', 'content' => $variable, 'properties' => ['class' => 'px-4 py-2 text-right']], - ]]; - } - - return $elements; - } -} diff --git a/app/Services/PdfMaker/Designs/Hipster.php b/app/Services/PdfMaker/Designs/Hipster.php deleted file mode 100644 index 943843ae7d..0000000000 --- a/app/Services/PdfMaker/Designs/Hipster.php +++ /dev/null @@ -1,206 +0,0 @@ - product||task */ - public $type; - - public function html() - { - return file_get_contents( - base_path('resources/views/pdf-designs/hipster.html') - ); - } - - public function elements(array $context, string $type = 'product'): array - { - $this->context = $context; - - $this->type = $type; - - $this->setup(); - - return [ - 'company-details' => [ - 'id' => 'company-details', - 'elements' => $this->companyDetails(), - ], - 'company-address' => [ - 'id' => 'company-address', - 'elements' => $this->companyAddress(), - ], - 'client-details' => [ - 'id' => 'client-details', - 'elements' => $this->clientDetails(), - ], - 'entity-details' => [ - 'id' => 'entity-details', - 'elements' => $this->entityDetails(), - ], - 'product-table' => [ - 'id' => 'product-table', - 'elements' => $this->productTable(), - ], - 'footer-elements' => [ - 'id' => 'footer', - 'elements' => [ - $this->sharedFooterElements(), - ], - ], - ]; - } - - public function companyDetails() - { - $variables = $this->context['pdf_variables']['company_details']; - - $elements = []; - - foreach ($variables as $variable) { - $elements[] = ['element' => 'p', 'content' => $variable]; - } - - return $elements; - } - - public function companyAddress(): array - { - $variables = $this->context['pdf_variables']['company_address']; - - $elements = []; - - foreach ($variables as $variable) { - $elements[] = ['element' => 'p', 'content' => $variable]; - } - - return $elements; - } - - public function clientDetails(): array - { - $variables = $this->context['pdf_variables']['client_details']; - - $elements = []; - - foreach ($variables as $variable) { - $elements[] = ['element' => 'p', 'content' => $variable]; - } - - return $elements; - } - - public function entityDetails(): array - { - $variables = $this->context['pdf_variables']['invoice_details']; - - if ($this->entity instanceof \App\Models\Quote) { - $variables = $this->context['pdf_variables']['quote_details']; - } - - $elements = []; - - foreach ($variables as $variable) { - $elements[] = ['element' => 'div', 'properties' => ['hidden' => $this->entityVariableCheck($variable), 'class' => 'space-x-4'], 'content' => '', 'elements' => [ - ['element' => 'span', 'content' => $variable . '_label', 'properties' => ['class' => 'font-semibold uppercase text-yellow-600']], - ['element' => 'span', 'content' => $variable, 'properties' => ['class' => 'uppercase']], - ]]; - } - - return $elements; - } - - public function productTable(): array - { - return [ - ['element' => 'thead', 'content' => '', 'properties' => ['class' => 'text-left'], 'elements' => $this->buildTableHeader()], - ['element' => 'tbody', 'content' => '', 'elements' => $this->buildTableBody()], - ['element' => 'tfoot', 'content' => '', 'elements' => $this->tableFooter()], - ]; - } - - public function buildTableHeader(): array - { - $this->processTaxColumns(); - - $elements = []; - - foreach ($this->context['pdf_variables']['product_columns'] as $column) { - $elements[] = ['element' => 'th', 'content' => $column . '_label', 'properties' => ['class' => 'border-l-2 border-black px-4 py-2 uppercase']]; - } - - return $elements; - } - - public function buildTableBody(): array - { - $elements = []; - - $items = $this->transformLineItems($this->entity->line_items); - - if (count($items) == 0) { - return []; - } - - foreach ($items as $row) { - $element = ['element' => 'tr', 'content' => '', 'elements' => []]; - - foreach ($this->context['pdf_variables']['product_columns'] as $key => $cell) { - $element['elements'][] = ['element' => 'td', 'content' => $row[$cell], 'properties' => ['class' => 'border-l-2 border-black px-4 py-4']]; - } - - $elements[] = $element; - } - - return $elements; - } - - public function tableFooter() - { - $variables = $this->entity->company->settings->pdf_variables->total_columns; - - $elements = [ - ['element' => 'tr', 'content' => '', 'elements' => [ - ['element' => 'td', 'content' => '$entity.public_notes', 'properties' => ['class' => 'px-4 py-4 text-right', 'colspan' => '100%']], - ]], - ]; - - foreach ($variables as $variable) { - ['element' => 'tr', 'properties' => ['hidden' => 'false'], 'content' => '', 'elements' => [ - ['element' => 'td', 'content' => $variable . '_label', 'properties' => ['class' => 'border-l-4 border-white px-4 text-right', 'colspan' => $this->calculateColspan(1)]], - ['element' => 'td', 'content' => $variable, 'properties' => ['class' => 'border-l-2 border-black px-4 py-2 text-right']], - ]]; - } - - return $elements; - } -} diff --git a/app/Services/PdfMaker/Designs/Modern.php b/app/Services/PdfMaker/Designs/Modern.php deleted file mode 100644 index 082c768521..0000000000 --- a/app/Services/PdfMaker/Designs/Modern.php +++ /dev/null @@ -1,206 +0,0 @@ - product||task */ - public $type; - - public function html() - { - return file_get_contents( - base_path('resources/views/pdf-designs/modern.html') - ); - } - - public function elements(array $context, string $type = 'product'): array - { - $this->context = $context; - - $this->type = $type; - - $this->setup(); - - return [ - 'entity-details' => [ - 'id' => 'entity-details', - 'elements' => $this->entityDetails(), - ], - 'client-details' => [ - 'id' => 'client-details', - 'elements' => $this->clientDetails(), - ], - 'product-table' => [ - 'id' => 'product-table', - 'elements' => $this->productTable(), - ], - 'company-details' => [ - 'id' => 'company-details', - 'elements' => $this->companyDetails(), - ], - 'company-address' => [ - 'id' => 'company-address', - 'elements' => $this->companyAddress(), - ], - 'footer-elements' => [ - 'id' => 'footer', - 'elements' => [ - $this->sharedFooterElements(), - ], - ], - ]; - } - - public function entityDetails(): array - { - $variables = $this->context['pdf_variables']['invoice_details']; - - if ($this->entity instanceof \App\Models\Quote) { - $variables = $this->context['pdf_variables']['quote_details']; - } - - $elements = []; - - foreach ($variables as $variable) { - $elements[] = ['element' => 'tr', 'properties' => ['hidden' => $this->entityVariableCheck($variable)], 'content' => '', 'elements' => [ - ['element' => 'th', 'content' => $variable . '_label', 'properties' => ['class' => 'text-left pr-16 lg:pr-24 font-normal']], - ['element' => 'th', 'content' => $variable, 'properties' => ['class' => 'text-left pr-16 lg:pr-24 font-normal']], - ]]; - } - - return $elements; - } - - public function clientDetails(): array - { - $variables = $this->context['pdf_variables']['client_details']; - - $elements = []; - - foreach ($variables as $variable) { - $elements[] = ['element' => 'p', 'content' => $variable]; - } - - return $elements; - } - - public function productTable(): array - { - return [ - ['element' => 'thead', 'content' => '', 'properties' => ['class' => 'text-left text-white bg-gray-900'], 'elements' => $this->buildTableHeader()], - ['element' => 'tbody', 'content' => '', 'elements' => $this->buildTableBody()], - ['element' => 'tfoot', 'content' => '', 'elements' => $this->tableFooter()], - ]; - } - - public function buildTableHeader(): array - { - $this->processTaxColumns(); - - $elements = []; - - foreach ($this->context['pdf_variables']['product_columns'] as $column) { - $elements[] = ['element' => 'th', 'content' => $column . '_label', 'properties' => ['class' => 'px-4 py-2']]; - } - - return $elements; - } - - public function buildTableBody(): array - { - $elements = []; - - $items = $this->transformLineItems($this->entity->line_items); - - if (count($items) == 0) { - return []; - } - - foreach ($items as $row) { - $element = ['element' => 'tr', 'properties' => ['class' => 'border-t border-b border-gray-900'], 'content' => '', 'elements' => []]; - - foreach ($this->context['pdf_variables']['product_columns'] as $key => $cell) { - $element['elements'][] = ['element' => 'td', 'content' => $row[$cell], 'properties' => ['class' => 'px-4 py-4']]; - } - - $elements[] = $element; - } - - return $elements; - } - - public function tableFooter() - { - $variables = $this->entity->company->settings->pdf_variables->total_columns; - - $elements = [ - ['element' => 'tr', 'content' => '', 'elements' => [ - ['element' => 'td', 'content' => '$entity.public_notes', 'properties' => ['class' => 'border-l-4 border-white px-4 text-right', 'colspan' => '100%']], - ]], - ]; - - foreach ($variables as $variable) { - ['element' => 'tr', 'properties' => ['hidden' => 'false'], 'content' => '', 'elements' => [ - ['element' => 'td', 'content' => $variable . '_label', 'properties' => ['class' => 'border-l-4 border-white px-4 text-right', 'colspan' => $this->calculateColspan(1)]], - ['element' => 'td', 'content' => $variable, 'properties' => ['class' => 'px-4 py-2 text-right']], - ]]; - } - - return $elements; - } - - public function companyDetails() - { - $variables = $this->context['pdf_variables']['company_details']; - - $elements = []; - - foreach ($variables as $variable) { - $elements[] = ['element' => 'p', 'content' => $variable]; - } - - return $elements; - } - - public function companyAddress(): array - { - $variables = $this->context['pdf_variables']['company_address']; - - $elements = []; - - foreach ($variables as $variable) { - $elements[] = ['element' => 'p', 'content' => $variable]; - } - - return $elements; - } -} diff --git a/app/Services/PdfMaker/Designs/Plain.php b/app/Services/PdfMaker/Designs/Plain.php deleted file mode 100644 index 55e1e3c577..0000000000 --- a/app/Services/PdfMaker/Designs/Plain.php +++ /dev/null @@ -1,191 +0,0 @@ - product||task */ - public $type; - - public function html(): ?string - { - return file_get_contents( - base_path('resources/views/pdf-designs/plain.html') - ); - } - - public function elements(array $context, string $type = 'product'): array - { - $this->context = $context; - - $this->type = $type; - - $this->setup(); - - return [ - 'company-address' => [ - 'id' => 'company-address', - 'elements' => $this->companyAddress(), - ], - 'entity-details' => [ - 'id' => 'entity-details', - 'elements' => $this->entityDetails(), - ], - 'client-details' => [ - 'id' => 'client-details', - 'elements' => $this->clientDetails(), - ], - 'product-table' => [ - 'id' => 'product-table', - 'elements' => $this->productTable(), - ], - 'footer-elements' => [ - 'id' => 'footer', - 'elements' => [ - $this->sharedFooterElements(), - ], - ], - ]; - } - - public function companyAddress(): array - { - $variables = $this->context['pdf_variables']['company_address']; - - $elements = []; - - foreach ($variables as $variable) { - $elements[] = ['element' => 'p', 'content' => $variable]; - } - - return $elements; - } - - public function entityDetails(): array - { - $variables = $this->context['pdf_variables']['invoice_details']; - - if ($this->entity instanceof \App\Models\Quote) { - $variables = $this->context['pdf_variables']['quote_details']; - } - - $elements = []; - - foreach ($variables as $variable) { - $element = ['element' => 'tr', 'properties' => ['hidden' => $this->entityVariableCheck($variable)], 'content' => '', 'elements' => [ - ['element' => 'th', 'content' => $variable . '_label', 'properties' => ['class' => 'text-left pr-4 font-normal']], - ['element' => 'th', 'content' => $variable, 'properties' => ['class' => 'text-left pr-4 font-medium']], - ]]; - - $elements[] = $element; - } - - return $elements; - } - - public function clientDetails(): array - { - $variables = $this->context['pdf_variables']['client_details']; - - $elements = []; - - foreach ($variables as $variable) { - $elements[] = ['element' => 'p', 'content' => $variable]; - } - - return $elements; - } - - public function productTable(): array - { - return [ - ['element' => 'thead', 'content' => '', 'properties' => ['class' => 'text-left bg-gray-200'], 'elements' => $this->buildTableHeader()], - ['element' => 'tbody', 'content' => '', 'elements' => $this->buildTableBody()], - ['element' => 'tfoot', 'content' => '', 'elements' => $this->tableFooter()], - ]; - } - - public function tableFooter() - { - $variables = $this->entity->company->settings->pdf_variables->total_columns; - - $elements = [ - ['element' => 'tr', 'content' => '', 'elements' => [ - ['element' => 'td', 'content' => '$entity.public_notes', 'properties' => ['class' => 'border-l-4 border-white px-4 text-right', 'colspan' => '100%']], - ]], - ]; - - foreach ($variables as $variable) { - $elements[] = ['element' => 'tr', 'properties' => ['hidden' => 'false'], 'content' => '', 'elements' => [ - ['element' => 'td', 'content' => $variable . '_label', 'properties' => ['class' => 'border-l-4 border-white px-4 text-right', 'colspan' => $this->calculateColspan(1)]], - ['element' => 'td', 'content' => $variable, 'properties' => ['class' => 'px-4 py-2 text-right']], - ]]; - } - - return $elements; - } - - public function buildTableHeader(): array - { - $this->processTaxColumns(); - - $elements = []; - - foreach ($this->context['pdf_variables']['product_columns'] as $column) { - $elements[] = ['element' => 'th', 'content' => $column . '_label', 'properties' => ['class' => 'px-4 py-2']]; - } - - return $elements; - } - - public function buildTableBody(): array - { - $elements = []; - - $items = $this->transformLineItems($this->entity->line_items); - - if (count($items) == 0) { - return []; - } - - foreach ($items as $row) { - $element = ['element' => 'tr', 'content' => '', 'elements' => []]; - - foreach ($this->context['pdf_variables']['product_columns'] as $key => $cell) { - $element['elements'][] = ['element' => 'td', 'content' => $row[$cell], 'properties' => ['class' => 'border-t-2 border-b border-gray-200 px-4 py-4']]; - } - - $elements[] = $element; - } - - return $elements; - } -} diff --git a/app/Services/PdfMaker/Designs/Playful.php b/app/Services/PdfMaker/Designs/Playful.php deleted file mode 100644 index 8f0fc6b762..0000000000 --- a/app/Services/PdfMaker/Designs/Playful.php +++ /dev/null @@ -1,206 +0,0 @@ - product||task */ - public $type; - - public function html() - { - return file_get_contents( - base_path('resources/views/pdf-designs/playful.html') - ); - } - - public function elements(array $context, string $type = 'product'): array - { - $this->context = $context; - - $this->type = $type; - - $this->setup(); - - return [ - 'entity-details' => [ - 'id' => 'entity-details', - 'elements' => $this->entityDetails(), - ], - 'company-details' => [ - 'id' => 'company-details', - 'elements' => $this->companyDetails(), - ], - 'company-address' => [ - 'id' => 'company-address', - 'elements' => $this->companyAddress(), - ], - 'client-details' => [ - 'id' => 'client-details', - 'elements' => $this->clientDetails(), - ], - 'product-table' => [ - 'id' => 'product-table', - 'elements' => $this->productTable(), - ], - 'footer-elements' => [ - 'id' => 'footer', - 'elements' => [ - $this->sharedFooterElements(), - ], - ], - ]; - } - - public function entityDetails(): array - { - $variables = $this->context['pdf_variables']['invoice_details']; - - if ($this->entity instanceof \App\Models\Quote) { - $variables = $this->context['pdf_variables']['quote_details']; - } - - $elements = []; - - foreach ($variables as $variable) { - $elements[] = ['element' => 'tr', 'properties' => ['hidden' => $this->entityVariableCheck($variable)], 'content' => '', 'elements' => [ - ['element' => 'th', 'content' => $variable . '_label', 'properties' => ['class' => 'text-left pr-4 font-normal']], - ['element' => 'th', 'content' => $variable, 'properties' => ['class' => 'text-left pr-4 font-medium']], - ]]; - } - - return $elements; - } - - public function companyDetails() - { - $variables = $this->context['pdf_variables']['company_details']; - - $elements = []; - - foreach ($variables as $variable) { - $elements[] = ['element' => 'p', 'content' => $variable]; - } - - return $elements; - } - - public function companyAddress(): array - { - $variables = $this->context['pdf_variables']['company_address']; - - $elements = []; - - foreach ($variables as $variable) { - $elements[] = ['element' => 'p', 'content' => $variable]; - } - - return $elements; - } - - public function clientDetails(): array - { - $variables = $this->context['pdf_variables']['client_details']; - - $elements = []; - - foreach ($variables as $variable) { - $elements[] = ['element' => 'p', 'content' => $variable]; - } - - return $elements; - } - - public function productTable(): array - { - return [ - ['element' => 'thead', 'content' => '', 'properties' => ['class' => 'text-left bg-teal-600'], 'elements' => $this->buildTableHeader()], - ['element' => 'tbody', 'content' => '', 'elements' => $this->buildTableBody()], - ['element' => 'tfoot', 'content' => '', 'elements' => $this->tableFooter()], - ]; - } - - public function buildTableHeader(): array - { - $this->processTaxColumns(); - - $elements = []; - - foreach ($this->context['pdf_variables']['product_columns'] as $column) { - $elements[] = ['element' => 'th', 'content' => $column . '_label', 'properties' => ['class' => 'font-semibold text-white px-4 py-3']]; - } - - return $elements; - } - - public function buildTableBody(): array - { - $elements = []; - - $items = $this->transformLineItems($this->entity->line_items); - - if (count($items) == 0) { - return []; - } - - foreach ($items as $row) { - $element = ['element' => 'tr', 'properties' => ['class' => 'border-b-2 border-teal-600'], 'content' => '', 'elements' => []]; - - foreach ($this->context['pdf_variables']['product_columns'] as $key => $cell) { - $element['elements'][] = ['element' => 'td', 'content' => $row[$cell], 'properties' => ['class' => 'px-4 py-4']]; - } - - $elements[] = $element; - } - - return $elements; - } - - public function tableFooter() - { - $variables = $this->entity->company->settings->pdf_variables->total_columns; - - $elements = [ - ['element' => 'tr', 'content' => '', 'elements' => [ - ['element' => 'td', 'content' => '$entity.public_notes', 'properties' => ['class' => 'border-l-4 border-white px-4 text-right', 'colspan' => '100%']], - ]], - ]; - - foreach ($variables as $variable) { - $elements[] = ['element' => 'tr', 'properties' => ['hidden' => $this->toggleHiddenProperty($this->entity->calc()->getTotalDiscount())], 'content' => '', 'elements' => [ - ['element' => 'td', 'content' => $variable . '_label', 'properties' => ['class' => 'border-l-4 border-white px-4 text-right', 'colspan' => $this->calculateColspan(1)]], - ['element' => 'td', 'content' => $variable, 'properties' => ['class' => 'px-4 py-2 text-right']], - ]]; - } - - return $elements; - } -}