widget data
This commit is contained in:
parent
a44d9d156b
commit
9da40446e6
|
|
@ -28,6 +28,8 @@ abstract class Widget
|
|||
'header' => 'components.widgets.header',
|
||||
];
|
||||
|
||||
public array $data = [];
|
||||
|
||||
public function __construct($model = null)
|
||||
{
|
||||
$this->model = $model;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,13 @@ class AccountBalance extends Widget
|
|||
public $report_class = 'App\Reports\IncomeExpense';
|
||||
|
||||
public function show()
|
||||
{
|
||||
$this->setData();
|
||||
|
||||
return $this->view('widgets.account_balance', $this->data);
|
||||
}
|
||||
|
||||
public function setData(): void
|
||||
{
|
||||
$accounts = Account::with('income_transactions', 'expense_transactions')->enabled()->take(5)->get()->map(function($account) {
|
||||
$account->balance_formatted = money($account->balance, $account->currency_code);
|
||||
|
|
@ -21,8 +28,8 @@ class AccountBalance extends Widget
|
|||
return $account;
|
||||
})->all();
|
||||
|
||||
return $this->view('widgets.account_balance', [
|
||||
$this->data = [
|
||||
'accounts' => $accounts,
|
||||
]);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,13 @@ class CashFlow extends Widget
|
|||
public $period;
|
||||
|
||||
public function show()
|
||||
{
|
||||
$this->setData();
|
||||
|
||||
return $this->view('widgets.cash_flow', $this->data);
|
||||
}
|
||||
|
||||
public function setData(): void
|
||||
{
|
||||
$this->setFilter();
|
||||
|
||||
|
|
@ -66,10 +73,10 @@ class CashFlow extends Widget
|
|||
'profit_for_humans' => $profit_amount->formatForHumans(),
|
||||
];
|
||||
|
||||
return $this->view('widgets.cash_flow', [
|
||||
$this->data = [
|
||||
'chart' => $chart,
|
||||
'totals' => $totals,
|
||||
]);
|
||||
];
|
||||
}
|
||||
|
||||
public function setFilter(): void
|
||||
|
|
|
|||
|
|
@ -11,11 +11,17 @@ class Currencies extends Widget
|
|||
|
||||
public function show()
|
||||
{
|
||||
$currencies = Currency::enabled()->take(5)->get();
|
||||
$this->setData();
|
||||
|
||||
return $this->view('widgets.currencies', [
|
||||
'currencies' => $currencies,
|
||||
]);
|
||||
return $this->view('widgets.currencies', $this->data);
|
||||
}
|
||||
|
||||
}
|
||||
public function setData(): void
|
||||
{
|
||||
$currencies = Currency::enabled()->take(5)->get();
|
||||
|
||||
$this->data = [
|
||||
'currencies' => $currencies,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,13 @@ class ExpensesByCategory extends Widget
|
|||
public $report_class = 'App\Reports\ExpenseSummary';
|
||||
|
||||
public function show()
|
||||
{
|
||||
$this->setData();
|
||||
|
||||
return $this->view('widgets.donut_chart', $this->data);
|
||||
}
|
||||
|
||||
public function setData(): void
|
||||
{
|
||||
Category::with('expense_transactions')->expense()->withSubCategory()->getWithoutChildren()->each(function ($category) {
|
||||
$amount = 0;
|
||||
|
|
@ -30,8 +37,8 @@ class ExpensesByCategory extends Widget
|
|||
$chart->options['legend']['width'] = 160;
|
||||
$chart->options['legend']['position'] = 'right';
|
||||
|
||||
return $this->view('widgets.donut_chart', [
|
||||
$this->data = [
|
||||
'chart' => $chart,
|
||||
]);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,13 @@ class Payables extends Widget
|
|||
public $report_class = 'Modules\AgedReceivablesPayables\Reports\AgedPayables';
|
||||
|
||||
public function show()
|
||||
{
|
||||
$this->setData();
|
||||
|
||||
return $this->view('widgets.receivables_payables', $this->data);
|
||||
}
|
||||
|
||||
public function setData(): void
|
||||
{
|
||||
$open = $overdue = 0;
|
||||
|
||||
|
|
@ -68,12 +75,12 @@ class Payables extends Widget
|
|||
|
||||
$grand_total_text = trans('widgets.total_unpaid_bills');
|
||||
|
||||
return $this->view('widgets.receivables_payables', [
|
||||
$this->data = [
|
||||
'totals' => $totals,
|
||||
'has_progress' => $has_progress,
|
||||
'progress' => $progress,
|
||||
'periods' => $periods,
|
||||
'grand_total_text' => $grand_total_text,
|
||||
]);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,13 @@ class ProfitLoss extends Widget
|
|||
public $period;
|
||||
|
||||
public function show()
|
||||
{
|
||||
$this->setData();
|
||||
|
||||
return $this->view('widgets.bar_chart', $this->data);
|
||||
}
|
||||
|
||||
public function setData(): void
|
||||
{
|
||||
$this->setFilter();
|
||||
|
||||
|
|
@ -44,9 +51,9 @@ class ProfitLoss extends Widget
|
|||
->setDataset(trans_choice('general.incomes', 1), 'column', array_values($this->getIncome()))
|
||||
->setDataset(trans_choice('general.expenses', 1), 'column', array_values($this->getExpense()));
|
||||
|
||||
return $this->view('widgets.bar_chart', [
|
||||
$this->data = [
|
||||
'chart' => $chart,
|
||||
]);
|
||||
];
|
||||
}
|
||||
|
||||
public function setFilter(): void
|
||||
|
|
|
|||
|
|
@ -15,6 +15,13 @@ class Receivables extends Widget
|
|||
public $report_class = 'Modules\AgedReceivablesPayables\Reports\AgedReceivables';
|
||||
|
||||
public function show()
|
||||
{
|
||||
$this->setData();
|
||||
|
||||
return $this->view('widgets.receivables_payables', $this->data);
|
||||
}
|
||||
|
||||
public function setData(): void
|
||||
{
|
||||
$open = $overdue = 0;
|
||||
|
||||
|
|
@ -68,12 +75,12 @@ class Receivables extends Widget
|
|||
|
||||
$grand_total_text = trans('widgets.total_unpaid_invoices');
|
||||
|
||||
return $this->view('widgets.receivables_payables', [
|
||||
$this->data = [
|
||||
'totals' => $totals,
|
||||
'has_progress' => $has_progress,
|
||||
'progress' => $progress,
|
||||
'periods' => $periods,
|
||||
'grand_total_text' => $grand_total_text,
|
||||
]);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue