Merge branch 'master' into title-subheading

This commit is contained in:
Cüneyt Şentürk
2023-07-19 14:43:19 +03:00
committed by GitHub
628 changed files with 65799 additions and 80258 deletions

View File

@@ -283,8 +283,8 @@ abstract class Index extends Component
$items[] = [
'title' => ($key == 'overdue') ? trans('general.overdue') : trans('documents.statuses.' . $key),
//'href' => route($route, ['search' => 'status:' . $key]),
'amount' => money($total, default_currency(), true)->formatForHumans(),
'tooltip' => money($total, default_currency(), true)->format(),
'amount' => money($total)->formatForHumans(),
'tooltip' => money($total)->format(),
];
}

View File

@@ -3,6 +3,7 @@
namespace App\Abstracts\View\Components\Documents;
use App\Abstracts\View\Component;
use App\Interfaces\Utility\DocumentNumber;
use App\Models\Common\Contact;
use App\Models\Document\Document;
use App\Models\Setting\Currency;
@@ -163,30 +164,45 @@ abstract class Form extends Component
/** @var bool */
public $hideItemName;
/** @var bool */
public $hideSettingItemName;
/** @var string */
public $textItemName;
/** @var bool */
public $hideItemDescription;
/** @var bool */
public $hideSettingItemDescription;
/** @var string */
public $textItemDescription;
/** @var bool */
public $hideItemQuantity;
/** @var bool */
public $hideSettingItemQuantity;
/** @var string */
public $textItemQuantity;
/** @var bool */
public $hideItemPrice;
/** @var bool */
public $hideSettingItemPrice;
/** @var string */
public $textItemPrice;
/** @var bool */
public $hideItemAmount;
/** @var bool */
public $hideSettingItemAmount;
/** @var string */
public $textItemAmount;
@@ -276,8 +292,8 @@ abstract class Form extends Component
bool $hideDocumentTitle = false, bool $hideDocumentSubheading = false, string $title = '', string $subheading = '',
bool $hideIssuedAt = false, string $textIssuedAt = '', string $issuedAt = '', bool $hideDueAt = false, string $textDueAt = '', string $dueAt = '', $periodDueAt = '',
bool $hideDocumentNumber = false, string $textDocumentNumber = '', string $documentNumber = '', bool $hideOrderNumber = false, string $textOrderNumber = '', string $orderNumber = '',
bool $hideEditItemColumns = false, bool $hideItems = false, bool $hideItemName = false, string $textItemName = '', bool $hideItemDescription = false, string $textItemDescription = '',
bool $hideItemQuantity = false, string $textItemQuantity = '', bool $hideItemPrice = false, string $textItemPrice = '', bool $hideItemAmount = false, string $textItemAmount = '',
bool $hideEditItemColumns = false, bool $hideItems = false, bool $hideItemName = false, bool $hideSettingItemName = false, string $textItemName = '', bool $hideItemDescription = false, bool $hideSettingItemDescription = false, string $textItemDescription = '',
bool $hideItemQuantity = false, bool $hideSettingItemQuantity = false, string $textItemQuantity = '', bool $hideItemPrice = false, bool $hideSettingItemPrice = false, string $textItemPrice = '', bool $hideItemAmount = false, bool $hideSettingItemAmount = false, string $textItemAmount = '',
bool $hideDiscount = false, bool $isSalePrice = false, bool $isPurchasePrice = false, int $searchCharLimit = 0, string $notes = '',
bool $showRecurring = false,
bool $hideAdvanced = false, string $textSectionAdvancedTitle = '', string $textSectionAdvancedDescription = '',
@@ -290,9 +306,11 @@ abstract class Form extends Component
$this->model = ! empty($model) ? $model : $document;
$this->document = $this->model;
$this->currencies = $this->getCurrencies($currencies);
$this->currency = $this->getCurrency($document, $currency, $currency_code);
$this->currency_code = ! empty($this->currency) ? $this->currency->code : default_currency();
$this->currency = $this->getCurrency($document, $currency, $currency_code);
$this->currencies = $this->getCurrencies($currencies);
$this->taxes = Tax::enabled()->orderBy('name')->get()->pluck('title', 'id');
/* -- Content Start -- */
@@ -357,18 +375,23 @@ abstract class Form extends Component
$this->hideItems = $this->getHideItems($type, $hideItems, $hideItemName, $hideItemDescription);
$this->hideItemName = $this->getHideItemName($type, $hideItemName);
$this->hideSettingItemName = $this->getHideSettingItemName($type, $hideSettingItemName);
$this->textItemName = $this->getTextItemName($type, $textItemName);
$this->hideItemDescription = $this->getHideItemDescription($type, $hideItemDescription);
$this->hideSettingItemDescription = $this->getHideSettingItemDescription($type, $hideSettingItemDescription);
$this->textItemDescription = $this->getTextItemDescription($type, $textItemDescription);
$this->hideItemQuantity = $this->getHideItemQuantity($type, $hideItemQuantity);
$this->hideSettingItemQuantity = $this->getHideSettingItemQuantity($type, $hideSettingItemQuantity);
$this->textItemQuantity = $this->getTextItemQuantity($type, $textItemQuantity);
$this->hideItemPrice = $this->getHideItemPrice($type, $hideItemPrice);
$this->hideSettingItemPrice = $this->getHideSettingItemPrice($type, $hideSettingItemPrice);
$this->textItemPrice = $this->getTextItemPrice($type, $textItemPrice);
$this->hideItemAmount = $this->getHideItemAmount($type, $hideItemAmount);
$this->hideSettingItemAmount = $this->getHideSettingItemAmount($type, $hideSettingItemAmount);
$this->textItemAmount = $this->getTextItemAmount($type, $textItemAmount);
$this->hideDiscount = $this->getHideDiscount($type, $hideDiscount);
@@ -763,7 +786,7 @@ abstract class Form extends Component
$issuedAt = Date::now()->toDateString();
}
$addDays = setting($this->getSettingKey($type, 'payment_terms'), 0) ?: 0;
$addDays = setting($this->getDocumentSettingKey($type, 'payment_terms'), 0) ?: 0;
$dueAt = Date::parse($issuedAt)->addDays($addDays)->toDateString();
@@ -815,10 +838,14 @@ abstract class Form extends Component
return $document->document_number;
}
$document_number = $this->getNextDocumentNumber($type);
$contact = ($this->contact instanceof Contact) ? $this->contact : null;
$utility = app(DocumentNumber::class);
$document_number = $utility->getNextNumber($type, $contact);
if (empty($document_number)) {
$document_number = $this->getNextDocumentNumber(Document::INVOICE_TYPE);
$document_number = $utility->getNextNumber(Document::INVOICE_TYPE, $contact);
}
return $document_number;
@@ -869,25 +896,35 @@ abstract class Form extends Component
return $hideItems;
}
protected function getHideItemName($type, $hideItemName)
protected function getHideItemName($type, $hideItemName): bool
{
if (! empty($hideItemName)) {
return $hideItemName;
}
// if you use settting translation
if ($hideItemName = setting($this->getSettingKey($type, 'item_name'), false) && $hideItemName == 'hide') {
return $hideItemName;
}
$hide = $this->getHideFromConfig($type, 'name');
if ($hide) {
return $hide;
}
// @todo what return value invoice or always false??
return setting('invoice.item_name', $hideItemName) == 'hide' ? true : false;
return false;
}
protected function getHideSettingItemName($type, $hideSettingItemName): bool
{
if (! empty($hideSettingItemName)) {
return $hideSettingItemName;
}
$hideItemName = setting($this->getDocumentSettingKey($type, 'item_name'), false);
// if you use settting translation
if ($hideItemName === 'hide') {
return true;
}
return false;
}
protected function getTextItemName($type, $textItemName)
@@ -897,18 +934,18 @@ abstract class Form extends Component
}
// if you use settting translation
if (setting($this->getSettingKey($type, 'item_name'), 'items') === 'custom') {
if (empty($textItemName = setting($this->getSettingKey($type, 'item_name_input')))) {
if (setting($this->getDocumentSettingKey($type, 'item_name'), 'items') === 'custom') {
if (empty($textItemName = setting($this->getDocumentSettingKey($type, 'item_name_input')))) {
$textItemName = 'general.items';
}
return $textItemName;
}
if (setting($this->getSettingKey($type, 'item_name')) !== null
&& (trans(setting($this->getSettingKey($type, 'item_name'))) != setting($this->getSettingKey($type, 'item_name')))
if (setting($this->getDocumentSettingKey($type, 'item_name')) !== null
&& (trans(setting($this->getDocumentSettingKey($type, 'item_name'))) != setting($this->getDocumentSettingKey($type, 'item_name')))
) {
return setting($this->getSettingKey($type, 'item_name'));
return setting($this->getDocumentSettingKey($type, 'item_name'));
}
$translation = $this->getTextFromConfig($type, 'items');
@@ -920,25 +957,33 @@ abstract class Form extends Component
return 'general.items';
}
protected function getHideItemDescription($type, $hideItemDescription)
protected function getHideItemDescription($type, $hideItemDescription): bool
{
if (! empty($hideItemDescription)) {
return $hideItemDescription;
}
// if you use settting translation
if ($hideItemDescription = setting($this->getSettingKey($type, 'hide_item_description'), false) && $hideItemDescription == 'hide') {
return $hideItemDescription;
}
$hide = $this->getHideFromConfig($type, 'description');
if ($hide) {
return $hide;
}
// @todo what return value invoice or always false??
return setting('invoice.hide_item_description', $hideItemDescription);
return false;
}
protected function getHideSettingItemDescription($type, $hideSettingItemDescription): bool
{
if (! empty($hideSettingItemDescription)) {
return $hideSettingItemDescription;
}
// if you use settting translation
if (setting($this->getDocumentSettingKey($type, 'hide_item_description'), false)) {
return true;
}
return false;
}
protected function getTextItemDescription($type, $textItemDescription)
@@ -956,25 +1001,35 @@ abstract class Form extends Component
return 'general.description';
}
protected function getHideItemQuantity($type, $hideItemQuantity)
protected function getHideItemQuantity($type, $hideItemQuantity): bool
{
if (! empty($hideItemQuantity)) {
return $hideItemQuantity;
}
// if you use settting translation
if ($hideItemQuantity = setting($this->getSettingKey($type, 'hide_quantity'), false) && $hideItemQuantity == 'hide') {
return $hideItemQuantity;
}
$hide = $this->getHideFromConfig($type, 'quantity');
if ($hide) {
return $hide;
}
// @todo what return value invoice or always false??
return setting('invoice.quantity_name', $hideItemQuantity) == 'hide' ? true : false;
return false;
}
protected function getHideSettingItemQuantity($type, $hideSettingItemQuantity): bool
{
if (! empty($hideSettingItemQuantity)) {
return $hideSettingItemQuantity;
}
$hideItemQuantity = setting($this->getDocumentSettingKey($type, 'quantity_name'), false);
// if you use settting translation
if ($hideItemQuantity === 'hide') {
return true;
}
return false;
}
protected function getTextItemQuantity($type, $textItemQuantity)
@@ -984,18 +1039,18 @@ abstract class Form extends Component
}
// if you use settting translation
if (setting($this->getSettingKey($type, 'quantity_name'), 'quantity') === 'custom') {
if (empty($textItemQuantity = setting($this->getSettingKey($type, 'quantity_name_input')))) {
if (setting($this->getDocumentSettingKey($type, 'quantity_name'), 'quantity') === 'custom') {
if (empty($textItemQuantity = setting($this->getDocumentSettingKey($type, 'quantity_name_input')))) {
$textItemQuantity = 'invoices.quantity';
}
return $textItemQuantity;
}
if (setting($this->getSettingKey($type, 'quantity_name')) !== null
&& (trans(setting($this->getSettingKey($type, 'quantity_name'))) != setting($this->getSettingKey($type, 'quantity_name')))
if (setting($this->getDocumentSettingKey($type, 'quantity_name')) !== null
&& (trans(setting($this->getDocumentSettingKey($type, 'quantity_name'))) != setting($this->getDocumentSettingKey($type, 'quantity_name')))
) {
return setting($this->getSettingKey($type, 'quantity_name'));
return setting($this->getDocumentSettingKey($type, 'quantity_name'));
}
$translation = $this->getTextFromConfig($type, 'quantity');
@@ -1007,25 +1062,35 @@ abstract class Form extends Component
return 'invoices.quantity';
}
protected function getHideItemPrice($type, $hideItemPrice)
protected function getHideItemPrice($type, $hideItemPrice): bool
{
if (! empty($hideItemPrice)) {
return $hideItemPrice;
}
// if you use settting translation
if ($hideItemPrice = setting($this->getSettingKey($type, 'hide_price'), false) && $hideItemPrice == 'hide') {
return $hideItemPrice;
}
$hide = $this->getHideFromConfig($type, 'price');
if ($hide) {
return $hide;
}
// @todo what return value invoice or always false??
return setting('invoice.price_name', $hideItemPrice) == 'hide' ? true : false;
return false;
}
protected function getHideSettingItemPrice($type, $hideSettingItemPrice): bool
{
if (! empty($hideSettingItemPrice)) {
return $hideSettingItemPrice;
}
$hideItemPrice = setting($this->getDocumentSettingKey($type, 'price_name'), false);
// if you use settting translation
if ($hideItemPrice === 'hide') {
return true;
}
return false;
}
protected function getTextItemPrice($type, $textItemPrice)
@@ -1035,18 +1100,18 @@ abstract class Form extends Component
}
// if you use settting translation
if (setting($this->getSettingKey($type, 'price_name'), 'price') === 'custom') {
if (empty($textItemPrice = setting($this->getSettingKey($type, 'price_name_input')))) {
if (setting($this->getDocumentSettingKey($type, 'price_name'), 'price') === 'custom') {
if (empty($textItemPrice = setting($this->getDocumentSettingKey($type, 'price_name_input')))) {
$textItemPrice = 'invoices.price';
}
return $textItemPrice;
}
if (setting($this->getSettingKey($type, 'price_name')) !== null
&& (trans(setting($this->getSettingKey($type, 'price_name'))) != setting($this->getSettingKey($type, 'price_name')))
if (setting($this->getDocumentSettingKey($type, 'price_name')) !== null
&& (trans(setting($this->getDocumentSettingKey($type, 'price_name'))) != setting($this->getDocumentSettingKey($type, 'price_name')))
) {
return setting($this->getSettingKey($type, 'price_name'));
return setting($this->getDocumentSettingKey($type, 'price_name'));
}
$translation = $this->getTextFromConfig($type, 'price');
@@ -1058,25 +1123,33 @@ abstract class Form extends Component
return 'invoices.price';
}
protected function getHideItemAmount($type, $hideItemAmount)
protected function getHideItemAmount($type, $hideItemAmount): bool
{
if (! empty($hideItemAmount)) {
return $hideItemAmount;
}
// if you use settting translation
if ($hideAmount = setting($this->getSettingKey($type, 'hide_amount'), false)) {
return $hideAmount;
}
$hide = $this->getHideFromConfig($type, 'amount');
if ($hide) {
return $hide;
}
// @todo what return value invoice or always false??
return setting('invoice.hide_amount', $hideAmount);
return false;
}
protected function getHideSettingItemAmount($type, $hideSettingItemAmount): bool
{
if (! empty($hideSettingItemAmount)) {
return $hideSettingItemAmount;
}
// if you use settting translation
if (setting($this->getDocumentSettingKey($type, 'hide_amount'), false)) {
return true;
}
return false;
}
protected function getTextItemAmount($type, $textItemAmount)
@@ -1101,7 +1174,7 @@ abstract class Form extends Component
}
// if you use settting translation
if ($hideDiscount = setting($this->getSettingKey($type, 'hide_discount'), false)) {
if ($hideDiscount = setting($this->getDocumentSettingKey($type, 'hide_discount'), false)) {
return $hideDiscount;
}
@@ -1122,7 +1195,7 @@ abstract class Form extends Component
}
// if you use settting translation
if ($settingCharLimit = setting($this->getSettingKey($type, 'item_search_chart_limit'), false)) {
if ($settingCharLimit = setting($this->getDocumentSettingKey($type, 'item_search_chart_limit'), false)) {
return $settingCharLimit;
}
@@ -1146,7 +1219,7 @@ abstract class Form extends Component
return $this->document->notes;
}
return setting($this->getSettingKey($this->type, 'notes'));
return setting($this->getDocumentSettingKey($this->type, 'notes'));
}
protected function getTextSectionAdvancedTitle($type, $textSectionAdvancedTitle)
@@ -1177,7 +1250,7 @@ abstract class Form extends Component
return $this->document->title;
}
return setting($this->getSettingKey($type, 'title'));
return setting($this->getDocumentSettingKey($type, 'title'));
}
protected function getSubheadingValue($type, $subheading)
@@ -1190,7 +1263,7 @@ abstract class Form extends Component
return $this->document->subheading;
}
return setting($this->getSettingKey($type, 'subheading'));
return setting($this->getDocumentSettingKey($type, 'subheading'));
}
protected function getFooterValue($footer)
@@ -1203,7 +1276,7 @@ abstract class Form extends Component
return $this->document->footer;
}
return setting($this->getSettingKey($this->type, 'footer'));
return setting($this->getDocumentSettingKey($this->type, 'footer'));
}
protected function getTypeCategory($type, $typeCategory)

View File

@@ -392,8 +392,8 @@ abstract class Index extends Component
foreach ($totals as $key => $total) {
$title = ($key == 'overdue') ? trans('general.overdue') : trans('documents.statuses.' . $key);
$href = route($route, ['search' => 'status:' . $key]);
$amount = money($total, default_currency(), true)->formatForHumans();
$tooltip = money($total, default_currency(), true)->format();
$amount = money($total)->formatForHumans();
$tooltip = money($total)->format();
$items[] = [
'title' => $title,

View File

@@ -11,7 +11,6 @@ use App\Abstracts\View\Component;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use Intervention\Image\Exception\NotReadableException;
use Image;
@@ -742,9 +741,7 @@ abstract class Show extends Component
return $textRecurringType;
}
$default_key = config('type.' . static::OBJECT_TYPE . '.' . $type . '.translation.prefix');
$translation = $this->getTextFromConfig($type, 'recurring_tye', $default_key);
$translation = config('type.' . static::OBJECT_TYPE . '.' . $type . '.translation.tab_document');
if (! empty($translation)) {
return $translation;
@@ -910,7 +907,7 @@ abstract class Show extends Component
return $template;
}
$documentTemplate = setting($this->getSettingKey($type, 'template'), 'default');
$documentTemplate = setting($this->getDocumentSettingKey($type, 'template'), 'default');
return $documentTemplate;
}
@@ -928,7 +925,7 @@ abstract class Show extends Component
if (! empty($media)) {
$path = $media->getDiskPath();
if (Storage::missing($path)) {
if (! $media->fileExists()) {
return $logo;
}
} else {
@@ -941,7 +938,7 @@ abstract class Show extends Component
$height = setting('invoice.logo_size_height');
if ($media) {
$image->make(Storage::get($path))->resize($width, $height)->encode();
$image->make($media->contents())->resize($width, $height)->encode();
} else {
$image->make($path)->resize($width, $height)->encode();
}
@@ -975,21 +972,28 @@ abstract class Show extends Component
return $backgroundColor;
}
if ($background_color = config('type.' . static::OBJECT_TYPE . '.' . $type . '.color', false)) {
return $background_color;
// checking setting color
$key = $this->getDocumentSettingKey($type, 'color');
if (! empty(setting($key))) {
$backgroundColor = setting($key);
}
if (! empty($alias = config('type.' . static::OBJECT_TYPE . '.' . $type . '.alias'))) {
$type = $alias . '.' . str_replace('-', '_', $type);
// checking config color
if (empty($backgroundColor) && $background_color = config('type.document.' . $type . '.color', false)) {
$backgroundColor = $background_color;
}
$backgroundColor = setting($this->getSettingKey($type, 'color'), '#55588b');
// set default color
if (empty($backgroundColor)) {
$backgroundColor = '#55588b';
}
return $this->getHexCodeOfTailwindClass($backgroundColor);
}
protected function getTextDocumentTitle($type, $textDocumentTitle)
{
{
if (! empty($textDocumentTitle)) {
return $textDocumentTitle;
}
@@ -998,7 +1002,7 @@ abstract class Show extends Component
return $this->document->title;
}
$key = $this->getSettingKey($type, 'title');
$key = $this->getDocumentSettingKey($type, 'title');
if (! empty(setting($key))) {
return setting($key);
@@ -1023,7 +1027,7 @@ abstract class Show extends Component
return $this->document->subheading;
}
$key = $this->getSettingKey($type, 'subheading');
$key = $this->getDocumentSettingKey($type, 'subheading');
if (!empty(setting($key))) {
return setting($key);
@@ -1153,8 +1157,8 @@ abstract class Show extends Component
}
// if you use settting translation
if (setting($this->getSettingKey($type, 'item_name'), 'items') == 'custom') {
if (empty($textItems = setting($this->getSettingKey($type, 'item_name_input')))) {
if (setting($this->getDocumentSettingKey($type, 'item_name'), 'items') == 'custom') {
if (empty($textItems = setting($this->getDocumentSettingKey($type, 'item_name_input')))) {
$textItems = 'general.items';
}
@@ -1177,8 +1181,8 @@ abstract class Show extends Component
}
// if you use settting translation
if (setting($this->getSettingKey($type, 'quantity_name'), 'quantity') === 'custom') {
if (empty($textQuantity = setting($this->getSettingKey($type, 'quantity_name_input')))) {
if (setting($this->getDocumentSettingKey($type, 'quantity_name'), 'quantity') === 'custom') {
if (empty($textQuantity = setting($this->getDocumentSettingKey($type, 'quantity_name_input')))) {
$textQuantity = 'invoices.quantity';
}
@@ -1201,8 +1205,8 @@ abstract class Show extends Component
}
// if you use settting translation
if (setting($this->getSettingKey($type, 'price_name'), 'price') === 'custom') {
if (empty($textPrice = setting($this->getSettingKey($type, 'price_name_input')))) {
if (setting($this->getDocumentSettingKey($type, 'price_name'), 'price') === 'custom') {
if (empty($textPrice = setting($this->getDocumentSettingKey($type, 'price_name_input')))) {
$textPrice = 'invoices.price';
}
@@ -1256,9 +1260,11 @@ abstract class Show extends Component
return $hideName;
}
$hideName = setting($this->getDocumentSettingKey($type, 'item_name'), false);
// if you use settting translation
if ($hideName = setting($this->getSettingKey($type, 'item_name'), false) && $hideName == 'hide') {
return $hideName;
if ($hideName === 'hide') {
return true;
}
$hide = $this->getHideFromConfig($type, 'name');
@@ -1267,8 +1273,7 @@ abstract class Show extends Component
return $hide;
}
// @todo what return value invoice or always false??
return setting('invoice.item_name', $hideName) == 'hide' ? true : false;
return false;
}
protected function getHideDescription($type, $hideDescription)
@@ -1278,8 +1283,8 @@ abstract class Show extends Component
}
// if you use settting translation
if ($hideDescription = setting($this->getSettingKey($type, 'hide_item_description'), false)) {
return $hideDescription;
if (setting($this->getDocumentSettingKey($type, 'hide_item_description'), false)) {
return true;
}
$hide = $this->getHideFromConfig($type, 'description');
@@ -1288,8 +1293,7 @@ abstract class Show extends Component
return $hide;
}
// @todo what return value invoice or always false??
return setting('invoice.hide_item_description', $hideDescription);
return false;
}
protected function getHideQuantity($type, $hideQuantity)
@@ -1298,9 +1302,11 @@ abstract class Show extends Component
return $hideQuantity;
}
$hideQuantity = setting($this->getDocumentSettingKey($type, 'quantity_name'), false);
// if you use settting translation
if ($hideQuantity = setting($this->getSettingKey($type, 'hide_quantity'), false) && $hideQuantity == 'hide') {
return $hideQuantity;
if ($hideQuantity === 'hide') {
return true;
}
$hide = $this->getHideFromConfig($type, 'quantity');
@@ -1309,8 +1315,7 @@ abstract class Show extends Component
return $hide;
}
// @todo what return value invoice or always false??
return setting('invoice.quantity_name', $hideQuantity) == 'hide' ? true : false;
return false;
}
protected function getHidePrice($type, $hidePrice)
@@ -1319,9 +1324,11 @@ abstract class Show extends Component
return $hidePrice;
}
$hidePrice = setting($this->getDocumentSettingKey($type, 'price_name'), false);
// if you use settting translation
if ($hidePrice = setting($this->getSettingKey($type, 'hide_price'), false) && $hidePrice == 'hide') {
return $hidePrice;
if ($hidePrice === 'hide') {
return true;
}
$hide = $this->getHideFromConfig($type, 'price');
@@ -1330,8 +1337,7 @@ abstract class Show extends Component
return $hide;
}
// @todo what return value invoice or always false??
return setting('invoice.price_name', $hidePrice) == 'hide' ? true : false;
return false;
}
protected function getHideDiscount($type, $hideDiscount)
@@ -1341,7 +1347,7 @@ abstract class Show extends Component
}
// if you use settting translation
if ($hideDiscount = setting($this->getSettingKey($type, 'hide_discount'), false)) {
if ($hideDiscount = setting($this->getDocumentSettingKey($type, 'hide_discount'), false)) {
return $hideDiscount;
}
@@ -1362,8 +1368,8 @@ abstract class Show extends Component
}
// if you use settting translation
if ($hideAmount = setting($this->getSettingKey($type, 'hide_amount'), false)) {
return $hideAmount;
if (setting($this->getDocumentSettingKey($type, 'hide_amount'), false)) {
return true;
}
$hide = $this->getHideFromConfig($type, 'amount');
@@ -1372,7 +1378,6 @@ abstract class Show extends Component
return $hide;
}
// @todo what return value invoice or always false??
return setting('invoice.hide_amount', $hideAmount);
return false;
}
}

View File

@@ -10,7 +10,6 @@ use App\Traits\Tailwind;
use App\Traits\ViewComponents;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use Intervention\Image\Exception\NotReadableException;
use Image;
@@ -210,7 +209,7 @@ abstract class Template extends Component
return $template;
}
$documentTemplate = setting($this->getSettingKey($type, 'template'), 'default');
$documentTemplate = setting($this->getDocumentSettingKey($type, 'template'), 'default');
return $documentTemplate;
}
@@ -228,7 +227,7 @@ abstract class Template extends Component
if (! empty($media)) {
$path = $media->getDiskPath();
if (Storage::missing($path)) {
if (! $media->fileExists()) {
return $logo;
}
} else {
@@ -241,7 +240,7 @@ abstract class Template extends Component
$height = setting('invoice.logo_size_height');
if ($media) {
$image->make(Storage::get($path))->resize($width, $height)->encode();
$image->make($media->contents())->resize($width, $height)->encode();
} else {
$image->make($path)->resize($width, $height)->encode();
}
@@ -275,16 +274,22 @@ abstract class Template extends Component
return $backgroundColor;
}
if ($background_color = config('type.document.' . $type . '.color', false)) {
return $background_color;
// checking setting color
$key = $this->getDocumentSettingKey($type, 'color');
if (! empty(setting($key))) {
$backgroundColor = setting($key);
}
if (! empty($alias = config('type.document.' . $type . '.alias'))) {
$type = $alias . '.' . str_replace('-', '_', $type);
// checking config color
if (empty($backgroundColor) && $background_color = config('type.document.' . $type . '.color', false)) {
$backgroundColor = $background_color;
}
$backgroundColor = setting($this->getSettingKey($type, 'color'), '#55588b');
// set default color
if (empty($backgroundColor)) {
$backgroundColor = '#55588b';
}
return $this->getHexCodeOfTailwindClass($backgroundColor);
}
@@ -299,7 +304,7 @@ abstract class Template extends Component
return $this->document->title;
}
$key = $this->getSettingKey($type, 'title');
$key = $this->getDocumentSettingKey($type, 'title');
if (! empty(setting($key))) {
return setting($key);
@@ -324,7 +329,7 @@ abstract class Template extends Component
return $this->document->subheading;
}
$key = $this->getSettingKey($type, 'subheading');
$key = $this->getDocumentSettingKey($type, 'subheading');
if (! empty(setting($key))) {
return setting($key);
@@ -454,18 +459,18 @@ abstract class Template extends Component
}
// if you use settting translation
if (setting($this->getSettingKey($type, 'item_name'), 'items') === 'custom') {
if (empty($textItems = setting($this->getSettingKey($type, 'item_name_input')))) {
if (setting($this->getDocumentSettingKey($type, 'item_name'), 'items') === 'custom') {
if (empty($textItems = setting($this->getDocumentSettingKey($type, 'item_name_input')))) {
$textItems = 'general.items';
}
return $textItems;
}
if (setting($this->getSettingKey($type, 'item_name')) !== null
&& (trans(setting($this->getSettingKey($type, 'item_name'))) != setting($this->getSettingKey($type, 'item_name')))
if (setting($this->getDocumentSettingKey($type, 'item_name')) !== null
&& (trans(setting($this->getDocumentSettingKey($type, 'item_name'))) != setting($this->getDocumentSettingKey($type, 'item_name')))
) {
return setting($this->getSettingKey($type, 'item_name'));
return setting($this->getDocumentSettingKey($type, 'item_name'));
}
$translation = $this->getTextFromConfig($type, 'items');
@@ -484,18 +489,18 @@ abstract class Template extends Component
}
// if you use settting translation
if (setting($this->getSettingKey($type, 'quantity_name'), 'quantity') === 'custom') {
if (empty($textQuantity = setting($this->getSettingKey($type, 'quantity_name_input')))) {
if (setting($this->getDocumentSettingKey($type, 'quantity_name'), 'quantity') === 'custom') {
if (empty($textQuantity = setting($this->getDocumentSettingKey($type, 'quantity_name_input')))) {
$textQuantity = 'invoices.quantity';
}
return $textQuantity;
}
if (setting($this->getSettingKey($type, 'quantity_name')) !== null
&& (trans(setting($this->getSettingKey($type, 'quantity_name'))) != setting($this->getSettingKey($type, 'quantity_name')))
if (setting($this->getDocumentSettingKey($type, 'quantity_name')) !== null
&& (trans(setting($this->getDocumentSettingKey($type, 'quantity_name'))) != setting($this->getDocumentSettingKey($type, 'quantity_name')))
) {
return setting($this->getSettingKey($type, 'quantity_name'));
return setting($this->getDocumentSettingKey($type, 'quantity_name'));
}
$translation = $this->getTextFromConfig($type, 'quantity');
@@ -514,18 +519,18 @@ abstract class Template extends Component
}
// if you use settting translation
if (setting($this->getSettingKey($type, 'price_name'), 'price') === 'custom') {
if (empty($textPrice = setting($this->getSettingKey($type, 'price_name_input')))) {
if (setting($this->getDocumentSettingKey($type, 'price_name'), 'price') === 'custom') {
if (empty($textPrice = setting($this->getDocumentSettingKey($type, 'price_name_input')))) {
$textPrice = 'invoices.price';
}
return $textPrice;
}
if (setting($this->getSettingKey($type, 'price_name')) !== null
&& (trans(setting($this->getSettingKey($type, 'price_name'))) != setting($this->getSettingKey($type, 'price_name')))
if (setting($this->getDocumentSettingKey($type, 'price_name')) !== null
&& (trans(setting($this->getDocumentSettingKey($type, 'price_name'))) != setting($this->getDocumentSettingKey($type, 'price_name')))
) {
return setting($this->getSettingKey($type, 'price_name'));
return setting($this->getDocumentSettingKey($type, 'price_name'));
}
$translation = $this->getTextFromConfig($type, 'price');
@@ -592,9 +597,11 @@ abstract class Template extends Component
return $hideName;
}
$hideName = setting($this->getDocumentSettingKey($type, 'item_name'), false);
// if you use settting translation
if ($hideName = setting($this->getSettingKey($type, 'item_name'), false) && $hideName == 'hide') {
return $hideName;
if ($hideName === 'hide') {
return true;
}
$hide = $this->getHideFromConfig($type, 'name');
@@ -603,8 +610,7 @@ abstract class Template extends Component
return $hide;
}
// @todo what return value invoice or always false??
return setting('invoice.item_name', $hideName) == 'hide' ? true : false;
return false;
}
protected function getHideDescription($type, $hideDescription)
@@ -614,8 +620,8 @@ abstract class Template extends Component
}
// if you use settting translation
if ($hideDescription = setting($this->getSettingKey($type, 'hide_item_description'), false)) {
return $hideDescription;
if (setting($this->getDocumentSettingKey($type, 'hide_item_description'), false)) {
return true;
}
$hide = $this->getHideFromConfig($type, 'description');
@@ -624,8 +630,7 @@ abstract class Template extends Component
return $hide;
}
// @todo what return value invoice or always false??
return setting('invoice.hide_item_description', $hideDescription);
return false;
}
protected function getHideQuantity($type, $hideQuantity)
@@ -634,9 +639,11 @@ abstract class Template extends Component
return $hideQuantity;
}
$hideQuantity = setting($this->getDocumentSettingKey($type, 'quantity_name'), false);
// if you use settting translation
if ($hideQuantity = setting($this->getSettingKey($type, 'hide_quantity'), false) && $hideQuantity == 'hide') {
return $hideQuantity;
if ($hideQuantity === 'hide') {
return true;
}
$hide = $this->getHideFromConfig($type, 'quantity');
@@ -645,8 +652,7 @@ abstract class Template extends Component
return $hide;
}
// @todo what return value invoice or always false??
return setting('invoice.quantity_name', $hideQuantity) == 'hide' ? true : false;
return false;
}
protected function getHidePrice($type, $hidePrice)
@@ -655,9 +661,11 @@ abstract class Template extends Component
return $hidePrice;
}
$hidePrice = setting($this->getDocumentSettingKey($type, 'price_name'), false);
// if you use settting translation
if ($hidePrice = setting($this->getSettingKey($type, 'hide_price'), false) && $hidePrice == 'hide') {
return $hidePrice;
if ($hidePrice === 'hide') {
return true;
}
$hide = $this->getHideFromConfig($type, 'price');
@@ -666,8 +674,7 @@ abstract class Template extends Component
return $hide;
}
// @todo what return value invoice or always false??
return setting('invoice.price_name', $hidePrice) == 'hide' ? true : false;
return false;
}
protected function getHideDiscount($type, $hideDiscount)
@@ -677,7 +684,7 @@ abstract class Template extends Component
}
// if you use settting translation
if ($hideDiscount = setting($this->getSettingKey($type, 'hide_discount'), false)) {
if ($hideDiscount = setting($this->getDocumentSettingKey($type, 'hide_discount'), false)) {
return $hideDiscount;
}
@@ -698,8 +705,8 @@ abstract class Template extends Component
}
// if you use settting translation
if ($hideAmount = setting($this->getSettingKey($type, 'hide_amount'), false)) {
return $hideAmount;
if (setting($this->getDocumentSettingKey($type, 'hide_amount'), false)) {
return true;
}
$hide = $this->getHideFromConfig($type, 'amount');
@@ -708,8 +715,7 @@ abstract class Template extends Component
return $hide;
}
// @todo what return value invoice or always false??
return setting('invoice.hide_amount', $hideAmount);
return false;
}
protected function getPrint($print)

View File

@@ -9,7 +9,6 @@ use App\Traits\Transactions;
use App\Utilities\Modules;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\Str;
use Intervention\Image\Facades\Image;
@@ -483,7 +482,7 @@ abstract class Show extends Component
return $template;
}
$transactionTemplate = setting($this->getSettingKey($type, 'template')) ?: 'default';
$transactionTemplate = setting($this->getTransactionSettingKey($type, 'template')) ?: 'default';
return $transactionTemplate;
}
@@ -501,7 +500,7 @@ abstract class Show extends Component
if (! empty($media)) {
$path = $media->getDiskPath();
if (Storage::missing($path)) {
if (! $media->fileExists()) {
return $logo;
}
} else {
@@ -514,7 +513,7 @@ abstract class Show extends Component
$height = setting('invoice.logo_size_height');
if ($media) {
$image->make(Storage::get($path))->resize($width, $height)->encode();
$image->make($media->contents())->resize($width, $height)->encode();
} else {
$image->make($path)->resize($width, $height)->encode();
}
@@ -1114,9 +1113,7 @@ abstract class Show extends Component
return $textRecurringType;
}
$default_key = config('type.transaction.' . $type . '.translation.transactions');
$translation = $this->getTextFromConfig($type, 'recurring_type', $default_key);
$translation = config('type.transaction.' . $type . '.translation.transactions');
if (! empty($translation)) {
return $translation;

View File

@@ -9,7 +9,6 @@ use App\Traits\Transactions;
use App\Utilities\Modules;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use Intervention\Image\Facades\Image;
use Intervention\Image\Exception\NotReadableException;
@@ -277,7 +276,7 @@ abstract class Template extends Component
if (!empty($media)) {
$path = $media->getDiskPath();
if (Storage::missing($path)) {
if (! $media->fileExists()) {
return $logo;
}
} else {
@@ -290,7 +289,7 @@ abstract class Template extends Component
$height = setting('invoice.logo_size_height');
if ($media) {
$image->make(Storage::get($path))->resize($width, $height)->encode();
$image->make($media->contents())->resize($width, $height)->encode();
} else {
$image->make($path)->resize($width, $height)->encode();
}