From bf55ff4ce43630b8ef70b1a467cda93197201f6d Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 17 Jun 2018 10:07:55 +0300 Subject: [PATCH] Added custom invoice fields to search --- app/Ninja/Repositories/AccountRepository.php | 15 +++++++++++++ resources/views/header.blade.php | 22 ++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/app/Ninja/Repositories/AccountRepository.php b/app/Ninja/Repositories/AccountRepository.php index f338cfaa5de1..4ae38eea9348 100644 --- a/app/Ninja/Repositories/AccountRepository.php +++ b/app/Ninja/Repositories/AccountRepository.php @@ -234,6 +234,21 @@ class AccountRepository 'tokens' => implode(',', [$invoice->invoice_number, $invoice->po_number]), 'url' => $invoice->present()->url, ]; + + if ($customValue = $invoice->custom_text_value1) { + $data[$account->present()->customLabel('invoice_text1')][] = [ + 'value' => "{$customValue}: {$invoice->getDisplayName()}", + 'tokens' => $customValue, + 'url' => $invoice->present()->url, + ]; + } + if ($customValue = $invoice->custom_text_value2) { + $data[$account->present()->customLabel('invoice_text2')][] = [ + 'value' => "{$customValue}: {$invoice->getDisplayName()}", + 'tokens' => $customValue, + 'url' => $invoice->present()->url, + ]; + } } } diff --git a/resources/views/header.blade.php b/resources/views/header.blade.php index 61f51f84e73a..11dac2571c91 100644 --- a/resources/views/header.blade.php +++ b/resources/views/header.blade.php @@ -95,6 +95,28 @@ } } @endif + @if (Auth::check() && Auth::user()->account->customLabel('invoice_text1')) + ,{ + name: 'data', + limit: 3, + display: 'value', + source: searchData(data['{{ Auth::user()->account->present()->customLabel('invoice_text1') }}'], 'tokens'), + templates: { + header: ' {{ Auth::user()->account->present()->customLabel('invoice_text1') }}' + } + } + @endif + @if (Auth::check() && Auth::user()->account->customLabel('invoice_text2')) + ,{ + name: 'data', + limit: 3, + display: 'value', + source: searchData(data['{{ Auth::user()->account->present()->customLabel('invoice_text2') }}'], 'tokens'), + templates: { + header: ' {{ Auth::user()->account->present()->customLabel('invoice_text2') }}' + } + } + @endif @foreach (['clients', 'contacts', 'invoices', 'quotes', 'navigation'] as $type) ,{ name: 'data',