mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-29 18:20:01 +00:00
Small fixes and updates. [skip ci]
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
use Firefly\Helper\Preferences\PreferencesHelperInterface as PHI;
|
||||
use Firefly\Storage\Account\AccountRepositoryInterface as ARI;
|
||||
use Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface as TJRI;
|
||||
use Firefly\Helper\Toolkit\ToolkitInterface as Toolkit;
|
||||
use Firefly\Storage\Budget\BudgetRepositoryInterface as BRI;
|
||||
|
||||
/**
|
||||
* Class HomeController
|
||||
@@ -11,21 +13,24 @@ class HomeController extends BaseController
|
||||
protected $_accounts;
|
||||
protected $_preferences;
|
||||
protected $_journal;
|
||||
protected $_budgets;
|
||||
protected $_tk;
|
||||
|
||||
/**
|
||||
* @param ARI $accounts
|
||||
* @param PHI $preferences
|
||||
* @param TJRI $journal
|
||||
*/
|
||||
public function __construct(ARI $accounts, PHI $preferences, TJRI $journal)
|
||||
public function __construct(ARI $accounts, PHI $preferences, TJRI $journal, Toolkit $toolkit, BRI $budgets)
|
||||
{
|
||||
$this->_accounts = $accounts;
|
||||
$this->_preferences = $preferences;
|
||||
$this->_journal = $journal;
|
||||
$this->_tk = $toolkit;
|
||||
$this->_budgets = $budgets;
|
||||
View::share('menu', 'home');
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -33,33 +38,36 @@ class HomeController extends BaseController
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// count, maybe we need some introductionary text to show:
|
||||
// count, maybe we need some introducing text to show:
|
||||
$count = $this->_accounts->count();
|
||||
|
||||
|
||||
// get the preference for the home accounts to show:
|
||||
$frontpage = $this->_preferences->get('frontpageAccounts', []);
|
||||
if($frontpage->data == []) {
|
||||
if ($frontpage->data == []) {
|
||||
$accounts = $this->_accounts->getActiveDefault();
|
||||
} else {
|
||||
$accounts = $this->_accounts->getByIds($frontpage->data);
|
||||
}
|
||||
|
||||
|
||||
// get the budgets for this period:
|
||||
$dates = $this->_tk->getDateRange();
|
||||
$budgets = $this->_budgets->getWithRepetitionsInPeriod($dates[0],\Session::get('range'));
|
||||
|
||||
$transactions = [];
|
||||
foreach($accounts as $account) {
|
||||
$transactions[] = [$this->_journal->getByAccount($account,15),$account];
|
||||
foreach ($accounts as $account) {
|
||||
$transactions[] = [$this->_journal->getByAccount($account, 15), $account];
|
||||
}
|
||||
|
||||
if(count($transactions) % 2 == 0) {
|
||||
if (count($transactions) % 2 == 0) {
|
||||
$transactions = array_chunk($transactions, 2);
|
||||
} elseif(count($transactions) == 1) {
|
||||
} elseif (count($transactions) == 1) {
|
||||
$transactions = array_chunk($transactions, 3);
|
||||
} else {
|
||||
$transactions = array_chunk($transactions, 3);
|
||||
}
|
||||
// build the home screen:
|
||||
return View::make('index')->with('count', $count)->with('transactions',$transactions);
|
||||
return View::make('index')->with('count', $count)->with('transactions', $transactions)->with('budgets',$budgets);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user