mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01:00
Support searching by custom client fields
This commit is contained in:
parent
e7df1f5e7c
commit
ed7cbf1d2b
@ -123,7 +123,8 @@ class AccountController extends BaseController
|
|||||||
|
|
||||||
public function getSearchData()
|
public function getSearchData()
|
||||||
{
|
{
|
||||||
$data = $this->accountRepo->getSearchData();
|
$account = Auth::user()->account;
|
||||||
|
$data = $this->accountRepo->getSearchData($account);
|
||||||
|
|
||||||
return Response::json($data);
|
return Response::json($data);
|
||||||
}
|
}
|
||||||
|
@ -70,16 +70,16 @@ class AccountRepository
|
|||||||
return $account;
|
return $account;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSearchData()
|
public function getSearchData($account)
|
||||||
{
|
{
|
||||||
$data = $this->getAccountSearchData();
|
$data = $this->getAccountSearchData($account);
|
||||||
|
|
||||||
$data['navigation'] = $this->getNavigationSearchData();
|
$data['navigation'] = $this->getNavigationSearchData();
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getAccountSearchData()
|
private function getAccountSearchData($account)
|
||||||
{
|
{
|
||||||
$data = [
|
$data = [
|
||||||
'clients' => [],
|
'clients' => [],
|
||||||
@ -88,6 +88,14 @@ class AccountRepository
|
|||||||
'quotes' => [],
|
'quotes' => [],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// include custom client fields in search
|
||||||
|
if ($account->custom_client_label1) {
|
||||||
|
$data[$account->custom_client_label1] = [];
|
||||||
|
}
|
||||||
|
if ($account->custom_client_label2) {
|
||||||
|
$data[$account->custom_client_label2] = [];
|
||||||
|
}
|
||||||
|
|
||||||
$clients = Client::scope()
|
$clients = Client::scope()
|
||||||
->with('contacts', 'invoices')
|
->with('contacts', 'invoices')
|
||||||
->get();
|
->get();
|
||||||
@ -96,20 +104,38 @@ class AccountRepository
|
|||||||
if ($client->name) {
|
if ($client->name) {
|
||||||
$data['clients'][] = [
|
$data['clients'][] = [
|
||||||
'value' => $client->name,
|
'value' => $client->name,
|
||||||
|
'tokens' => $client->name,
|
||||||
'url' => $client->present()->url,
|
'url' => $client->present()->url,
|
||||||
];
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($client->custom_value1) {
|
||||||
|
$data[$account->custom_client_label1][] = [
|
||||||
|
'value' => "{$client->custom_value1}: " . $client->getDisplayName(),
|
||||||
|
'tokens' => $client->custom_value1,
|
||||||
|
'url' => $client->present()->url,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
if ($client->custom_value2) {
|
||||||
|
$data[$account->custom_client_label2][] = [
|
||||||
|
'value' => "{$client->custom_value2}: " . $client->getDisplayName(),
|
||||||
|
'tokens' => $client->custom_value2,
|
||||||
|
'url' => $client->present()->url,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($client->contacts as $contact) {
|
foreach ($client->contacts as $contact) {
|
||||||
if ($contact->getFullName()) {
|
if ($contact->getFullName()) {
|
||||||
$data['contacts'][] = [
|
$data['contacts'][] = [
|
||||||
'value' => $contact->getDisplayName(),
|
'value' => $contact->getDisplayName(),
|
||||||
|
'tokens' => $contact->getDisplayName(),
|
||||||
'url' => $client->present()->url,
|
'url' => $client->present()->url,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
if ($contact->email) {
|
if ($contact->email) {
|
||||||
$data[trans('texts.contacts')][] = [
|
$data['contacts'][] = [
|
||||||
'value' => $contact->email,
|
'value' => $contact->email,
|
||||||
|
'tokens' => $contact->email,
|
||||||
'url' => $client->present()->url,
|
'url' => $client->present()->url,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@ -119,6 +145,7 @@ class AccountRepository
|
|||||||
$entityType = $invoice->getEntityType();
|
$entityType = $invoice->getEntityType();
|
||||||
$data["{$entityType}s"][] = [
|
$data["{$entityType}s"][] = [
|
||||||
'value' => $invoice->getDisplayName() . ': ' . $client->getDisplayName(),
|
'value' => $invoice->getDisplayName() . ': ' . $client->getDisplayName(),
|
||||||
|
'tokens' => $invoice->getDisplayName() . ': ' . $client->getDisplayName(),
|
||||||
'url' => $invoice->present()->url,
|
'url' => $invoice->present()->url,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@ -156,6 +183,7 @@ class AccountRepository
|
|||||||
$features[] = ['new_tax_rate', '/tax_rates/create'];
|
$features[] = ['new_tax_rate', '/tax_rates/create'];
|
||||||
$features[] = ['new_product', '/products/create'];
|
$features[] = ['new_product', '/products/create'];
|
||||||
$features[] = ['new_user', '/users/create'];
|
$features[] = ['new_user', '/users/create'];
|
||||||
|
$features[] = ['custom_fields', '/settings/invoice_settings'];
|
||||||
|
|
||||||
$settings = array_merge(Account::$basicSettings, Account::$advancedSettings);
|
$settings = array_merge(Account::$basicSettings, Account::$advancedSettings);
|
||||||
|
|
||||||
@ -169,6 +197,7 @@ class AccountRepository
|
|||||||
foreach ($features as $feature) {
|
foreach ($features as $feature) {
|
||||||
$data[] = [
|
$data[] = [
|
||||||
'value' => trans('texts.' . $feature[0]),
|
'value' => trans('texts.' . $feature[0]),
|
||||||
|
'tokens' => trans('texts.' . $feature[0]),
|
||||||
'url' => URL::to($feature[1])
|
'url' => URL::to($feature[1])
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -274,11 +274,31 @@
|
|||||||
hint: true,
|
hint: true,
|
||||||
highlight: true,
|
highlight: true,
|
||||||
}
|
}
|
||||||
|
@if (Auth::check() && Auth::user()->account->custom_client_label1)
|
||||||
|
,{
|
||||||
|
name: 'data',
|
||||||
|
display: 'value',
|
||||||
|
source: searchData(data['{{ Auth::user()->account->custom_client_label1 }}'], 'tokens'),
|
||||||
|
templates: {
|
||||||
|
header: ' <span style="font-weight:600;font-size:16px">{{ Auth::user()->account->custom_client_label1 }}</span>'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@endif
|
||||||
|
@if (Auth::check() && Auth::user()->account->custom_client_label2)
|
||||||
|
,{
|
||||||
|
name: 'data',
|
||||||
|
display: 'value',
|
||||||
|
source: searchData(data['{{ Auth::user()->account->custom_client_label2 }}'], 'tokens'),
|
||||||
|
templates: {
|
||||||
|
header: ' <span style="font-weight:600;font-size:16px">{{ Auth::user()->account->custom_client_label2 }}</span>'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@endif
|
||||||
@foreach (['clients', 'contacts', 'invoices', 'quotes', 'navigation'] as $type)
|
@foreach (['clients', 'contacts', 'invoices', 'quotes', 'navigation'] as $type)
|
||||||
,{
|
,{
|
||||||
name: 'data',
|
name: 'data',
|
||||||
display: 'value',
|
display: 'value',
|
||||||
source: searchData(data['{{ $type }}'], 'value', true),
|
source: searchData(data['{{ $type }}'], 'tokens', true),
|
||||||
templates: {
|
templates: {
|
||||||
header: ' <span style="font-weight:600;font-size:16px">{{ trans("texts.{$type}") }}</span>'
|
header: ' <span style="font-weight:600;font-size:16px">{{ trans("texts.{$type}") }}</span>'
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user