1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 15:13:29 +01:00
invoiceninja/app/Ninja/Reports/QuoteReport.php

53 lines
1.7 KiB
PHP
Raw Normal View History

2017-03-29 20:17:05 +02:00
<?php
namespace App\Ninja\Reports;
use App\Models\Client;
use Auth;
class QuoteReport extends AbstractReport
{
public $columns = [
'client',
'quote_number',
'quote_date',
'amount',
'status',
];
public function run()
{
$account = Auth::user()->account;
$status = $this->options['invoice_status'];
$clients = Client::scope()
2017-03-31 08:01:07 +02:00
->orderBy('name')
2017-03-29 20:17:05 +02:00
->withArchived()
->with('contacts')
->with(['invoices' => function ($query) use ($status) {
if ($status == 'draft') {
$query->whereIsPublic(false);
}
$query->quotes()
->withArchived()
->where('invoice_date', '>=', $this->startDate)
->where('invoice_date', '<=', $this->endDate)
->with(['invoice_items']);
}]);
foreach ($clients->get() as $client) {
foreach ($client->invoices as $invoice) {
$this->data[] = [
$this->isExport ? $client->getDisplayName() : $client->present()->link,
$this->isExport ? $invoice->invoice_number : $invoice->present()->link,
$invoice->present()->invoice_date,
$account->formatMoney($invoice->amount, $client),
$invoice->present()->status(),
];
2017-03-31 08:01:07 +02:00
$this->addToTotals($client->currency_id, 'amount', $invoice->amount);
}
2017-03-29 20:17:05 +02:00
}
}
}