mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-06 12:45:30 +00:00
Made big headway in preference management, accounts, importing stuff, etc. etc.
This commit is contained in:
@@ -1,23 +1,50 @@
|
||||
<?php
|
||||
|
||||
//use Firefly\Storage\Account\AccountRepositoryInterface as ARI;
|
||||
use Firefly\Storage\Account\AccountRepositoryInterface as ARI;
|
||||
|
||||
class AccountController extends \BaseController
|
||||
{
|
||||
|
||||
// public function __construct(ARI $accounts) {
|
||||
// $this->accounts = $accounts;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Display a listing of the resource.
|
||||
// *
|
||||
// * @return Response
|
||||
// */
|
||||
// public function index()
|
||||
// {
|
||||
//
|
||||
// }
|
||||
public function __construct(ARI $accounts) {
|
||||
$this->accounts = $accounts;
|
||||
|
||||
View::share('menu', 'accounts');
|
||||
}
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$all = $this->accounts->get();
|
||||
$list = [
|
||||
'personal' => [],
|
||||
'beneficiaries' => [],
|
||||
'initial' => [],
|
||||
'cash' => []
|
||||
];
|
||||
|
||||
foreach($all as $account) {
|
||||
switch($account->accounttype->description) {
|
||||
case 'Default account':
|
||||
$list['personal'][] = $account;
|
||||
break;
|
||||
case 'Cash account':
|
||||
$list['cash'][] = $account;
|
||||
break;
|
||||
case 'Initial balance account':
|
||||
$list['initial'][] = $account;
|
||||
break;
|
||||
case 'Beneficiary account':
|
||||
$list['beneficiaries'][] = $account;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return View::make('accounts.index')->with('accounts',$list);
|
||||
}
|
||||
//
|
||||
//
|
||||
/**
|
||||
@@ -46,16 +73,16 @@ class AccountController extends \BaseController
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * Display the specified resource.
|
||||
// *
|
||||
// * @param int $id
|
||||
// * @return Response
|
||||
// */
|
||||
// public function show($id)
|
||||
// {
|
||||
// //
|
||||
// }
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param Account $account
|
||||
* @return Response
|
||||
*/
|
||||
public function show(Account $account)
|
||||
{
|
||||
|
||||
}
|
||||
//
|
||||
//
|
||||
// /**
|
||||
|
61
app/controllers/ChartController.php
Normal file
61
app/controllers/ChartController.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
use Carbon\Carbon as Carbon;
|
||||
use Firefly\Storage\Account\AccountRepositoryInterface as ARI;
|
||||
|
||||
class ChartController extends BaseController
|
||||
{
|
||||
|
||||
public function __construct(ARI $accounts)
|
||||
{
|
||||
$this->accounts = $accounts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show home charts.
|
||||
*/
|
||||
public function home(Account $account = null)
|
||||
{
|
||||
// chart
|
||||
$chart = App::make('gchart');
|
||||
$chart->addColumn('Day of the month', 'date');
|
||||
|
||||
// date
|
||||
$today = new Carbon;
|
||||
$past = clone $today;
|
||||
$past->subMonth();
|
||||
$current = clone $past;
|
||||
|
||||
if (is_null($account)) {
|
||||
// get accounts:
|
||||
$accounts = $this->accounts->getActiveDefault();
|
||||
|
||||
foreach ($accounts as $account) {
|
||||
$chart->addColumn($account->name, 'number');
|
||||
}
|
||||
|
||||
while ($current <= $today) {
|
||||
$row = [clone $current];
|
||||
|
||||
// loop accounts:
|
||||
foreach ($accounts as $account) {
|
||||
$row[] = $account->balance(clone $current);
|
||||
}
|
||||
$current->addDay();
|
||||
$chart->addRowArray($row);
|
||||
}
|
||||
} else {
|
||||
$chart->addColumn($account->name, 'number');
|
||||
while ($current <= $today) {
|
||||
$row = [clone $current,$account->balance(clone $current)];
|
||||
$current->addDay();
|
||||
$chart->addRowArray($row);
|
||||
}
|
||||
}
|
||||
|
||||
$chart->generate();
|
||||
return $chart->getData();
|
||||
|
||||
|
||||
}
|
||||
}
|
@@ -1,19 +1,35 @@
|
||||
<?php
|
||||
use Carbon\Carbon as Carbon;
|
||||
use Firefly\Helper\Preferences\PreferencesHelperInterface as PHI;
|
||||
use Firefly\Storage\Account\AccountRepositoryInterface as ARI;
|
||||
|
||||
class HomeController extends BaseController {
|
||||
|
||||
public function __construct(ARI $accounts) {
|
||||
class HomeController extends BaseController
|
||||
{
|
||||
protected $accounts;
|
||||
protected $preferences;
|
||||
|
||||
public function __construct(ARI $accounts, PHI $preferences)
|
||||
{
|
||||
$this->accounts = $accounts;
|
||||
$this->preferences = $preferences;
|
||||
View::share('menu', 'home');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
// get list setting:
|
||||
$pref = $this->preferences->get('frontpageAccounts', []);
|
||||
|
||||
// get the accounts to display on the home screen:
|
||||
$count = $this->accounts->count();
|
||||
if ($pref->data == []) {
|
||||
$list = $this->accounts->getActiveDefault();
|
||||
} else {
|
||||
$list = $this->accounts->getByIds($pref->data);
|
||||
}
|
||||
|
||||
|
||||
// build the home screen:
|
||||
|
||||
return View::make('index')->with('count',$count);
|
||||
}
|
||||
return View::make('index')->with('count', $count)->with('accounts', $list);
|
||||
}
|
||||
}
|
@@ -9,6 +9,7 @@ class MigrationController extends BaseController
|
||||
public function __construct(MHI $migration)
|
||||
{
|
||||
$this->migration = $migration;
|
||||
View::share('menu', 'home');
|
||||
|
||||
}
|
||||
|
||||
|
39
app/controllers/PreferencesController.php
Normal file
39
app/controllers/PreferencesController.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
use Firefly\Helper\Preferences\PreferencesHelperInterface as PHI;
|
||||
use Firefly\Storage\Account\AccountRepositoryInterface as ARI;
|
||||
|
||||
class PreferencesController extends BaseController
|
||||
{
|
||||
protected $accounts;
|
||||
protected $preferences;
|
||||
|
||||
public function __construct(ARI $accounts, PHI $preferences)
|
||||
{
|
||||
|
||||
$this->accounts = $accounts;
|
||||
$this->preferences = $preferences;
|
||||
View::share('menu', 'home');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$accounts = $this->accounts->getDefault();
|
||||
|
||||
// pref:
|
||||
$frontpage = $this->preferences->get('frontpageAccounts', []);
|
||||
return View::make('preferences.index')->with('accounts', $accounts)->with('frontpageAccounts', $frontpage);
|
||||
}
|
||||
|
||||
public function postIndex()
|
||||
{
|
||||
$frontpageAccounts = [];
|
||||
foreach(Input::get('frontpageAccounts') as $id) {
|
||||
$frontpageAccounts[] = intval($id);
|
||||
}
|
||||
$this->preferences->set('frontpageAccounts',$frontpageAccounts);
|
||||
Session::flash('success', 'Preferences saved!');
|
||||
return Redirect::route('preferences');
|
||||
}
|
||||
|
||||
}
|
@@ -7,6 +7,7 @@ class ProfileController extends BaseController
|
||||
|
||||
public function __construct(URI $user) {
|
||||
$this->user = $user;
|
||||
View::share('menu', 'home');
|
||||
}
|
||||
|
||||
public function index()
|
||||
|
Reference in New Issue
Block a user