From 1a93c08a60d558fd6ccf170d43003a1130d8590f Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Fri, 26 Jan 2018 14:11:23 +0200 Subject: [PATCH] Add user column in reports --- app/Ninja/Reports/ClientReport.php | 4 +++- app/Ninja/Reports/CreditReport.php | 4 +++- app/Ninja/Reports/ExpenseReport.php | 4 +++- app/Ninja/Reports/InvoiceReport.php | 4 +++- app/Ninja/Reports/PaymentReport.php | 4 +++- app/Ninja/Reports/QuoteReport.php | 4 +++- app/Ninja/Reports/TaskReport.php | 4 +++- 7 files changed, 21 insertions(+), 7 deletions(-) diff --git a/app/Ninja/Reports/ClientReport.php b/app/Ninja/Reports/ClientReport.php index 08e8f71d6c8d..989da1d060e8 100644 --- a/app/Ninja/Reports/ClientReport.php +++ b/app/Ninja/Reports/ClientReport.php @@ -16,6 +16,7 @@ class ClientReport extends AbstractReport 'balance' => [], 'public_notes' => ['columnSelector-false'], 'private_notes' => ['columnSelector-false'], + 'user' => ['columnSelector-false'], ]; $user = auth()->user(); @@ -38,7 +39,7 @@ class ClientReport extends AbstractReport $clients = Client::scope() ->orderBy('name') ->withArchived() - ->with('contacts') + ->with(['contacts', 'user']) ->with(['invoices' => function ($query) { $query->where('invoice_date', '>=', $this->startDate) ->where('invoice_date', '<=', $this->endDate) @@ -63,6 +64,7 @@ class ClientReport extends AbstractReport $account->formatMoney($amount - $paid, $client), $client->public_notes, $client->private_notes, + $client->user->getDisplayName(), ]; if ($account->custom_client_label1) { diff --git a/app/Ninja/Reports/CreditReport.php b/app/Ninja/Reports/CreditReport.php index d4e1711755b9..6ba311c3897f 100644 --- a/app/Ninja/Reports/CreditReport.php +++ b/app/Ninja/Reports/CreditReport.php @@ -13,6 +13,7 @@ class CreditReport extends AbstractReport 'client' => [], 'amount' => [], 'balance' => [], + 'user' => ['columnSelector-false'], ]; return $columns; @@ -25,7 +26,7 @@ class CreditReport extends AbstractReport $clients = Client::scope() ->orderBy('name') ->withArchived() - ->with(['credits' => function ($query) { + ->with(['user', 'credits' => function ($query) { $query->where('credit_date', '>=', $this->startDate) ->where('credit_date', '<=', $this->endDate) ->withArchived(); @@ -48,6 +49,7 @@ class CreditReport extends AbstractReport $this->isExport ? $client->getDisplayName() : $client->present()->link, $account->formatMoney($amount, $client), $account->formatMoney($balance, $client), + $client->user->getDisplayName(), ]; $this->data[] = $row; diff --git a/app/Ninja/Reports/ExpenseReport.php b/app/Ninja/Reports/ExpenseReport.php index bcb69ca66b17..531df702cd53 100644 --- a/app/Ninja/Reports/ExpenseReport.php +++ b/app/Ninja/Reports/ExpenseReport.php @@ -20,6 +20,7 @@ class ExpenseReport extends AbstractReport 'amount' => [], 'public_notes' => ['columnSelector-false'], 'private_notes' => ['columnSelector-false'], + 'user' => ['columnSelector-false'], ]; if (TaxRate::scope()->count()) { @@ -43,7 +44,7 @@ class ExpenseReport extends AbstractReport $expenses = Expense::scope() ->orderBy('expense_date', 'desc') ->withArchived() - ->with('client.contacts', 'vendor', 'expense_category') + ->with('client.contacts', 'vendor', 'expense_category', 'user') ->where('expense_date', '>=', $this->startDate) ->where('expense_date', '<=', $this->endDate); @@ -72,6 +73,7 @@ class ExpenseReport extends AbstractReport Utils::formatMoney($amount, $expense->currency_id), $expense->public_notes, $expense->private_notes, + $expense->user->getDisplayName(), ]; if ($hasTaxRates) { diff --git a/app/Ninja/Reports/InvoiceReport.php b/app/Ninja/Reports/InvoiceReport.php index 710c9ba5f0d1..d88c52278459 100644 --- a/app/Ninja/Reports/InvoiceReport.php +++ b/app/Ninja/Reports/InvoiceReport.php @@ -21,6 +21,7 @@ class InvoiceReport extends AbstractReport 'paid' => [], 'method' => [], 'private_notes' => ['columnSelector-false'], + 'user' => ['columnSelector-false'], ]; if (TaxRate::scope()->count()) { @@ -49,7 +50,7 @@ class InvoiceReport extends AbstractReport $clients = Client::scope() ->orderBy('name') ->withArchived() - ->with('contacts') + ->with('contacts', 'user') ->with(['invoices' => function ($query) use ($statusIds) { $query->invoices() ->withArchived() @@ -93,6 +94,7 @@ class InvoiceReport extends AbstractReport $payment ? $account->formatMoney($payment->getCompletedAmount(), $client) : '', $payment ? $payment->present()->method : '', $invoice->private_notes, + $invoice->user->getDisplayName(), ]; if ($hasTaxRates) { diff --git a/app/Ninja/Reports/PaymentReport.php b/app/Ninja/Reports/PaymentReport.php index b38b7a7d7f40..13dd355b83bb 100644 --- a/app/Ninja/Reports/PaymentReport.php +++ b/app/Ninja/Reports/PaymentReport.php @@ -19,6 +19,7 @@ class PaymentReport extends AbstractReport 'paid' => [], 'method' => [], 'private_notes' => ['columnSelector-false'], + 'user' => ['columnSelector-false'], ]; } @@ -38,7 +39,7 @@ class PaymentReport extends AbstractReport ->whereHas('invoice', function ($query) { $query->where('is_deleted', '=', false); }) - ->with('client.contacts', 'invoice', 'payment_type', 'account_gateway.gateway') + ->with('client.contacts', 'invoice', 'payment_type', 'account_gateway.gateway', 'user') ->where('payment_date', '>=', $this->startDate) ->where('payment_date', '<=', $this->endDate); @@ -66,6 +67,7 @@ class PaymentReport extends AbstractReport $amount, $payment->present()->method, $payment->private_notes, + $payment->user->getDisplayName(), ]; if (! isset($invoiceMap[$invoice->id])) { diff --git a/app/Ninja/Reports/QuoteReport.php b/app/Ninja/Reports/QuoteReport.php index 9dcf8d13f16e..61fee8e98220 100644 --- a/app/Ninja/Reports/QuoteReport.php +++ b/app/Ninja/Reports/QuoteReport.php @@ -18,6 +18,7 @@ class QuoteReport extends AbstractReport 'amount' => [], 'status' => [], 'private_notes' => ['columnSelector-false'], + 'user' => ['columnSelector-false'], ]; if (TaxRate::scope()->count()) { @@ -46,7 +47,7 @@ class QuoteReport extends AbstractReport $clients = Client::scope() ->orderBy('name') ->withArchived() - ->with('contacts') + ->with('contacts', 'user') ->with(['invoices' => function ($query) use ($statusIds) { $query->quotes() ->withArchived() @@ -80,6 +81,7 @@ class QuoteReport extends AbstractReport $account->formatMoney($invoice->amount, $client), $invoice->present()->status(), $invoice->private_notes, + $invoice->user->getDisplayName(), ]; if ($hasTaxRates) { diff --git a/app/Ninja/Reports/TaskReport.php b/app/Ninja/Reports/TaskReport.php index 37c364cd1cff..1b1980c213a1 100644 --- a/app/Ninja/Reports/TaskReport.php +++ b/app/Ninja/Reports/TaskReport.php @@ -16,6 +16,7 @@ class TaskReport extends AbstractReport 'description' => [], 'duration' => [], 'amount' => [], + 'user' => ['columnSelector-false'], ]; } @@ -26,7 +27,7 @@ class TaskReport extends AbstractReport $tasks = Task::scope() ->orderBy('created_at', 'desc') - ->with('client.contacts', 'project', 'account') + ->with('client.contacts', 'project', 'account', 'user') ->withArchived() ->dateRange($startDate, $endDate); @@ -45,6 +46,7 @@ class TaskReport extends AbstractReport $task->description, Utils::formatTime($task->getDuration()), Utils::formatMoney($amount, $currencyId), + $task->user->getDisplayName(), ]; $this->addToTotals($currencyId, 'duration', $task->getDuration());