diff --git a/app/Helpers/Report/ReportHelper.php b/app/Helpers/Report/ReportHelper.php index 9c4a4c4ad7..4ffd22f66f 100644 --- a/app/Helpers/Report/ReportHelper.php +++ b/app/Helpers/Report/ReportHelper.php @@ -7,6 +7,7 @@ use Carbon\Carbon; use FireflyIII\Models\Account; use Illuminate\Database\Query\JoinClause; use Illuminate\Support\Collection; +use Session; /** * Class ReportHelper @@ -40,12 +41,7 @@ class ReportHelper implements ReportHelperInterface */ public function firstDate() { - $journal = Auth::user()->transactionjournals()->orderBy('date', 'ASC')->first(); - if ($journal) { - return $journal->date; - } - - return Carbon::now(); + return Session::get('first'); } /** diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index cfd2f0ad70..25203d8f6f 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -3,12 +3,11 @@ use Auth; use Cache; use Carbon\Carbon; -use Navigation; +use Input; use Preferences; use Redirect; use Session; -use URL; -use Input; + /** * Class HomeController * @@ -24,12 +23,19 @@ class HomeController extends Controller { } - public function dateRange() { + public function dateRange() + { $start = new Carbon(Input::get('start')); - $end = new Carbon(Input::get('end')); + $end = new Carbon(Input::get('end')); - Session::put('start',$start); - Session::put('end',$end); + $diff = $start->diffInDays($end); + + if ($diff > 50) { + Session::flash('warning', $diff . ' days of data may take a while to load.'); + } + + Session::put('start', $start); + Session::put('end', $end); } /** diff --git a/app/Http/Middleware/Range.php b/app/Http/Middleware/Range.php index 7ec8a5265e..36c68e019a 100644 --- a/app/Http/Middleware/Range.php +++ b/app/Http/Middleware/Range.php @@ -6,9 +6,9 @@ namespace FireflyIII\Http\Middleware; use Carbon\Carbon; use Closure; use Illuminate\Contracts\Auth\Guard; +use Navigation; use Preferences; use Session; -use Navigation; /** * Class SessionFilter @@ -59,6 +59,14 @@ class Range Session::put('start', $start); Session::put('end', $end); } + if (!Session::has('first')) { + $journal = $this->auth->user()->transactionjournals()->orderBy('date', 'ASC')->first(['transaction_journals.*']); + if ($journal) { + Session::put('first', $journal->date); + } else { + Session::put('first', Carbon::now()); + } + } } diff --git a/public/js/firefly.js b/public/js/firefly.js index 958897974f..cf002bd366 100644 --- a/public/js/firefly.js +++ b/public/js/firefly.js @@ -7,7 +7,8 @@ $(function () { ranges: { 'This Month': [moment().startOf('month'), moment().endOf('month')], 'Last Month': [moment().subtract('month', 1).startOf('month'), moment().subtract('month', 1).endOf('month')], - 'Next Month': [moment().add('month', 1).startOf('month'), moment().add('month', 1).endOf('month')] + 'Next Month': [moment().add('month', 1).startOf('month'), moment().add('month', 1).endOf('month')], + 'Everything': [firstDate, moment()] }, opens: 'left', @@ -21,6 +22,7 @@ $(function () { $.post(dateRangeURL, { start: start.format('YYYY-MM-DD'), end: end.format('YYYY-MM-DD'), + label: label, _token: token }).success(function() { window.location.reload(true); diff --git a/resources/views/layouts/default.blade.php b/resources/views/layouts/default.blade.php index 53b51f95da..b02c5b9bf2 100644 --- a/resources/views/layouts/default.blade.php +++ b/resources/views/layouts/default.blade.php @@ -128,6 +128,7 @@ var titleString = "{{Session::get('start')->format('j M Y')}} - {{Session::get('end')->format('j M Y')}}"; var dateRangeURL = "{{route('daterange')}}"; var token = "{{csrf_token()}}"; + var firstDate = moment("{{Session::get('first')->format('Y-m-d')}}"); $('#daterange span').text(titleString);