mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fixed #267
This commit is contained in:
parent
307e6a2337
commit
ec18165698
@ -18,8 +18,9 @@ use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\Tag;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface as ARI;
|
||||
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use Input;
|
||||
use Log;
|
||||
use Preferences;
|
||||
use Route;
|
||||
use Session;
|
||||
@ -41,18 +42,24 @@ class HomeController extends Controller
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function dateRange()
|
||||
/**
|
||||
* @param Request $request
|
||||
*/
|
||||
public function dateRange(Request $request)
|
||||
{
|
||||
|
||||
$start = new Carbon(Input::get('start'));
|
||||
$end = new Carbon(Input::get('end'));
|
||||
$label = Input::get('label');
|
||||
$start = new Carbon($request->get('start'));
|
||||
$end = new Carbon($request->get('end'));
|
||||
$label = $request->get('label');
|
||||
$isCustomRange = false;
|
||||
|
||||
Log::debug('Received dateRange', ['start' => $request->get('start'), 'end' => $request->get('end'), 'label' => $request->get('label')]);
|
||||
|
||||
// check if the label is "everything" or "Custom range" which will betray
|
||||
// a possible problem with the budgets.
|
||||
if ($label === strval(trans('firefly.everything')) || $label === strval(trans('firefly.customRange'))) {
|
||||
$isCustomRange = true;
|
||||
Log::debug('Range is now marked as "custom".');
|
||||
}
|
||||
|
||||
$diff = $start->diffInDays($end);
|
||||
@ -173,11 +180,11 @@ class HomeController extends Controller
|
||||
$search = [
|
||||
'{account}', '{what}', '{rule}', '{tj}', '{category}', '{budget}', '{code}', '{date}', '{attachment}', '{bill}', '{limitrepetition}',
|
||||
'{currency}', '{jobKey}', '{piggyBank}', '{ruleGroup}', '{rule}', '{route}', '{unfinishedJournal}',
|
||||
'{reportType}', '{start_date}', '{end_date}', '{accountList}','{tag}','{journalList}'
|
||||
'{reportType}', '{start_date}', '{end_date}', '{accountList}', '{tag}', '{journalList}',
|
||||
|
||||
];
|
||||
$replace = [1, 'asset', 1, 1, 1, 1, 'abc', '2016-01-01', 1, 1, 1, 1, 1, 1, 1, 1, 'index', 1,
|
||||
'default', '20160101', '20160131', '1,2',1,'1,2'
|
||||
'default', '20160101', '20160131', '1,2', 1, '1,2',
|
||||
];
|
||||
if (count($search) != count($replace)) {
|
||||
echo 'count';
|
||||
|
@ -13,6 +13,7 @@ namespace FireflyIII\Http\Middleware;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Closure;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Http\Request;
|
||||
@ -64,7 +65,6 @@ class Range
|
||||
// ignore preference. set the range to be the current month:
|
||||
if (!Session::has('start') && !Session::has('end')) {
|
||||
|
||||
/** @var \FireflyIII\Models\Preference $viewRange */
|
||||
$viewRange = Preferences::get('viewRange', '1M')->data;
|
||||
$start = new Carbon;
|
||||
$start = Navigation::updateStartDate($viewRange, $start);
|
||||
@ -94,14 +94,51 @@ class Range
|
||||
|
||||
private function datePicker()
|
||||
{
|
||||
|
||||
|
||||
$current = Carbon::now()->formatLocalized('%B %Y');
|
||||
$next = Carbon::now()->endOfMonth()->addDay()->formatLocalized('%B %Y');
|
||||
$prev = Carbon::now()->startOfMonth()->subDay()->formatLocalized('%B %Y');
|
||||
View::share('currentPeriodName', $current);
|
||||
View::share('previousPeriodName', $prev);
|
||||
View::share('nextPeriodName', $next);
|
||||
$viewRange = Preferences::get('viewRange', '1M')->data;
|
||||
$start = Session::get('start');
|
||||
$end = Session::get('end');
|
||||
$prevStart = Navigation::subtractPeriod($start, $viewRange);// subtract for previous period
|
||||
$prevEnd = Navigation::subtractPeriod($end, $viewRange);
|
||||
$nextStart = Navigation::addPeriod($start, $viewRange, 0);// add for previous period
|
||||
$nextEnd = Navigation::addPeriod($end, $viewRange, 0);
|
||||
$ranges = [];
|
||||
$ranges['current'] = [$start->format('Y-m-d'), $end->format('Y-m-d')];
|
||||
$ranges['previous'] = [$prevStart->format('Y-m-d'), $prevEnd->format('Y-m-d')];
|
||||
$ranges['next'] = [$nextStart->format('Y-m-d'), $nextEnd->format('Y-m-d')];
|
||||
|
||||
switch ($viewRange) {
|
||||
case '1D':
|
||||
$format = (string)trans('config.month_and_day');
|
||||
break;
|
||||
case '3M':
|
||||
$format = (string)trans('config.quarter_in_year');
|
||||
break;
|
||||
case '6M':
|
||||
$format = (string)trans('config.half_year');
|
||||
break;
|
||||
case '1Y':
|
||||
$format = (string)trans('config.year');
|
||||
break;
|
||||
case '1M':
|
||||
$format = (string)trans('config.month');
|
||||
break;
|
||||
default:
|
||||
throw new FireflyException('The date picker does not yet support "' . $viewRange . '".');
|
||||
case '1W':
|
||||
$format = (string)trans('config.week_in_year');
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
$current = $start->formatLocalized($format);
|
||||
$next = $nextStart->formatLocalized($format);
|
||||
$prev = $prevStart->formatLocalized($format);
|
||||
View::share('dpStart', $start->format('Y-m-d'));
|
||||
View::share('dpEnd', $end->format('Y-m-d'));
|
||||
View::share('dpCurrent', $current);
|
||||
View::share('dpPrevious', $prev);
|
||||
View::share('dpNext', $next);
|
||||
View::share('dpRanges', $ranges);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,14 +6,9 @@ $(function () {
|
||||
$('.currency-option').click(currencySelect);
|
||||
|
||||
var ranges = {};
|
||||
// range for the current period:
|
||||
ranges[dateRangeConfig.currentPeriod] = [moment().startOf('month'), moment().endOf('month')];
|
||||
|
||||
// range for the previous period:
|
||||
ranges[dateRangeConfig.previousPeriod] = [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')];
|
||||
|
||||
// range for the next period:
|
||||
ranges[dateRangeConfig.nextPeriod] = [moment().add(1, 'month').startOf('month'), moment().add(1, 'month').endOf('month')];
|
||||
ranges[dateRangeConfig.currentPeriod] = [moment(dateRangeConfig.ranges.current[0]), moment(dateRangeConfig.ranges.current[1])];
|
||||
ranges[dateRangeConfig.previousPeriod] = [moment(dateRangeConfig.ranges.previous[0]), moment(dateRangeConfig.ranges.previous[1])];
|
||||
ranges[dateRangeConfig.nextPeriod] = [moment(dateRangeConfig.ranges.next[0]), moment(dateRangeConfig.ranges.next[1])];
|
||||
|
||||
// range for everything:
|
||||
ranges[dateRangeConfig.everything] = [dateRangeConfig.firstDate, moment()];
|
||||
@ -51,7 +46,7 @@ $(function () {
|
||||
console.log('Succesfully sent new date range [' + start.format('YYYY-MM-DD') + '-' + end.format('YYYY-MM-DD') + '].');
|
||||
window.location.reload(true);
|
||||
}).fail(function () {
|
||||
console.log('Could not send new date range [' + start.format('YYYY-MM-DD') + '-' + end.format('YYYY-MM-DD') + ']');
|
||||
console.log('Could not send new date range.');
|
||||
alert('Could not change date range');
|
||||
|
||||
});
|
||||
|
@ -167,20 +167,21 @@
|
||||
|
||||
// date range picker configuration:
|
||||
var dateRangeConfig = {
|
||||
startDate: moment("{{ Session.get('start').format('Y-m-d') }}"),
|
||||
endDate: moment("{{ Session.get('end').format('Y-m-d') }}"),
|
||||
startDate: moment("{{ dpStart }}"),
|
||||
endDate: moment("{{ dpEnd }}"),
|
||||
linkTitle: "{{ Session.get('start').formatLocalized(monthAndDayFormat) }} - {{ Session.get('end').formatLocalized(monthAndDayFormat) }}",
|
||||
URL: "{{ route('daterange') }}",
|
||||
firstDate: moment("{{ Session.get('first').format('Y-m-d') }}"),
|
||||
currentPeriod: "{{ currentPeriodName }}",
|
||||
previousPeriod: "{{ previousPeriodName }}",
|
||||
nextPeriod: "{{ nextPeriodName }}",
|
||||
currentPeriod: "{{ dpCurrent }}",
|
||||
previousPeriod: "{{ dpPrevious }}",
|
||||
nextPeriod: "{{ dpNext }}",
|
||||
everything: '{{ 'everything'|_ }}',
|
||||
customRangeLabel: '{{ 'customRange'|_ }}',
|
||||
applyLabel: '{{ 'apply'|_ }}',
|
||||
cancelLabel: '{{ 'cancel'|_ }}',
|
||||
fromLabel: '{{ 'from'|_ }}',
|
||||
toLabel: '{{ 'to'|_ }}'
|
||||
toLabel: '{{ 'to'|_ }}',
|
||||
ranges: {{ dpRanges|json_encode|raw }}
|
||||
};
|
||||
|
||||
var token = "{{ csrf_token() }}";
|
||||
|
Loading…
Reference in New Issue
Block a user