Add everything range

This commit is contained in:
James Cole
2015-03-02 13:19:13 +01:00
parent 7183d72e5c
commit edda470bf8
5 changed files with 28 additions and 15 deletions

View File

@@ -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');
}
/**

View File

@@ -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);
}
/**

View File

@@ -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());
}
}
}

View File

@@ -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);

View File

@@ -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);
</script>