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??
return setting('invoice.hide_item_name', $hideName);
} }
protected function getHideDescription($type, $hideDescription) protected function getTextReleatedDocumentNumber($type, $textReleatedDocumentNumber)
{ {
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??
return setting('invoice.hide_item_description', $hideDescription);
} }
protected function getHideQuantity($type, $hideQuantity) protected function getTextReleatedConcat($type, $textReleatedContact)
{ {
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??
return setting('invoice.hide_quantity', $hideQuantity);
} }
protected function getHidePrice($type, $hidePrice) protected function getTextReleatedDocumentDate($type, $textReleatedDocumentDate)
{ {
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??
return setting('invoice.hide_price', $hidePrice);
} }
protected function getHideDiscount($type, $hideDiscount) protected function getTextReleatedDocumentAmount($type, $textReleatedDocumentAmount)
{ {
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??
return setting('invoice.hide_discount', $hideDiscount);
} }
protected function getHideAmount($type, $hideAmount) protected function getTextReleatedAmount($type, $textReleatedAmount)
{ {
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) { protected function routeDocumentShow($type, $routeDocumentShow)
return $hide; {
if (!empty($routeDocumentShow)) {
return $routeDocumentShow;
} }
// @todo what return value invoice or always false?? if (!$this->transaction->document) {
return setting('invoice.hide_amount', $hideAmount); 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,136 +1,170 @@
<div class="row border-bottom-1 pt-6 pb-6">
<div class="col-16"> @stack('company_start')
<div class="text company"> @if (!$hideCompany)
@stack('company_logo_start') <div class="row border-bottom-1 pt-6 pb-6">
@if (!$hideCompanyLogo) <div class="col-16">
@if (!empty($document->contact->logo) && !empty($document->contact->logo->id)) <div class="text company">
<img src="{{ Storage::url($document->contact->logo->id) }}" height="128" width="128" alt="{{ $document->contact_name }}"/> @stack('company_logo_start')
@else @if (!$hideCompanyLogo)
<img src="{{ $logo }}" alt="{{ setting('company.name') }}"/> @if (!empty($transaction->contact->logo) && !empty($transaction->contact->logo->id))
<img src="{{ Storage::url($transaction->contact->logo->id) }}" height="128" width="128" alt="{{ $transaction->contact->name }}"/>
@else
<img src="{{ $logo }}" alt="{{ setting('company.name') }}"/>
@endif
@endif @endif
@endif @stack('company_logo_end')
@stack('company_logo_end') </div>
</div>
<div class="col-42">
<div class="text company lead">
@stack('company_details_start')
@if (!$hideCompanyDetails)
@if (!$hideCompanyName)
<h2 class="mb-1">
{{ setting('company.name') }}
</h2>
@endif
@if (!$hideCompanyAddress)
<p>{!! nl2br(setting('company.address')) !!}</p>
@endif
@if (!$hideCompanyTaxNumber)
<p>
@if (setting('company.tax_number'))
{{ trans('general.tax_number') }}: {{ setting('company.tax_number') }}
@endif
</p>
@endif
@if (!$hideCompanyPhone)
<p>
@if (setting('company.phone'))
{{ setting('company.phone') }}
@endif
</p>
@endif
@if (!$hideCompanyEmail)
<p>{{ setting('company.email') }}</p>
@endif
@endif
@stack('company_details_end')
</div>
</div> </div>
</div> </div>
@endif
<div class="col-42"> @stack('company_end')
<div class="text company lead">
@stack('company_details_start')
@if (!$hideCompanyDetails)
@if (!$hideCompanyName)
<h2 class="mb-1">
{{ setting('company.name') }}
</h2>
@endif
@if (!$hideCompanyAddress)
<p>{!! nl2br(setting('company.address')) !!}</p>
@endif
@if (!$hideCompanyTaxNumber)
<p>
@if (setting('company.tax_number'))
{{ trans('general.tax_number') }}: {{ setting('company.tax_number') }}
@endif
</p>
@endif
@if (!$hideCompanyPhone)
<p>
@if (setting('company.phone'))
{{ setting('company.phone') }}
@endif
</p>
@endif
@if (!$hideCompanyEmail)
<p>{{ setting('company.email') }}</p>
@endif
@endif
@stack('company_details_end')
</div>
</div>
</div>
<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">
<p> @if (!$hidePaidAt)
<strong>{{ trans('general.date') }}:</strong> <p>
</p> <strong>{{ trans($textPaidAt) }}:</strong>
</p>
@endif
<p> @if (!$hideAccount)
<strong>{{ trans_choice('general.accounts', 1) }}:</strong> <p>
</p> <strong>{{ trans_choice($textAccount, 1) }}:</strong>
</p>
@endif
<p> @if (!$hideCategory)
{{ trans_choice('general.categories', 1) }}:</strong> <p>
</p> {{ trans_choice($textCategory, 1) }}:</strong>
</p>
@endif
<p> @if (!$hidePaymentMethods)
<strong>{{ trans_choice('general.payment_methods', 1) }}:</strong> <p>
</p> <strong>{{ trans_choice($textPaymentMethods, 1) }}:</strong>
</p>
@endif
<p> @if (!$hideReference)
<strong>{{ trans('general.reference') }}:</strong> <p>
</p> <strong>{{ trans($textReference) }}:</strong>
</p>
@endif
<p> @if (!$hideDescription)
<strong>{{ trans('general.description') }}:</strong> <p>
</p> <strong>{{ trans($textDescription) }}:</strong>
</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">
<p class="border-bottom-1"> @if (!$hidePaidAt)
@date($transaction->paid_at) <p class="border-bottom-1">
</p> @date($transaction->paid_at)
</p>
@endif
<p class="border-bottom-1"> @if (!$hideAccount)
{{ $transaction->account->name }} <p class="border-bottom-1">
</p> {{ $transaction->account->name }}
</p>
@endif
<p class="border-bottom-1"> @if (!$hideCategory)
{{ $transaction->category->name }} <p class="border-bottom-1">
</p> {{ $transaction->category->name }}
</p>
@endif
<p class="border-bottom-1"> @if (!$hidePaymentMethods)
{{ $payment_methods[$transaction->payment_method] }} <p class="border-bottom-1">
</p> {{ $payment_methods[$transaction->payment_method] }}
</p>
@endif
<p class="border-bottom-1"> @if (!$hideReference)
{{ $transaction->reference }} <p class="border-bottom-1">
</p> {{ $transaction->reference }}
</p>
@endif
<p> @if (!$hideDescription)
{!! nl2br($transaction->description) !!} <p>
</p> {!! nl2br($transaction->description) !!}
</p>
@endif
</div> </div>
</div> </div>
<div class="text company mt-5"> @if (!$hideContact)
<h2>{{ trans('general.paid_by') }}</h2> <div class="text company mt-5">
<h2>{{ trans($textPaidBy) }}</h2>
@if ($hideContactInfo) @if ($hideContactInfo)
<strong>{{ trans($textContactInfo) }}</strong><br> <strong>{{ trans($textContactInfo) }}</strong><br>
@endif @endif
@stack('name_input_start') @stack('name_input_start')
@if (!$hideContactName) @if (!$hideContactName)
<strong>{{ $transaction->contact->name }}</strong><br> <strong>{{ $transaction->contact->name }}</strong><br>
@endif @endif
@stack('name_input_end') @stack('name_input_end')
@stack('address_input_start') @stack('address_input_start')
@if (!$hideContactAddress) @if (!$hideContactAddress)
<p>{!! nl2br($transaction->contact->address) !!}</p> <p>{!! nl2br($transaction->contact->address) !!}</p>
@endif @endif
@stack('address_input_end') @stack('address_input_end')
@stack('tax_number_input_start') @stack('tax_number_input_start')
@if (!$hideContactTaxNumber) @if (!$hideContactTaxNumber)
<p> <p>
@if ($transaction->contact->tax_number) @if ($transaction->contact->tax_number)
@ -138,9 +172,9 @@
@endif @endif
</p> </p>
@endif @endif
@stack('tax_number_input_end') @stack('tax_number_input_end')
@stack('phone_input_start') @stack('phone_input_start')
@if (!$hideContactPhone) @if (!$hideContactPhone)
<p> <p>
@if ($transaction->contact->phone) @if ($transaction->contact->phone)
@ -148,100 +182,130 @@
@endif @endif
</p> </p>
@endif @endif
@stack('phone_input_end') @stack('phone_input_end')
@stack('email_start') @stack('email_start')
@if (!$hideContactEmail) @if (!$hideContactEmail)
<p> <p>
{{ $transaction->contact->email }} {{ $transaction->contact->email }}
</p> </p>
@endif @endif
@stack('email_input_end') @stack('email_input_end')
</div> </div>
@endif
</div> </div>
<div class="d-flex flex-column align-items-end col-lg-5 pr-0"> @if (!$hideAmount)
<div class="card bg-success show-card-bg-success border-0 mt-4 mb-0"> <div class="d-flex flex-column align-items-end col-lg-5 pr-0">
<div class="card-body"> <div class="card bg-success show-card-bg-success border-0 mt-4 mb-0">
<div class="row"> <div class="card-body">
<div class="col card-amount-badge text-center mt-3"> <div class="row">
<h5 class="text-muted mb-0 text-white">{{ trans('general.amount') }}</h5> <div class="col card-amount-badge text-center mt-3">
<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)
</span> </span>
</div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> @endif
</div> </div>
</div> </div>
@if ($transaction->document) @if (!$hideReletad)
<div class="row mt-3 mb-3"> @if ($transaction->document)
<div class="col-100"> <div class="row mt-3 mb-3">
<div class="text"> <div class="col-100">
<h3>{{ trans('invoices.related_revenue') }}</h3> <div class="text">
<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">
<th class="item text-left"> @if (!$hideReletadDocumentNumber)
<span>{{ trans_choice('general.numbers', 1) }}</span> <th class="item text-left">
</th> <span>{{ trans_choice($textReleatedDocumentNumber, 1) }}</span>
</th>
@endif
<th class="quantity"> @if (!$hideReletadContact)
{{ trans_choice('general.customers', 1) }} <th class="quantity">
</th> {{ trans_choice($textReleatedContact, 1) }}
</th>
@endif
<th class="price"> @if (!$hideReletadDocumentDate)
{{ trans('invoices.invoice_date') }} <th class="price">
</th> {{ trans($textReleatedDocumentDate) }}
</th>
@endif
<th class="price"> @if (!$hideReletadDocumentAmount)
{{ trans('invoices.invoice_date') }} <th class="price">
</th> {{ trans($textReleatedDocumentAmount) }}
</th>
@endif
<th class="total"> @if (!$hideReletadAmount)
{{ trans('general.amount') }} <th class="total">
</th> {{ trans($textReleatedAmount) }}
</tr> </th>
</thead> @endif
</tr>
</thead>
<tbody> <tbody>
<tr class="border-bottom-1"> <tr class="border-bottom-1">
<td class="item"> @if (!$hideReletadDocumentNumber)
<a href="{{ route('invoices.show' , $transaction->document->id) }}"> <td class="item">
{{ $transaction->document->document_number }} <a href="{{ route($routeDocumentShow, $transaction->document->id) }}">
</a> {{ $transaction->document->document_number }}
</td> </a>
</td>
@endif
<td class="quantity"> @if (!$hideReletadContact)
{{ $transaction->document->contact_name }} <td class="quantity">
</td> {{ $transaction->document->contact_name }}
</td>
@endif
<td class="price"> @if (!$hideReletadDocumentDate)
@date($transaction->document->due_at) <td class="price">
</td> @date($transaction->document->due_at)
</td>
@endif
<td class="price"> @if (!$hideReletadDocumentAmount)
@money($transaction->document->amount, $transaction->document->currency_code, true) <td class="price">
</td> @money($transaction->document->amount, $transaction->document->currency_code, true)
</td>
@endif
<td class="total"> @if (!$hideReletadAmount)
@money($transaction->amount, $transaction->currency_code, true) <td class="total">
</td> @money($transaction->amount, $transaction->currency_code, true)
</tr> </td>
</tbody> @endif
</table> </tr>
</tbody>
</table>
</div>
</div> </div>
</div> </div>
</div> @else
@else <div class="row mt-3 mb-3">
<div class="row mt-3 mb-3"> <p class="text-right">
<p> {{ trans('invoices.overdue_revenue') }}:
{{ trans('invoices.overdue_revenue') }}: <strong style="font-weight: bold;">@money($transaction->amount, $transaction->currency_code, true)</strong> <strong style="font-weight: bold;">
</p> @money($transaction->amount, $transaction->currency_code, true)
</div> </strong>
</p>
</div>
@endif
@endif @endif