Search by client number (3.X) #1328

This commit is contained in:
Hillel Coren 2017-02-28 20:24:30 +02:00
parent 631a401e8c
commit 7ffbda80c5
4 changed files with 11 additions and 3 deletions

View File

@ -249,6 +249,6 @@ trait GeneratesNumbers
public function clientNumbersEnabled() public function clientNumbersEnabled()
{ {
return $this->hasFeature(FEATURE_INVOICE_SETTINGS) && $this->client_number_counter; return $this->hasFeature(FEATURE_INVOICE_SETTINGS) && $this->client_number_counter > 0;
} }
} }

View File

@ -32,6 +32,13 @@ class ClientDatatable extends EntityDatatable
return link_to("clients/{$model->public_id}", $model->email ?: '')->toHtml(); return link_to("clients/{$model->public_id}", $model->email ?: '')->toHtml();
}, },
], ],
[
'id_number',
function ($model) {
return $model->id_number;
},
Auth::user()->account->clientNumbersEnabled()
],
[ [
'client_created_at', 'client_created_at',
function ($model) { function ($model) {

View File

@ -126,7 +126,7 @@ class AccountRepository
foreach ($clients as $client) { foreach ($clients as $client) {
if ($client->name) { if ($client->name) {
$data['clients'][] = [ $data['clients'][] = [
'value' => $client->name, 'value' => ($account->clientNumbersEnabled() && $client->id_number ? $client->id_number . ': ' : '') . $client->name,
'tokens' => implode(',', [$client->name, $client->id_number, $client->vat_number, $client->work_phone]), 'tokens' => implode(',', [$client->name, $client->id_number, $client->vat_number, $client->work_phone]),
'url' => $client->present()->url, 'url' => $client->present()->url,
]; ];

View File

@ -51,7 +51,8 @@ class ClientRepository extends BaseRepository
'contacts.email', 'contacts.email',
'clients.deleted_at', 'clients.deleted_at',
'clients.is_deleted', 'clients.is_deleted',
'clients.user_id' 'clients.user_id',
'clients.id_number'
); );
$this->applyFilters($query, ENTITY_CLIENT); $this->applyFilters($query, ENTITY_CLIENT);