mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-02 10:22:09 +00:00
Clean up filters, extend index and small fix for title.
This commit is contained in:
@@ -7,9 +7,7 @@ App::before(
|
||||
|
||||
if (Auth::check()) {
|
||||
$toolkit = App::make('Firefly\Helper\Toolkit\ToolkitInterface');
|
||||
$toolkit->getDateRange($request);
|
||||
$toolkit->getReminders();
|
||||
|
||||
$toolkit->getDateRange();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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,68 +39,19 @@ 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()
|
||||
protected function _getRange()
|
||||
{
|
||||
// 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()
|
||||
{
|
||||
if (!is_null(\Input::get('range'))) {
|
||||
$range = \Input::get('range');
|
||||
} else {
|
||||
if (!is_null(\Session::get('range'))) {
|
||||
$range = \Session::get('range');
|
||||
} else {
|
||||
@@ -105,38 +62,10 @@ class Toolkit implements ToolkitInterface
|
||||
// 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;
|
||||
}
|
||||
|
||||
}
|
@@ -12,20 +12,9 @@ use Illuminate\Http\Request;
|
||||
interface ToolkitInterface
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
*
|
||||
* @return mixed
|
||||
* @return null
|
||||
*/
|
||||
public function getDateRange(Request $request);
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDateRangeDates();
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getReminders();
|
||||
public function getDateRange();
|
||||
|
||||
}
|
@@ -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>
|
||||
|
@@ -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>
|
||||
|
@@ -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">
|
||||
|
Reference in New Issue
Block a user