mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Ajax some report parts.
This commit is contained in:
91
app/Http/Controllers/Report/BudgetController.php
Normal file
91
app/Http/Controllers/Report/BudgetController.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/**
|
||||
* BudgetController.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\Helpers\Report\BudgetReportHelperInterface;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Class BudgetController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers\Report
|
||||
*/
|
||||
class BudgetController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* @param BudgetReportHelperInterface $helper
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function budgetReport(BudgetReportHelperInterface $helper, Carbon $start, Carbon $end, Collection $accounts)
|
||||
{
|
||||
|
||||
// chart properties for cache:
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty('budget-report');
|
||||
$cache->addProperty($accounts->pluck('id')->toArray());
|
||||
if ($cache->has()) {
|
||||
return $cache->get();
|
||||
}
|
||||
|
||||
$budgets = $helper->getBudgetReport($start, $end, $accounts);
|
||||
|
||||
$result = view('reports.partials.budgets', compact('budgets'))->render();
|
||||
$cache->store($result);
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BudgetReportHelperInterface $helper
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function budgetYearOverview(BudgetReportHelperInterface $helper, Carbon $start, Carbon $end, Collection $accounts)
|
||||
{
|
||||
|
||||
// chart properties for cache:
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty('budget-year-overview');
|
||||
$cache->addProperty($accounts->pluck('id')->toArray());
|
||||
if ($cache->has()) {
|
||||
return $cache->get();
|
||||
}
|
||||
|
||||
$budgets = $helper->budgetYearOverview($start, $end, $accounts);
|
||||
|
||||
$result = view('reports.partials.budget-year-overview', compact('budgets'))->render();
|
||||
$cache->store($result);
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,7 +15,6 @@ namespace FireflyIII\Http\Controllers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Helpers\Report\BudgetReportHelperInterface;
|
||||
use FireflyIII\Helpers\Report\ReportHelperInterface;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
@@ -37,8 +36,6 @@ use View;
|
||||
*/
|
||||
class ReportController extends Controller
|
||||
{
|
||||
/** @var BudgetReportHelperInterface */
|
||||
protected $budgetHelper;
|
||||
/** @var ReportHelperInterface */
|
||||
protected $helper;
|
||||
|
||||
@@ -55,8 +52,7 @@ class ReportController extends Controller
|
||||
View::share('title', trans('firefly.reports'));
|
||||
View::share('mainTitleIcon', 'fa-line-chart');
|
||||
|
||||
$this->helper = app(ReportHelperInterface::class);
|
||||
$this->budgetHelper = app(BudgetReportHelperInterface::class);
|
||||
$this->helper = app(ReportHelperInterface::class);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
@@ -219,10 +215,8 @@ class ReportController extends Controller
|
||||
*/
|
||||
private function defaultMonth(string $reportType, Carbon $start, Carbon $end, Collection $accounts)
|
||||
{
|
||||
// get report stuff!
|
||||
$budgets = $this->budgetHelper->getBudgetReport($start, $end, $accounts);
|
||||
$bills = $this->helper->getBillReport($start, $end, $accounts);
|
||||
$tags = $this->helper->tagReport($start, $end, $accounts);
|
||||
$bills = $this->helper->getBillReport($start, $end, $accounts);
|
||||
$tags = $this->helper->tagReport($start, $end, $accounts);
|
||||
|
||||
// and some id's, joined:
|
||||
$accountIds = join(',', $accounts->pluck('id')->toArray());
|
||||
@@ -233,9 +227,9 @@ class ReportController extends Controller
|
||||
compact(
|
||||
'start', 'end',
|
||||
'tags',
|
||||
'budgets',
|
||||
'bills',
|
||||
'accountIds', 'reportType'
|
||||
'accountIds',
|
||||
'reportType'
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -281,8 +275,7 @@ class ReportController extends Controller
|
||||
*/
|
||||
private function defaultYear(string $reportType, Carbon $start, Carbon $end, Collection $accounts)
|
||||
{
|
||||
$tags = $this->helper->tagReport($start, $end, $accounts);
|
||||
$budgets = $this->budgetHelper->budgetYearOverview($start, $end, $accounts);
|
||||
$tags = $this->helper->tagReport($start, $end, $accounts);
|
||||
|
||||
Session::flash('gaEventCategory', 'report');
|
||||
Session::flash('gaEventAction', 'year');
|
||||
@@ -299,7 +292,8 @@ class ReportController extends Controller
|
||||
return view(
|
||||
'reports.default.year',
|
||||
compact(
|
||||
'start', 'reportType', 'accountIds', 'end', 'tags', 'budgets'
|
||||
'start', 'reportType',
|
||||
'accountIds', 'end', 'tags'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -323,6 +323,7 @@ class CsvSetup implements SetupInterface
|
||||
|
||||
foreach ($config['column-do-mapping'] as $index => $mustBeMapped) {
|
||||
if ($mustBeMapped) {
|
||||
|
||||
$column = $config['column-roles'][$index] ?? '_ignore';
|
||||
|
||||
// is valid column?
|
||||
|
||||
Reference in New Issue
Block a user