From 238618a1c3bd12a75406d169949b850f50d60e9d Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Wed, 28 Feb 2018 10:12:23 +0200 Subject: [PATCH] Adding charts to reports --- app/Ninja/Reports/AbstractReport.php | 5 ++++- app/Ninja/Reports/AgingReport.php | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/Ninja/Reports/AbstractReport.php b/app/Ninja/Reports/AbstractReport.php index 56372151c4fe..46199e3f7256 100644 --- a/app/Ninja/Reports/AbstractReport.php +++ b/app/Ninja/Reports/AbstractReport.php @@ -7,6 +7,7 @@ use Auth; use DateInterval; use DatePeriod; use stdClass; +use App\Models\Client; class AbstractReport { @@ -154,7 +155,9 @@ class AbstractReport if ($subgroup == 'user') { return $entity->user->getDisplayName(); } elseif ($subgroup == 'client') { - if ($entity->client) { + if ($entity instanceof Client) { + return $entity->getDisplayName(); + } elseif ($entity->client) { return $entity->client->getDisplayName(); } else { return trans('texts.unset'); diff --git a/app/Ninja/Reports/AgingReport.php b/app/Ninja/Reports/AgingReport.php index 0b4a3ada5881..1def788fea6b 100644 --- a/app/Ninja/Reports/AgingReport.php +++ b/app/Ninja/Reports/AgingReport.php @@ -24,6 +24,7 @@ class AgingReport extends AbstractReport public function run() { $account = Auth::user()->account; + $subgroup = $this->options['subgroup']; $clients = Client::scope() ->orderBy('name') @@ -56,6 +57,14 @@ class AgingReport extends AbstractReport //$this->addToTotals($client->currency_id, 'paid', $payment ? $payment->getCompletedAmount() : 0); //$this->addToTotals($client->currency_id, 'amount', $invoice->amount); //$this->addToTotals($client->currency_id, 'balance', $invoice->balance); + + if ($subgroup == 'age') { + $dimension = trans('texts.' .$invoice->present()->ageGroup); + } else { + $dimension = $this->getDimension($client); + } + + $this->addChartData($dimension, $invoice->invoice_date, $invoice->balance); } } }