Skip to content

Firefly III: a personal finances manager

Clean up filters, extend index and small fix for title.

James Coleab9e5f716d92
diff --git a/app/filters.php b/app/filters.php
index 45cb747772..b784c9bb3d 100644
--- a/app/filters.php
+++ b/app/filters.php
@@ -7,9 +7,7 @@ App::before(
if (Auth::check()) {
$toolkit = App::make('Firefly\Helper\Toolkit\ToolkitInterface');
- $toolkit->getDateRange($request);
- $toolkit->getReminders();
-
+ $toolkit->getDateRange();
}
}
diff --git a/app/lib/Firefly/Helper/Toolkit/Toolkit.php b/app/lib/Firefly/Helper/Toolkit/Toolkit.php
index c968bf0ca3..3dd5f6def5 100644
--- a/app/lib/Firefly/Helper/Toolkit/Toolkit.php
+++ b/app/lib/Firefly/Helper/Toolkit/Toolkit.php
@@ -3,29 +3,35 @@
namespace Firefly\Helper\Toolkit;
use Carbon\Carbon;
-use Illuminate\Http\Request;
/**
* Class Toolkit
*
* @package Firefly\Helper\Toolkit
* @SuppressWarnings(PHPMD.CamelCaseMethodName)
- * @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
*/
class Toolkit implements ToolkitInterface
{
/**
- * @param Request $request
+ * Lots of code in Firefly III still depends on session['start'], session['end'] and
+ * session['range'] to be available, even though this feature has been removed from Firefly
+ * in favor of a new reporting feature. This reporting feature can show the user past and future
+ * date ranges instead of the dashboard (the dashboard always shows "right now").
*
- * @return \Illuminate\Http\RedirectResponse|mixed|null
+ * The only actual choice the user is left with is the range, which can be changed using the Preferences pane.
+ *
+ * The start/end dates are set here, regardless of what the user might want to see.
+ *
+ * @return null
*/
- public function getDateRange(Request $request)
+ public function getDateRange()
{
$range = $this->_getRange();
- $start = $this->_getStartDate();
- $end = $this->_getEndDate();
+ // start and end are always "now", and get edited later.
+ $start = new Carbon;
+ $end = new Carbon;
// update start only:
$start = $this->_updateStartDate($range, $start);
@@ -33,110 +39,33 @@ class Toolkit implements ToolkitInterface
// update end only:
$end = $this->_updateEndDate($range, $start, $end);
- if (\Input::get('action') == 'prev') {
- $start = $this->_moveStartPrevious($range, $start);
- $end = $this->_moveEndPrevious($range, $end);
- }
- if (\Input::get('action') == 'next') {
- $start = $this->_moveStartNext($range, $start);
- $end = $this->_moveEndNext($range, $end);
- }
-
// save in session:
\Session::put('start', $start);
\Session::put('end', $end);
\Session::put('range', $range);
- if (!is_null(\Input::get('action'))) {
- return \Redirect::to($request->url());
-
- }
-
return null;
-
- }
-
- /**
- * @return array
- */
- public function getDateRangeDates()
- {
- return [\Session::get('start'), \Session::get('end')];
- }
-
- /**
- * @return mixed
- */
- public function getReminders()
- {
- // get reminders, for menu, mumble mumble:
- $today = new Carbon;
- $reminders = \Auth::user()->reminders()->where('class', 'PiggybankReminder')->validOn($today)->get();
-
- /** @var \Reminder $reminder */
- foreach ($reminders as $index => $reminder) {
- if (\Session::has('dismissal-' . $reminder->id)) {
- $time = \Session::get('dismissal-' . $reminder->id);
- if ($time >= $today) {
- unset($reminders[$index]);
- }
-
- }
- }
- \Session::put('reminderCount', count($reminders));
-
}
/**
* @return mixed
*/
- protected function _getrange()
+ protected function _getRange()
{
- if (!is_null(\Input::get('range'))) {
- $range = \Input::get('range');
+ if (!is_null(\Session::get('range'))) {
+ $range = \Session::get('range');
} else {
- if (!is_null(\Session::get('range'))) {
- $range = \Session::get('range');
- } else {
- /** @noinspection PhpUndefinedClassInspection */
- $preferences = \App::make('Firefly\Helper\Preferences\PreferencesHelperInterface');
- $viewRange = $preferences->get('viewRange', '1M');
+ /** @noinspection PhpUndefinedClassInspection */
+ $preferences = \App::make('Firefly\Helper\Preferences\PreferencesHelperInterface');
+ $viewRange = $preferences->get('viewRange', '1M');
- // default range:
- $range = $viewRange->data;
- }
+ // default range:
+ $range = $viewRange->data;
}
-
return $range;
}
- /**
- * @return Carbon|mixed
- */
- protected function _getStartDate()
- {
- $start = \Session::has('start') ? \Session::get('start') : new Carbon;
- if (\Input::get('start') && \Input::get('end')) {
- $start = new Carbon(\Input::get('start'));
- }
-
- return $start;
- }
-
- /**
- * @return Carbon|mixed
- */
- protected function _getEndDate()
- {
- $end = \Session::has('end') ? \Session::get('end') : new Carbon;
- if (\Input::get('start') && \Input::get('end')) {
- $end = new Carbon(\Input::get('end'));
- }
-
- return $end;
- }
-
/**
* @param $range
* @param Carbon $start
@@ -211,118 +140,4 @@ class Toolkit implements ToolkitInterface
return $end;
}
-
- /**
- * @param $range
- * @param Carbon $start
- *
- * @return Carbon
- */
- protected function _moveStartPrevious($range, Carbon $start)
- {
- switch ($range) {
- case '1D':
- $start->subDay();
- break;
- case '1W':
- $start->subWeek();
- break;
- case '1M':
- $start->subMonth();
- break;
- case '3M':
- $start->subMonths(3)->firstOfQuarter();
- break;
- case '6M':
- $start->subMonths(6);
- break;
- }
- return $start;
- }
-
- /**
- * @param $range
- * @param Carbon $end
- *
- * @return Carbon
- */
- protected function _moveEndPrevious($range, Carbon $end)
- {
- switch ($range) {
- case '1D':
- $end->subDay();
- break;
- case '1W':
- $end->subWeek();
- break;
- case '1M':
- $end->startOfMonth()->subMonth()->endOfMonth();
- break;
- case '3M':
- $end->subMonths(3)->lastOfQuarter();
- break;
- case '6M':
- $end->subMonths(6);
- break;
- }
- return $end;
-
- }
-
- /**
- * @param $range
- * @param Carbon $start
- *
- * @return Carbon
- */
- protected function _moveStartNext($range, Carbon $start)
- {
- switch ($range) {
- case '1D':
- $start->addDay();
- break;
- case '1W':
- $start->addWeek();
- break;
- case '1M':
- $start->addMonth();
- break;
- case '3M':
- $start->addMonths(3)->firstOfQuarter();
- break;
- case '6M':
- $start->addMonths(6);
- break;
- }
- return $start;
- }
-
- /**
- * @param $range
- * @param Carbon $end
- *
- * @return Carbon
- */
- protected function _moveEndNext($range, Carbon $end)
- {
- switch ($range) {
- case '1D':
- $end->addDay();
- break;
- case '1W':
- $end->addWeek();
- break;
- case '1M':
- $end->addMonth();
- break;
- case '3M':
- $end->addMonths(6)->lastOfQuarter();
- break;
- case '6M':
- $end->addMonths(6);
- break;
- }
- return $end;
- }
-
-}
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/app/lib/Firefly/Helper/Toolkit/ToolkitInterface.php b/app/lib/Firefly/Helper/Toolkit/ToolkitInterface.php
index 2ecbd8947b..df754556b4 100644
--- a/app/lib/Firefly/Helper/Toolkit/ToolkitInterface.php
+++ b/app/lib/Firefly/Helper/Toolkit/ToolkitInterface.php
@@ -12,20 +12,9 @@ use Illuminate\Http\Request;
interface ToolkitInterface
{
/**
- * @param Request $request
*
- * @return mixed
+ * @return null
*/
- public function getDateRange(Request $request);
+ public function getDateRange();
- /**
- * @return mixed
- */
- public function getDateRangeDates();
-
- /**
- * @return mixed
- */
- public function getReminders();
-
-}
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/app/views/index.blade.php b/app/views/index.blade.php
index 39ab8bac1a..2eb0f12500 100644
--- a/app/views/index.blade.php
+++ b/app/views/index.blade.php
@@ -34,25 +34,6 @@
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-credit-card fa-fw"></i> <a href="#">Your accounts</a>
- <div class="pull-right">
- <div class="btn-group">
- <button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown">
- Actions
- <span class="caret"></span>
- </button>
- <ul class="dropdown-menu pull-right" role="menu">
- <li><a href="#">Action</a>
- </li>
- <li><a href="#">Another action</a>
- </li>
- <li><a href="#">Something else here</a>
- </li>
- <li class="divider"></li>
- <li><a href="#">Separated link</a>
- </li>
- </ul>
- </div>
- </div>
</div>
<div class="panel-body">
<div id="accounts-chart" style="height:300px;"></div>
@@ -61,25 +42,6 @@
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-tasks fa-fw"></i> <a href="{{route('budgets.index')}}">Budgets and spending</a>
- <div class="pull-right">
- <div class="btn-group">
- <button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown">
- Actions
- <span class="caret"></span>
- </button>
- <ul class="dropdown-menu pull-right" role="menu">
- <li><a href="#">Action</a>
- </li>
- <li><a href="#">Another action</a>
- </li>
- <li><a href="#">Something else here</a>
- </li>
- <li class="divider"></li>
- <li><a href="#">Separated link</a>
- </li>
- </ul>
- </div>
- </div>
</div>
<div class="panel-body">
<div id="budgets"></div>
@@ -88,25 +50,6 @@
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-bar-chart fa-fw"></i> <a href="{{route('categories.index')}}">Categories</a>
- <div class="pull-right">
- <div class="btn-group">
- <button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown">
- Actions
- <span class="caret"></span>
- </button>
- <ul class="dropdown-menu pull-right" role="menu">
- <li><a href="#">Action</a>
- </li>
- <li><a href="#">Another action</a>
- </li>
- <li><a href="#">Something else here</a>
- </li>
- <li class="divider"></li>
- <li><a href="#">Separated link</a>
- </li>
- </ul>
- </div>
- </div>
</div>
<div class="panel-body">
<div id="categories"></div>
diff --git a/app/views/layouts/default.blade.php b/app/views/layouts/default.blade.php
index 88f0b1f84b..807711963e 100644
--- a/app/views/layouts/default.blade.php
+++ b/app/views/layouts/default.blade.php
@@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<base href="{{URL::route('index')}}/">
<title>Firefly
- @if(isset($title))
+ @if(isset($title) && $title != 'Firefly')
// {{{$title}}}
@endif
</title>
diff --git a/app/views/partials/menu.blade.php b/app/views/partials/menu.blade.php
index 62b2cd3cf2..fc97fd35f7 100644
--- a/app/views/partials/menu.blade.php
+++ b/app/views/partials/menu.blade.php
@@ -72,6 +72,9 @@
<li>
<a href="#"><i class="fa fa-tags fa-fw"></i> Tags</a>
</li>
+ <li>
+ <a href="#"><i class="fa fa-tags fa-fw"></i> Reports</a>
+ </li>
<li>
<a href="{{route('transactions.index')}}"><i class="fa fa-repeat fa-fw"></i> Transactions<span class="fa arrow"></span></a>
<ul class="nav nav-second-level">