2022-01-20 02:15:33 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2024-04-12 06:15:41 +02:00
|
|
|
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
|
2022-01-20 02:15:33 +01:00
|
|
|
*
|
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
2022-01-21 02:00:32 +01:00
|
|
|
use App\Services\Chart\ChartService;
|
2024-06-28 23:42:45 +02:00
|
|
|
use App\Http\Requests\Chart\ShowChartRequest;
|
|
|
|
use App\Http\Requests\Chart\ShowCalculatedFieldRequest;
|
2022-01-20 02:15:33 +01:00
|
|
|
|
|
|
|
class ChartController extends BaseController
|
|
|
|
{
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-05-12 01:01:54 +02:00
|
|
|
* @param ShowChartRequest $request
|
2022-01-20 02:15:33 +01:00
|
|
|
*/
|
2022-01-21 02:00:32 +01:00
|
|
|
public function totals(ShowChartRequest $request)
|
2022-01-20 02:15:33 +01:00
|
|
|
{
|
2023-05-16 07:35:29 +02:00
|
|
|
/** @var \App\Models\User auth()->user() */
|
|
|
|
$user = auth()->user();
|
|
|
|
$cs = new ChartService($user->company(), $user, $user->isAdmin());
|
2022-01-20 02:15:33 +01:00
|
|
|
|
2022-01-21 07:04:01 +01:00
|
|
|
return response()->json($cs->totals($request->input('start_date'), $request->input('end_date')), 200);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function chart_summary(ShowChartRequest $request)
|
|
|
|
{
|
2023-05-16 07:35:29 +02:00
|
|
|
|
|
|
|
/** @var \App\Models\User auth()->user() */
|
|
|
|
$user = auth()->user();
|
|
|
|
$cs = new ChartService($user->company(), $user, $user->isAdmin());
|
2022-01-21 07:04:01 +01:00
|
|
|
|
|
|
|
return response()->json($cs->chart_summary($request->input('start_date'), $request->input('end_date')), 200);
|
2022-01-20 02:15:33 +01:00
|
|
|
}
|
2023-05-21 12:31:55 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param ShowChartRequest $request
|
|
|
|
*/
|
|
|
|
public function totalsV2(ShowChartRequest $request)
|
|
|
|
{
|
|
|
|
/** @var \App\Models\User auth()->user() */
|
|
|
|
$user = auth()->user();
|
|
|
|
$cs = new ChartService($user->company(), $user, $user->isAdmin());
|
|
|
|
|
|
|
|
return response()->json($cs->totals($request->input('start_date'), $request->input('end_date')), 200);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function chart_summaryV2(ShowChartRequest $request)
|
|
|
|
{
|
|
|
|
|
|
|
|
/** @var \App\Models\User auth()->user() */
|
|
|
|
$user = auth()->user();
|
|
|
|
$cs = new ChartService($user->company(), $user, $user->isAdmin());
|
2024-01-14 05:05:00 +01:00
|
|
|
|
2023-05-21 12:31:55 +02:00
|
|
|
return response()->json($cs->chart_summary($request->input('start_date'), $request->input('end_date')), 200);
|
|
|
|
}
|
|
|
|
|
2024-07-24 04:27:09 +02:00
|
|
|
public function calculatedFields(ShowCalculatedFieldRequest $request)
|
2024-06-28 23:42:45 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
/** @var \App\Models\User auth()->user() */
|
|
|
|
$user = auth()->user();
|
|
|
|
$cs = new ChartService($user->company(), $user, $user->isAdmin());
|
|
|
|
$result = $cs->getCalculatedField($request->all());
|
2024-08-22 08:45:06 +02:00
|
|
|
|
2024-06-28 23:42:45 +02:00
|
|
|
return response()->json($result, 200);
|
2023-05-21 12:31:55 +02:00
|
|
|
|
2024-06-28 23:42:45 +02:00
|
|
|
}
|
2022-01-20 02:15:33 +01:00
|
|
|
}
|