diff --git a/app/Http/Controllers/ClientController.php b/app/Http/Controllers/ClientController.php index 0682c1fd7e04..c77087184499 100644 --- a/app/Http/Controllers/ClientController.php +++ b/app/Http/Controllers/ClientController.php @@ -115,13 +115,13 @@ class ClientController extends BaseController 'client' => $client, 'credit' => $client->getTotalCredit(), 'title' => trans('texts.view_client'), - 'hasRecurringInvoices' => Invoice::scope()->where('is_recurring', '=', true)->whereClientId($client->id)->count() > 0, - 'hasQuotes' => Invoice::scope()->invoiceType(INVOICE_TYPE_QUOTE)->whereClientId($client->id)->count() > 0, - 'hasTasks' => Task::scope()->whereClientId($client->id)->count() > 0, + 'hasRecurringInvoices' => Invoice::scope()->recurring()->withArchived()->whereClientId($client->id)->count() > 0, + 'hasQuotes' => Invoice::scope()->quotes()->withArchived()->whereClientId($client->id)->count() > 0, + 'hasTasks' => Task::scope()->withArchived()->whereClientId($client->id)->count() > 0, 'gatewayLink' => $token ? $token->gatewayLink() : false, 'gatewayName' => $token ? $token->gatewayName() : false, ]; - + return View::make('clients.show', $data); } diff --git a/app/Http/Controllers/CreditController.php b/app/Http/Controllers/CreditController.php index 7634ffb1e243..13dd24a6d978 100644 --- a/app/Http/Controllers/CreditController.php +++ b/app/Http/Controllers/CreditController.php @@ -101,6 +101,6 @@ class CreditController extends BaseController Session::flash('message', $message); } - return Redirect::to('credits'); + return $this->returnBulk(ENTITY_CREDIT, $action, $ids); } } diff --git a/app/Http/Controllers/PaymentController.php b/app/Http/Controllers/PaymentController.php index de333dbb425c..5b38a2f37aff 100644 --- a/app/Http/Controllers/PaymentController.php +++ b/app/Http/Controllers/PaymentController.php @@ -192,6 +192,6 @@ class PaymentController extends BaseController Session::flash('message', $message); } - return redirect()->to('payments'); + return $this->returnBulk(ENTITY_PAYMENT, $action, $ids); } } diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index c11cf86eb50a..41d7914e9a30 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -353,6 +353,16 @@ class Invoice extends EntityModel implements BalanceAffecting ->where('is_recurring', '=', false); } + /** + * @param $query + * @return mixed + */ + public function scopeRecurring($query) + { + return $query->where('invoice_type_id', '=', INVOICE_TYPE_STANDARD) + ->where('is_recurring', '=', true); + } + /** * @param $query * @return mixed diff --git a/app/Ninja/Datatables/ClientDatatable.php b/app/Ninja/Datatables/ClientDatatable.php index bbad2be0362d..cb4850f73e7d 100644 --- a/app/Ninja/Datatables/ClientDatatable.php +++ b/app/Ninja/Datatables/ClientDatatable.php @@ -19,9 +19,9 @@ class ClientDatatable extends EntityDatatable } ], [ - 'first_name', + 'contact', function ($model) { - return link_to("clients/{$model->public_id}", $model->first_name.' '.$model->last_name)->toHtml(); + return link_to("clients/{$model->public_id}", $model->contact ?: '')->toHtml(); } ], [ diff --git a/app/Ninja/Repositories/ClientRepository.php b/app/Ninja/Repositories/ClientRepository.php index 21af63169093..a465a4767abd 100644 --- a/app/Ninja/Repositories/ClientRepository.php +++ b/app/Ninja/Repositories/ClientRepository.php @@ -35,6 +35,7 @@ class ClientRepository extends BaseRepository ->select( DB::raw('COALESCE(clients.currency_id, accounts.currency_id) currency_id'), DB::raw('COALESCE(clients.country_id, accounts.country_id) country_id'), + DB::raw("CONCAT(contacts.first_name, ' ', contacts.last_name) contact"), 'clients.public_id', 'clients.name', 'contacts.first_name', diff --git a/app/Ninja/Repositories/InvoiceRepository.php b/app/Ninja/Repositories/InvoiceRepository.php index 786c4be45c95..2254934c13d4 100644 --- a/app/Ninja/Repositories/InvoiceRepository.php +++ b/app/Ninja/Repositories/InvoiceRepository.php @@ -107,10 +107,9 @@ class InvoiceRepository extends BaseRepository $query->where(function ($query) use ($filter) { $query->where('clients.name', 'like', '%'.$filter.'%') ->orWhere('invoices.invoice_number', 'like', '%'.$filter.'%') - ->orWhere('invoice_statuses.name', 'like', '%'.$filter.'%') - ->orWhere('contacts.first_name', 'like', '%'.$filter.'%') - ->orWhere('contacts.last_name', 'like', '%'.$filter.'%') - ->orWhere('contacts.email', 'like', '%'.$filter.'%'); + ->orWhere('contacts.first_name', 'like', '%'.$filter.'%') + ->orWhere('contacts.last_name', 'like', '%'.$filter.'%') + ->orWhere('contacts.email', 'like', '%'.$filter.'%'); }); } diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 214d2a327130..d9b50468ac87 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -2226,7 +2226,7 @@ $LANG = array( 'vendor_name' => 'Vendor', 'entity_state' => 'State', 'payment_status_name' => 'Status', - 'client_created_at' => 'Created At', + 'client_created_at' => 'Date Created', ); return $LANG; diff --git a/resources/views/clients/show.blade.php b/resources/views/clients/show.blade.php index 4424c9d1c1cd..f09912a47bbb 100644 --- a/resources/views/clients/show.blade.php +++ b/resources/views/clients/show.blade.php @@ -193,7 +193,7 @@