diff --git a/app/Http/Controllers/Report/InOutController.php b/app/Http/Controllers/Report/InOutController.php
index abc23c55fb..83ce241de1 100644
--- a/app/Http/Controllers/Report/InOutController.php
+++ b/app/Http/Controllers/Report/InOutController.php
@@ -19,7 +19,6 @@ use FireflyIII\Helpers\Report\ReportHelperInterface;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Support\CacheProperties;
use Illuminate\Support\Collection;
-use Response;
/**
* Class InOutController
@@ -37,29 +36,83 @@ class InOutController extends Controller
*
* @return \Illuminate\Http\JsonResponse
*/
- public function inOutReport(ReportHelperInterface $helper, Carbon $start, Carbon $end, Collection $accounts)
+ public function expenseReport(ReportHelperInterface $helper, Carbon $start, Carbon $end, Collection $accounts)
{
// chart properties for cache:
$cache = new CacheProperties;
$cache->addProperty($start);
$cache->addProperty($end);
- $cache->addProperty('in-out-report');
+ $cache->addProperty('expense-report');
$cache->addProperty($accounts->pluck('id')->toArray());
if ($cache->has()) {
- return Response::json($cache->get());
+ return $cache->get();
+ }
+
+ $expenses = $helper->getExpenseReport($start, $end, $accounts);
+
+ $result = view('reports.partials.expenses', compact('expenses'))->render();
+ $cache->store($result);
+
+ return $result;
+
+ }
+
+ /**
+ * @param ReportHelperInterface $helper
+ * @param Carbon $start
+ * @param Carbon $end
+ * @param Collection $accounts
+ *
+ * @return \Illuminate\Http\JsonResponse
+ */
+ public function incExpReport(ReportHelperInterface $helper, Carbon $start, Carbon $end, Collection $accounts)
+ {
+ // chart properties for cache:
+ $cache = new CacheProperties;
+ $cache->addProperty($start);
+ $cache->addProperty($end);
+ $cache->addProperty('inc-exp-report');
+ $cache->addProperty($accounts->pluck('id')->toArray());
+ if ($cache->has()) {
+ return $cache->get();
}
$incomes = $helper->getIncomeReport($start, $end, $accounts);
$expenses = $helper->getExpenseReport($start, $end, $accounts);
- $result = [
- 'income' => view('reports.partials.income', compact('incomes'))->render(),
- 'expenses' => view('reports.partials.expenses', compact('expenses'))->render(),
- 'incomes_expenses' => view('reports.partials.income-vs-expenses', compact('expenses', 'incomes'))->render(),
- ];
+ $result = view('reports.partials.income-vs-expenses', compact('expenses', 'incomes'))->render();
$cache->store($result);
- return Response::json($result);
+ return $result;
+
+ }
+
+ /**
+ * @param ReportHelperInterface $helper
+ * @param Carbon $start
+ * @param Carbon $end
+ * @param Collection $accounts
+ *
+ * @return \Illuminate\Http\JsonResponse
+ */
+ public function incomeReport(ReportHelperInterface $helper, Carbon $start, Carbon $end, Collection $accounts)
+ {
+ // chart properties for cache:
+ $cache = new CacheProperties;
+ $cache->addProperty($start);
+ $cache->addProperty($end);
+ $cache->addProperty('income-report');
+ $cache->addProperty($accounts->pluck('id')->toArray());
+ if ($cache->has()) {
+ return $cache->get();
+ }
+
+ $incomes = $helper->getIncomeReport($start, $end, $accounts);
+
+ $result = view('reports.partials.income', compact('incomes'))->render();
+ $cache->store($result);
+
+ return $result;
}
diff --git a/public/js/ff/reports/default/all.js b/public/js/ff/reports/default/all.js
index 5d47620714..0c534045ca 100644
--- a/public/js/ff/reports/default/all.js
+++ b/public/js/ff/reports/default/all.js
@@ -1,4 +1,4 @@
-/* globals startDate, showOnlyTop, showFullList, endDate, reportType, accountIds, inOutReportUrl, accountReportUrl */
+/* globals startDate, showOnlyTop, showFullList, endDate, reportType, expenseReportUri, accountIds, incExpReportUri,accountReportUri, incomeReportUri */
/*
* all.js
* Copyright (C) 2016 thegrumpydictator@gmail.com
@@ -13,23 +13,19 @@ $(function () {
// load the account report, which this report shows:
- loadAccountReport();
+ loadAjaxPartial('accountReport', accountReportUri);
- // load income / expense / difference:
- loadInOutReport();
-
- // trigger info click
- triggerInfoClick();
-
- // trigger list length things:
- listLengthInitial();
+ // load income and expense reports:
+ loadAjaxPartial('incomeReport',incomeReportUri);
+ loadAjaxPartial('expenseReport',expenseReportUri);
+ loadAjaxPartial('incomeVsExpenseReport',incExpReportUri);
});
function triggerInfoClick() {
"use strict";
// find the little info buttons and respond to them.
- $('.firefly-info-button').unbind('clicl').click(clickInfoButton);
+ $('.firefly-info-button').unbind('click').click(clickInfoButton);
}
function listLengthInitial() {
@@ -58,44 +54,6 @@ function triggerList(e) {
return false;
}
-function loadInOutReport() {
- "use strict";
- console.log('Going to grab ' + inOutReportUrl);
- $.get(inOutReportUrl).done(placeInOutReport).fail(failInOutReport);
-}
-
-function placeInOutReport(data) {
- "use strict";
- $('#incomeReport').removeClass('loading').html(data.income);
- $('#expenseReport').removeClass('loading').html(data.expenses);
- $('#incomeVsExpenseReport').removeClass('loading').html(data.incomes_expenses);
- listLengthInitial();
- triggerInfoClick();
-}
-
-function failInOutReport() {
- "use strict";
- console.log('Fail in/out report data!');
- $('#incomeReport').removeClass('loading').addClass('general-chart-error');
- $('#expenseReport').removeClass('loading').addClass('general-chart-error');
- $('#incomeVsExpenseReport').removeClass('loading').addClass('general-chart-error');
-}
-
-function loadAccountReport() {
- "use strict";
- $.get(accountReportUrl).done(placeAccountReport).fail(failAccountReport);
-}
-
-function placeAccountReport(data) {
- "use strict";
- $('#accountReport').removeClass('loading').html(data);
-}
-
-function failAccountReport(data) {
- "use strict";
- $('#accountReport').removeClass('loading').addClass('general-chart-error');
-}
-
function clickInfoButton(e) {
"use strict";
// find all data tags, regardless of what they are:
@@ -125,8 +83,7 @@ function respondInfoButton(data) {
"use strict";
// remove wait cursor
$('body').removeClass('waiting');
- $('#defaultModal').empty().html(data.html);
- $('#defaultModal').modal('show');
+ $('#defaultModal').empty().html(data.html).modal('show');
}
@@ -150,6 +107,12 @@ function displayAjaxPartial(data, holder) {
// find a sortable table and make it sortable:
$.bootstrapSortable(true);
+
+ // find the info click things and respond to them:
+ triggerInfoClick();
+
+ // trigger list thing
+ listLengthInitial();
}
function failAjaxPartial(uri, holder) {
diff --git a/public/js/ff/reports/default/month.js b/public/js/ff/reports/default/month.js
index 7c15f922b6..4e34d95032 100644
--- a/public/js/ff/reports/default/month.js
+++ b/public/js/ff/reports/default/month.js
@@ -1,74 +1,15 @@
-/* globals google, budgetReportUrl, startDate ,reportURL, endDate , reportType ,accountIds, lineChart, categoryReportUrl, balanceReportUrl */
+/* globals google, categoryReportUri, budgetReportUri, balanceReportUri */
$(function () {
"use strict";
drawChart();
- loadCategoryReport();
- loadBalanceReport();
- loadBudgetReport();
+ loadAjaxPartial('categoryReport', categoryReportUri);
+ loadAjaxPartial('budgetReport', budgetReportUri);
+ loadAjaxPartial('balanceReport',balanceReportUri);
});
-function loadCategoryReport() {
- "use strict";
- console.log('Going to grab ' + categoryReportUrl);
- $.get(categoryReportUrl).done(placeCategoryReport).fail(failCategoryReport);
-}
-
-function loadBudgetReport() {
- "use strict";
- console.log('Going to grab ' + budgetReportUrl);
- $.get(budgetReportUrl).done(placeBudgetReport).fail(failBudgetReport);
-}
-
-
-function loadBalanceReport() {
- "use strict";
- console.log('Going to grab ' + categoryReportUrl);
- $.get(balanceReportUrl).done(placeBalanceReport).fail(failBalanceReport);
-}
-
-function placeBudgetReport(data) {
- "use strict";
- $('#budgetReport').removeClass('loading').html(data);
- listLengthInitial();
- triggerInfoClick();
-}
-
-function placeBalanceReport(data) {
- "use strict";
- $('#balanceReport').removeClass('loading').html(data);
- listLengthInitial();
- triggerInfoClick();
-}
-
-function placeCategoryReport(data) {
- "use strict";
- $('#categoryReport').removeClass('loading').html(data);
- listLengthInitial();
- triggerInfoClick();
-}
-
-function failBudgetReport() {
- "use strict";
- console.log('Fail budget report data!');
- $('#budgetReport').removeClass('loading').addClass('general-chart-error');
-}
-
-function failBalanceReport() {
- "use strict";
- console.log('Fail balance report data!');
- $('#balanceReport').removeClass('loading').addClass('general-chart-error');
-}
-
-function failCategoryReport() {
- "use strict";
- console.log('Fail category report data!');
- $('#categoryReport').removeClass('loading').addClass('general-chart-error');
-}
-
-
function drawChart() {
"use strict";
diff --git a/public/js/ff/reports/default/year.js b/public/js/ff/reports/default/year.js
index e0cb494772..cea6c09c03 100644
--- a/public/js/ff/reports/default/year.js
+++ b/public/js/ff/reports/default/year.js
@@ -1,4 +1,4 @@
-/* globals google, accountIds, budgetYearOverviewUrl */
+/* globals google, accountIds, budgetYearOverviewUri */
var chartDrawn;
var budgetChart;
@@ -7,30 +7,9 @@ $(function () {
chartDrawn = false;
drawChart();
- //
- loadBudgetOverview();
+ loadAjaxPartial('budgetOverview',budgetYearOverviewUri);
});
-function loadBudgetOverview() {
- "use strict";
- console.log('Going to grab ' + budgetYearOverviewUrl);
- $.get(budgetYearOverviewUrl).done(placeBudgetOverview).fail(failBudgetOverview);
-}
-
-function placeBudgetOverview(data) {
- "use strict";
- $('#budgetOverview').removeClass('loading').html(data);
- $('.budget-chart-activate').on('click', clickBudgetChart);
-}
-
-function failBudgetOverview() {
- "use strict";
- console.log('Fail budget overview data!');
- $('#budgetOverview').removeClass('loading').addClass('general-chart-error');
-}
-
-
-
function drawChart() {
"use strict";
diff --git a/resources/views/reports/default/month.twig b/resources/views/reports/default/month.twig
index bd4f6789b8..69285bff64 100644
--- a/resources/views/reports/default/month.twig
+++ b/resources/views/reports/default/month.twig
@@ -132,11 +132,14 @@
var accountIds = '{{ accountIds }}';
- var accountReportUrl = '{{ route('reports.data.accountReport', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
- var inOutReportUrl = '{{ route('reports.data.inOutReport', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
- var categoryReportUrl = '{{ route('reports.data.categoryReport', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
- var balanceReportUrl = '{{ route('reports.data.balanceReport', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
- var budgetReportUrl = '{{ route('reports.data.budgetReport', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
+ var accountReportUri = '{{ route('reports.data.accountReport', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
+ var incomeReportUri = '{{ route('reports.data.incomeReport', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
+ var expenseReportUri = '{{ route('reports.data.expenseReport', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
+ var incExpReportUri = '{{ route('reports.data.incExpReport', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
+ var categoryReportUri = '{{ route('reports.data.categoryReport', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
+ var budgetReportUri = '{{ route('reports.data.budgetReport', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
+ var balanceReportUri = '{{ route('reports.data.balanceReport', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
+
diff --git a/resources/views/reports/default/year.twig b/resources/views/reports/default/year.twig
index 41e6ef0ebb..99a9a75d11 100644
--- a/resources/views/reports/default/year.twig
+++ b/resources/views/reports/default/year.twig
@@ -123,9 +123,12 @@
var accountIds = '{{ accountIds }}';
- var accountReportUrl = '{{ route('reports.data.accountReport', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
- var inOutReportUrl = '{{ route('reports.data.inOutReport', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
- var budgetYearOverviewUrl = '{{ route('reports.data.budgetYearOverview', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
+ var accountReportUri = '{{ route('reports.data.accountReport', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
+ var incomeReportUri = '{{ route('reports.data.incomeReport', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
+ var expenseReportUri = '{{ route('reports.data.expenseReport', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
+ var incExpReportUri = '{{ route('reports.data.incExpReport', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
+
+ var budgetYearOverviewUri = '{{ route('reports.data.budgetYearOverview', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
diff --git a/routes/web.php b/routes/web.php
index d7a6f64b5d..793d8e769a 100755
--- a/routes/web.php
+++ b/routes/web.php
@@ -316,10 +316,20 @@ Route::group(
['uses' => 'Report\AccountController@accountReport', 'as' => 'reports.data.accountReport']
);
- // income report
+ // income and expenses report
Route::get(
- '/reports/data/in-out-report/{start_date}/{end_date}/{accountList}',
- ['uses' => 'Report\InOutController@inOutReport', 'as' => 'reports.data.inOutReport']
+ '/reports/data/inc-exp-report/{start_date}/{end_date}/{accountList}',
+ ['uses' => 'Report\InOutController@incExpReport', 'as' => 'reports.data.incExpReport']
+ );
+ // (income report):
+ Route::get(
+ '/reports/data/income-report/{start_date}/{end_date}/{accountList}',
+ ['uses' => 'Report\InOutController@incomeReport', 'as' => 'reports.data.incomeReport']
+ );
+ // (expense report):
+ Route::get(
+ '/reports/data/expense-report/{start_date}/{end_date}/{accountList}',
+ ['uses' => 'Report\InOutController@expenseReport', 'as' => 'reports.data.expenseReport']
);
// category report: