mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-14 00:04:24 +00:00
Some changes in the charts and range thing.
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
use Carbon\Carbon as Carbon;
|
use Carbon\Carbon as Carbon;
|
||||||
use Firefly\Storage\Account\AccountRepositoryInterface as ARI;
|
use Firefly\Storage\Account\AccountRepositoryInterface as ARI;
|
||||||
|
use Firefly\Helper\Toolkit\Toolkit as tk;
|
||||||
|
|
||||||
class ChartController extends BaseController
|
class ChartController extends BaseController
|
||||||
{
|
{
|
||||||
@@ -16,17 +17,16 @@ class ChartController extends BaseController
|
|||||||
/**
|
/**
|
||||||
* Show home charts.
|
* Show home charts.
|
||||||
*/
|
*/
|
||||||
public function home($account = null)
|
public function homeAccount($account = null)
|
||||||
{
|
{
|
||||||
|
list($start,$end) = tk::getDateRange();
|
||||||
|
$current = clone $start;
|
||||||
|
|
||||||
// chart
|
// chart
|
||||||
$chart = App::make('gchart');
|
$chart = App::make('gchart');
|
||||||
$chart->addColumn('Day of the month', 'date');
|
$chart->addColumn('Day of the month', 'date');
|
||||||
|
|
||||||
// date
|
|
||||||
$today = new Carbon;
|
|
||||||
$past = clone $today;
|
|
||||||
$past->subMonth();
|
|
||||||
$current = clone $past;
|
|
||||||
|
|
||||||
if (is_null($account)) {
|
if (is_null($account)) {
|
||||||
// get accounts:
|
// get accounts:
|
||||||
@@ -36,7 +36,7 @@ class ChartController extends BaseController
|
|||||||
$chart->addColumn($account->name, 'number');
|
$chart->addColumn($account->name, 'number');
|
||||||
}
|
}
|
||||||
|
|
||||||
while ($current <= $today) {
|
while ($current <= $end) {
|
||||||
$row = [clone $current];
|
$row = [clone $current];
|
||||||
|
|
||||||
// loop accounts:
|
// loop accounts:
|
||||||
@@ -52,7 +52,7 @@ class ChartController extends BaseController
|
|||||||
return View::make('error')->with('message', 'No account found.');
|
return View::make('error')->with('message', 'No account found.');
|
||||||
}
|
}
|
||||||
$chart->addColumn($account->name, 'number');
|
$chart->addColumn($account->name, 'number');
|
||||||
while ($current <= $today) {
|
while ($current <= $end) {
|
||||||
$row = [clone $current, $account->balance(clone $current)];
|
$row = [clone $current, $account->balance(clone $current)];
|
||||||
$current->addDay();
|
$current->addDay();
|
||||||
$chart->addRowArray($row);
|
$chart->addRowArray($row);
|
||||||
|
@@ -20,6 +20,10 @@ class HomeController extends BaseController
|
|||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
|
// get preferred viewing range
|
||||||
|
$viewRange = $this->preferences->get('viewRange','week');
|
||||||
|
|
||||||
|
|
||||||
// get list setting:
|
// get list setting:
|
||||||
$pref = $this->preferences->get('frontpageAccounts', []);
|
$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']);
|
Route::get('/', ['uses' => 'HomeController@index', 'as' => 'index']);
|
||||||
|
|
||||||
// chart controller
|
// 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
|
// preferences controller
|
||||||
Route::get('/preferences', ['uses' => 'PreferencesController@index', 'as' => 'preferences']);
|
Route::get('/preferences', ['uses' => 'PreferencesController@index', 'as' => 'preferences']);
|
||||||
|
@@ -32,8 +32,11 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
@else
|
@else
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- ACCOUNTS -->
|
<!-- ACCOUNTS -->
|
||||||
<div class="row" style="border-top:1px #eee solid;">
|
<div class="row">
|
||||||
@foreach($accounts as $index => $account)
|
@foreach($accounts as $index => $account)
|
||||||
<div class="col-lg-6">
|
<div class="col-lg-6">
|
||||||
<h4>{{{$account->name}}} chart</h4>
|
<h4>{{{$account->name}}} chart</h4>
|
||||||
@@ -62,6 +65,32 @@
|
|||||||
@endforeach
|
@endforeach
|
||||||
</div>
|
</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
|
@endif
|
||||||
|
|
||||||
@stop
|
@stop
|
||||||
|
@@ -13,7 +13,7 @@ function drawAccountChart() {
|
|||||||
var accountID = obj.data('id').toString();
|
var accountID = obj.data('id').toString();
|
||||||
var holderID = $(v).attr('id').toString();
|
var holderID = $(v).attr('id').toString();
|
||||||
console.log('AccountID: ' + accountID + ', ' + 'holderID ' + holderID);
|
console.log('AccountID: ' + accountID + ', ' + 'holderID ' + holderID);
|
||||||
var URL = 'chart/home/' + accountID;
|
var URL = 'chart/home/account/' + accountID;
|
||||||
console.log('URL: ' + URL);
|
console.log('URL: ' + URL);
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user