From d3f82863f5248d26c02bb4bf0a22414c9b6b2fa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Fri, 25 Jun 2021 08:45:00 +0300 Subject: [PATCH] Template variable.. --- .../View/Components/TransactionTemplate.php | 659 ++++++++---------- .../transactions/show/transaction.blade.php | 51 ++ .../transactions/template/default.blade.php | 408 ++++++----- 3 files changed, 564 insertions(+), 554 deletions(-) diff --git a/app/Abstracts/View/Components/TransactionTemplate.php b/app/Abstracts/View/Components/TransactionTemplate.php index c32f8fb14..08c2def0e 100644 --- a/app/Abstracts/View/Components/TransactionTemplate.php +++ b/app/Abstracts/View/Components/TransactionTemplate.php @@ -19,134 +19,177 @@ abstract class TransactionTemplate extends Base use DateTime; use Transactions; + /** @var string */ public $type; - public $item; - public $transaction; - /** @var string */ - public $transactionTemplate; - - public $date_format; - public $logo; - public $backgroundColor; - - public $hideFooter; - - public $hideCompanyLogo; - - public $hideCompanyDetails; - - public $hideCompanyName; - - public $hideCompanyAddress; - - public $hideCompanyTaxNumber; - - public $hideCompanyPhone; - - public $hideCompanyEmail; - - public $hideContactInfo; - - public $hideContactName; - - public $hideContactAddress; - - public $hideContactTaxNumber; - - public $hideContactPhone; - - public $hideContactEmail; - - public $hideOrderNumber; - - public $hidetransactionNumber; - - public $hideIssuedAt; - - public $hideDueAt; - /** @var array */ public $payment_methods; - /** @var string */ - public $texttransactionTitle; + /** @var bool */ + public $hideCompany; - /** @var string */ - public $texttransactionSubheading; + /** @var bool */ + public $hideCompanyLogo; - public $textContactInfo; + /** @var bool */ + public $hideCompanyDetails; - /** @var string */ - public $textIssuedAt; + /** @var bool */ + public $hideCompanyName; - /** @var string */ - public $textDueAt; + /** @var bool */ + public $hideCompanyAddress; - /** @var string */ - public $texttransactionNumber; + /** @var bool */ + public $hideCompanyTaxNumber; - /** @var string */ - public $textOrderNumber; + /** @var bool */ + public $hideCompanyPhone; - public $hideItems; + /** @var bool */ + public $hideCompanyEmail; - public $hideName; + /** @var bool */ + public $hideContentTitle; + /** @var bool */ + public $hidePaidAt; + + /** @var bool */ + public $hideAccount; + + /** @var bool */ + public $hideCategory; + + /** @var bool */ + public $hidePaymentMethods; + + /** @var bool */ + public $hideReference; + + /** @var bool */ public $hideDescription; - public $hideQuantity; - - public $hidePrice; - - public $hideDiscount; - + /** @var bool */ public $hideAmount; /** @var string */ - public $textItems; + public $textContentTitle; /** @var string */ - public $textQuantity; + public $textPaidAt; /** @var string */ - public $textPrice; + public $textAccount; + + /** @var string */ + public $textCategory; + + /** @var string */ + public $textPaymentMethods; + + /** @var string */ + public $textReference; + + /** @var string */ + public $textDescription; /** @var string */ public $textAmount; - public $hideNote; + /** @var string */ + public $textPaidBy; + /** @var bool */ + public $hideContact; + + /** @var bool */ + public $hideContactInfo; + + /** @var bool */ + public $hideContactName; + + /** @var bool */ + public $hideContactAddress; + + /** @var bool */ + public $hideContactTaxNumber; + + /** @var bool */ + public $hideContactPhone; + + /** @var bool */ + public $hideContactEmail; + + /** @var bool */ + public $hideReletad; + + /** @var bool */ + public $hideReletadDocumentNumber; + + /** @var bool */ + public $hideReletadContact; + + /** @var bool */ + public $hideReletadDocumentDate; + + /** @var bool */ + public $hideReletadDocumentAmount; + + /** @var bool */ + public $hideReletadAmount; + + /** @var string */ + public $textReleatedTransansaction; + + /** @var string */ + public $textReleatedDocumentNumber; + + /** @var string */ + public $textReleatedContact; + + /** @var string */ + public $textReleatedDocumentDate; + + /** @var string */ + public $textReleatedDocumentAmount; + + /** @var string */ + public $textReleatedAmount; + + /** @var string */ + public $routeDocumentShow; /** * Create a new component instance. * * @return void */ public function __construct( - $type, $transaction, $item = false, $transactionTemplate = '', $logo = '', $backgroundColor = '', - bool $hideFooter = false, bool $hideCompanyLogo = false, bool $hideCompanyDetails = false, array $payment_methods = [], - 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, - bool $hideOrderNumber = false, bool $hidetransactionNumber = false, bool $hideIssuedAt = false, bool $hideDueAt = false, - string $texttransactionTitle = '', string $texttransactionSubheading = '', - string $textContactInfo = '', string $texttransactionNumber = '', string $textOrderNumber = '', string $textIssuedAt = '', string $textDueAt = '', - bool $hideItems = false, bool $hideName = false, bool $hideDescription = false, bool $hideQuantity = false, bool $hidePrice = false, bool $hideDiscount = false, bool $hideAmount = false, bool $hideNote = false, - string $textItems = '', string $textQuantity = '', string $textPrice = '', string $textAmount = '' - ) { + $type, $transaction, $logo = '', array $payment_methods = [], + bool $hideCompany = false, bool $hideCompanyLogo = false, bool $hideCompanyDetails = false, bool $hideCompanyName = false, bool $hideCompanyAddress = false, + bool $hideCompanyTaxNumber = false, bool $hideCompanyPhone = false, bool $hideCompanyEmail = false, + bool $hideContentTitle = false,bool $hidePaidAt = false, bool $hideAccount = false, bool $hideCategory = false, bool $hidePaymentMethods = false, bool $hideReference = false, bool $hideDescription = false, + bool $hideAmount = false, + string $textContentTitle = '', string $textPaidAt = '', string $textAccount = '', string $textCategory = '', string $textPaymentMethods = '', string $textReference = '', string $textDescription = '', + string $textAmount = '', string $textPaidBy = '', + bool $hideContact = false, bool $hideContactInfo = false, bool $hideContactName = false, bool $hideContactAddress = false, bool $hideContactTaxNumber = false, + bool $hideContactPhone = false, bool $hideContactEmail = false, + bool $hideReletad = false, bool $hideReletadDocumentNumber = false, bool $hideReletadContact = false, bool $hideReletadDocumentDate = false, bool $hideReletadDocumentAmount = false, bool $hideReletadAmount = false, + string $textReleatedTransansaction = '', string $textReleatedDocumentNumber = '', string $textReleatedContact = '', string $textReleatedDocumentDate = '', string $textReleatedDocumentAmount = '', string $textReleatedAmount = '', + string $routeDocumentShow = '' + ) { $this->type = $type; - $this->item = $item; $this->transaction = $transaction; - $this->transactionTemplate = $this->gettransactionTemplate($type, $transactionTemplate); - $this->logo = $this->getLogo($logo); - $this->backgroundColor = $this->getBackgroundColor($type, $backgroundColor); + $this->logo = $this->getLogo($logo); $this->payment_methods = ($payment_methods) ?: Modules::getPaymentMethods(); - $this->hideFooter = $hideFooter; + // Company Information Hide checker + $this->hideCompany = $hideCompany; $this->hideCompanyLogo = $hideCompanyLogo; $this->hideCompanyDetails = $hideCompanyDetails; $this->hideCompanyName = $hideCompanyName; @@ -154,53 +197,54 @@ abstract class TransactionTemplate extends Base $this->hideCompanyTaxNumber = $hideCompanyTaxNumber; $this->hideCompanyPhone = $hideCompanyPhone; $this->hideCompanyEmail = $hideCompanyEmail; + + // Transaction Information Hide checker + $this->hideContentTitle = $hideContentTitle; + $this->hidePaidAt = $hidePaidAt; + $this->hideAccount = $hideAccount; + $this->hideCategory = $hideCategory; + $this->hidePaymentMethods = $hidePaymentMethods; + $this->hideReference = $hideReference; + $this->hideDescription = $hideDescription; + $this->hideAmount = $hideAmount; + + // Transaction Information Text + $this->textContentTitle = $this->getTextContentTitle($type, $textContentTitle); + $this->textPaidAt = $this->getTextPaidAt($type, $textPaidAt); + $this->textAccount = $this->getTextAccount($type, $textAccount); + $this->textCategory = $this->getTextCategory($type, $textCategory); + $this->textPaymentMethods = $this->getTextPaymentMethods($type, $textPaymentMethods); + $this->textReference = $this->getTextReference($type, $textReference); + $this->textDescription = $this->getTextDescription($type, $textDescription); + $this->textAmount = $this->getTextAmount($type, $textAmount); + $this->textPaidBy = $this->getTextPaidBy($type, $textPaidBy); + + // Contact Information Hide checker + $this->hideContact = $hideContact; $this->hideContactInfo = $hideContactInfo; $this->hideContactName = $hideContactName; $this->hideContactAddress = $hideContactAddress; $this->hideContactTaxNumber = $hideContactTaxNumber; $this->hideContactPhone = $hideContactPhone; $this->hideContactEmail = $hideContactEmail; - $this->hideOrderNumber = $hideOrderNumber; - $this->hidetransactionNumber = $hidetransactionNumber; - $this->hideIssuedAt = $hideIssuedAt; - $this->hideDueAt = $hideDueAt; - $this->texttransactionTitle = $this->getTexttransactionTitle($type, $texttransactionTitle); - $this->texttransactionSubheading = $this->gettexttransactionSubheading($type, $texttransactionSubheading); - $this->textContactInfo = $this->getTextContactInfo($type, $textContactInfo); - $this->textIssuedAt = $this->getTextIssuedAt($type, $textIssuedAt); - $this->texttransactionNumber = $this->getTexttransactionNumber($type, $texttransactionNumber); - $this->textDueAt = $this->getTextDueAt($type, $textDueAt); - $this->textOrderNumber = $this->getTextOrderNumber($type, $textOrderNumber); + // Releated Information Hide checker + $this->hideReletad = $hideReletad; + $this->hideReletadDocumentNumber = $hideReletadDocumentNumber; + $this->hideReletadContact = $hideReletadContact; + $this->hideReletadDocumentDate = $hideReletadDocumentDate; + $this->hideReletadDocumentAmount = $hideReletadDocumentAmount; + $this->hideReletadAmount = $hideReletadAmount; - $this->hideItems = $this->getHideItems($type, $hideItems, $hideName, $hideDescription); - $this->hideName = $this->getHideName($type, $hideName); - $this->hideDescription = $this->getHideDescription($type, $hideDescription); - $this->hideQuantity = $this->getHideQuantity($type, $hideQuantity); - $this->hidePrice = $this->getHidePrice($type, $hidePrice); - $this->hideDiscount = $this->getHideDiscount($type, $hideDiscount); - $this->hideAmount = $this->getHideAmount($type, $hideAmount); - $this->hideNote = $hideNote; + // Releated Information Text + $this->textReleatedTransansaction = $this->getTextReleatedTransansaction($type, $textReleatedTransansaction); + $this->textReleatedDocumentNumber = $this->getTextReleatedDocumentNumber($type, $textReleatedDocumentNumber); + $this->textReleatedContact = $this->getTextReleatedConcat($type, $textReleatedContact); + $this->textReleatedDocumentDate = $this->getTextReleatedDocumentDate($type, $textReleatedDocumentDate); + $this->textReleatedDocumentAmount = $this->getTextReleatedDocumentAmount($type, $textReleatedDocumentAmount); + $this->textReleatedAmount = $this->getTextReleatedAmount($type, $textReleatedAmount); - $this->textItems = $this->getTextItems($type, $textItems); - $this->textQuantity = $this->getTextQuantity($type, $textQuantity); - $this->textPrice = $this->getTextPrice($type, $textPrice); - $this->textAmount = $this->getTextAmount($type, $textAmount); - } - - protected function gettransactionTemplate($type, $transactionTemplate) - { - if (!empty($transactionTemplate)) { - return $transactionTemplate; - } - - if ($template = config('type.' . $type . 'template', false)) { - return $template; - } - - $transactionTemplate = setting($this->getSettingKey($type, 'template'), 'default'); - - return $transactionTemplate; + $this->routeDocumentShow = $this->routeDocumentShow($type, $routeDocumentShow); } protected function getLogo($logo) @@ -255,242 +299,109 @@ abstract class TransactionTemplate extends Base return 'data:image/' . $extension . ';base64,' . base64_encode($image); } - protected function getBackgroundColor($type, $backgroundColor) + protected function getTextContentTitle($type, $textContentTitle) { - if (!empty($backgroundColor)) { - return $backgroundColor; + if (!empty($textContentTitle)) { + return $textContentTitle; } - if ($background_color = config('type.' . $type . 'color', false)) { - return $background_color; - } - - - if (!empty($alias = config('type.' . $type . '.alias'))) { - $type = $alias . '.' . str_replace('-', '_', $type); - } - - $backgroundColor = setting($this->getSettingKey($type, 'color'), '#55588b'); - - return $backgroundColor; - } - - protected function getTexttransactionTitle($type, $texttransactionTitle) - { - if (!empty($texttransactionTitle)) { - return $texttransactionTitle; - } - - if (!empty(setting($type . '.title'))) { - return setting($type . '.title'); - } - - $translation = $this->getTextFromConfig($type, 'transaction_title', Str::plural($type)); - - if (!empty($translation)) { - return trans_choice($translation, 1); - } - - return setting('invoice.title'); - } - - protected function getTexttransactionSubheading($type, $texttransactionSubheading) - { - if (!empty($texttransactionSubheading)) { - return $texttransactionSubheading; - } - - if (!empty(setting($type . '.subheading'))) { - return setting($type . '.subheading'); - } - - $translation = $this->getTextFromConfig($type, 'transaction_subheading', 'subheading'); - - if (!empty($translation)) { - return trans($translation); - } - - return false; - } - - protected function getTexttransactionNumber($type, $texttransactionNumber) - { - if (!empty($texttransactionNumber)) { - return $texttransactionNumber; - } - - switch ($type) { - case 'bill': - case 'expense': - case 'purchase': - $default_key = 'bill_number'; - break; - default: - $default_key = 'invoice_number'; - break; - } - - $translation = $this->getTextFromConfig($type, 'transaction_number', $default_key); + $translation = $this->getTextFromConfig($type, $type . '_made', 'revenue_made'); if (!empty($translation)) { return $translation; } - return 'general.numbers'; + return 'revenues.revenue_made'; } - protected function getTextOrderNumber($type, $textOrderNumber) + protected function getTextPaidAt($type, $textPaidAt) { - if (!empty($textOrderNumber)) { - return $textOrderNumber; + if (!empty($textPaidAt)) { + return $textPaidAt; } - $translation = $this->getTextFromConfig($type, 'order_number'); + $translation = $this->getTextFromConfig($type, 'paid_at', 'date'); if (!empty($translation)) { return $translation; } - return 'invoices.order_number'; + return 'general.date'; } - protected function getTextContactInfo($type, $textContactInfo) + protected function getTextAccount($type, $textAccount) { - if (!empty($textContactInfo)) { - return $textContactInfo; + if (!empty($textAccount)) { + return $textAccount; } - switch ($type) { - case 'bill': - case 'expense': - case 'purchase': - $default_key = 'bill_from'; - break; - default: - $default_key = 'bill_to'; - break; - } - - $translation = $this->getTextFromConfig($type, 'contact_info', $default_key); + $translation = $this->getTextFromConfig($type, 'accounts', 'accounts', 'trans_choice'); if (!empty($translation)) { return $translation; } - return 'invoices.bill_to'; + return 'general.accounts'; } - protected function getTextIssuedAt($type, $textIssuedAt) + protected function getTextCategory($type, $textCategory) { - if (!empty($textIssuedAt)) { - return $textIssuedAt; + if (!empty($textCategory)) { + return $textCategory; } - switch ($type) { - case 'bill': - case 'expense': - case 'purchase': - $default_key = 'bill_date'; - break; - default: - $default_key = 'invoice_date'; - break; - } - - $translation = $this->getTextFromConfig($type, 'issued_at', $default_key); + $translation = $this->getTextFromConfig($type, 'categories', 'categories', 'trans_choice'); if (!empty($translation)) { return $translation; } - return 'invoices.invoice_date'; + return 'general.categories'; } - protected function getTextDueAt($type, $textDueAt) + protected function getTextPaymentMethods($type, $textPaymentMethods) { - if (!empty($textDueAt)) { - return $textDueAt; + if (!empty($textPaymentMethods)) { + return $textPaymentMethods; } - $translation = $this->getTextFromConfig($type, 'due_at', 'due_date'); + $translation = $this->getTextFromConfig($type, 'payment_methods', 'payment_methods', 'trans_choice'); if (!empty($translation)) { return $translation; } - return 'invoices.due_date'; + return 'general.payment_methods'; } - protected function getTextItems($type, $textItems) + protected function getTextReference($type, $textReference) { - if (!empty($textItems)) { - return $textItems; + if (!empty($textReference)) { + return $textReference; } - // if you use settting translation - if (setting($this->getSettingKey($type, 'item_name'), 'items') == 'custom') { - if (empty($textItems = setting($this->getSettingKey($type, 'item_name_input')))) { - $textItems = 'general.items'; - } - - return $textItems; - } - - $translation = $this->getTextFromConfig($type, 'items'); + $translation = $this->getTextFromConfig($type, 'reference', 'reference'); if (!empty($translation)) { return $translation; } - return 'general.items'; + return 'general.reference'; } - protected function getTextQuantity($type, $textQuantity) + protected function getTextDescription($type, $textDescription) { - if (!empty($textQuantity)) { - return $textQuantity; + if (!empty($textDescription)) { + return $textDescription; } - // if you use settting translation - if (setting($this->getSettingKey($type, 'quantity_name'), 'quantity') === 'custom') { - if (empty($textQuantity = setting($this->getSettingKey($type, 'quantity_name_input')))) { - $textQuantity = 'invoices.quantity'; - } - - return $textQuantity; - } - - $translation = $this->getTextFromConfig($type, 'quantity'); + $translation = $this->getTextFromConfig($type, 'description', 'description'); if (!empty($translation)) { return $translation; } - return 'invoices.quantity'; - } - - protected function getTextPrice($type, $textPrice) - { - if (!empty($textPrice)) { - return $textPrice; - } - - // if you use settting translation - if (setting($this->getSettingKey($type, 'price_name'), 'price') === 'custom') { - if (empty($textPrice = setting($this->getSettingKey($type, 'price_name_input')))) { - $textPrice = 'invoices.price'; - } - - return $textPrice; - } - - $translation = $this->getTextFromConfig($type, 'price'); - - if (!empty($translation)) { - return $translation; - } - - return 'invoices.price'; + return 'general.description'; } protected function getTextAmount($type, $textAmount) @@ -499,7 +410,7 @@ abstract class TransactionTemplate extends Base return $textAmount; } - $translation = $this->getTextFromConfig($type, 'amount'); + $translation = $this->getTextFromConfig($type, 'amount', 'amount'); if (!empty($translation)) { return $translation; @@ -508,146 +419,130 @@ abstract class TransactionTemplate extends Base return 'general.amount'; } - protected function getHideItems($type, $hideItems, $hideName, $hideDescription) + protected function getTextPaidBy($type, $textPaidBy) { - if (!empty($hideItems)) { - return $hideItems; + if (!empty($textPaidBy)) { + return $textPaidBy; } - $hide = $this->getHideFromConfig($type, 'items'); + $translation = $this->getTextFromConfig($type, 'paid_by', 'paid_by'); - if ($hide) { - return $hide; + if (!empty($translation)) { + return $translation; } - $hideItems = ($this->getHideName($type, $hideName) & $this->getHideDescription($type, $hideDescription)) ? true : false; - - return $hideItems; + return 'general.paid_by'; } - protected function getHideName($type, $hideName) + protected function getTextReleatedTransansaction($type, $textReleatedTransansaction) { - if (!empty($hideName)) { - return $hideName; + if (!empty($textReleatedTransansaction)) { + return $textReleatedTransansaction; } - // if you use settting translation - if ($hideName = setting($this->getSettingKey($type, 'hide_item_name'), false)) { - return $hideName; + $translation = $this->getTextFromConfig($type, 'related_revenue', 'related_revenue'); + + if (!empty($translation)) { + return $translation; } - $hide = $this->getHideFromConfig($type, 'name'); - - if ($hide) { - return $hide; - } - - // @todo what return value invoice or always false?? - return setting('invoice.hide_item_name', $hideName); + return 'general.related_revenue'; } - protected function getHideDescription($type, $hideDescription) + protected function getTextReleatedDocumentNumber($type, $textReleatedDocumentNumber) { - if (!empty($hideDescription)) { - return $hideDescription; + if (!empty($textReleatedDocumentNumber)) { + return $textReleatedDocumentNumber; } - // if you use settting translation - if ($hideDescription = setting($this->getSettingKey($type, 'hide_item_description'), false)) { - return $hideDescription; + $translation = $this->getTextFromConfig($type, 'related_document_number', 'numbers'); + + if (!empty($translation)) { + return $translation; } - $hide = $this->getHideFromConfig($type, 'description'); - - if ($hide) { - return $hide; - } - - // @todo what return value invoice or always false?? - return setting('invoice.hide_item_description', $hideDescription); + return 'general.numbers'; } - protected function getHideQuantity($type, $hideQuantity) + protected function getTextReleatedConcat($type, $textReleatedContact) { - if (!empty($hideQuantity)) { - return $hideQuantity; + if (!empty($textReleatedContact)) { + return $textReleatedContact; } - // if you use settting translation - if ($hideQuantity = setting($this->getSettingKey($type, 'hide_quantity'), false)) { - return $hideQuantity; + $translation = $this->getTextFromConfig($type, 'related_contact', 'contact'); + + if (!empty($translation)) { + return $translation; } - $hide = $this->getHideFromConfig($type, 'quantity'); - - if ($hide) { - return $hide; - } - - // @todo what return value invoice or always false?? - return setting('invoice.hide_quantity', $hideQuantity); + return 'general.customers'; } - protected function getHidePrice($type, $hidePrice) + protected function getTextReleatedDocumentDate($type, $textReleatedDocumentDate) { - if (!empty($hidePrice)) { - return $hidePrice; + if (!empty($textReleatedDocumentDate)) { + return $textReleatedDocumentDate; } - // if you use settting translation - if ($hidePrice = setting($this->getSettingKey($type, 'hide_price'), false)) { - return $hidePrice; + $translation = $this->getTextFromConfig($type, 'related_document_date', 'due_date'); + + if (!empty($translation)) { + return $translation; } - $hide = $this->getHideFromConfig($type, 'price'); - - if ($hide) { - return $hide; - } - - // @todo what return value invoice or always false?? - return setting('invoice.hide_price', $hidePrice); + return 'invoices.invoice_date'; } - protected function getHideDiscount($type, $hideDiscount) + protected function getTextReleatedDocumentAmount($type, $textReleatedDocumentAmount) { - if (!empty($hideDiscount)) { - return $hideDiscount; + if (!empty($textReleatedDocumentAmount)) { + return $textReleatedDocumentAmount; } - // if you use settting translation - if ($hideDiscount = setting($this->getSettingKey($type, 'hide_discount'), false)) { - return $hideDiscount; + $translation = $this->getTextFromConfig($type, 'related_document_amount', 'amount'); + + if (!empty($translation)) { + return $translation; } - $hide = $this->getHideFromConfig($type, 'discount'); - - if ($hide) { - return $hide; - } - - // @todo what return value invoice or always false?? - return setting('invoice.hide_discount', $hideDiscount); + return 'general.amount'; } - protected function getHideAmount($type, $hideAmount) + protected function getTextReleatedAmount($type, $textReleatedAmount) { - if (!empty($hideAmount)) { - return $hideAmount; + if (!empty($textReleatedAmount)) { + return $textReleatedAmount; } - // if you use settting translation - if ($hideAmount = setting($this->getSettingKey($type, 'hide_amount'), false)) { - return $hideAmount; + $translation = $this->getTextFromConfig($type, 'related_amount', 'amount'); + + if (!empty($translation)) { + return $translation; } - $hide = $this->getHideFromConfig($type, 'amount'); + return 'general.amount'; + } - if ($hide) { - return $hide; + protected function routeDocumentShow($type, $routeDocumentShow) + { + if (!empty($routeDocumentShow)) { + return $routeDocumentShow; } - // @todo what return value invoice or always false?? - return setting('invoice.hide_amount', $hideAmount); + if (!$this->transaction->document) { + return $routeDocumentShow; + } + + //example route parameter. + $parameter = 1; + + $route = $this->getRouteFromConfig($this->transaction->document->type, 'show', $parameter); + + if (!empty($route)) { + return $route; + } + + return 'invoices.show'; } } diff --git a/resources/views/components/transactions/show/transaction.blade.php b/resources/views/components/transactions/show/transaction.blade.php index c682814ff..1ce1f0d31 100644 --- a/resources/views/components/transactions/show/transaction.blade.php +++ b/resources/views/components/transactions/show/transaction.blade.php @@ -13,6 +13,57 @@ :payment_methods="$payment_methods" transaction-template="{{ $transactionTemplate }}" logo="{{ $logo }}" + + hide-company="{{ $hideCompany }}" + hide-company-logo="{{ $hideCompanyLogo }}" + hide-company-details="{{ $hideCompanyDetails }}" + hide-company-name="{{ $hideCompanyName }}" + hide-company-address="{{ $hideCompanyAddress }}" + hide-company-tax-number="{{ $hideCompanyTaxNumber }}" + hide-company-phone="{{ $hideCompanyPhone }}" + hide-company-email="{{ $hideCompanyEmail }}" + + hide-content-title="{{ $hideContentTitle }}" + hide-paid-at="{{ $hidePaidAt }}" + hide-account="{{ $hideAccount }}" + hide-category="{{ $hideCategory }}" + hide-payment-methods="{{ $hidePaymentMethods }}" + hide-reference="{{ $hideReference }}" + hide-description="{{ $hideDescription }}" + hide-amount="{{ $hideAmount }}" + + text-content-title="{{ $textContentTitle }}" + text-paid-at="{{ $textPaidAt }}" + text-account="{{ $textAccount }}" + text-category="{{ $textCategory }}" + text-payment-methods="{{ $textPaymentMethods }}" + text-reference="{{ $textReference }}" + text-description="{{ $textDescription }}" + text-paid-by="{{ $textAmount }}" + + hide-contact="{{ $hideContact }}" + hide-contact-info="{{ $hideContactInfo }}" + hide-contact-name="{{ $hideContactName }}" + hide-contact-address="{{ $hideContactAddress }}" + hide-contact-tax-number="{{ $hideContactTaxNumber }}" + hide-contact-phone="{{ $hideContactPhone }}" + hide-contact-email="{{ $hideContactEmail }}" + + hide-releated="{{ $hideReletad }}" + hide-releated-document-number="{{ $hideReletadDocumentNumber }}" + hide-releated-contact="{{ $hideReletadContact }}" + hide-releated-document-date="{{ $hideReletadDocumentDate }}" + hide-releated-document-amount="{{ $hideReletadDocumentAmount }}" + hide-releated-amount="{{ $hideReletadAmount }}" + + text-releated-transaction="{{ $textReleatedTransansaction }}" + text-releated-document-number="{{ $textReleatedDocumentNumber }}" + text-releated-contact="{{ $textReleatedContact }}" + text-releated-document-date="{{ $textReleatedDocumentDate }}" + text-releated-document-amount="{{ $textReleatedDocumentAmount }}" + text-releated-amount="{{ $textReleatedAmount }}" + + route-document-show="{{ $routeDocumentShow }}" /> @endswitch @else diff --git a/resources/views/components/transactions/template/default.blade.php b/resources/views/components/transactions/template/default.blade.php index b89e0c7e7..9b96b86cc 100644 --- a/resources/views/components/transactions/template/default.blade.php +++ b/resources/views/components/transactions/template/default.blade.php @@ -1,136 +1,170 @@ -
-
-
- @stack('company_logo_start') - @if (!$hideCompanyLogo) - @if (!empty($document->contact->logo) && !empty($document->contact->logo->id)) - {{ $document->contact_name }} - @else - {{ setting('company.name') }} + +@stack('company_start') +@if (!$hideCompany) +
+
+
+ @stack('company_logo_start') + @if (!$hideCompanyLogo) + @if (!empty($transaction->contact->logo) && !empty($transaction->contact->logo->id)) + {{ $transaction->contact->name }} + @else + {{ setting('company.name') }} + @endif @endif - @endif - @stack('company_logo_end') + @stack('company_logo_end') +
+
+ +
+
+ @stack('company_details_start') + @if (!$hideCompanyDetails) + @if (!$hideCompanyName) +

+ {{ setting('company.name') }} +

+ @endif + + @if (!$hideCompanyAddress) +

{!! nl2br(setting('company.address')) !!}

+ @endif + + @if (!$hideCompanyTaxNumber) +

+ @if (setting('company.tax_number')) + {{ trans('general.tax_number') }}: {{ setting('company.tax_number') }} + @endif +

+ @endif + + @if (!$hideCompanyPhone) +

+ @if (setting('company.phone')) + {{ setting('company.phone') }} + @endif +

+ @endif + + @if (!$hideCompanyEmail) +

{{ setting('company.email') }}

+ @endif + @endif + @stack('company_details_end') +
- -
-
- @stack('company_details_start') - @if (!$hideCompanyDetails) - @if (!$hideCompanyName) -

- {{ setting('company.name') }} -

- @endif - - @if (!$hideCompanyAddress) -

{!! nl2br(setting('company.address')) !!}

- @endif - - @if (!$hideCompanyTaxNumber) -

- @if (setting('company.tax_number')) - {{ trans('general.tax_number') }}: {{ setting('company.tax_number') }} - @endif -

- @endif - - @if (!$hideCompanyPhone) -

- @if (setting('company.phone')) - {{ setting('company.phone') }} - @endif -

- @endif - - @if (!$hideCompanyEmail) -

{{ setting('company.email') }}

- @endif - @endif - @stack('company_details_end') -
-
-
+@endif +@stack('company_end')
-

{{ trans('invoices.revenue_made') }}

+ @if (!$hideContentTitle) +

+ {{ trans($textContentTitle) }} +

+ @endif
-

- {{ trans('general.date') }}: -

+ @if (!$hidePaidAt) +

+ {{ trans($textPaidAt) }}: +

+ @endif -

- {{ trans_choice('general.accounts', 1) }}: -

+ @if (!$hideAccount) +

+ {{ trans_choice($textAccount, 1) }}: +

+ @endif -

- {{ trans_choice('general.categories', 1) }}: -

+ @if (!$hideCategory) +

+ {{ trans_choice($textCategory, 1) }}: +

+ @endif -

- {{ trans_choice('general.payment_methods', 1) }}: -

+ @if (!$hidePaymentMethods) +

+ {{ trans_choice($textPaymentMethods, 1) }}: +

+ @endif -

- {{ trans('general.reference') }}: -

+ @if (!$hideReference) +

+ {{ trans($textReference) }}: +

+ @endif -

- {{ trans('general.description') }}: -

+ @if (!$hideDescription) +

+ {{ trans($textDescription) }}: +

+ @endif
-

- @date($transaction->paid_at) -

+ @if (!$hidePaidAt) +

+ @date($transaction->paid_at) +

+ @endif -

- {{ $transaction->account->name }} -

+ @if (!$hideAccount) +

+ {{ $transaction->account->name }} +

+ @endif -

- {{ $transaction->category->name }} -

+ @if (!$hideCategory) +

+ {{ $transaction->category->name }} +

+ @endif -

- {{ $payment_methods[$transaction->payment_method] }} -

+ @if (!$hidePaymentMethods) +

+ {{ $payment_methods[$transaction->payment_method] }} +

+ @endif -

- {{ $transaction->reference }} -

+ @if (!$hideReference) +

+ {{ $transaction->reference }} +

+ @endif -

- {!! nl2br($transaction->description) !!} -

+ @if (!$hideDescription) +

+ {!! nl2br($transaction->description) !!} +

+ @endif
-
-

{{ trans('general.paid_by') }}

+ @if (!$hideContact) +
+

{{ trans($textPaidBy) }}

- @if ($hideContactInfo) - {{ trans($textContactInfo) }}
- @endif - - @stack('name_input_start') + @if ($hideContactInfo) + {{ trans($textContactInfo) }}
+ @endif + + @stack('name_input_start') @if (!$hideContactName) {{ $transaction->contact->name }}
@endif - @stack('name_input_end') - - @stack('address_input_start') + @stack('name_input_end') + + @stack('address_input_start') @if (!$hideContactAddress)

{!! nl2br($transaction->contact->address) !!}

@endif - @stack('address_input_end') - - @stack('tax_number_input_start') + @stack('address_input_end') + + @stack('tax_number_input_start') @if (!$hideContactTaxNumber)

@if ($transaction->contact->tax_number) @@ -138,9 +172,9 @@ @endif

@endif - @stack('tax_number_input_end') - - @stack('phone_input_start') + @stack('tax_number_input_end') + + @stack('phone_input_start') @if (!$hideContactPhone)

@if ($transaction->contact->phone) @@ -148,100 +182,130 @@ @endif

@endif - @stack('phone_input_end') - - @stack('email_start') + @stack('phone_input_end') + + @stack('email_start') @if (!$hideContactEmail)

{{ $transaction->contact->email }}

@endif - @stack('email_input_end') -
+ @stack('email_input_end') +
+ @endif
-
-
-
-
-
-
{{ trans('general.amount') }}
+ @if (!$hideAmount) +
+
+
+
+
+
+ {{ trans($textAmount) }} +
- - @money($transaction->amount, $transaction->currency_code, true) - + + @money($transaction->amount, $transaction->currency_code, true) + +
-
+ @endif
-@if ($transaction->document) -
-
-
-

{{ trans('invoices.related_revenue') }}

+@if (!$hideReletad) + @if ($transaction->document) +
+
+
+

{{ trans($textReleatedTransansaction) }}

- - - - +
- {{ trans_choice('general.numbers', 1) }} -
+ + + @if (!$hideReletadDocumentNumber) + + @endif - + @if (!$hideReletadContact) + + @endif - + @if (!$hideReletadDocumentDate) + + @endif - + @if (!$hideReletadDocumentAmount) + + @endif - - - + @if (!$hideReletadAmount) + + @endif + + - - - + + + @if (!$hideReletadDocumentNumber) + + @endif - + @if (!$hideReletadContact) + + @endif - + @if (!$hideReletadDocumentDate) + + @endif - + @if (!$hideReletadDocumentAmount) + + @endif - - - -
+ {{ trans_choice($textReleatedDocumentNumber, 1) }} + - {{ trans_choice('general.customers', 1) }} - + {{ trans_choice($textReleatedContact, 1) }} + - {{ trans('invoices.invoice_date') }} - + {{ trans($textReleatedDocumentDate) }} + - {{ trans('invoices.invoice_date') }} - + {{ trans($textReleatedDocumentAmount) }} + - {{ trans('general.amount') }} -
+ {{ trans($textReleatedAmount) }} +
- - {{ $transaction->document->document_number }} - -
+ + {{ $transaction->document->document_number }} + + - {{ $transaction->document->contact_name }} - + {{ $transaction->document->contact_name }} + - @date($transaction->document->due_at) - + @date($transaction->document->due_at) + - @money($transaction->document->amount, $transaction->document->currency_code, true) - + @money($transaction->document->amount, $transaction->document->currency_code, true) + - @money($transaction->amount, $transaction->currency_code, true) -
+ @if (!$hideReletadAmount) + + @money($transaction->amount, $transaction->currency_code, true) + + @endif + + + +
-
-@else -
-

- {{ trans('invoices.overdue_revenue') }}: @money($transaction->amount, $transaction->currency_code, true) -

-
+ @else +
+

+ {{ trans('invoices.overdue_revenue') }}: + + @money($transaction->amount, $transaction->currency_code, true) + +

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