mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-24 08:00:12 -06:00
Moved a report out of the controller.
This commit is contained in:
parent
a1f797c4d1
commit
ea7ee7ee9a
44
app/Http/Controllers/Report/AccountController.php
Normal file
44
app/Http/Controllers/Report/AccountController.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* AccountController.php
|
||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This software may be modified and distributed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||
*
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers\Report;
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Repositories\Account\AccountTaskerInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Class AccountController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers\Report
|
||||
*/
|
||||
class AccountController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function accountReport(Carbon $start, Carbon $end, Collection $accounts)
|
||||
{
|
||||
$accountTasker = app(AccountTaskerInterface::class);
|
||||
$accountReport = $accountTasker->getAccountReport($start, $end, $accounts);
|
||||
|
||||
return view('reports.partials.accounts', compact('accountReport'));
|
||||
}
|
||||
}
|
@ -16,7 +16,6 @@ namespace FireflyIII\Http\Controllers;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Crud\Account\AccountCrudInterface;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Helpers\Report\AccountReportHelperInterface;
|
||||
use FireflyIII\Helpers\Report\BalanceReportHelperInterface;
|
||||
use FireflyIII\Helpers\Report\BudgetReportHelperInterface;
|
||||
use FireflyIII\Helpers\Report\ReportHelperInterface;
|
||||
@ -24,7 +23,6 @@ use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface as ARI;
|
||||
use FireflyIII\Repositories\Account\AccountTaskerInterface;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
@ -41,8 +39,6 @@ use View;
|
||||
class ReportController extends Controller
|
||||
{
|
||||
|
||||
/** @var AccountTaskerInterface */
|
||||
protected $accountTasker;
|
||||
/** @var BalanceReportHelperInterface */
|
||||
protected $balanceHelper;
|
||||
|
||||
@ -235,7 +231,6 @@ class ReportController extends Controller
|
||||
private function createRepositories()
|
||||
{
|
||||
$this->helper = app(ReportHelperInterface::class);
|
||||
$this->accountTasker = app(AccountTaskerInterface::class);
|
||||
$this->budgetHelper = app(BudgetReportHelperInterface::class);
|
||||
$this->balanceHelper = app(BalanceReportHelperInterface::class);
|
||||
}
|
||||
@ -254,7 +249,6 @@ class ReportController extends Controller
|
||||
$expenseTopLength = 8;
|
||||
|
||||
// get report stuff!
|
||||
$accountReport = $this->accountTasker->getAccountReport($start, $end, $accounts);
|
||||
$incomes = $this->helper->getIncomeReport($start, $end, $accounts);
|
||||
$expenses = $this->helper->getExpenseReport($start, $end, $accounts);
|
||||
$budgets = $this->budgetHelper->getBudgetReport($start, $end, $accounts);
|
||||
@ -271,7 +265,7 @@ class ReportController extends Controller
|
||||
'reports.default.month',
|
||||
compact(
|
||||
'start', 'end', 'reportType',
|
||||
'accountReport', 'tags',
|
||||
'tags',
|
||||
'incomes', 'incomeTopLength',
|
||||
'expenses', 'expenseTopLength',
|
||||
'budgets', 'balance',
|
||||
@ -298,7 +292,6 @@ class ReportController extends Controller
|
||||
// list of users stuff:
|
||||
$budgets = app(BudgetRepositoryInterface::class)->getActiveBudgets();
|
||||
$categories = app(CategoryRepositoryInterface::class)->getCategories();
|
||||
$accountReport = $this->accountTasker->getAccountReport($start, $end, $accounts);
|
||||
$incomes = $this->helper->getIncomeReport($start, $end, $accounts);
|
||||
$expenses = $this->helper->getExpenseReport($start, $end, $accounts);
|
||||
$tags = $this->helper->tagReport($start, $end, $accounts);
|
||||
@ -314,7 +307,8 @@ class ReportController extends Controller
|
||||
return view(
|
||||
'reports.default.multi-year',
|
||||
compact(
|
||||
'budgets', 'accounts', 'categories', 'start', 'end', 'accountIds', 'reportType', 'accountReport', 'incomes', 'expenses',
|
||||
'budgets', 'accounts', 'categories', 'start', 'end', 'accountIds', 'reportType',
|
||||
'incomes', 'expenses',
|
||||
'incomeTopLength', 'expenseTopLength', 'tags'
|
||||
)
|
||||
);
|
||||
@ -333,7 +327,6 @@ class ReportController extends Controller
|
||||
$incomeTopLength = 8;
|
||||
$expenseTopLength = 8;
|
||||
|
||||
$accountReport = $this->accountTasker->getAccountReport($start, $end, $accounts);
|
||||
$incomes = $this->helper->getIncomeReport($start, $end, $accounts);
|
||||
$expenses = $this->helper->getExpenseReport($start, $end, $accounts);
|
||||
$tags = $this->helper->tagReport($start, $end, $accounts);
|
||||
@ -354,7 +347,7 @@ class ReportController extends Controller
|
||||
return view(
|
||||
'reports.default.year',
|
||||
compact(
|
||||
'start', 'accountReport', 'incomes', 'reportType', 'accountIds', 'end',
|
||||
'start', 'incomes', 'reportType', 'accountIds', 'end',
|
||||
'expenses', 'incomeTopLength', 'expenseTopLength', 'tags', 'budgets'
|
||||
)
|
||||
);
|
||||
|
@ -74,3 +74,8 @@ body.waiting * {
|
||||
margin-bottom: 10px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.loading {
|
||||
background:url('/images/loading-small.gif') no-repeat center center;
|
||||
min-height:30px;
|
||||
}
|
BIN
public/images/loading-small.gif
Normal file
BIN
public/images/loading-small.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
@ -17,8 +17,26 @@ $(function () {
|
||||
// find the little info buttons and respond to them.
|
||||
$('.firefly-info-button').click(clickInfoButton);
|
||||
|
||||
// load the account report, which this report shows:
|
||||
loadAccountReport();
|
||||
|
||||
});
|
||||
|
||||
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:
|
||||
|
@ -20,8 +20,7 @@
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
{% include 'reports/partials/accounts.twig' %}
|
||||
<div class="col-lg-6 col-md-6 col-sm-6 loading" id="accountReport">
|
||||
</div>
|
||||
<div class="col-lg-3 col-md-3 col-sm-3">
|
||||
<!-- income -->
|
||||
@ -93,6 +92,9 @@
|
||||
var hideTheRest = '{{ trans('firefly.hideTheRest',{number:incomeTopLength}) }}';
|
||||
var showTheRestExpense = '{{ trans('firefly.showTheRest',{number:expenseTopLength}) }}';
|
||||
var hideTheRestExpense = '{{ trans('firefly.hideTheRest',{number:expenseTopLength}) }}';
|
||||
|
||||
<!-- some URL's -->
|
||||
var accountReportUrl = '{{ route('reports.data.accountReport', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
|
||||
</script>
|
||||
<script type="text/javascript" src="js/ff/reports/default/all.js"></script>
|
||||
<script type="text/javascript" src="js/ff/reports/default/month.js"></script>
|
||||
|
@ -31,9 +31,7 @@
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
{% include 'reports/partials/accounts.twig' %}
|
||||
|
||||
<div class="col-lg-6 col-md-6 col-sm-6 loading" id="accountReport">
|
||||
</div>
|
||||
<div class="col-lg-3 col-md-3 col-sm-3">
|
||||
<!-- income -->
|
||||
@ -176,6 +174,9 @@
|
||||
var showTheRestExpense = '{{ trans('firefly.showTheRest',{number:expenseTopLength}) }}';
|
||||
var hideTheRestExpense = '{{ trans('firefly.hideTheRest',{number:expenseTopLength}) }}';
|
||||
|
||||
<!-- some URL's -->
|
||||
var accountReportUrl = '{{ route('reports.data.accountReport', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
|
||||
|
||||
</script>
|
||||
<script type="text/javascript" src="js/ff/reports/default/all.js"></script>
|
||||
<script type="text/javascript" src="js/ff/reports/default/multi-year.js"></script>
|
||||
|
@ -31,7 +31,8 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
{% include 'reports/partials/accounts.twig' %}
|
||||
<div class="loading" id="accountReport">
|
||||
</div>
|
||||
{% include 'reports/partials/income-vs-expenses.twig' %}
|
||||
|
||||
</div>
|
||||
@ -133,6 +134,9 @@
|
||||
var hideTheRest = '{{ trans('firefly.hideTheRest',{number:incomeTopLength}) }}';
|
||||
var showTheRestExpense = '{{ trans('firefly.showTheRest',{number:expenseTopLength}) }}';
|
||||
var hideTheRestExpense = '{{ trans('firefly.hideTheRest',{number:expenseTopLength}) }}';
|
||||
|
||||
<!-- some URL's -->
|
||||
var accountReportUrl = '{{ route('reports.data.accountReport', [start.format('Ymd'), end.format('Ymd'), accountIds]) }}';
|
||||
</script>
|
||||
|
||||
<script type="text/javascript" src="js/ff/reports/default/all.js"></script>
|
||||
|
@ -40,7 +40,7 @@ Route::group(
|
||||
Route::group(
|
||||
['middleware' => 'user-simple-auth'], function () {
|
||||
Route::get('/error', 'HomeController@displayError');
|
||||
Route::any('logout', ['uses' => 'Auth\LoginController@logout','as' => 'logout']);
|
||||
Route::any('logout', ['uses' => 'Auth\LoginController@logout', 'as' => 'logout']);
|
||||
Route::get('/flush', ['uses' => 'HomeController@flush']);
|
||||
}
|
||||
);
|
||||
@ -312,6 +312,14 @@ Route::group(
|
||||
Route::get('/reports', ['uses' => 'ReportController@index', 'as' => 'reports.index']);
|
||||
Route::get('/reports/report/{reportType}/{start_date}/{end_date}/{accountList}', ['uses' => 'ReportController@report', 'as' => 'reports.report']);
|
||||
|
||||
/**
|
||||
* Report AJAX data Controller:
|
||||
*/
|
||||
Route::get(
|
||||
'/reports/data/accountReport/{start_date}/{end_date}/{accountList}',
|
||||
['uses' => 'Report\AccountController@accountReport', 'as' => 'reports.data.accountReport']
|
||||
);
|
||||
|
||||
/**
|
||||
* Rules Controller
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user