mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Add in controllers for reports
This commit is contained in:
parent
82fa7cbae0
commit
552c630a63
@ -44,7 +44,7 @@ class VendorExport extends BaseExport
|
|||||||
'id_number' => 'vendor.id_number',
|
'id_number' => 'vendor.id_number',
|
||||||
'name' => 'vendor.name',
|
'name' => 'vendor.name',
|
||||||
'number' => 'vendor.number',
|
'number' => 'vendor.number',
|
||||||
'client_phone' => 'vendor.phone',
|
'phone' => 'vendor.phone',
|
||||||
'postal_code' => 'vendor.postal_code',
|
'postal_code' => 'vendor.postal_code',
|
||||||
'private_notes' => 'vendor.private_notes',
|
'private_notes' => 'vendor.private_notes',
|
||||||
'public_notes' => 'vendor.public_notes',
|
'public_notes' => 'vendor.public_notes',
|
||||||
|
@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Invoice Ninja (https://invoiceninja.com).
|
||||||
|
*
|
||||||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @license https://www.elastic.co/licensing/elastic-license
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Reports;
|
||||||
|
|
||||||
|
use App\Export\CSV\PurchaseOrderItemExport;
|
||||||
|
use App\Http\Controllers\BaseController;
|
||||||
|
use App\Http\Requests\Report\GenericReportRequest;
|
||||||
|
use App\Jobs\Report\SendToAdmin;
|
||||||
|
use App\Utils\Traits\MakesHash;
|
||||||
|
|
||||||
|
class PurchaseOrderItemReportController extends BaseController
|
||||||
|
{
|
||||||
|
use MakesHash;
|
||||||
|
|
||||||
|
private string $filename = 'purchase_order_items.csv';
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function __invoke(GenericReportRequest $request)
|
||||||
|
{
|
||||||
|
if ($request->has('send_email') && $request->get('send_email')) {
|
||||||
|
SendToAdmin::dispatch(auth()->user()->company(), $request->all(), PurchaseOrderItemExport::class, $this->filename);
|
||||||
|
|
||||||
|
return response()->json(['message' => 'working...'], 200);
|
||||||
|
}
|
||||||
|
// expect a list of visible fields, or use the default
|
||||||
|
|
||||||
|
$export = new PurchaseOrderItemExport(auth()->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);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* PurchaseOrder Ninja (https://invoiceninja.com).
|
||||||
|
*
|
||||||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2023. PurchaseOrder Ninja LLC (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @license https://www.elastic.co/licensing/elastic-license
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Reports;
|
||||||
|
|
||||||
|
use App\Export\CSV\PurchaseOrderExport;
|
||||||
|
use App\Http\Controllers\BaseController;
|
||||||
|
use App\Http\Requests\Report\GenericReportRequest;
|
||||||
|
use App\Jobs\Report\SendToAdmin;
|
||||||
|
use App\Utils\Traits\MakesHash;
|
||||||
|
|
||||||
|
class PurchaseOrderReportController extends BaseController
|
||||||
|
{
|
||||||
|
use MakesHash;
|
||||||
|
|
||||||
|
private string $filename = 'purchase_orders.csv';
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function __invoke(GenericReportRequest $request)
|
||||||
|
{
|
||||||
|
if ($request->has('send_email') && $request->get('send_email')) {
|
||||||
|
SendToAdmin::dispatch(auth()->user()->company(), $request->all(), PurchaseOrderExport::class, $this->filename);
|
||||||
|
|
||||||
|
return response()->json(['message' => 'working...'], 200);
|
||||||
|
}
|
||||||
|
// expect a list of visible fields, or use the default
|
||||||
|
|
||||||
|
$export = new PurchaseOrderExport(auth()->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);
|
||||||
|
}
|
||||||
|
}
|
53
app/Http/Controllers/Reports/VendorReportController.php
Normal file
53
app/Http/Controllers/Reports/VendorReportController.php
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Invoice Ninja (https://invoiceninja.com).
|
||||||
|
*
|
||||||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @license https://www.elastic.co/licensing/elastic-license
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Reports;
|
||||||
|
|
||||||
|
use App\Export\CSV\VendorExport;
|
||||||
|
use App\Http\Controllers\BaseController;
|
||||||
|
use App\Http\Requests\Report\GenericReportRequest;
|
||||||
|
use App\Jobs\Report\SendToAdmin;
|
||||||
|
use App\Utils\Traits\MakesHash;
|
||||||
|
|
||||||
|
class VendorReportController extends BaseController
|
||||||
|
{
|
||||||
|
use MakesHash;
|
||||||
|
|
||||||
|
private string $filename = 'vendors.csv';
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function __invoke(GenericReportRequest $request)
|
||||||
|
{
|
||||||
|
if ($request->has('send_email') && $request->get('send_email')) {
|
||||||
|
SendToAdmin::dispatch(auth()->user()->company(), $request->all(), VendorExport::class, $this->filename);
|
||||||
|
|
||||||
|
return response()->json(['message' => 'working...'], 200);
|
||||||
|
}
|
||||||
|
// expect a list of visible fields, or use the default
|
||||||
|
|
||||||
|
$export = new VendorExport(auth()->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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user