Files
firefly-iii/app/Http/Controllers/Popup/ReportController.php

64 lines
2.2 KiB
PHP
Raw Normal View History

2016-04-01 16:06:55 +02:00
<?php
2022-12-29 19:42:26 +01:00
2016-04-01 16:06:55 +02:00
/**
* ReportController.php
2020-01-31 07:32:04 +01:00
* Copyright (c) 2019 james@firefly-iii.org
2016-04-01 16:06:55 +02:00
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
2017-10-21 08:40:00 +02:00
*
* This program is distributed in the hope that it will be useful,
2017-10-21 08:40:00 +02:00
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
2017-10-21 08:40:00 +02:00
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
2016-04-01 16:06:55 +02:00
*/
2017-03-29 21:20:54 +02:00
declare(strict_types=1);
2016-04-01 16:06:55 +02:00
namespace FireflyIII\Http\Controllers\Popup;
2023-02-22 18:03:31 +01:00
use FireflyIII\Exceptions\FireflyException;
2016-04-01 16:06:55 +02:00
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Support\Http\Controllers\RenderPartialViews;
2018-07-08 12:28:42 +02:00
use Illuminate\Http\JsonResponse;
2016-04-01 16:06:55 +02:00
use Illuminate\Http\Request;
/**
2017-11-15 12:25:49 +01:00
* Class ReportController.
2016-04-01 16:06:55 +02:00
*/
class ReportController extends Controller
{
2021-04-06 17:00:16 +02:00
use RenderPartialViews;
2017-03-29 21:20:54 +02:00
2016-04-01 16:06:55 +02:00
/**
2018-07-21 08:06:24 +02:00
* Generate popup view.
2018-08-06 19:14:30 +02:00
*
2023-02-22 18:03:31 +01:00
* @throws FireflyException
2016-04-01 16:06:55 +02:00
*/
2018-07-08 12:28:42 +02:00
public function general(Request $request): JsonResponse
2016-04-01 16:06:55 +02:00
{
2016-05-22 15:48:34 +02:00
$attributes = $request->get('attributes') ?? [];
2016-04-01 16:06:55 +02:00
$attributes = $this->parseAttributes($attributes);
2016-04-03 14:55:56 +02:00
app('view')->share('start', $attributes['startDate']);
app('view')->share('end', $attributes['endDate']);
2016-04-03 14:55:56 +02:00
2021-09-18 10:21:29 +02:00
$html = match ($attributes['location']) {
2023-07-15 16:02:42 +02:00
default => sprintf('Firefly III cannot handle "%s"-popups.', $attributes['location']),
2021-09-18 10:21:29 +02:00
'budget-spent-amount' => $this->budgetSpentAmount($attributes),
2023-07-15 16:02:42 +02:00
'expense-entry' => $this->expenseEntry($attributes),
'income-entry' => $this->incomeEntry($attributes),
'category-entry' => $this->categoryEntry($attributes),
'budget-entry' => $this->budgetEntry($attributes),
2021-09-18 10:21:29 +02:00
};
2023-12-20 19:35:52 +01:00
2018-03-10 20:30:09 +01:00
return response()->json(['html' => $html]);
2016-04-01 16:06:55 +02:00
}
2016-04-08 17:54:25 +02:00
}