mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-19 04:49:30 +00:00
More extensions and views. First home view is semi-complete, time to write some tests again.
This commit is contained in:
@@ -5,28 +5,31 @@ use Firefly\Storage\Account\AccountRepositoryInterface as ARI;
|
||||
class AccountController extends \BaseController
|
||||
{
|
||||
|
||||
public function __construct(ARI $accounts) {
|
||||
public function __construct(ARI $accounts)
|
||||
{
|
||||
$this->accounts = $accounts;
|
||||
|
||||
View::share('menu', 'accounts');
|
||||
}
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$all = $this->accounts->get();
|
||||
$list = [
|
||||
'personal' => [],
|
||||
'personal' => [],
|
||||
'beneficiaries' => [],
|
||||
'initial' => [],
|
||||
'cash' => []
|
||||
'initial' => [],
|
||||
'cash' => []
|
||||
];
|
||||
|
||||
foreach($all as $account) {
|
||||
switch($account->accounttype->description) {
|
||||
foreach ($all as $account) {
|
||||
// @codeCoverageIgnoreStart
|
||||
switch ($account->accounttype->description) {
|
||||
case 'Default account':
|
||||
$list['personal'][] = $account;
|
||||
break;
|
||||
@@ -41,10 +44,11 @@ class AccountController extends \BaseController
|
||||
break;
|
||||
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
|
||||
return View::make('accounts.index')->with('accounts',$list);
|
||||
}
|
||||
return View::make('accounts.index')->with('accounts', $list);
|
||||
}
|
||||
//
|
||||
//
|
||||
/**
|
||||
@@ -73,16 +77,17 @@ class AccountController extends \BaseController
|
||||
// }
|
||||
//
|
||||
//
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param Account $account
|
||||
* @return Response
|
||||
*/
|
||||
public function show(Account $account)
|
||||
{
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
//
|
||||
//
|
||||
// /**
|
||||
|
||||
@@ -6,6 +6,8 @@ use Firefly\Storage\Account\AccountRepositoryInterface as ARI;
|
||||
class ChartController extends BaseController
|
||||
{
|
||||
|
||||
protected $accounts;
|
||||
|
||||
public function __construct(ARI $accounts)
|
||||
{
|
||||
$this->accounts = $accounts;
|
||||
@@ -14,7 +16,7 @@ class ChartController extends BaseController
|
||||
/**
|
||||
* Show home charts.
|
||||
*/
|
||||
public function home(Account $account = null)
|
||||
public function home($account = null)
|
||||
{
|
||||
// chart
|
||||
$chart = App::make('gchart');
|
||||
@@ -45,9 +47,13 @@ class ChartController extends BaseController
|
||||
$chart->addRowArray($row);
|
||||
}
|
||||
} else {
|
||||
$account = $this->accounts->find($account);
|
||||
if (is_null($account)) {
|
||||
return View::make('error')->with('message', 'No account found.');
|
||||
}
|
||||
$chart->addColumn($account->name, 'number');
|
||||
while ($current <= $today) {
|
||||
$row = [clone $current,$account->balance(clone $current)];
|
||||
$row = [clone $current, $account->balance(clone $current)];
|
||||
$current->addDay();
|
||||
$chart->addRowArray($row);
|
||||
}
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
<?php
|
||||
use Firefly\Helper\Preferences\PreferencesHelperInterface as PHI;
|
||||
use Firefly\Storage\Account\AccountRepositoryInterface as ARI;
|
||||
use Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface as TJRI;
|
||||
|
||||
|
||||
class HomeController extends BaseController
|
||||
{
|
||||
protected $accounts;
|
||||
protected $preferences;
|
||||
protected $tj;
|
||||
|
||||
public function __construct(ARI $accounts, PHI $preferences)
|
||||
public function __construct(ARI $accounts, PHI $preferences, TJRI $tj)
|
||||
{
|
||||
$this->accounts = $accounts;
|
||||
$this->preferences = $preferences;
|
||||
$this->tj = $tj;
|
||||
View::share('menu', 'home');
|
||||
}
|
||||
|
||||
@@ -28,6 +31,11 @@ class HomeController extends BaseController
|
||||
$list = $this->accounts->getByIds($pref->data);
|
||||
}
|
||||
|
||||
// get transactions for each account:
|
||||
foreach ($list as $account) {
|
||||
$account->transactionList = $this->tj->getByAccount($account,10);
|
||||
}
|
||||
|
||||
|
||||
// build the home screen:
|
||||
return View::make('index')->with('count', $count)->with('accounts', $list);
|
||||
|
||||
Reference in New Issue
Block a user