2016-04-01 16:06:55 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
*
|
2019-10-02 06:37:26 +02:00
|
|
|
* This file is part of Firefly III (https://github.com/firefly-iii).
|
2016-10-05 06:52:15 +02:00
|
|
|
*
|
2019-10-02 06:37:26 +02:00
|
|
|
* 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
|
|
|
*
|
2019-10-02 06:37:26 +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
|
2019-10-02 06:37:26 +02:00
|
|
|
* GNU Affero General Public License for more details.
|
2017-10-21 08:40:00 +02:00
|
|
|
*
|
2019-10-02 06:37:26 +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-05-20 12:41:23 +02:00
|
|
|
|
2016-04-01 16:06:55 +02:00
|
|
|
namespace FireflyIII\Http\Controllers\Popup;
|
|
|
|
|
|
|
|
use FireflyIII\Http\Controllers\Controller;
|
2018-08-10 18:19:51 +02:00
|
|
|
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.
|
2018-07-20 14:34:56 +02:00
|
|
|
*
|
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
|
|
|
*
|
2016-04-01 16:06:55 +02:00
|
|
|
* @param Request $request
|
|
|
|
*
|
2018-07-08 12:28:42 +02:00
|
|
|
* @return JsonResponse
|
2019-08-17 10:47:10 +02:00
|
|
|
*
|
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
|
|
|
|
2018-07-14 16:08:34 +02:00
|
|
|
app('view')->share('start', $attributes['startDate']);
|
|
|
|
app('view')->share('end', $attributes['endDate']);
|
2016-04-03 14:55:56 +02:00
|
|
|
|
2016-04-01 16:06:55 +02:00
|
|
|
switch ($attributes['location']) {
|
|
|
|
default:
|
2018-07-20 14:34:56 +02:00
|
|
|
$html = sprintf('Firefly III cannot handle "%s"-popups.', $attributes['location']);
|
|
|
|
break;
|
2016-04-01 16:06:55 +02:00
|
|
|
case 'budget-spent-amount':
|
|
|
|
$html = $this->budgetSpentAmount($attributes);
|
2016-04-03 11:07:51 +02:00
|
|
|
break;
|
|
|
|
case 'expense-entry':
|
|
|
|
$html = $this->expenseEntry($attributes);
|
2016-04-01 16:06:55 +02:00
|
|
|
break;
|
2016-04-03 11:14:36 +02:00
|
|
|
case 'income-entry':
|
|
|
|
$html = $this->incomeEntry($attributes);
|
|
|
|
break;
|
2016-04-03 11:20:55 +02:00
|
|
|
case 'category-entry':
|
|
|
|
$html = $this->categoryEntry($attributes);
|
|
|
|
break;
|
2019-09-01 15:23:33 +02:00
|
|
|
case 'budget-entry':
|
|
|
|
$html = $this->budgetEntry($attributes);
|
|
|
|
break;
|
2016-04-01 16:06:55 +02: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
|
|
|
}
|