From d33ba81f87e3fbb5fc760a41f6b0dbd255909afb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Wed, 6 Jan 2021 18:30:43 +0300 Subject: [PATCH] Show and Print item line component add --- .../View/Components/DocumentTemplate.php | 5 ++- .../Documents/Template/LineItem.php | 18 ++++++++ .../documents/template/classic.blade.php | 13 +++++- .../documents/template/default.blade.php | 13 +++++- .../documents/template/line-item.blade.php} | 4 +- .../documents/template/modern.blade.php | 13 +++++- .../partials/documents/item/show.blade.php | 43 ------------------- 7 files changed, 61 insertions(+), 48 deletions(-) create mode 100644 app/View/Components/Documents/Template/LineItem.php rename resources/views/{partials/documents/item/print.blade.php => components/documents/template/line-item.blade.php} (96%) delete mode 100644 resources/views/partials/documents/item/show.blade.php diff --git a/app/Abstracts/View/Components/DocumentTemplate.php b/app/Abstracts/View/Components/DocumentTemplate.php index 682ee38b6..bf30fdde2 100644 --- a/app/Abstracts/View/Components/DocumentTemplate.php +++ b/app/Abstracts/View/Components/DocumentTemplate.php @@ -16,6 +16,8 @@ abstract class DocumentTemplate extends Component public $type; + public $item; + public $document; /** @var string */ @@ -111,7 +113,7 @@ abstract class DocumentTemplate extends Component * @return void */ public function __construct( - $type, $document, $documentTemplate = '', $logo = '', $backgroundColor = '', + $type, $item = false, $document, $documentTemplate = '', $logo = '', $backgroundColor = '', bool $hideFooter = false, bool $hideCompanyLogo = false, bool $hideCompanyDetails = false, bool $hideCompanyName = false, bool $hideCompanyAddress = false, bool $hideCompanyTaxNumber = false, bool $hideCompanyPhone = false, bool $hideCompanyEmail = false, bool $hideContactInfo = false, bool $hideContactName = false, bool $hideContactAddress = false, bool $hideContactTaxNumber = false, bool $hideContactPhone = false, bool $hideContactEmail = false, @@ -121,6 +123,7 @@ abstract class DocumentTemplate extends Component string $textItems = '', string $textQuantity = '', string $textPrice = '', string $textAmount = '' ) { $this->type = $type; + $this->item = $item; $this->document = $document; $this->documentTemplate = $this->getDocumentTemplate($type, $documentTemplate); $this->logo = $this->getLogo($logo); diff --git a/app/View/Components/Documents/Template/LineItem.php b/app/View/Components/Documents/Template/LineItem.php new file mode 100644 index 000000000..83621c7e5 --- /dev/null +++ b/app/View/Components/Documents/Template/LineItem.php @@ -0,0 +1,18 @@ + @foreach($document->items as $item) - @include('partials.documents.item.print', ['document' => $document]) + @endforeach diff --git a/resources/views/components/documents/template/default.blade.php b/resources/views/components/documents/template/default.blade.php index 7fc4b023e..566b5037f 100644 --- a/resources/views/components/documents/template/default.blade.php +++ b/resources/views/components/documents/template/default.blade.php @@ -187,7 +187,18 @@ @foreach($document->items as $item) - @include('partials.documents.item.print', ['document' => $document]) + @endforeach diff --git a/resources/views/partials/documents/item/print.blade.php b/resources/views/components/documents/template/line-item.blade.php similarity index 96% rename from resources/views/partials/documents/item/print.blade.php rename to resources/views/components/documents/template/line-item.blade.php index 973ae8f5c..af1ec12e7 100644 --- a/resources/views/partials/documents/item/print.blade.php +++ b/resources/views/components/documents/template/line-item.blade.php @@ -11,6 +11,8 @@
{!! \Illuminate\Support\Str::limit($item->item->description, 500) !!} @endif @endif + + @stack('item_custom_fields') @endif @stack('name_td_end') @@ -40,4 +42,4 @@ @money($item->total, $document->currency_code, true) @endif @stack('total_td_end') - \ No newline at end of file + diff --git a/resources/views/components/documents/template/modern.blade.php b/resources/views/components/documents/template/modern.blade.php index 8075ea7f4..05618714f 100644 --- a/resources/views/components/documents/template/modern.blade.php +++ b/resources/views/components/documents/template/modern.blade.php @@ -175,7 +175,18 @@ @foreach($document->items as $item) - @include('partials.documents.item.print', ['document' => $document]) + @endforeach diff --git a/resources/views/partials/documents/item/show.blade.php b/resources/views/partials/documents/item/show.blade.php deleted file mode 100644 index c1b039849..000000000 --- a/resources/views/partials/documents/item/show.blade.php +++ /dev/null @@ -1,43 +0,0 @@ - - @stack('name_td_start') - @if (!$hideItems || (!$hideName && !$hideDescription)) - - @if (!$hideName) - {{ $item->name }} - @endif - - @if (!$hideDescription) - @if (!empty($item->item->description)) -
{!! \Illuminate\Support\Str::limit($item->item->description, 500) !!} - @endif - @endif - - @endif - @stack('name_td_end') - - @stack('quantity_td_start') - @if (!$hideQuantity) - {{ $item->quantity }} - @endif - @stack('quantity_td_end') - - @stack('price_td_start') - @if (!$hidePrice) - @money($item->price, $document->currency_code, true) - @endif - @stack('price_td_end') - - @if (!$hideDiscount) - @if (in_array(setting('localisation.discount_location', 'total'), ['item', 'both'])) - @stack('discount_td_start') - {{ $item->discount }} - @stack('discount_td_end') - @endif - @endif - - @stack('total_td_start') - @if (!$hideAmount) - @money($item->total, $document->currency_code, true) - @endif - @stack('total_td_end') - \ No newline at end of file