mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-31 15:42:03 -04:00
Fixed problem with search when using foreign language
This commit is contained in:
parent
668eab0279
commit
0ea8461706
@ -75,26 +75,26 @@ class AccountRepository
|
|||||||
->where('clients.deleted_at', '=', null)
|
->where('clients.deleted_at', '=', null)
|
||||||
->where('clients.account_id', '=', \Auth::user()->account_id)
|
->where('clients.account_id', '=', \Auth::user()->account_id)
|
||||||
->whereRaw("clients.name <> ''")
|
->whereRaw("clients.name <> ''")
|
||||||
->select(\DB::raw("'" . trans('texts.clients') . "' as type, clients.public_id, clients.name, '' as token"));
|
->select(\DB::raw("'clients' as type, '" . trans('texts.clients') . "' as trans_type, clients.public_id, clients.name, '' as token"));
|
||||||
|
|
||||||
$contacts = \DB::table('clients')
|
$contacts = \DB::table('clients')
|
||||||
->join('contacts', 'contacts.client_id', '=', 'clients.id')
|
->join('contacts', 'contacts.client_id', '=', 'clients.id')
|
||||||
->where('clients.deleted_at', '=', null)
|
->where('clients.deleted_at', '=', null)
|
||||||
->where('clients.account_id', '=', \Auth::user()->account_id)
|
->where('clients.account_id', '=', \Auth::user()->account_id)
|
||||||
->whereRaw("CONCAT(contacts.first_name, contacts.last_name, contacts.email) <> ''")
|
->whereRaw("CONCAT(contacts.first_name, contacts.last_name, contacts.email) <> ''")
|
||||||
->select(\DB::raw("'" . trans('texts.contacts') . "' as type, clients.public_id, CONCAT(contacts.first_name, ' ', contacts.last_name, ' ', contacts.email) as name, '' as token"));
|
->select(\DB::raw("'clients' as type, '" . trans('texts.contacts') . "' as trans_type, clients.public_id, CONCAT(contacts.first_name, ' ', contacts.last_name, ' ', contacts.email) as name, '' as token"));
|
||||||
|
|
||||||
$invoices = \DB::table('clients')
|
$invoices = \DB::table('clients')
|
||||||
->join('invoices', 'invoices.client_id', '=', 'clients.id')
|
->join('invoices', 'invoices.client_id', '=', 'clients.id')
|
||||||
->where('clients.account_id', '=', \Auth::user()->account_id)
|
->where('clients.account_id', '=', \Auth::user()->account_id)
|
||||||
->where('clients.deleted_at', '=', null)
|
->where('clients.deleted_at', '=', null)
|
||||||
->where('invoices.deleted_at', '=', null)
|
->where('invoices.deleted_at', '=', null)
|
||||||
->select(\DB::raw("'" . trans('texts.invoices') . "' as type, invoices.public_id, CONCAT(invoices.invoice_number, ': ', clients.name) as name, invoices.invoice_number as token"));
|
->select(\DB::raw("'invoices' as type, '" . trans('texts.invoices') . "' as trans_type, invoices.public_id, CONCAT(invoices.invoice_number, ': ', clients.name) as name, invoices.invoice_number as token"));
|
||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
|
|
||||||
foreach ($clients->union($contacts)->union($invoices)->get() as $row) {
|
foreach ($clients->union($contacts)->union($invoices)->get() as $row) {
|
||||||
$type = $row->type;
|
$type = $row->trans_type;
|
||||||
|
|
||||||
if (!isset($data[$type])) {
|
if (!isset($data[$type])) {
|
||||||
$data[$type] = [];
|
$data[$type] = [];
|
||||||
@ -111,6 +111,7 @@ class AccountRepository
|
|||||||
'value' => $row->name,
|
'value' => $row->name,
|
||||||
'public_id' => $row->public_id,
|
'public_id' => $row->public_id,
|
||||||
'tokens' => $tokens,
|
'tokens' => $tokens,
|
||||||
|
'entity_type' => $row->type,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,7 +282,7 @@
|
|||||||
}
|
}
|
||||||
$('#search').typeahead(datasets).on('typeahead:selected', function(element, datum, name) {
|
$('#search').typeahead(datasets).on('typeahead:selected', function(element, datum, name) {
|
||||||
var type = name == 'Contacts' ? 'clients' : name.toLowerCase();
|
var type = name == 'Contacts' ? 'clients' : name.toLowerCase();
|
||||||
window.location = '{{ URL::to('/') }}' + '/' + type + '/' + datum.public_id;
|
window.location = '{{ URL::to('/') }}' + '/' + datum.entity_type + '/' + datum.public_id;
|
||||||
}).focus().typeahead('setQuery', $('#search').val());
|
}).focus().typeahead('setQuery', $('#search').val());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user