mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-11-22 08:56:39 -06:00
Some changes in the charts and range thing.
This commit is contained in:
parent
c7d3ef6a97
commit
5e8cfb512b
@ -2,6 +2,7 @@
|
||||
|
||||
use Carbon\Carbon as Carbon;
|
||||
use Firefly\Storage\Account\AccountRepositoryInterface as ARI;
|
||||
use Firefly\Helper\Toolkit\Toolkit as tk;
|
||||
|
||||
class ChartController extends BaseController
|
||||
{
|
||||
@ -16,17 +17,16 @@ class ChartController extends BaseController
|
||||
/**
|
||||
* Show home charts.
|
||||
*/
|
||||
public function home($account = null)
|
||||
public function homeAccount($account = null)
|
||||
{
|
||||
list($start,$end) = tk::getDateRange();
|
||||
$current = clone $start;
|
||||
|
||||
// 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:
|
||||
@ -36,7 +36,7 @@ class ChartController extends BaseController
|
||||
$chart->addColumn($account->name, 'number');
|
||||
}
|
||||
|
||||
while ($current <= $today) {
|
||||
while ($current <= $end) {
|
||||
$row = [clone $current];
|
||||
|
||||
// loop accounts:
|
||||
@ -52,7 +52,7 @@ class ChartController extends BaseController
|
||||
return View::make('error')->with('message', 'No account found.');
|
||||
}
|
||||
$chart->addColumn($account->name, 'number');
|
||||
while ($current <= $today) {
|
||||
while ($current <= $end) {
|
||||
$row = [clone $current, $account->balance(clone $current)];
|
||||
$current->addDay();
|
||||
$chart->addRowArray($row);
|
||||
|
@ -20,6 +20,10 @@ class HomeController extends BaseController
|
||||
|
||||
public function index()
|
||||
{
|
||||
// get preferred viewing range
|
||||
$viewRange = $this->preferences->get('viewRange','week');
|
||||
|
||||
|
||||
// get list setting:
|
||||
$pref = $this->preferences->get('frontpageAccounts', []);
|
||||
|
||||
|
44
app/lib/Firefly/Helper/Toolkit/Toolkit.php
Normal file
44
app/lib/Firefly/Helper/Toolkit/Toolkit.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace Firefly\Helper\Toolkit;
|
||||
|
||||
|
||||
class Toolkit
|
||||
{
|
||||
|
||||
/**
|
||||
* Based on the preference 'viewRange' and other variables I have not yet thought of,
|
||||
* this method will return a date range that defines the 'current' period of time.
|
||||
*
|
||||
* ie. the current week or month.
|
||||
*
|
||||
* $start is always the past, $end is 'now' or at least later.
|
||||
*/
|
||||
public static function getDateRange()
|
||||
{
|
||||
$preferences = \App::make('Firefly\Helper\Preferences\PreferencesHelperInterface');
|
||||
$viewRange = $preferences->get('viewRange', 'week');
|
||||
|
||||
// as you can see, this method now only supports "right now":
|
||||
$now = new \Carbon\Carbon;
|
||||
$start = clone $now;
|
||||
$end = clone $now;
|
||||
|
||||
|
||||
switch ($viewRange->data) {
|
||||
case 'week':
|
||||
$start->startOfWeek();
|
||||
$end->endOfWeek();
|
||||
break;
|
||||
default:
|
||||
case 'month':
|
||||
$start->startOfMonth();
|
||||
$end->endOfMonth();
|
||||
break;
|
||||
}
|
||||
return [$start, $end];
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
8
app/lib/Firefly/Helper/Toolkit/ToolkitInterface.php
Normal file
8
app/lib/Firefly/Helper/Toolkit/ToolkitInterface.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Firefly\Helper\Toolkit;
|
||||
|
||||
|
||||
class ToolkitInterface {
|
||||
|
||||
}
|
@ -6,7 +6,7 @@ Route::group(['before' => 'auth'], function () {
|
||||
Route::get('/', ['uses' => 'HomeController@index', 'as' => 'index']);
|
||||
|
||||
// chart controller
|
||||
Route::get('/chart/home/{account?}', ['uses' => 'ChartController@home', 'as' => 'chart.home']);
|
||||
Route::get('/chart/home/account/{account?}', ['uses' => 'ChartController@homeAccount', 'as' => 'chart.home']);
|
||||
|
||||
// preferences controller
|
||||
Route::get('/preferences', ['uses' => 'PreferencesController@index', 'as' => 'preferences']);
|
||||
|
@ -32,8 +32,11 @@
|
||||
</p>
|
||||
</div>
|
||||
@else
|
||||
|
||||
|
||||
|
||||
<!-- ACCOUNTS -->
|
||||
<div class="row" style="border-top:1px #eee solid;">
|
||||
<div class="row">
|
||||
@foreach($accounts as $index => $account)
|
||||
<div class="col-lg-6">
|
||||
<h4>{{{$account->name}}} chart</h4>
|
||||
@ -62,6 +65,32 @@
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
|
||||
<!-- week / month / year navigation -->
|
||||
<div class="row">
|
||||
<div class="col-lg-2 col-sm-6 col-md-2">
|
||||
<a href="#" class="btn btn-default btn-xs">Previous [period]</a>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-offset-8 col-lg-2 col-sm-6 col-md-offset-8 col-md-2" style="text-align: right;">
|
||||
<a href="#" class="btn btn-default btn-xs">Next [period]</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Beneficiaries, categories and budget pie charts: -->
|
||||
<div class="row">
|
||||
<div class="col-lg-4 col-sm-6 col-md-6">
|
||||
<h4>Beneficiaries</h4>
|
||||
</div>
|
||||
<div class="col-lg-4 col-sm-6 col-md-6">
|
||||
<h4>Categories</h4>
|
||||
</div>
|
||||
<div class="col-lg-4 col-sm-6 col-md-6">
|
||||
<h4>Budgets</h4>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@endif
|
||||
|
||||
@stop
|
||||
|
@ -13,7 +13,7 @@ function drawAccountChart() {
|
||||
var accountID = obj.data('id').toString();
|
||||
var holderID = $(v).attr('id').toString();
|
||||
console.log('AccountID: ' + accountID + ', ' + 'holderID ' + holderID);
|
||||
var URL = 'chart/home/' + accountID;
|
||||
var URL = 'chart/home/account/' + accountID;
|
||||
console.log('URL: ' + URL);
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user