get('timezone', 'UTC'); return responder()->success( ProjectReportExport::init( $request->input('users', User::all()->pluck('id')->toArray()), $request->input('projects', Project::all()->pluck('id')->toArray()), Carbon::parse($request->input('start_at'))->setTimezone($companyTimezone), Carbon::parse($request->input('end_at'))->setTimezone($companyTimezone), $companyTimezone )->collection()->all(), )->respond(); } /** * @api {post} /api/report/dashboard/download Download Dashboard Report * @apiDescription Downloads a dashboard report in the specified file format. * * @apiVersion 4.0.0 * @apiName DownloadDashboardReport * @apiGroup Reports * @apiUse AuthHeader * @apiHeader {String} Accept Accept mime type. Example: `text/csv`. * * @apiParam {String} start_at The start date and time for the report in ISO 8601 format. * @apiParam {String} end_at The end date and time for the report in ISO 8601 format. * @apiParam {String} user_timezone The timezone of the user. Example: `Asia/Omsk`. * @apiParam {Array} users List of user IDs to include in the report. * @apiParam {Array} projects List of project IDs to include in the report. * * @apiParamExample {json} Request Example: * { * "start_at": "2023-11-01T16:15:09Z", * "end_at": "2023-11-30T23:59:07Z", * "user_timezone": "Asia/Omsk", * "users": [7], * "projects": [159] * } * * @apiSuccess {String} url The URL where the generated report can be downloaded. * * @apiSuccessExample {json} Success Response: * HTTP/1.1 200 OK * { * "status": 200, * "success": true, * "data": { * "url": "/storage/reports/1b11d8f9-c5a3-4fe5-86bd-ae6a3031352c/Dashboard_Report.csv" * } * } * * @apiUse 400Error * @apiUse UnauthorizedError * @apiUse ForbiddenError */ /** * @throws Throwable */ public function download(ProjectReportRequest $request): JsonResponse { $companyTimezone = Settings::scope('core')->get('timezone', 'UTC'); $job = new GenerateAndSendReport( ProjectReportExport::init( $request->input('users', User::all()->pluck('id')->toArray()), $request->input('projects', Project::all()->pluck('id')->toArray()), Carbon::parse($request->input('start_at'))->setTimezone($companyTimezone), Carbon::parse($request->input('end_at'))->setTimezone($companyTimezone), $companyTimezone ), $request->user(), ReportHelper::getReportFormat($request), ); app(Dispatcher::class)->dispatchSync($job); return responder()->success(['url' => $job->getPublicPath()])->respond(); } }