Template variable..

This commit is contained in:
Cüneyt Şentürk 2021-06-25 08:45:00 +03:00
parent 43e31fd647
commit d3f82863f5
3 changed files with 564 additions and 554 deletions

View File

@ -19,134 +19,177 @@ abstract class TransactionTemplate extends Base
use DateTime; use DateTime;
use Transactions; use Transactions;
/** @var string */
public $type; public $type;
public $item;
public $transaction; public $transaction;
/** @var string */
public $transactionTemplate;
public $date_format;
public $logo; 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 */ /** @var array */
public $payment_methods; public $payment_methods;
/** @var string */ /** @var bool */
public $texttransactionTitle; public $hideCompany;
/** @var string */ /** @var bool */
public $texttransactionSubheading; public $hideCompanyLogo;
public $textContactInfo; /** @var bool */
public $hideCompanyDetails;
/** @var string */ /** @var bool */
public $textIssuedAt; public $hideCompanyName;
/** @var string */ /** @var bool */
public $textDueAt; public $hideCompanyAddress;
/** @var string */ /** @var bool */
public $texttransactionNumber; public $hideCompanyTaxNumber;
/** @var string */ /** @var bool */
public $textOrderNumber; 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 $hideDescription;
public $hideQuantity; /** @var bool */
public $hidePrice;
public $hideDiscount;
public $hideAmount; public $hideAmount;
/** @var string */ /** @var string */
public $textItems; public $textContentTitle;
/** @var string */ /** @var string */
public $textQuantity; public $textPaidAt;
/** @var string */ /** @var string */
public $textPrice; public $textAccount;
/** @var string */
public $textCategory;
/** @var string */
public $textPaymentMethods;
/** @var string */
public $textReference;
/** @var string */
public $textDescription;
/** @var string */ /** @var string */
public $textAmount; 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. * Create a new component instance.
* *
* @return void * @return void
*/ */
public function __construct( public function __construct(
$type, $transaction, $item = false, $transactionTemplate = '', $logo = '', $backgroundColor = '', $type, $transaction, $logo = '', array $payment_methods = [],
bool $hideFooter = false, bool $hideCompanyLogo = false, bool $hideCompanyDetails = false, array $payment_methods = [], bool $hideCompany = false, bool $hideCompanyLogo = false, bool $hideCompanyDetails = false, bool $hideCompanyName = false, bool $hideCompanyAddress = false,
bool $hideCompanyName = false, bool $hideCompanyAddress = false, bool $hideCompanyTaxNumber = false, bool $hideCompanyPhone = false, bool $hideCompanyEmail = false, bool $hideContactInfo = false, bool $hideCompanyTaxNumber = false, bool $hideCompanyPhone = false, bool $hideCompanyEmail = false,
bool $hideContactName = false, bool $hideContactAddress = false, bool $hideContactTaxNumber = false, bool $hideContactPhone = false, bool $hideContactEmail = false, bool $hideContentTitle = false,bool $hidePaidAt = false, bool $hideAccount = false, bool $hideCategory = false, bool $hidePaymentMethods = false, bool $hideReference = false, bool $hideDescription = false,
bool $hideOrderNumber = false, bool $hidetransactionNumber = false, bool $hideIssuedAt = false, bool $hideDueAt = false, bool $hideAmount = false,
string $texttransactionTitle = '', string $texttransactionSubheading = '', string $textContentTitle = '', string $textPaidAt = '', string $textAccount = '', string $textCategory = '', string $textPaymentMethods = '', string $textReference = '', string $textDescription = '',
string $textContactInfo = '', string $texttransactionNumber = '', string $textOrderNumber = '', string $textIssuedAt = '', string $textDueAt = '', string $textAmount = '', string $textPaidBy = '',
bool $hideItems = false, bool $hideName = false, bool $hideDescription = false, bool $hideQuantity = false, bool $hidePrice = false, bool $hideDiscount = false, bool $hideAmount = false, bool $hideNote = false, bool $hideContact = false, bool $hideContactInfo = false, bool $hideContactName = false, bool $hideContactAddress = false, bool $hideContactTaxNumber = false,
string $textItems = '', string $textQuantity = '', string $textPrice = '', string $textAmount = '' 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->type = $type;
$this->item = $item;
$this->transaction = $transaction; $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->payment_methods = ($payment_methods) ?: Modules::getPaymentMethods();
$this->hideFooter = $hideFooter; // Company Information Hide checker
$this->hideCompany = $hideCompany;
$this->hideCompanyLogo = $hideCompanyLogo; $this->hideCompanyLogo = $hideCompanyLogo;
$this->hideCompanyDetails = $hideCompanyDetails; $this->hideCompanyDetails = $hideCompanyDetails;
$this->hideCompanyName = $hideCompanyName; $this->hideCompanyName = $hideCompanyName;
@ -154,53 +197,54 @@ abstract class TransactionTemplate extends Base
$this->hideCompanyTaxNumber = $hideCompanyTaxNumber; $this->hideCompanyTaxNumber = $hideCompanyTaxNumber;
$this->hideCompanyPhone = $hideCompanyPhone; $this->hideCompanyPhone = $hideCompanyPhone;
$this->hideCompanyEmail = $hideCompanyEmail; $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->hideContactInfo = $hideContactInfo;
$this->hideContactName = $hideContactName; $this->hideContactName = $hideContactName;
$this->hideContactAddress = $hideContactAddress; $this->hideContactAddress = $hideContactAddress;
$this->hideContactTaxNumber = $hideContactTaxNumber; $this->hideContactTaxNumber = $hideContactTaxNumber;
$this->hideContactPhone = $hideContactPhone; $this->hideContactPhone = $hideContactPhone;
$this->hideContactEmail = $hideContactEmail; $this->hideContactEmail = $hideContactEmail;
$this->hideOrderNumber = $hideOrderNumber;
$this->hidetransactionNumber = $hidetransactionNumber;
$this->hideIssuedAt = $hideIssuedAt;
$this->hideDueAt = $hideDueAt;
$this->texttransactionTitle = $this->getTexttransactionTitle($type, $texttransactionTitle); // Releated Information Hide checker
$this->texttransactionSubheading = $this->gettexttransactionSubheading($type, $texttransactionSubheading); $this->hideReletad = $hideReletad;
$this->textContactInfo = $this->getTextContactInfo($type, $textContactInfo); $this->hideReletadDocumentNumber = $hideReletadDocumentNumber;
$this->textIssuedAt = $this->getTextIssuedAt($type, $textIssuedAt); $this->hideReletadContact = $hideReletadContact;
$this->texttransactionNumber = $this->getTexttransactionNumber($type, $texttransactionNumber); $this->hideReletadDocumentDate = $hideReletadDocumentDate;
$this->textDueAt = $this->getTextDueAt($type, $textDueAt); $this->hideReletadDocumentAmount = $hideReletadDocumentAmount;
$this->textOrderNumber = $this->getTextOrderNumber($type, $textOrderNumber); $this->hideReletadAmount = $hideReletadAmount;
$this->hideItems = $this->getHideItems($type, $hideItems, $hideName, $hideDescription); // Releated Information Text
$this->hideName = $this->getHideName($type, $hideName); $this->textReleatedTransansaction = $this->getTextReleatedTransansaction($type, $textReleatedTransansaction);
$this->hideDescription = $this->getHideDescription($type, $hideDescription); $this->textReleatedDocumentNumber = $this->getTextReleatedDocumentNumber($type, $textReleatedDocumentNumber);
$this->hideQuantity = $this->getHideQuantity($type, $hideQuantity); $this->textReleatedContact = $this->getTextReleatedConcat($type, $textReleatedContact);
$this->hidePrice = $this->getHidePrice($type, $hidePrice); $this->textReleatedDocumentDate = $this->getTextReleatedDocumentDate($type, $textReleatedDocumentDate);
$this->hideDiscount = $this->getHideDiscount($type, $hideDiscount); $this->textReleatedDocumentAmount = $this->getTextReleatedDocumentAmount($type, $textReleatedDocumentAmount);
$this->hideAmount = $this->getHideAmount($type, $hideAmount); $this->textReleatedAmount = $this->getTextReleatedAmount($type, $textReleatedAmount);
$this->hideNote = $hideNote;
$this->textItems = $this->getTextItems($type, $textItems); $this->routeDocumentShow = $this->routeDocumentShow($type, $routeDocumentShow);
$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;
} }
protected function getLogo($logo) protected function getLogo($logo)
@ -255,242 +299,109 @@ abstract class TransactionTemplate extends Base
return 'data:image/' . $extension . ';base64,' . base64_encode($image); return 'data:image/' . $extension . ';base64,' . base64_encode($image);
} }
protected function getBackgroundColor($type, $backgroundColor) protected function getTextContentTitle($type, $textContentTitle)
{ {
if (!empty($backgroundColor)) { if (!empty($textContentTitle)) {
return $backgroundColor; return $textContentTitle;
} }
if ($background_color = config('type.' . $type . 'color', false)) { $translation = $this->getTextFromConfig($type, $type . '_made', 'revenue_made');
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);
if (!empty($translation)) { if (!empty($translation)) {
return $translation; return $translation;
} }
return 'general.numbers'; return 'revenues.revenue_made';
} }
protected function getTextOrderNumber($type, $textOrderNumber) protected function getTextPaidAt($type, $textPaidAt)
{ {
if (!empty($textOrderNumber)) { if (!empty($textPaidAt)) {
return $textOrderNumber; return $textPaidAt;
} }
$translation = $this->getTextFromConfig($type, 'order_number'); $translation = $this->getTextFromConfig($type, 'paid_at', 'date');
if (!empty($translation)) { if (!empty($translation)) {
return $translation; return $translation;
} }
return 'invoices.order_number'; return 'general.date';
} }
protected function getTextContactInfo($type, $textContactInfo) protected function getTextAccount($type, $textAccount)
{ {
if (!empty($textContactInfo)) { if (!empty($textAccount)) {
return $textContactInfo; return $textAccount;
} }
switch ($type) { $translation = $this->getTextFromConfig($type, 'accounts', 'accounts', 'trans_choice');
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);
if (!empty($translation)) { if (!empty($translation)) {
return $translation; return $translation;
} }
return 'invoices.bill_to'; return 'general.accounts';
} }
protected function getTextIssuedAt($type, $textIssuedAt) protected function getTextCategory($type, $textCategory)
{ {
if (!empty($textIssuedAt)) { if (!empty($textCategory)) {
return $textIssuedAt; return $textCategory;
} }
switch ($type) { $translation = $this->getTextFromConfig($type, 'categories', 'categories', 'trans_choice');
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);
if (!empty($translation)) { if (!empty($translation)) {
return $translation; return $translation;
} }
return 'invoices.invoice_date'; return 'general.categories';
} }
protected function getTextDueAt($type, $textDueAt) protected function getTextPaymentMethods($type, $textPaymentMethods)
{ {
if (!empty($textDueAt)) { if (!empty($textPaymentMethods)) {
return $textDueAt; return $textPaymentMethods;
} }
$translation = $this->getTextFromConfig($type, 'due_at', 'due_date'); $translation = $this->getTextFromConfig($type, 'payment_methods', 'payment_methods', 'trans_choice');
if (!empty($translation)) { if (!empty($translation)) {
return $translation; return $translation;
} }
return 'invoices.due_date'; return 'general.payment_methods';
} }
protected function getTextItems($type, $textItems) protected function getTextReference($type, $textReference)
{ {
if (!empty($textItems)) { if (!empty($textReference)) {
return $textItems; return $textReference;
} }
// if you use settting translation $translation = $this->getTextFromConfig($type, 'reference', 'reference');
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');
if (!empty($translation)) { if (!empty($translation)) {
return $translation; return $translation;
} }
return 'general.items'; return 'general.reference';
} }
protected function getTextQuantity($type, $textQuantity) protected function getTextDescription($type, $textDescription)
{ {
if (!empty($textQuantity)) { if (!empty($textDescription)) {
return $textQuantity; return $textDescription;
} }
// if you use settting translation $translation = $this->getTextFromConfig($type, 'description', 'description');
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');
if (!empty($translation)) { if (!empty($translation)) {
return $translation; return $translation;
} }
return 'invoices.quantity'; return 'general.description';
}
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';
} }
protected function getTextAmount($type, $textAmount) protected function getTextAmount($type, $textAmount)
@ -499,7 +410,7 @@ abstract class TransactionTemplate extends Base
return $textAmount; return $textAmount;
} }
$translation = $this->getTextFromConfig($type, 'amount'); $translation = $this->getTextFromConfig($type, 'amount', 'amount');
if (!empty($translation)) { if (!empty($translation)) {
return $translation; return $translation;
@ -508,146 +419,130 @@ abstract class TransactionTemplate extends Base
return 'general.amount'; return 'general.amount';
} }
protected function getHideItems($type, $hideItems, $hideName, $hideDescription) protected function getTextPaidBy($type, $textPaidBy)
{ {
if (!empty($hideItems)) { if (!empty($textPaidBy)) {
return $hideItems; return $textPaidBy;
} }
$hide = $this->getHideFromConfig($type, 'items'); $translation = $this->getTextFromConfig($type, 'paid_by', 'paid_by');
if ($hide) { if (!empty($translation)) {
return $hide; return $translation;
} }
$hideItems = ($this->getHideName($type, $hideName) & $this->getHideDescription($type, $hideDescription)) ? true : false; return 'general.paid_by';
return $hideItems;
} }
protected function getHideName($type, $hideName) protected function getTextReleatedTransansaction($type, $textReleatedTransansaction)
{ {
if (!empty($hideName)) { if (!empty($textReleatedTransansaction)) {
return $hideName; return $textReleatedTransansaction;
} }
// if you use settting translation $translation = $this->getTextFromConfig($type, 'related_revenue', 'related_revenue');
if ($hideName = setting($this->getSettingKey($type, 'hide_item_name'), false)) {
return $hideName; if (!empty($translation)) {
return $translation;
} }
$hide = $this->getHideFromConfig($type, 'name'); return 'general.related_revenue';
if ($hide) {
return $hide;
} }
// @todo what return value invoice or always false?? protected function getTextReleatedDocumentNumber($type, $textReleatedDocumentNumber)
return setting('invoice.hide_item_name', $hideName);
}
protected function getHideDescription($type, $hideDescription)
{ {
if (!empty($hideDescription)) { if (!empty($textReleatedDocumentNumber)) {
return $hideDescription; return $textReleatedDocumentNumber;
} }
// if you use settting translation $translation = $this->getTextFromConfig($type, 'related_document_number', 'numbers');
if ($hideDescription = setting($this->getSettingKey($type, 'hide_item_description'), false)) {
return $hideDescription; if (!empty($translation)) {
return $translation;
} }
$hide = $this->getHideFromConfig($type, 'description'); return 'general.numbers';
if ($hide) {
return $hide;
} }
// @todo what return value invoice or always false?? protected function getTextReleatedConcat($type, $textReleatedContact)
return setting('invoice.hide_item_description', $hideDescription);
}
protected function getHideQuantity($type, $hideQuantity)
{ {
if (!empty($hideQuantity)) { if (!empty($textReleatedContact)) {
return $hideQuantity; return $textReleatedContact;
} }
// if you use settting translation $translation = $this->getTextFromConfig($type, 'related_contact', 'contact');
if ($hideQuantity = setting($this->getSettingKey($type, 'hide_quantity'), false)) {
return $hideQuantity; if (!empty($translation)) {
return $translation;
} }
$hide = $this->getHideFromConfig($type, 'quantity'); return 'general.customers';
if ($hide) {
return $hide;
} }
// @todo what return value invoice or always false?? protected function getTextReleatedDocumentDate($type, $textReleatedDocumentDate)
return setting('invoice.hide_quantity', $hideQuantity);
}
protected function getHidePrice($type, $hidePrice)
{ {
if (!empty($hidePrice)) { if (!empty($textReleatedDocumentDate)) {
return $hidePrice; return $textReleatedDocumentDate;
} }
// if you use settting translation $translation = $this->getTextFromConfig($type, 'related_document_date', 'due_date');
if ($hidePrice = setting($this->getSettingKey($type, 'hide_price'), false)) {
return $hidePrice; if (!empty($translation)) {
return $translation;
} }
$hide = $this->getHideFromConfig($type, 'price'); return 'invoices.invoice_date';
if ($hide) {
return $hide;
} }
// @todo what return value invoice or always false?? protected function getTextReleatedDocumentAmount($type, $textReleatedDocumentAmount)
return setting('invoice.hide_price', $hidePrice);
}
protected function getHideDiscount($type, $hideDiscount)
{ {
if (!empty($hideDiscount)) { if (!empty($textReleatedDocumentAmount)) {
return $hideDiscount; return $textReleatedDocumentAmount;
} }
// if you use settting translation $translation = $this->getTextFromConfig($type, 'related_document_amount', 'amount');
if ($hideDiscount = setting($this->getSettingKey($type, 'hide_discount'), false)) {
return $hideDiscount; if (!empty($translation)) {
return $translation;
} }
$hide = $this->getHideFromConfig($type, 'discount'); return 'general.amount';
if ($hide) {
return $hide;
} }
// @todo what return value invoice or always false?? protected function getTextReleatedAmount($type, $textReleatedAmount)
return setting('invoice.hide_discount', $hideDiscount);
}
protected function getHideAmount($type, $hideAmount)
{ {
if (!empty($hideAmount)) { if (!empty($textReleatedAmount)) {
return $hideAmount; return $textReleatedAmount;
} }
// if you use settting translation $translation = $this->getTextFromConfig($type, 'related_amount', 'amount');
if ($hideAmount = setting($this->getSettingKey($type, 'hide_amount'), false)) {
return $hideAmount; if (!empty($translation)) {
return $translation;
} }
$hide = $this->getHideFromConfig($type, 'amount'); return 'general.amount';
if ($hide) {
return $hide;
} }
// @todo what return value invoice or always false?? protected function routeDocumentShow($type, $routeDocumentShow)
return setting('invoice.hide_amount', $hideAmount); {
if (!empty($routeDocumentShow)) {
return $routeDocumentShow;
}
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';
} }
} }

View File

@ -13,6 +13,57 @@
:payment_methods="$payment_methods" :payment_methods="$payment_methods"
transaction-template="{{ $transactionTemplate }}" transaction-template="{{ $transactionTemplate }}"
logo="{{ $logo }}" 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 @endswitch
@else @else

View File

@ -1,10 +1,13 @@
@stack('company_start')
@if (!$hideCompany)
<div class="row border-bottom-1 pt-6 pb-6"> <div class="row border-bottom-1 pt-6 pb-6">
<div class="col-16"> <div class="col-16">
<div class="text company"> <div class="text company">
@stack('company_logo_start') @stack('company_logo_start')
@if (!$hideCompanyLogo) @if (!$hideCompanyLogo)
@if (!empty($document->contact->logo) && !empty($document->contact->logo->id)) @if (!empty($transaction->contact->logo) && !empty($transaction->contact->logo->id))
<img src="{{ Storage::url($document->contact->logo->id) }}" height="128" width="128" alt="{{ $document->contact_name }}"/> <img src="{{ Storage::url($transaction->contact->logo->id) }}" height="128" width="128" alt="{{ $transaction->contact->name }}"/>
@else @else
<img src="{{ $logo }}" alt="{{ setting('company.name') }}"/> <img src="{{ $logo }}" alt="{{ setting('company.name') }}"/>
@endif @endif
@ -51,68 +54,99 @@
</div> </div>
</div> </div>
</div> </div>
@endif
@stack('company_end')
<div class="row border-bottom-1 w-100 mt-6 pb-6 d-flex flex-column"> <div class="row border-bottom-1 w-100 mt-6 pb-6 d-flex flex-column">
<h2 class="text-center text-uppercase mb-6">{{ trans('invoices.revenue_made') }}</h2> @if (!$hideContentTitle)
<h2 class="text-center text-uppercase mb-6">
{{ trans($textContentTitle) }}
</h2>
@endif
<div class="d-flex"> <div class="d-flex">
<div class="d-flex flex-column col-lg-7 pl-0"> <div class="d-flex flex-column col-lg-7 pl-0">
<div class="d-flex mt-3"> <div class="d-flex mt-3">
<div class="text company show-company col-lg-4 pl-0"> <div class="text company show-company col-lg-4 pl-0">
@if (!$hidePaidAt)
<p> <p>
<strong>{{ trans('general.date') }}:</strong> <strong>{{ trans($textPaidAt) }}:</strong>
</p> </p>
@endif
@if (!$hideAccount)
<p> <p>
<strong>{{ trans_choice('general.accounts', 1) }}:</strong> <strong>{{ trans_choice($textAccount, 1) }}:</strong>
</p> </p>
@endif
@if (!$hideCategory)
<p> <p>
{{ trans_choice('general.categories', 1) }}:</strong> {{ trans_choice($textCategory, 1) }}:</strong>
</p> </p>
@endif
@if (!$hidePaymentMethods)
<p> <p>
<strong>{{ trans_choice('general.payment_methods', 1) }}:</strong> <strong>{{ trans_choice($textPaymentMethods, 1) }}:</strong>
</p> </p>
@endif
@if (!$hideReference)
<p> <p>
<strong>{{ trans('general.reference') }}:</strong> <strong>{{ trans($textReference) }}:</strong>
</p> </p>
@endif
@if (!$hideDescription)
<p> <p>
<strong>{{ trans('general.description') }}:</strong> <strong>{{ trans($textDescription) }}:</strong>
</p> </p>
@endif
</div> </div>
<div class="text company col-lg-8 pr-0 show-company show-company-value"> <div class="text company col-lg-8 pr-0 show-company show-company-value">
@if (!$hidePaidAt)
<p class="border-bottom-1"> <p class="border-bottom-1">
@date($transaction->paid_at) @date($transaction->paid_at)
</p> </p>
@endif
@if (!$hideAccount)
<p class="border-bottom-1"> <p class="border-bottom-1">
{{ $transaction->account->name }} {{ $transaction->account->name }}
</p> </p>
@endif
@if (!$hideCategory)
<p class="border-bottom-1"> <p class="border-bottom-1">
{{ $transaction->category->name }} {{ $transaction->category->name }}
</p> </p>
@endif
@if (!$hidePaymentMethods)
<p class="border-bottom-1"> <p class="border-bottom-1">
{{ $payment_methods[$transaction->payment_method] }} {{ $payment_methods[$transaction->payment_method] }}
</p> </p>
@endif
@if (!$hideReference)
<p class="border-bottom-1"> <p class="border-bottom-1">
{{ $transaction->reference }} {{ $transaction->reference }}
</p> </p>
@endif
@if (!$hideDescription)
<p> <p>
{!! nl2br($transaction->description) !!} {!! nl2br($transaction->description) !!}
</p> </p>
@endif
</div> </div>
</div> </div>
@if (!$hideContact)
<div class="text company mt-5"> <div class="text company mt-5">
<h2>{{ trans('general.paid_by') }}</h2> <h2>{{ trans($textPaidBy) }}</h2>
@if ($hideContactInfo) @if ($hideContactInfo)
<strong>{{ trans($textContactInfo) }}</strong><br> <strong>{{ trans($textContactInfo) }}</strong><br>
@ -158,14 +192,18 @@
@endif @endif
@stack('email_input_end') @stack('email_input_end')
</div> </div>
@endif
</div> </div>
@if (!$hideAmount)
<div class="d-flex flex-column align-items-end col-lg-5 pr-0"> <div class="d-flex flex-column align-items-end col-lg-5 pr-0">
<div class="card bg-success show-card-bg-success border-0 mt-4 mb-0"> <div class="card bg-success show-card-bg-success border-0 mt-4 mb-0">
<div class="card-body"> <div class="card-body">
<div class="row"> <div class="row">
<div class="col card-amount-badge text-center mt-3"> <div class="col card-amount-badge text-center mt-3">
<h5 class="text-muted mb-0 text-white">{{ trans('general.amount') }}</h5> <h5 class="text-muted mb-0 text-white">
{{ trans($textAmount) }}
</h5>
<span class="h2 font-weight-bold mb-0 text-white"> <span class="h2 font-weight-bold mb-0 text-white">
@money($transaction->amount, $transaction->currency_code, true) @money($transaction->amount, $transaction->currency_code, true)
@ -175,63 +213,85 @@
</div> </div>
</div> </div>
</div> </div>
@endif
</div> </div>
</div> </div>
@if (!$hideReletad)
@if ($transaction->document) @if ($transaction->document)
<div class="row mt-3 mb-3"> <div class="row mt-3 mb-3">
<div class="col-100"> <div class="col-100">
<div class="text"> <div class="text">
<h3>{{ trans('invoices.related_revenue') }}</h3> <h3>{{ trans($textReleatedTransansaction) }}</h3>
<table class="table table-flush table-hover mt-3"> <table class="table table-flush table-hover mt-3">
<thead class="thead-light"> <thead class="thead-light">
<tr class="border-bottom-1"> <tr class="border-bottom-1">
@if (!$hideReletadDocumentNumber)
<th class="item text-left"> <th class="item text-left">
<span>{{ trans_choice('general.numbers', 1) }}</span> <span>{{ trans_choice($textReleatedDocumentNumber, 1) }}</span>
</th> </th>
@endif
@if (!$hideReletadContact)
<th class="quantity"> <th class="quantity">
{{ trans_choice('general.customers', 1) }} {{ trans_choice($textReleatedContact, 1) }}
</th> </th>
@endif
@if (!$hideReletadDocumentDate)
<th class="price"> <th class="price">
{{ trans('invoices.invoice_date') }} {{ trans($textReleatedDocumentDate) }}
</th> </th>
@endif
@if (!$hideReletadDocumentAmount)
<th class="price"> <th class="price">
{{ trans('invoices.invoice_date') }} {{ trans($textReleatedDocumentAmount) }}
</th> </th>
@endif
@if (!$hideReletadAmount)
<th class="total"> <th class="total">
{{ trans('general.amount') }} {{ trans($textReleatedAmount) }}
</th> </th>
@endif
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr class="border-bottom-1"> <tr class="border-bottom-1">
@if (!$hideReletadDocumentNumber)
<td class="item"> <td class="item">
<a href="{{ route('invoices.show' , $transaction->document->id) }}"> <a href="{{ route($routeDocumentShow, $transaction->document->id) }}">
{{ $transaction->document->document_number }} {{ $transaction->document->document_number }}
</a> </a>
</td> </td>
@endif
@if (!$hideReletadContact)
<td class="quantity"> <td class="quantity">
{{ $transaction->document->contact_name }} {{ $transaction->document->contact_name }}
</td> </td>
@endif
@if (!$hideReletadDocumentDate)
<td class="price"> <td class="price">
@date($transaction->document->due_at) @date($transaction->document->due_at)
</td> </td>
@endif
@if (!$hideReletadDocumentAmount)
<td class="price"> <td class="price">
@money($transaction->document->amount, $transaction->document->currency_code, true) @money($transaction->document->amount, $transaction->document->currency_code, true)
</td> </td>
@endif
@if (!$hideReletadAmount)
<td class="total"> <td class="total">
@money($transaction->amount, $transaction->currency_code, true) @money($transaction->amount, $transaction->currency_code, true)
</td> </td>
@endif
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -240,8 +300,12 @@
</div> </div>
@else @else
<div class="row mt-3 mb-3"> <div class="row mt-3 mb-3">
<p> <p class="text-right">
{{ trans('invoices.overdue_revenue') }}: <strong style="font-weight: bold;">@money($transaction->amount, $transaction->currency_code, true)</strong> {{ trans('invoices.overdue_revenue') }}:
<strong style="font-weight: bold;">
@money($transaction->amount, $transaction->currency_code, true)
</strong>
</p> </p>
</div> </div>
@endif @endif
@endif