mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Refactor for reports
This commit is contained in:
parent
269fe7b38c
commit
9089d548b5
@ -41,28 +41,12 @@ class ActivityReportController extends BaseController
|
||||
|
||||
return response()->json(['message' => 'working...'], 200);
|
||||
}
|
||||
// expect a list of visible fields, or use the default
|
||||
|
||||
if($request->has('output') && $request->input('output') == 'json') {
|
||||
$hash = \Illuminate\Support\Str::uuid();
|
||||
|
||||
$hash = \Illuminate\Support\Str::uuid();
|
||||
PreviewReport::dispatch($user->company(), $request->all(), ActivityExport::class, $hash);
|
||||
|
||||
PreviewReport::dispatch($user->company(), $request->all(), ActivityExport::class, $hash);
|
||||
return response()->json(['message' => $hash], 200);
|
||||
|
||||
return response()->json(['message' => $hash], 200);
|
||||
}
|
||||
|
||||
$export = new ActivityExport($user->company(), $request->all());
|
||||
|
||||
$csv = $export->run();
|
||||
|
||||
$headers = [
|
||||
'Content-Disposition' => 'attachment',
|
||||
'Content-Type' => 'text/csv',
|
||||
];
|
||||
|
||||
return response()->streamDownload(function () use ($csv) {
|
||||
echo $csv;
|
||||
}, $this->filename, $headers);
|
||||
}
|
||||
}
|
||||
|
@ -72,30 +72,11 @@ class ClientContactReportController extends BaseController
|
||||
return response()->json(['message' => 'working...'], 200);
|
||||
}
|
||||
|
||||
$hash = \Illuminate\Support\Str::uuid();
|
||||
|
||||
// expect a list of visible fields, or use the default
|
||||
if($request->has('output') && $request->input('output') == 'json') {
|
||||
PreviewReport::dispatch($user->company(), $request->all(), ContactExport::class, $hash);
|
||||
|
||||
$hash = \Illuminate\Support\Str::uuid();
|
||||
return response()->json(['message' => $hash], 200);
|
||||
|
||||
PreviewReport::dispatch($user->company(), $request->all(), ContactExport::class, $hash);
|
||||
|
||||
return response()->json(['message' => $hash], 200);
|
||||
}
|
||||
|
||||
|
||||
// expect a list of visible fields, or use the default
|
||||
$export = new ContactExport($user->company(), $request->all());
|
||||
|
||||
$csv = $export->run();
|
||||
|
||||
$headers = [
|
||||
'Content-Disposition' => 'attachment',
|
||||
'Content-Type' => 'text/csv',
|
||||
];
|
||||
|
||||
return response()->streamDownload(function () use ($csv) {
|
||||
echo $csv;
|
||||
}, $this->filename, $headers);
|
||||
}
|
||||
}
|
||||
|
@ -73,27 +73,11 @@ class ClientReportController extends BaseController
|
||||
return response()->json(['message' => 'working...'], 200);
|
||||
}
|
||||
|
||||
// expect a list of visible fields, or use the default
|
||||
if($request->has('output') && $request->input('output') == 'json') {
|
||||
$hash = \Illuminate\Support\Str::uuid();
|
||||
|
||||
$hash = \Illuminate\Support\Str::uuid();
|
||||
PreviewReport::dispatch($user->company(), $request->all(), ClientExport::class, $hash);
|
||||
|
||||
PreviewReport::dispatch($user->company(), $request->all(), ClientExport::class, $hash);
|
||||
return response()->json(['message' => $hash], 200);
|
||||
|
||||
return response()->json(['message' => $hash], 200);
|
||||
}
|
||||
|
||||
$export = new ClientExport($user->company(), $request->all());
|
||||
|
||||
$csv = $export->run();
|
||||
|
||||
$headers = [
|
||||
'Content-Disposition' => 'attachment',
|
||||
'Content-Type' => 'text/csv',
|
||||
];
|
||||
|
||||
return response()->streamDownload(function () use ($csv) {
|
||||
echo $csv;
|
||||
}, $this->filename, $headers);
|
||||
}
|
||||
}
|
||||
|
@ -72,27 +72,11 @@ class InvoiceReportController extends BaseController
|
||||
return response()->json(['message' => 'working...'], 200);
|
||||
}
|
||||
|
||||
if($request->has('output') && $request->input('output') == 'json') {
|
||||
$hash = \Illuminate\Support\Str::uuid();
|
||||
|
||||
$hash = \Illuminate\Support\Str::uuid();
|
||||
PreviewReport::dispatch($user->company(), $request->all(), InvoiceExport::class, $hash);
|
||||
|
||||
PreviewReport::dispatch($user->company(), $request->all(), InvoiceExport::class, $hash);
|
||||
return response()->json(['message' => $hash], 200);
|
||||
|
||||
return response()->json(['message' => $hash], 200);
|
||||
}
|
||||
|
||||
// expect a list of visible fields, or use the default
|
||||
$export = new InvoiceExport($user->company(), $request->all());
|
||||
|
||||
$csv = $export->run();
|
||||
|
||||
$headers = [
|
||||
'Content-Disposition' => 'attachment',
|
||||
'Content-Type' => 'text/csv',
|
||||
];
|
||||
|
||||
return response()->streamDownload(function () use ($csv) {
|
||||
echo $csv;
|
||||
}, $this->filename, $headers);
|
||||
}
|
||||
}
|
||||
|
@ -72,29 +72,13 @@ class PaymentReportController extends BaseController
|
||||
|
||||
return response()->json(['message' => 'working...'], 200);
|
||||
}
|
||||
// expect a list of visible fields, or use the default
|
||||
|
||||
if($request->has('output') && $request->input('output') == 'json') {
|
||||
$hash = \Illuminate\Support\Str::uuid();
|
||||
|
||||
$hash = \Illuminate\Support\Str::uuid();
|
||||
PreviewReport::dispatch($user->company(), $request->all(), PaymentExport::class, $hash);
|
||||
|
||||
PreviewReport::dispatch($user->company(), $request->all(), PaymentExport::class, $hash);
|
||||
return response()->json(['message' => $hash], 200);
|
||||
|
||||
return response()->json(['message' => $hash], 200);
|
||||
}
|
||||
|
||||
$export = new PaymentExport($user->company(), $request->all());
|
||||
|
||||
$csv = $export->run();
|
||||
|
||||
$headers = [
|
||||
'Content-Disposition' => 'attachment',
|
||||
'Content-Type' => 'text/csv',
|
||||
];
|
||||
|
||||
return response()->streamDownload(function () use ($csv) {
|
||||
echo $csv;
|
||||
}, $this->filename, $headers);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -73,28 +73,12 @@ class ProductReportController extends BaseController
|
||||
|
||||
return response()->json(['message' => 'working...'], 200);
|
||||
}
|
||||
// expect a list of visible fields, or use the default
|
||||
|
||||
if($request->has('output') && $request->input('output') == 'json') {
|
||||
$hash = \Illuminate\Support\Str::uuid();
|
||||
|
||||
$hash = \Illuminate\Support\Str::uuid();
|
||||
PreviewReport::dispatch($user->company(), $request->all(), ProductExport::class, $hash);
|
||||
|
||||
PreviewReport::dispatch($user->company(), $request->all(), ProductExport::class, $hash);
|
||||
return response()->json(['message' => $hash], 200);
|
||||
|
||||
return response()->json(['message' => $hash], 200);
|
||||
}
|
||||
|
||||
$export = new ProductExport($user->company(), $request->all());
|
||||
|
||||
$csv = $export->run();
|
||||
|
||||
$headers = [
|
||||
'Content-Disposition' => 'attachment',
|
||||
'Content-Type' => 'text/csv',
|
||||
];
|
||||
|
||||
return response()->streamDownload(function () use ($csv) {
|
||||
echo $csv;
|
||||
}, $this->filename, $headers);
|
||||
}
|
||||
}
|
||||
|
@ -39,28 +39,12 @@ class PurchaseOrderItemReportController extends BaseController
|
||||
|
||||
return response()->json(['message' => 'working...'], 200);
|
||||
}
|
||||
// expect a list of visible fields, or use the default
|
||||
|
||||
if($request->has('output') && $request->input('output') == 'json') {
|
||||
$hash = \Illuminate\Support\Str::uuid();
|
||||
|
||||
$hash = \Illuminate\Support\Str::uuid();
|
||||
PreviewReport::dispatch($user->company(), $request->all(), PurchaseOrderItemExport::class, $hash);
|
||||
|
||||
PreviewReport::dispatch($user->company(), $request->all(), PurchaseOrderItemExport::class, $hash);
|
||||
return response()->json(['message' => $hash], 200);
|
||||
|
||||
return response()->json(['message' => $hash], 200);
|
||||
}
|
||||
|
||||
$export = new PurchaseOrderItemExport($user->company(), $request->all());
|
||||
|
||||
$csv = $export->run();
|
||||
|
||||
$headers = [
|
||||
'Content-Disposition' => 'attachment',
|
||||
'Content-Type' => 'text/csv',
|
||||
];
|
||||
|
||||
return response()->streamDownload(function () use ($csv) {
|
||||
echo $csv;
|
||||
}, $this->filename, $headers);
|
||||
}
|
||||
}
|
||||
|
@ -41,29 +41,12 @@ class PurchaseOrderReportController extends BaseController
|
||||
|
||||
return response()->json(['message' => 'working...'], 200);
|
||||
}
|
||||
// expect a list of visible fields, or use the default
|
||||
|
||||
if($request->has('output') && $request->input('output') == 'json') {
|
||||
$hash = \Illuminate\Support\Str::uuid();
|
||||
|
||||
$hash = \Illuminate\Support\Str::uuid();
|
||||
PreviewReport::dispatch($user->company(), $request->all(), PurchaseOrderExport::class, $hash);
|
||||
|
||||
PreviewReport::dispatch($user->company(), $request->all(), PurchaseOrderExport::class, $hash);
|
||||
return response()->json(['message' => $hash], 200);
|
||||
|
||||
return response()->json(['message' => $hash], 200);
|
||||
}
|
||||
|
||||
|
||||
$export = new PurchaseOrderExport($user->company(), $request->all());
|
||||
|
||||
$csv = $export->run();
|
||||
|
||||
$headers = [
|
||||
'Content-Disposition' => 'attachment',
|
||||
'Content-Type' => 'text/csv',
|
||||
];
|
||||
|
||||
return response()->streamDownload(function () use ($csv) {
|
||||
echo $csv;
|
||||
}, $this->filename, $headers);
|
||||
}
|
||||
}
|
||||
|
@ -71,28 +71,12 @@ class QuoteItemReportController extends BaseController
|
||||
|
||||
return response()->json(['message' => 'working...'], 200);
|
||||
}
|
||||
// expect a list of visible fields, or use the default
|
||||
|
||||
if($request->has('output') && $request->input('output') == 'json') {
|
||||
$hash = \Illuminate\Support\Str::uuid();
|
||||
|
||||
$hash = \Illuminate\Support\Str::uuid();
|
||||
PreviewReport::dispatch($user->company(), $request->all(), QuoteItemExport::class, $hash);
|
||||
|
||||
PreviewReport::dispatch($user->company(), $request->all(), QuoteItemExport::class, $hash);
|
||||
return response()->json(['message' => $hash], 200);
|
||||
|
||||
return response()->json(['message' => $hash], 200);
|
||||
}
|
||||
|
||||
$export = new QuoteItemExport($user->company(), $request->all());
|
||||
|
||||
$csv = $export->run();
|
||||
|
||||
$headers = [
|
||||
'Content-Disposition' => 'attachment',
|
||||
'Content-Type' => 'text/csv',
|
||||
];
|
||||
|
||||
return response()->streamDownload(function () use ($csv) {
|
||||
echo $csv;
|
||||
}, $this->filename, $headers);
|
||||
}
|
||||
}
|
||||
|
@ -71,28 +71,12 @@ class QuoteReportController extends BaseController
|
||||
|
||||
return response()->json(['message' => 'working...'], 200);
|
||||
}
|
||||
// expect a list of visible fields, or use the default
|
||||
|
||||
if($request->has('output') && $request->input('output') == 'json') {
|
||||
$hash = \Illuminate\Support\Str::uuid();
|
||||
|
||||
$hash = \Illuminate\Support\Str::uuid();
|
||||
PreviewReport::dispatch($user->company(), $request->all(), QuoteExport::class, $hash);
|
||||
|
||||
PreviewReport::dispatch($user->company(), $request->all(), QuoteExport::class, $hash);
|
||||
return response()->json(['message' => $hash], 200);
|
||||
|
||||
return response()->json(['message' => $hash], 200);
|
||||
}
|
||||
|
||||
$export = new QuoteExport($user->company(), $request->all());
|
||||
|
||||
$csv = $export->run();
|
||||
|
||||
$headers = [
|
||||
'Content-Disposition' => 'attachment',
|
||||
'Content-Type' => 'text/csv',
|
||||
];
|
||||
|
||||
return response()->streamDownload(function () use ($csv) {
|
||||
echo $csv;
|
||||
}, $this->filename, $headers);
|
||||
}
|
||||
}
|
||||
|
@ -39,28 +39,12 @@ class RecurringInvoiceReportController extends BaseController
|
||||
|
||||
return response()->json(['message' => 'working...'], 200);
|
||||
}
|
||||
// expect a list of visible fields, or use the default
|
||||
|
||||
if($request->has('output') && $request->input('output') == 'json') {
|
||||
$hash = \Illuminate\Support\Str::uuid();
|
||||
|
||||
$hash = \Illuminate\Support\Str::uuid();
|
||||
PreviewReport::dispatch($user->company(), $request->all(), RecurringInvoiceExport::class, $hash);
|
||||
|
||||
PreviewReport::dispatch($user->company(), $request->all(), RecurringInvoiceExport::class, $hash);
|
||||
return response()->json(['message' => $hash], 200);
|
||||
|
||||
return response()->json(['message' => $hash], 200);
|
||||
}
|
||||
|
||||
$export = new RecurringInvoiceExport($user->company(), $request->all());
|
||||
|
||||
$csv = $export->run();
|
||||
|
||||
$headers = [
|
||||
'Content-Disposition' => 'attachment',
|
||||
'Content-Type' => 'text/csv',
|
||||
];
|
||||
|
||||
return response()->streamDownload(function () use ($csv) {
|
||||
echo $csv;
|
||||
}, $this->filename, $headers);
|
||||
}
|
||||
}
|
||||
|
@ -71,28 +71,12 @@ class TaskReportController extends BaseController
|
||||
|
||||
return response()->json(['message' => 'working...'], 200);
|
||||
}
|
||||
// expect a list of visible fields, or use the default
|
||||
|
||||
if($request->has('output') && $request->input('output') == 'json') {
|
||||
$hash = \Illuminate\Support\Str::uuid();
|
||||
|
||||
$hash = \Illuminate\Support\Str::uuid();
|
||||
PreviewReport::dispatch($user->company(), $request->all(), TaskExport::class, $hash);
|
||||
|
||||
PreviewReport::dispatch($user->company(), $request->all(), TaskExport::class, $hash);
|
||||
return response()->json(['message' => $hash], 200);
|
||||
|
||||
return response()->json(['message' => $hash], 200);
|
||||
}
|
||||
|
||||
$export = new TaskExport($user->company(), $request->all());
|
||||
|
||||
$csv = $export->run();
|
||||
|
||||
$headers = [
|
||||
'Content-Disposition' => 'attachment',
|
||||
'Content-Type' => 'text/csv',
|
||||
];
|
||||
|
||||
return response()->streamDownload(function () use ($csv) {
|
||||
echo $csv;
|
||||
}, $this->filename, $headers);
|
||||
}
|
||||
}
|
||||
|
@ -39,28 +39,12 @@ class VendorReportController extends BaseController
|
||||
|
||||
return response()->json(['message' => 'working...'], 200);
|
||||
}
|
||||
// expect a list of visible fields, or use the default
|
||||
|
||||
if($request->has('output') && $request->input('output') == 'json') {
|
||||
$hash = \Illuminate\Support\Str::uuid();
|
||||
|
||||
$hash = \Illuminate\Support\Str::uuid();
|
||||
PreviewReport::dispatch($user->company(), $request->all(), VendorExport::class, $hash);
|
||||
|
||||
PreviewReport::dispatch($user->company(), $request->all(), VendorExport::class, $hash);
|
||||
return response()->json(['message' => $hash], 200);
|
||||
|
||||
return response()->json(['message' => $hash], 200);
|
||||
}
|
||||
|
||||
$export = new VendorExport($user->company(), $request->all());
|
||||
|
||||
$csv = $export->run();
|
||||
|
||||
$headers = [
|
||||
'Content-Disposition' => 'attachment',
|
||||
'Content-Type' => 'text/csv',
|
||||
];
|
||||
|
||||
return response()->streamDownload(function () use ($csv) {
|
||||
echo $csv;
|
||||
}, $this->filename, $headers);
|
||||
}
|
||||
}
|
||||
|
@ -38,8 +38,12 @@ class PreviewReport implements ShouldQueue
|
||||
|
||||
/** @var \App\Export\CSV\CreditExport $export */
|
||||
$export = new $this->report_class($this->company, $this->request);
|
||||
$report = $export->returnJson();
|
||||
|
||||
if($this->request['output'] == 'json' ?? false)
|
||||
$report = $export->returnJson();
|
||||
else
|
||||
$report = $export->run();
|
||||
|
||||
Cache::put($this->hash, $report, 60 * 60);
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@ use App\Models\PurchaseOrder;
|
||||
use App\Models\PurchaseOrderInvitation;
|
||||
use App\Models\Quote;
|
||||
use App\Models\QuoteInvitation;
|
||||
use App\Models\RecurringInvoice;
|
||||
use App\Models\RecurringInvoiceInvitation;
|
||||
use App\Models\Vendor;
|
||||
use App\Models\VendorContact;
|
||||
@ -51,7 +52,7 @@ class PdfConfiguration
|
||||
|
||||
public Design $design;
|
||||
|
||||
public Invoice | Credit | Quote | PurchaseOrder $entity;
|
||||
public Invoice | Credit | Quote | PurchaseOrder | RecurringInvoice $entity;
|
||||
|
||||
public string $entity_design_id;
|
||||
|
||||
|
@ -322,6 +322,8 @@ Route::group(['middleware' => ['throttle:api', 'api_db', 'token_auth', 'locale']
|
||||
Route::post('reports/tax_summary_report', TaxSummaryReportController::class);
|
||||
Route::post('reports/user_sales_report', UserSalesReportController::class);
|
||||
Route::post('reports/preview/{hash}', ReportPreviewController::class);
|
||||
Route::post('exports/preview/{hash}', ReportPreviewController::class);
|
||||
|
||||
Route::post('templates/preview/{hash}', TemplatePreviewController::class);
|
||||
Route::post('search', SearchController::class);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user