mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-28 18:01:26 -06:00
Code to fix #964
This commit is contained in:
parent
3d0ecaa8d2
commit
985cc100e2
@ -27,8 +27,8 @@ use Carbon\Carbon;
|
||||
use DB;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Http\Middleware\IsLimitedUser;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
use Illuminate\Http\Request;
|
||||
@ -38,8 +38,8 @@ use Log;
|
||||
use Monolog\Handler\RotatingFileHandler;
|
||||
use Preferences;
|
||||
use ReflectionException;
|
||||
use Response;
|
||||
use Route as RouteFacade;
|
||||
use Session;
|
||||
use View;
|
||||
|
||||
/**
|
||||
@ -55,11 +55,13 @@ class HomeController extends Controller
|
||||
parent::__construct();
|
||||
View::share('title', 'Firefly III');
|
||||
View::share('mainTitleIcon', 'fa-fire');
|
||||
$this->middleware(IsLimitedUser::class)->except(['dateRange', 'index']);
|
||||
$this->middleware(IsLimitedUser::class)->except(['dateRange', 'index']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function dateRange(Request $request)
|
||||
{
|
||||
@ -80,12 +82,17 @@ class HomeController extends Controller
|
||||
$diff = $start->diffInDays($end);
|
||||
|
||||
if ($diff > 50) {
|
||||
Session::flash('warning', strval(trans('firefly.warning_much_data', ['days' => $diff])));
|
||||
$request->session()->flash('warning', strval(trans('firefly.warning_much_data', ['days' => $diff])));
|
||||
}
|
||||
|
||||
Session::put('is_custom_range', $isCustomRange);
|
||||
Session::put('start', $start);
|
||||
Session::put('end', $end);
|
||||
$request->session()->put('is_custom_range', $isCustomRange);
|
||||
Log::debug(sprintf('Set is_custom_range to %s', var_export($isCustomRange, true)));
|
||||
$request->session()->put('start', $start);
|
||||
Log::debug(sprintf('Set start to %s', $start->format('Y-m-d H:i:s')));
|
||||
$request->session()->put('end', $end);
|
||||
Log::debug(sprintf('Set end to %s', $end->format('Y-m-d H:i:s')));
|
||||
|
||||
return Response::json(['ok' => 'ok']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -176,7 +183,7 @@ class HomeController extends Controller
|
||||
Log::debug('Call twig:clean...');
|
||||
try {
|
||||
Artisan::call('twig:clean');
|
||||
} catch(ReflectionException $e) {
|
||||
} catch (ReflectionException $e) {
|
||||
// dont care
|
||||
}
|
||||
Log::debug('Call view:clear...');
|
||||
@ -265,12 +272,12 @@ class HomeController extends Controller
|
||||
/**
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
*/
|
||||
public function testFlash()
|
||||
public function testFlash(Request $request)
|
||||
{
|
||||
Session::flash('success', 'This is a success message.');
|
||||
Session::flash('info', 'This is an info message.');
|
||||
Session::flash('warning', 'This is a warning.');
|
||||
Session::flash('error', 'This is an error!');
|
||||
$request->session()->flash('success', 'This is a success message.');
|
||||
$request->session()->flash('info', 'This is an info message.');
|
||||
$request->session()->flash('warning', 'This is a warning.');
|
||||
$request->session()->flash('error', 'This is an error!');
|
||||
|
||||
return redirect(route('home'));
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use Illuminate\Http\Request;
|
||||
use Log;
|
||||
use Navigation;
|
||||
use Preferences;
|
||||
|
||||
/**
|
||||
@ -140,6 +139,7 @@ class JavascriptController extends Controller
|
||||
$first = session('first');
|
||||
$title = sprintf('%s - %s', $start->formatLocalized($this->monthAndDayFormat), $end->formatLocalized($this->monthAndDayFormat));
|
||||
$isCustom = session('is_custom_range');
|
||||
$today = new Carbon;
|
||||
$ranges = [
|
||||
// first range is the current range:
|
||||
$title => [$start, $end],
|
||||
@ -149,28 +149,36 @@ class JavascriptController extends Controller
|
||||
// when current range is a custom range, add the current period as the next range.
|
||||
if ($isCustom) {
|
||||
Log::debug('Custom is true.');
|
||||
$index = Navigation::periodShow($start, $viewRange);
|
||||
$customPeriodStart = Navigation::startOfPeriod($start, $viewRange);
|
||||
$customPeriodEnd = Navigation::endOfPeriod($customPeriodStart, $viewRange);
|
||||
$index = app('navigation')->periodShow($start, $viewRange);
|
||||
$customPeriodStart = app('navigation')->startOfPeriod($start, $viewRange);
|
||||
$customPeriodEnd = app('navigation')->endOfPeriod($customPeriodStart, $viewRange);
|
||||
$ranges[$index] = [$customPeriodStart, $customPeriodEnd];
|
||||
}
|
||||
// then add previous range and next range
|
||||
$previousDate = Navigation::subtractPeriod($start, $viewRange);
|
||||
$index = Navigation::periodShow($previousDate, $viewRange);
|
||||
$previousStart = Navigation::startOfPeriod($previousDate, $viewRange);
|
||||
$previousEnd = Navigation::endOfPeriod($previousStart, $viewRange);
|
||||
$previousDate = app('navigation')->subtractPeriod($start, $viewRange);
|
||||
$index = app('navigation')->periodShow($previousDate, $viewRange);
|
||||
$previousStart = app('navigation')->startOfPeriod($previousDate, $viewRange);
|
||||
$previousEnd = app('navigation')->endOfPeriod($previousStart, $viewRange);
|
||||
$ranges[$index] = [$previousStart, $previousEnd];
|
||||
|
||||
$nextDate = Navigation::addPeriod($start, $viewRange, 0);
|
||||
$index = Navigation::periodShow($nextDate, $viewRange);
|
||||
$nextStart = Navigation::startOfPeriod($nextDate, $viewRange);
|
||||
$nextEnd = Navigation::endOfPeriod($nextStart, $viewRange);
|
||||
$nextDate = app('navigation')->addPeriod($start, $viewRange, 0);
|
||||
$index = app('navigation')->periodShow($nextDate, $viewRange);
|
||||
$nextStart = app('navigation')->startOfPeriod($nextDate, $viewRange);
|
||||
$nextEnd = app('navigation')->endOfPeriod($nextStart, $viewRange);
|
||||
$ranges[$index] = [$nextStart, $nextEnd];
|
||||
|
||||
// today:
|
||||
$todayStart = app('navigation')->startOfPeriod($today, $viewRange);
|
||||
$todayEnd = app('navigation')->endOfPeriod($todayStart, $viewRange);
|
||||
if ($todayStart->ne($start) || $todayEnd->ne($end)) {
|
||||
$ranges[ucfirst(strval(trans('firefly.today')))] = [$todayStart, $todayEnd];
|
||||
}
|
||||
|
||||
// everything
|
||||
$index = strval(trans('firefly.everything'));
|
||||
$ranges[$index] = [$first, new Carbon];
|
||||
|
||||
|
||||
$return = [
|
||||
'title' => $title,
|
||||
'configuration' => [
|
||||
|
Loading…
Reference in New Issue
Block a user