Skip to content

Firefly III: a personal finances manager

Update the ranges to reflect the current dates.

James Colee9969bdd5f64
diff --git a/app/Http/Middleware/Range.php b/app/Http/Middleware/Range.php
index 36c68e019a..b37db6b6b4 100644
--- a/app/Http/Middleware/Range.php
+++ b/app/Http/Middleware/Range.php
@@ -9,6 +9,7 @@ use Illuminate\Contracts\Auth\Guard;
use Navigation;
use Preferences;
use Session;
+use View;
/**
* Class SessionFilter
@@ -68,6 +69,14 @@ class Range
}
}
+ // set current / next / prev month.
+ $current = Carbon::now()->format('F Y');
+ $next = Carbon::now()->endOfMonth()->addDay()->format('F Y');
+ $prev = Carbon::now()->startOfMonth()->subDay()->format('F Y');
+ View::share('currentMonthName', $current);
+ View::share('previousMonthName', $prev);
+ View::share('nextMonthName', $next);
+
}
diff --git a/public/js/firefly.js b/public/js/firefly.js
index 0bf2c43a4f..e0a35830ea 100644
--- a/public/js/firefly.js
+++ b/public/js/firefly.js
@@ -2,14 +2,21 @@ $(function () {
$('.currencySelect').click(currencySelect);
+ ranges = {};
+ ranges[currentMonthName] = [moment().startOf('month'), moment().endOf('month')];
+ ranges[previousMonthName] = [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')];
+ ranges[nextMonthName] = [moment().add(1, 'month').startOf('month'), moment().add(1, 'month').endOf('month')];
+ ranges['Everything'] = [firstDate, moment()];
+
$('#daterange').daterangepicker(
{
- ranges: {
- 'This Month': [moment().startOf('month'), moment().endOf('month')],
- 'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')],
- 'Next Month': [moment().add(1, 'month').startOf('month'), moment().add(1, 'month').endOf('month')],
- 'Everything': [firstDate, moment()]
- },
+ //View::share('currentMonthName', $current);
+ //View::share('previousMonthName', $prev);
+ //View::share('nextMonthName', $next);
+
+
+ ranges: ranges
+ ,
opens: 'left',
format: 'DD-MM-YYYY',
diff --git a/resources/views/layouts/default.blade.php b/resources/views/layouts/default.blade.php
index d260d81dde..03f24a7048 100644
--- a/resources/views/layouts/default.blade.php
+++ b/resources/views/layouts/default.blade.php
@@ -132,6 +132,9 @@
var dateRangeURL = "{{route('daterange')}}";
var token = "{{csrf_token()}}";
var firstDate = moment("{{Session::get('first')->format('Y-m-d')}}");
+ var currentMonthName = "{{$currentMonthName}}";
+ var previousMonthName = "{{$previousMonthName}}";
+ var nextMonthName = "{{$nextMonthName}}";
$('#daterange span').text(titleString);
</script>