2016-04-01 16:06:55 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* ReportController.php
|
2017-10-21 08:40:00 +02:00
|
|
|
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
2016-04-01 16:06:55 +02:00
|
|
|
*
|
2017-10-21 08:40:00 +02:00
|
|
|
* This file is part of Firefly III.
|
2016-10-05 06:52:15 +02:00
|
|
|
*
|
2017-10-21 08:40:00 +02:00
|
|
|
* Firefly III is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Firefly III is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2017-12-17 14:41:58 +01:00
|
|
|
* along with Firefly III. If not, see <http://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-08-09 17:46:14 +02:00
|
|
|
use FireflyIII\Support\Http\Controllers\RequestInformation;
|
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
|
|
|
|
{
|
2018-08-10 18:19:51 +02:00
|
|
|
use RequestInformation, 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;
|
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
|
|
|
}
|